package opartgui;
import java.awt.event.*;
import javax.swing.event.*;
import java.io.*;
import java.awt.geom.*;
import javax.swing.*;
import java.awt.*;


public class BrittaniaOptionPane{

        private JPanel OptionPanel = new javax.swing.JPanel();
        private JScrollPane OptionPane = new JScrollPane();
        private boolean yOverride = false;
        protected JFrame colorFrame;
        
        public BrittaniaOptionPane(){
        
        }

        private JLabel colorOneLabel = new javax.swing.JLabel();
        private JPanel colorOnePanel = new javax.swing.JPanel();

        private JLabel colorTwoLabel = new javax.swing.JLabel();
        private JPanel colorTwoPanel = new javax.swing.JPanel();


        private JLabel lineQuantityLabel = new javax.swing.JLabel();
        private JTextField lineQuantityField = new javax.swing.JTextField();

        private JLabel lineThicknessLabel = new javax.swing.JLabel();
        private JTextField lineThicknessField = new javax.swing.JTextField();

        private JLabel lineChangeLabel = new javax.swing.JLabel();
        private JTextField lineChangeField = new javax.swing.JTextField();

        private JLabel circleQuantityLabel = new javax.swing.JLabel();
        private JTextField circleQuantityField = new javax.swing.JTextField();
        
        private JLabel circleSizeStartLabel = new javax.swing.JLabel();
        private JTextField circleSizeStartField = new javax.swing.JTextField();
        
        private JLabel circleOffsetXLabel = new javax.swing.JLabel();
        private JTextField circleOffsetXField = new javax.swing.JTextField();
        
        private JLabel circleOffsetYLabel = new javax.swing.JLabel();
        private JTextField circleOffsetYField = new javax.swing.JTextField();
        
        private JLabel circleULHCStartXLabel = new javax.swing.JLabel();
        private JTextField circleULHCStartXField = new javax.swing.JTextField();
        
        private JLabel circleULHCStartYLabel = new javax.swing.JLabel();
        private JTextField circleULHCStartYField = new javax.swing.JTextField();

        private JLabel circleSizeChangeLabel = new javax.swing.JLabel();
        private JTextField circleSizeChangeField = new javax.swing.JTextField();

        private JSlider lineQuantitySlider = new javax.swing.JSlider();
        private JSlider lineThicknessSlider = new javax.swing.JSlider();
        private JSlider lineChangeSlider = new javax.swing.JSlider();
        private JSlider circleQuantitySlider = new javax.swing.JSlider();
        private JSlider circleSizeStartSlider = new javax.swing.JSlider();
        private JSlider circleULHCStartXSlider = new javax.swing.JSlider();
        private JSlider circleULHCStartYSlider = new javax.swing.JSlider();
        private JSlider circleSizeChangeSlider = new javax.swing.JSlider();
        private JSlider circleOffsetYSlider = new javax.swing.JSlider();
        private JSlider circleOffsetXSlider = new javax.swing.JSlider();
        private JButton DrawButton = new javax.swing.JButton();
        private JButton colorOneButton = new javax.swing.JButton();
        private JButton colorTwoButton = new javax.swing.JButton();


