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 CrestOptionPane {

        private JPanel OptionPanel = new javax.swing.JPanel();
        private JScrollPane OptionPane = new JScrollPane();
        protected JFrame colorFrame;

        public CrestOptionPane(){
        }

        private JLabel colorOneLabel = new javax.swing.JLabel();
        private JPanel colorOnePanel = new javax.swing.JPanel();
        private JLabel xtransLabel = new javax.swing.JLabel();
        private JTextField xtransField = new javax.swing.JTextField();
        private JLabel wavedepthOneLabel = new javax.swing.JLabel();
        private JTextField wavedepthOneField = new javax.swing.JTextField();
        private JLabel wavewidthOneLabel = new javax.swing.JLabel();
        private JTextField wavewidthOneField = new javax.swing.JTextField();
        private JLabel wavedepthTwoLabel = new javax.swing.JLabel();
        private JTextField wavedepthTwoField = new javax.swing.JTextField();
        private JLabel wavewidthTwoLabel = new javax.swing.JLabel();
        private JTextField wavewidthTwoField = new javax.swing.JTextField();
        private JLabel wavedepthThreeLabel = new javax.swing.JLabel();
        private JTextField wavedepthThreeField = new javax.swing.JTextField();
        private JLabel wavewidthThreeLabel = new javax.swing.JLabel();
        private JTextField wavewidthThreeField = new javax.swing.JTextField();
        private JLabel wavedepthFourLabel = new javax.swing.JLabel();
        private JTextField wavedepthFourField = new javax.swing.JTextField();
        private JLabel wavewidthFourLabel = new javax.swing.JLabel();
        private JTextField wavewidthFourField = new javax.swing.JTextField();


        private JButton DrawButton = new javax.swing.JButton();
        private JButton colorOneButton = new javax.swing.JButton();

        private JSlider xtransSlider = new javax.swing.JSlider();
        private JSlider wavedepthOneSlider = new javax.swing.JSlider();
        private JSlider wavewidthOneSlider = new javax.swing.JSlider();
        private JSlider wavedepthTwoSlider = new javax.swing.JSlider();
        private JSlider wavewidthTwoSlider = new javax.swing.JSlider();
        private JSlider wavedepthThreeSlider = new javax.swing.JSlider();
        private JSlider wavewidthThreeSlider = new javax.swing.JSlider();
        private JSlider wavedepthFourSlider = new javax.swing.JSlider();
        private JSlider wavewidthFourSlider = new javax.swing.JSlider();


        public JScrollPane crestPaneLoad(){

       //  OptionPane.setBackground(new java.awt.Color(153, 153, 255));
//         OptionPane.setBorder(new javax.swing.border.EtchedBorder());
//         OptionPane.setPreferredSize(new java.awt.Dimension(200, 600));


        OptionPanel.setBackground(new java.awt.Color(153, 153, 255));
        OptionPanel.setBorder(new javax.swing.border.EtchedBorder());
        OptionPanel.setPreferredSize(new java.awt.Dimension(200, 880));
        
        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.Crest.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);

        xtransLabel.setText("Separation");
        xtransLabel.setPreferredSize(new java.awt.Dimension(90, 20));
        OptionPanel.add(xtransLabel, java.awt.BorderLayout.CENTER);

        xtransField.setText("5");
        xtransField.setPreferredSize(new java.awt.Dimension(90, 20));
        OptionPanel.add(xtransField, java.awt.BorderLayout.CENTER);

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

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


        wavedepthOneLabel.setText("Wave Depth One");
        wavedepthOneLabel.setPreferredSize(new java.awt.Dimension(90, 20));
        OptionPanel.add(wavedepthOneLabel, java.awt.BorderLayout.CENTER);

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

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

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

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


        wavedepthTwoLabel.setText("Wave Depth Two");
        wavedepthTwoLabel.setPreferredSize(new java.awt.Dimension(90, 20));
        OptionPanel.add(wavedepthTwoLabel, java.awt.BorderLayout.CENTER);

        wavedepthTwoField.setText("150");
        wavedepthTwoField.setPreferredSize(new java.awt.Dimension(90, 20));
        OptionPanel.add(wavedepthTwoField, java.awt.BorderLayout.CENTER);

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

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

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

        wavedepthThreeLabel.setText("Wave Depth Three");
        wavedepthThreeLabel.setPreferredSize(new java.awt.Dimension(90, 20));
        OptionPanel.add(wavedepthThreeLabel, java.awt.BorderLayout.CENTER);

        wavedepthThreeField.setText("180");
        wavedepthThreeField.setPreferredSize(new java.awt.Dimension(90, 20));
        OptionPanel.add(wavedepthThreeField, java.awt.BorderLayout.CENTER);

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

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

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

        wavedepthFourLabel.setText("Wave Depth Four");
        wavedepthFourLabel.setPreferredSize(new java.awt.Dimension(90, 20));
        OptionPanel.add(wavedepthFourLabel, java.awt.BorderLayout.CENTER);

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

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

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

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

        wavewidthOneLabel.setText("Wave Width One");
        wavewidthOneLabel.setPreferredSize(new java.awt.Dimension(90, 20));
        OptionPanel.add(wavewidthOneLabel, java.awt.BorderLayout.CENTER);

        wavewidthOneField.setText("250");
        wavewidthOneField.setPreferredSize(new java.awt.Dimension(90, 20));
        OptionPanel.add(wavewidthOneField, java.awt.BorderLayout.CENTER);

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

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

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


        wavewidthTwoLabel.setText("Wave Width Two");
        wavewidthTwoLabel.setPreferredSize(new java.awt.Dimension(90, 20));
        OptionPanel.add(wavewidthTwoLabel, java.awt.BorderLayout.CENTER);

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

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

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

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

        wavewidthThreeLabel.setText("Wave Width Three");
        wavewidthThreeLabel.setPreferredSize(new java.awt.Dimension(90, 20));
        OptionPanel.add(wavewidthThreeLabel, java.awt.BorderLayout.CENTER);

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

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

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

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

        wavewidthFourLabel.setText("Wave Width Four");
        wavewidthFourLabel.setPreferredSize(new java.awt.Dimension(90, 20));
        OptionPanel.add(wavewidthFourLabel, java.awt.BorderLayout.CENTER);

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

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

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

        OptionPanel.add(wavewidthFourSlider, 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.Crest.doDraw(Integer.parseInt(wavewidthOneField.getText()),
        				Integer.parseInt(wavewidthTwoField.getText()),
        				Integer.parseInt(wavewidthThreeField.getText()),
        				Integer.parseInt(wavewidthFourField.getText()),
                                        Integer.parseInt(wavedepthOneField.getText()),
                                        Integer.parseInt(wavedepthTwoField.getText()),
        				Integer.parseInt(wavedepthThreeField.getText()),
        				Integer.parseInt(wavedepthFourField.getText()),
                                        Integer.parseInt(xtransField.getText())));

    }

    private void DrawButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DrawButtonActionPerformed
        Draw();
    }//GEN-LAST:event_DrawButtonActionPerformed


    private void wavewidthOneSliderMouseReleased(MouseEvent evt) {
               wavewidthOneField.setText(Integer.toString(wavewidthOneSlider.getValue()));
               Draw();
    }

    private void xtransSliderMouseReleased(MouseEvent evt) {
               xtransField.setText(Integer.toString(xtransSlider.getValue()));
               Draw();
    }

    private void wavewidthTwoSliderMouseReleased(MouseEvent evt) {
               wavewidthTwoField.setText(Integer.toString(wavewidthTwoSlider.getValue()));
               Draw();
    }

    private void wavewidthThreeSliderMouseReleased(MouseEvent evt) {
               wavewidthThreeField.setText(Integer.toString(wavewidthThreeSlider.getValue()));
               Draw();
    }

    private void wavewidthFourSliderMouseReleased(MouseEvent evt) {
               wavewidthFourField.setText(Integer.toString(wavewidthFourSlider.getValue()));
               Draw();
    }

    private void wavedepthOneSliderMouseReleased(MouseEvent evt) {
               wavedepthOneField.setText(Integer.toString(wavedepthOneSlider.getValue()));
               Draw();
    }

    private void wavedepthTwoSliderMouseReleased(MouseEvent evt) {
               wavedepthTwoField.setText(Integer.toString(wavedepthTwoSlider.getValue()));
               Draw();
    }

    private void wavedepthThreeSliderMouseReleased(MouseEvent evt) {
               wavedepthThreeField.setText(Integer.toString(wavedepthThreeSlider.getValue()));
               Draw();
    }

    private void wavedepthFourSliderMouseReleased(MouseEvent evt) {
               wavedepthFourField.setText(Integer.toString(wavedepthFourSlider.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.Crest.colorOne = selectedColor;
                     Draw();
                }
    }
}
