/*
 * BarPanel_n.java
 *
 * Created on November 12, 2003, 5:45 PM
 */
package usda.weru.weps.gui;

import usda.weru.weps.Barrier;

/**
 * This GUI allows the user to select the different types of barries that could be
 * put along the different directions like north, east, etc.
 * @author  manmohan
 */
public class BarPanel_n extends javax.swing.JFrame {

    private static final long serialVersionUID = 1L;

    /** 
     * Default constructor that creates the new form BarPanel_n 
     */
    public BarPanel_n() {
        initComponents();
    }

    /**
     * Single argument constructor for the barrier panel
     * @param title This is the title string of the GUI frame.
     */
    public BarPanel_n(java.lang.String title) {
        this();
        setTitle(title);
    }

    /** This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        RBG_BarPanel = new javax.swing.ButtonGroup();
        JP_main = new javax.swing.JPanel();
        JRB_N = new javax.swing.JRadioButton();
        JCB_N = new javax.swing.JComboBox<Barrier>();
        JCB_S = new javax.swing.JComboBox<Barrier>();
        JRB_S = new javax.swing.JRadioButton();
        JRB_E = new javax.swing.JRadioButton();
        JRB_W = new javax.swing.JRadioButton();
        JRB_None = new javax.swing.JRadioButton();
        JCB_E = new javax.swing.JComboBox<Barrier>();
        JCB_W = new javax.swing.JComboBox<Barrier>();
        JB_detail = new javax.swing.JButton();

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        JP_main.setToolTipText("BarPanel:main");

        RBG_BarPanel.add(JRB_N);
        JRB_N.setText("N");
        JRB_N.setToolTipText("BarPanel:nButton");
        JRB_N.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                JRBN_MouseClicked(evt);
            }
        });

        JCB_N.setToolTipText("BarPanel:nBox");
        JCB_N.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                JCBN_ItemStateChanged(evt);
            }
        });

        JCB_S.setToolTipText("BarPanel:sBox");
        JCB_S.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                JCBS_ItemStateChanged(evt);
            }
        });

        RBG_BarPanel.add(JRB_S);
        JRB_S.setText("S");
        JRB_S.setToolTipText("BarPanel:sButton");
        JRB_S.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                JRBS_MouseClicked(evt);
            }
        });

        RBG_BarPanel.add(JRB_E);
        JRB_E.setText("E");
        JRB_E.setToolTipText("BarPanel:eButton");
        JRB_E.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                JRBE_MouseClicked(evt);
            }
        });

        RBG_BarPanel.add(JRB_W);
        JRB_W.setText("W");
        JRB_W.setToolTipText("BarPanel:wButton");
        JRB_W.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                JRBW_MouseClicked(evt);
            }
        });

        RBG_BarPanel.add(JRB_None);
        JRB_None.setSelected(true);
        JRB_None.setText("None");
        JRB_None.setHideActionText(true);

        JCB_E.setToolTipText("BarPanel:eBox");
        JCB_E.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                JCBE_ItemStateChanged(evt);
            }
        });

        JCB_W.setToolTipText("BarPanel:wBox");
        JCB_W.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                JCBW_ItemStateChanged(evt);
            }
        });

        JB_detail.setText("Edit Selected Barrier");
        JB_detail.setToolTipText("BarPanel:detail");
        JB_detail.setEnabled(false);
        JB_detail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_detail_ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout JP_mainLayout = new javax.swing.GroupLayout(JP_main);
        JP_main.setLayout(JP_mainLayout);
        JP_mainLayout.setHorizontalGroup(
            JP_mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JP_mainLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(JP_mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(JB_detail, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, JP_mainLayout.createSequentialGroup()
                        .addGroup(JP_mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(JRB_S, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(JRB_N, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(JP_mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(JCB_S, 0, 142, Short.MAX_VALUE)
                            .addComponent(JCB_N, 0, 142, Short.MAX_VALUE)))
                    .addGroup(JP_mainLayout.createSequentialGroup()
                        .addComponent(JRB_E, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(JCB_E, 0, 142, Short.MAX_VALUE))
                    .addGroup(JP_mainLayout.createSequentialGroup()
                        .addComponent(JRB_W, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(JCB_W, 0, 142, Short.MAX_VALUE))
                    .addGroup(JP_mainLayout.createSequentialGroup()
                        .addComponent(JRB_None, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        JP_mainLayout.setVerticalGroup(
            JP_mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JP_mainLayout.createSequentialGroup()
                .addGroup(JP_mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JRB_N, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(JCB_N, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, 0)
                .addGroup(JP_mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(JCB_S, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(JRB_S, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, 0)
                .addGroup(JP_mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JRB_E, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(JCB_E, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, 0)
                .addGroup(JP_mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(JRB_W, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(JCB_W, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(JRB_None, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(JB_detail, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        JRB_None.getAccessibleContext().setAccessibleDescription("BarPanel:wButton");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(JP_main, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(JP_main, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        setSize(new java.awt.Dimension(212, 169));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents
    private int countN = 0;
    private int countW = 0;
    private int countE = 0;
    private int countS = 0;
    private void JRBN_MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_JRBN_MouseClicked
        JRBN_mouseClicked(evt);
        if (JRB_N.isSelected()) {
            countN++;
            if (countN % 2 == 0) {
                JRB_N.setSelected(false);
                JRB_None.setSelected(true);
                JRBNone_mouseClicked(evt);
                JB_detail.setEnabled(false);
            } else {
                JRB_N.setSelected(true);
                JB_detail.setEnabled(true);
            }
            countS = 0;
            countW = 0;
            countE = 0;
        }
    }//GEN-LAST:event_JRBN_MouseClicked

    private void JRBW_MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_JRBW_MouseClicked
        JRBW_mouseClicked(evt);
        if (JRB_W.isSelected()) {
            countW++;
            if (countW % 2 == 0) {
                JRB_W.setSelected(false);
                JRB_None.setSelected(true);
                JRBNone_mouseClicked(evt);
                JB_detail.setEnabled(false);
            } else {
                JRB_W.setSelected(true);
                JB_detail.setEnabled(true);
            }
            countN = 0;
            countS = 0;
            countE = 0;
        }

    }//GEN-LAST:event_JRBW_MouseClicked

    private void JRBE_MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_JRBE_MouseClicked
        JRBE_mouseClicked(evt);
        if (JRB_E.isSelected()) {
            countE++;
            if (countE % 2 == 0) {
                JRB_E.setSelected(false);
                JRB_None.setSelected(true);
                JRBNone_mouseClicked(evt);
                JB_detail.setEnabled(false);
            } else {
                JRB_E.setSelected(true);
                JB_detail.setEnabled(true);
            }
            countN = 0;
            countW = 0;
            countS = 0;
        }
    }//GEN-LAST:event_JRBE_MouseClicked

    private void JRBS_MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_JRBS_MouseClicked
        JRBS_mouseClicked(evt);
        if (JRB_S.isSelected()) {
            countS++;
            if (countS % 2 == 0) {
                JRB_S.setSelected(false);
                JRB_None.setSelected(true);
                JRBNone_mouseClicked(evt);
                JB_detail.setEnabled(false);
            } else {
                JRB_S.setSelected(true);
                JB_detail.setEnabled(true);
            }
            countN = 0;
            countW = 0;
            countE = 0;
        }
    }//GEN-LAST:event_JRBS_MouseClicked

    private void JB_detail_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_detail_ActionPerformed
        JB_detail_actionPerformed(evt);
    }//GEN-LAST:event_JB_detail_ActionPerformed

    private void JCBN_ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_JCBN_ItemStateChanged
        JCBN_itemStateChanged(evt);
    }//GEN-LAST:event_JCBN_ItemStateChanged

    private void JCBS_ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_JCBS_ItemStateChanged
        JCBS_itemStateChanged(evt);
    }//GEN-LAST:event_JCBS_ItemStateChanged

    private void JCBE_ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_JCBE_ItemStateChanged
        JCBE_itemStateChanged(evt);
    }//GEN-LAST:event_JCBE_ItemStateChanged

    private void JCBW_ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_JCBW_ItemStateChanged
        JCBW_itemStateChanged(evt);
    }//GEN-LAST:event_JCBW_ItemStateChanged

    /** 
     * This method is called when the "NORTH radio button" gets clicked for selecting
     * or de-selecting NORTH side barrier.  
     * @param evt This mouse event is generated when the NORTH barrier is to be chosen
     * to set up some type of preset barriers populated in the combo-box.
     */
    public void JRBN_mouseClicked(java.awt.event.MouseEvent evt) {
    }