        public JScrollPane brittaniaPaneLoad(){

               OptionPanel.setBackground(new java.awt.Color(153, 153, 255));
               OptionPanel.setBorder(new javax.swing.border.EtchedBorder());
               OptionPanel.setPreferredSize(new java.awt.Dimension(200, 980));
               
               colorOneLabel.setText("Color One");
               colorOneLabel.setPreferredSize(new java.awt.Dimension(150, 20));
               OptionPanel.add(colorOneLabel, java.awt.BorderLayout.CENTER);

               colorOnePanel.setPreferredSize(new java.awt.Dimension(30, 20));
               colorOnePanel.setBackground(opart1.Brittania.colorOne);
               OptionPanel.add(colorOnePanel, java.awt.BorderLayout.CENTER);

               colorOneButton.setText("Choose Color");
               colorOneButton.setPreferredSize(new java.awt.Dimension(150, 20));
               colorOneButton.addActionListener(new ActionListener() {
               public void actionPerformed(java.awt.event.ActionEvent evt) {
                      colorOneButtonActionPerformed(evt);
                      }
               });

               OptionPanel.add(colorOneButton, BorderLayout.CENTER);

               colorTwoLabel.setText("Color Two");
               colorTwoLabel.setPreferredSize(new java.awt.Dimension(150, 20));
               OptionPanel.add(colorTwoLabel, java.awt.BorderLayout.CENTER);

               colorTwoPanel.setPreferredSize(new java.awt.Dimension(30, 20));
               colorTwoPanel.setBackground(opart1.Brittania.colorTwo);
               OptionPanel.add(colorTwoPanel, java.awt.BorderLayout.CENTER);

               colorTwoButton.setText("Choose Color");
               colorTwoButton.setPreferredSize(new java.awt.Dimension(150, 20));
               colorTwoButton.addActionListener(new ActionListener() {
               public void actionPerformed(java.awt.event.ActionEvent evt) {
                      colorTwoButtonActionPerformed(evt);
                      }
               });

               OptionPanel.add(colorTwoButton, BorderLayout.CENTER);


               lineQuantityLabel.setText("Line Quantity");
               lineQuantityLabel.setPreferredSize(new java.awt.Dimension(150, 20));
               OptionPanel.add(lineQuantityLabel, java.awt.BorderLayout.CENTER);

               lineQuantityField.setText("29");
               lineQuantityField.setPreferredSize(new java.awt.Dimension(30, 20));
               OptionPanel.add(lineQuantityField, java.awt.BorderLayout.CENTER);

               lineQuantitySlider.setBackground(new java.awt.Color(153, 153, 255));
               lineQuantitySlider.setForeground(new java.awt.Color(0, 51, 51));
               lineQuantitySlider.setMajorTickSpacing(10);
               lineQuantitySlider.setPaintLabels(true);
               lineQuantitySlider.setPaintTicks(true);
               lineQuantitySlider.setMaximum(50);
               lineQuantitySlider.setMinimum(0);
               lineQuantitySlider.setValue(29);
               lineQuantitySlider.setPreferredSize(new java.awt.Dimension(180, 50));
               lineQuantitySlider.addMouseListener(new MouseAdapter() {
               public void mouseReleased(MouseEvent evt) {
                      lineQuantitySliderMouseReleased(evt);
                      }
               });
               OptionPanel.add(lineQuantitySlider, java.awt.BorderLayout.CENTER);

               lineThicknessLabel.setText("Line Thickness");
               lineThicknessLabel.setPreferredSize(new java.awt.Dimension(150, 20));
               OptionPanel.add(lineThicknessLabel, java.awt.BorderLayout.CENTER);

               lineThicknessField.setText("40");
               lineThicknessField.setPreferredSize(new java.awt.Dimension(30, 20));
               OptionPanel.add(lineThicknessField, java.awt.BorderLayout.CENTER);

               lineThicknessSlider.setBackground(new java.awt.Color(153, 153, 255));
               lineThicknessSlider.setForeground(new java.awt.Color(0, 51, 51));
               lineThicknessSlider.setMajorTickSpacing(20);
               lineThicknessSlider.setPaintLabels(true);
               lineThicknessSlider.setPaintTicks(true);
               lineThicknessSlider.setMaximum(80);
               lineThicknessSlider.setMinimum(0);
               lineThicknessSlider.setValue(40);
               lineThicknessSlider.setPreferredSize(new java.awt.Dimension(180, 50));
               lineThicknessSlider.addMouseListener(new MouseAdapter() {
               public void mouseReleased(MouseEvent evt) {
                      lineThicknessSliderMouseReleased(evt);
                      }
               });
               OptionPanel.add(lineThicknessSlider, java.awt.BorderLayout.CENTER);

               lineChangeLabel.setText("Line Change");
               lineChangeLabel.setPreferredSize(new java.awt.Dimension(150, 20));
               OptionPanel.add(lineChangeLabel, java.awt.BorderLayout.CENTER);

               lineChangeField.setText("2");
               lineChangeField.setPreferredSize(new java.awt.Dimension(30, 20));
               OptionPanel.add(lineChangeField, java.awt.BorderLayout.CENTER);

               lineChangeSlider.setBackground(new java.awt.Color(153, 153, 255));
               lineChangeSlider.setForeground(new java.awt.Color(0, 51, 51));
               lineChangeSlider.setMajorTickSpacing(2);
               lineChangeSlider.setPaintLabels(true);
               lineChangeSlider.setPaintTicks(true);
               lineChangeSlider.setMaximum(10);
               lineChangeSlider.setMinimum(0);
               lineChangeSlider.setValue(2);
               lineChangeSlider.setPreferredSize(new java.awt.Dimension(180, 50));
               lineChangeSlider.addMouseListener(new MouseAdapter() {
               public void mouseReleased(MouseEvent evt) {
                      lineChangeSliderMouseReleased(evt);
                      }
               });
               OptionPanel.add(lineChangeSlider, java.awt.BorderLayout.CENTER);

               circleULHCStartYLabel.setText("Circle ULHCStart Y");
               circleULHCStartYLabel.setPreferredSize(new java.awt.Dimension(150, 20));
               OptionPanel.add(circleULHCStartYLabel, java.awt.BorderLayout.CENTER);

               circleULHCStartYField.setText("200");
               circleULHCStartYField.setPreferredSize(new java.awt.Dimension(30, 20));
               OptionPanel.add(circleULHCStartYField, java.awt.BorderLayout.CENTER);

               circleULHCStartYSlider.setBackground(new java.awt.Color(153, 153, 255));
               circleULHCStartYSlider.setForeground(new java.awt.Color(0, 51, 51));
               circleULHCStartYSlider.setMajorTickSpacing(100);
               circleULHCStartYSlider.setPaintLabels(true);
               circleULHCStartYSlider.setPaintTicks(true);
               circleULHCStartYSlider.setMaximum(300);
               circleULHCStartYSlider.setMinimum(-300);
               circleULHCStartYSlider.setValue(200);
               circleULHCStartYSlider.setPreferredSize(new java.awt.Dimension(180, 50));
               circleULHCStartYSlider.addMouseListener(new MouseAdapter() {
               public void mouseReleased(MouseEvent evt) {
                      circleULHCStartYSliderMouseReleased(evt);
                      }
               });
               OptionPanel.add(circleULHCStartYSlider, java.awt.BorderLayout.CENTER);

               circleULHCStartXLabel.setText("Circle ULHCStart X");
               circleULHCStartXLabel.setPreferredSize(new java.awt.Dimension(150, 20));
               OptionPanel.add(circleULHCStartXLabel, java.awt.BorderLayout.CENTER);

               circleULHCStartXField.setText("100");
               circleULHCStartXField.setPreferredSize(new java.awt.Dimension(30, 20));
               OptionPanel.add(circleULHCStartXField, java.awt.BorderLayout.CENTER);

               circleULHCStartXSlider.setBackground(new java.awt.Color(153, 153, 255));
               circleULHCStartXSlider.setForeground(new java.awt.Color(0, 51, 51));
               circleULHCStartXSlider.setMajorTickSpacing(100);
               circleULHCStartXSlider.setPaintLabels(true);
               circleULHCStartXSlider.setPaintTicks(true);
               circleULHCStartXSlider.setMaximum(300);
               circleULHCStartXSlider.setMinimum(-300);
               circleULHCStartXSlider.setValue(100);
               circleULHCStartXSlider.setPreferredSize(new java.awt.Dimension(180, 50));
               circleULHCStartXSlider.addMouseListener(new MouseAdapter() {

               public void mouseReleased(MouseEvent evt) {
                      circleULHCStartXSliderMouseReleased(evt);
                      }
               });
               OptionPanel.add(circleULHCStartXSlider, java.awt.BorderLayout.CENTER);


               circleOffsetYLabel.setText("Circle Offset Y");
               circleOffsetYLabel.setPreferredSize(new java.awt.Dimension(150, 20));
               OptionPanel.add(circleOffsetYLabel, java.awt.BorderLayout.CENTER);

               circleOffsetYField.setText("20");
               circleOffsetYField.setPreferredSize(new java.awt.Dimension(30, 20));
               OptionPanel.add(circleOffsetYField, java.awt.BorderLayout.CENTER);

               circleOffsetYSlider.setBackground(new java.awt.Color(153, 153, 255));
               circleOffsetYSlider.setForeground(new java.awt.Color(0, 51, 51));
               circleOffsetYSlider.setMajorTickSpacing(10);
               circleOffsetYSlider.setPaintLabels(true);
               circleOffsetYSlider.setPaintTicks(true);
               circleOffsetYSlider.setMaximum(50);
               circleOffsetYSlider.setMinimum(0);
               circleOffsetYSlider.setValue(20);
               circleOffsetYSlider.setPreferredSize(new java.awt.Dimension(180, 50));
               circleOffsetYSlider.addMouseListener(new MouseAdapter() {
               public void mouseReleased(MouseEvent evt) {
                      circleOffsetYSliderMouseReleased(evt);
                      }
               });
               OptionPanel.add(circleOffsetYSlider, java.awt.BorderLayout.CENTER);

               circleOffsetXLabel.setText("Circle Offset X");
               circleOffsetXLabel.setPreferredSize(new java.awt.Dimension(150, 20));
               OptionPanel.add(circleOffsetXLabel, java.awt.BorderLayout.CENTER);

               circleOffsetXField.setText("20");
               circleOffsetXField.setPreferredSize(new java.awt.Dimension(30, 20));
               OptionPanel.add(circleOffsetXField, java.awt.BorderLayout.CENTER);

               circleOffsetXSlider.setBackground(new java.awt.Color(153, 153, 255));
               circleOffsetXSlider.setForeground(new java.awt.Color(0, 51, 51));
               circleOffsetXSlider.setMajorTickSpacing(10);
               circleOffsetXSlider.setPaintLabels(true);
               circleOffsetXSlider.setPaintTicks(true);
               circleOffsetXSlider.setMaximum(50);
               circleOffsetXSlider.setMinimum(0);
               circleOffsetXSlider.setValue(20);
               circleOffsetXSlider.setPreferredSize(new java.awt.Dimension(180, 50));
               circleOffsetXSlider.addMouseListener(new MouseAdapter() {

               public void mouseReleased(MouseEvent evt) {
                      circleOffsetXSliderMouseReleased(evt);
                      }
               });
               OptionPanel.add(circleOffsetXSlider, java.awt.BorderLayout.CENTER);

               circleQuantityLabel.setText("Circle Quantity");
               circleQuantityLabel.setPreferredSize(new java.awt.Dimension(150, 20));
               OptionPanel.add(circleQuantityLabel, java.awt.BorderLayout.CENTER);

               circleQuantityField.setText("14");
               circleQuantityField.setPreferredSize(new java.awt.Dimension(30, 20));
               OptionPanel.add(circleQuantityField, java.awt.BorderLayout.CENTER);

               circleQuantitySlider.setBackground(new java.awt.Color(153, 153, 255));
               circleQuantitySlider.setForeground(new java.awt.Color(0, 51, 51));
               circleQuantitySlider.setMajorTickSpacing(5);
               circleQuantitySlider.setPaintLabels(true);
               circleQuantitySlider.setPaintTicks(true);
               circleQuantitySlider.setMaximum(30);
               circleQuantitySlider.setMinimum(0);
               circleQuantitySlider.setValue(14);
               circleQuantitySlider.setPreferredSize(new java.awt.Dimension(180, 50));
               circleQuantitySlider.addMouseListener(new MouseAdapter() {

               public void mouseReleased(MouseEvent evt) {
                      circleQuantitySliderMouseReleased(evt);
                      }
               });

               OptionPanel.add(circleQuantitySlider, java.awt.BorderLayout.CENTER);

               circleSizeStartLabel.setText("Initial Circle Size");
               circleSizeStartLabel.setPreferredSize(new java.awt.Dimension(150, 20));
               OptionPanel.add(circleSizeStartLabel, java.awt.BorderLayout.CENTER);

               circleSizeStartField.setText("400");
               circleSizeStartField.setPreferredSize(new java.awt.Dimension(30, 20));
               OptionPanel.add(circleSizeStartField, java.awt.BorderLayout.CENTER);

               circleSizeStartSlider.setBackground(new java.awt.Color(153, 153, 255));
               circleSizeStartSlider.setForeground(new java.awt.Color(0, 51, 51));
               circleSizeStartSlider.setMajorTickSpacing(100);
               circleSizeStartSlider.setPaintLabels(true);
               circleSizeStartSlider.setPaintTicks(true);
               circleSizeStartSlider.setMaximum(600);
               circleSizeStartSlider.setMinimum(0);
               circleSizeStartSlider.setValue(400);
               circleSizeStartSlider.setPreferredSize(new java.awt.Dimension(180, 50));
               circleSizeStartSlider.addMouseListener(new MouseAdapter() {

               public void mouseReleased(MouseEvent evt) {
                      circleSizeStartSliderMouseReleased(evt);
                      }
               });

               OptionPanel.add(circleSizeStartSlider, java.awt.BorderLayout.CENTER);

               circleSizeChangeLabel.setText("Circle Size Change");
               circleSizeChangeLabel.setPreferredSize(new java.awt.Dimension(150, 20));
               OptionPanel.add(circleSizeChangeLabel, java.awt.BorderLayout.CENTER);

               circleSizeChangeField.setText("50");
               circleSizeChangeField.setPreferredSize(new java.awt.Dimension(30, 20));
               OptionPanel.add(circleSizeChangeField, java.awt.BorderLayout.CENTER);

               circleSizeChangeSlider.setBackground(new java.awt.Color(153, 153, 255));
               circleSizeChangeSlider.setForeground(new java.awt.Color(0, 51, 51));
               circleSizeChangeSlider.setMajorTickSpacing(20);
               circleSizeChangeSlider.setPaintLabels(true);
               circleSizeChangeSlider.setPaintTicks(true);
               circleSizeChangeSlider.setMaximum(100);
               circleSizeChangeSlider.setMinimum(0);
               circleSizeChangeSlider.setValue(50);
               circleSizeChangeSlider.setPreferredSize(new java.awt.Dimension(180, 50));
               circleSizeChangeSlider.addMouseListener(new MouseAdapter() {

               public void mouseReleased(MouseEvent evt) {
                      circleSizeChangeSliderMouseReleased(evt);
                      }
               });

               OptionPanel.add(circleSizeChangeSlider, java.awt.BorderLayout.CENTER);

               DrawButton.setBackground(new java.awt.Color(102, 102, 255));
               DrawButton.setText("Draw");
               DrawButton.setPreferredSize(new java.awt.Dimension(100, 20));
               DrawButton.addActionListener(new java.awt.event.ActionListener() {

               public void actionPerformed(java.awt.event.ActionEvent evt) {
                      DrawButtonActionPerformed(evt);
                      }
               });

               OptionPanel.add(DrawButton, java.awt.BorderLayout.CENTER);

               OptionPane.setViewportView(OptionPanel);
               return OptionPane;
        }

        public void Draw(){
                opart1.imagePanel.doDisplay(opart1.Brittania.doDraw(Integer.parseInt(lineQuantityField.getText()),
		Integer.parseInt(circleSizeStartField.getText()),
        	Integer.parseInt(circleSizeChangeField.getText()),
        	Integer.parseInt(circleQuantityField.getText()),
        	Integer.parseInt(circleOffsetXField.getText()),
        	Integer.parseInt(circleOffsetYField.getText()),
                Integer.parseInt(circleULHCStartXField.getText()),
        	Integer.parseInt(circleULHCStartYField.getText()),
                Integer.parseInt(lineThicknessField.getText()),
        	Integer.parseInt(lineChangeField.getText()), yOverride));
        }

        private void DrawButtonActionPerformed(java.awt.event.ActionEvent evt) {
                Draw();
        }

        private void lineQuantitySliderMouseReleased(MouseEvent evt) {
               lineQuantityField.setText(Integer.toString(lineQuantitySlider.getValue()));
               Draw();
        }

        private void lineThicknessSliderMouseReleased(MouseEvent evt) {
               lineThicknessField.setText(Integer.toString(lineThicknessSlider.getValue()));
               Draw();
        }
        
        private void lineChangeSliderMouseReleased(MouseEvent evt) {
               lineChangeField.setText(Integer.toString(lineChangeSlider.getValue()));
               Draw();
        }