    /** 
     * This method is called when the "SOUTH radio button" gets clicked for selecting
     * or de-selecting SOUTH side barrier.  
     * @param evt This mouse event is generated when the SOUTH barrier is to be chosen
     * to set up some type of preset barriers populated in the combo-box.
     */
    public void JRBS_mouseClicked(java.awt.event.MouseEvent evt) {
    }

    /** 
     * This method is called when the "EAST radio button" gets clicked for selecting
     * or de-selecting EAST side barrier..  
     * @param evt This mouse event is generated when the EAST barrier is to be chosen
     * to set up some type of preset barriers populated in the combo-box.
     */
    public void JRBE_mouseClicked(java.awt.event.MouseEvent evt) {
    }

    /** 
     * This method is called when the "WEST radio button" gets clicked for selecting
     * or de-selecting the WEST side barrier.  
     * @param evt This mouse event is generated when the WEST barrier is to be chosen
     * to set up some type of preset barriers populated in the combo-box.
     */
    public void JRBW_mouseClicked(java.awt.event.MouseEvent evt) {
    }

    /** 
     * This method is called when the "NONE radio button" gets clicked for selecting
     * or de-selecting the barriers .. here no barrier should be selected or all deselected
     * @param evt This mouse event is generated when the NONE barrier is to be chosen
     * to set up some type of preset barriers populated in the combo-box.
     */
    public void JRBNone_mouseClicked(java.awt.event.MouseEvent evt) {
    }