        private void circleOffsetYSliderMouseReleased(MouseEvent evt) {
               circleOffsetYField.setText(Integer.toString(circleOffsetYSlider.getValue()));
               Draw();
        }

        private void circleOffsetXSliderMouseReleased(MouseEvent evt) {
               circleOffsetXField.setText(Integer.toString(circleOffsetXSlider.getValue()));
               Draw();
        }

        private void circleULHCStartYSliderMouseReleased(MouseEvent evt) {
               yOverride = true;
               circleULHCStartYField.setText(Integer.toString(circleULHCStartYSlider.getValue()));
               Draw();
        }

        private void circleULHCStartXSliderMouseReleased(MouseEvent evt) {
               circleULHCStartXField.setText(Integer.toString(circleULHCStartXSlider.getValue()));
               Draw();
        }
        
        private void colorOneButtonActionPerformed(java.awt.event.ActionEvent evt) {

                colorFrame = new JFrame();
                Color selectedColor = JColorChooser.showDialog(colorFrame, "Pick A Color", opart1.Orient.colorOne);
                if(selectedColor == null) {
                                 System.out.println("No Colour Selected");
                }
                else {
                     colorOnePanel.setBackground(selectedColor);
                     opart1.Brittania.colorOne = selectedColor;
                     Draw();
                }
        }

        private void colorTwoButtonActionPerformed(java.awt.event.ActionEvent evt) {

                colorFrame = new JFrame();
                Color selectedColor = JColorChooser.showDialog(colorFrame, "Pick A Color", opart1.Orient.colorOne);
                 if(selectedColor == null) {
                                 System.out.println("No Colour Selected");
                }
                else {
                     colorTwoPanel.setBackground(selectedColor);
                     opart1.Brittania.colorTwo = selectedColor;
                     Draw();
                }
        }

        private void circleSizeStartSliderMouseReleased(MouseEvent evt) {
               circleSizeStartField.setText(Integer.toString(circleSizeStartSlider.getValue()));
               Draw();
        }

        private void circleSizeChangeSliderMouseReleased(MouseEvent evt) {
               circleSizeChangeField.setText(Integer.toString(circleSizeChangeSlider.getValue()));
               Draw();
        }

        private void circleQuantitySliderMouseReleased(MouseEvent evt) {
               circleQuantityField.setText(Integer.toString(circleQuantitySlider.getValue()));
               Draw();
        }

}