    /** 
     * This method is called when the "NORTH Combo Box" is clicked for selecting
     * or de-selecting the side barriers either changing the current selection or
     * or making the selection for the first time.  
     * @param evt This mouse event is generated when the NORTH Combo Box is clicked
     * to set up some type of preset barriers populated in the combo-box list.
     */
    public void JCBN_itemStateChanged(java.awt.event.ItemEvent evt) {
    }

    /** 
     * This method is called when the "SOUTH Combo Box" is clicked for selecting
     * or de-selecting the side barriers either changing the current selection or
     * or making the selection for the first time.  
     * @param evt This mouse event is generated when the SOUTH Combo Box is clicked
     * to set up some type of preset barriers populated in the combo-box list.
     */
    public void JCBS_itemStateChanged(java.awt.event.ItemEvent evt) {
    }

    /** 
     * This method is called when the "EAST Combo Box" is clicked for selecting
     * or de-selecting the side barriers either changing the current selection or
     * or making the selection for the first time.  
     * @param evt This mouse event is generated when the EAST Combo Box is clicked
     * to set up some type of preset barriers populated in the combo-box list.
     */
    public void JCBE_itemStateChanged(java.awt.event.ItemEvent evt) {
    }

    /** 
     * This method is called when the "WEST Combo Box" is clicked for selecting
     * or de-selecting the side barriers either changing the current selection or
     * or making the selection for the first time.  
     * @param evt This mouse event is generated when the WEST Combo Box is clicked
     * to set up some type of preset barriers populated in the combo-box list.
     */
    public void JCBW_itemStateChanged(java.awt.event.ItemEvent evt) {
    }

    /** 
     * This method is called when the dimensions like width, height, porosity, etc.
     * of a particular barrier that is currrently selected needs to be changed. 
     * @param evt This action event is generated when the Edit Selected Barrier button
     * is clicked for modifying current barrier dimensions.
     */
    public void JB_detail_actionPerformed(java.awt.event.ActionEvent evt) {
    }

    /** 
     * This method is called when the about dialog is to be closed by hitting the 
     * "Red X" button of the window.
     * @param evt The window event generated when the " Red X " button on the 
     * window is hit. 
     */
    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
        System.exit(0);
    }//GEN-LAST:event_exitForm

    /**
     * This method is used if this dialog is rum as an independent application.
     * @param args These are the command line arguments passed to the main method.
     */
    public static void main(String args[]) {
        new BarPanel_n().setVisible(true);
    }

    /**
     * This method notifies when the window or frame is resized and the components 
     * need to be re-arranged so they are evenly spaced relative to each other.
     */
    @Override
    public void addNotify() {
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton JB_detail;
    public javax.swing.JComboBox<Barrier> JCB_E;
    public javax.swing.JComboBox<Barrier> JCB_N;
    public javax.swing.JComboBox<Barrier> JCB_S;
    public javax.swing.JComboBox<Barrier> JCB_W;
    public javax.swing.JPanel JP_main;
    public javax.swing.JRadioButton JRB_E;
    public javax.swing.JRadioButton JRB_N;
    public javax.swing.JRadioButton JRB_None;
    public javax.swing.JRadioButton JRB_S;
    public javax.swing.JRadioButton JRB_W;
    public javax.swing.ButtonGroup RBG_BarPanel;
    // End of variables declaration//GEN-END:variables

}
