001    /*
002     * AdvEtchControls.java
003     *
004     * Created on January 13, 2003, 5:51 PM
005     */
006    
007    package spirograph;
008    
009    /**
010     * A swing based interface for the advanced environment
011     * options. This class is indended to supplant AdvEnv.
012     *
013     * @author  Patrick G. Heck, gus.heck@olin.edu
014     */
015    public class AdvEtchControls extends javax.swing.JFrame {
016        
017        /** Creates new form AdvEtchControls */
018        public AdvEtchControls() {
019            initComponents();
020        }
021        
022        /** This method is called from within the constructor to
023         * initialize the form.
024         * WARNING: Do NOT modify this code. The content of this method is
025         * always regenerated by the Form Editor.
026         */
027        private void initComponents() {//GEN-BEGIN:initComponents
028            java.awt.GridBagConstraints gridBagConstraints;
029    
030            edgeControlButtonGroup = new javax.swing.ButtonGroup();
031            controlModeButtonGroup = new javax.swing.ButtonGroup();
032            centerPanel = new javax.swing.JPanel();
033            edgePanel = new javax.swing.JPanel();
034            stickyRadioButton = new javax.swing.JRadioButton();
035            bounceRadioButton = new javax.swing.JRadioButton();
036            wrapRadioButton = new javax.swing.JRadioButton();
037            circularRadioButton = new javax.swing.JRadioButton();
038            movementPanel = new javax.swing.JPanel();
039            posRadioButton = new javax.swing.JRadioButton();
040            velRadioButton = new javax.swing.JRadioButton();
041            accelRatioButton = new javax.swing.JRadioButton();
042            horzDelayPanel = new javax.swing.JPanel();
043            horzDelaySlider = new javax.swing.JSlider();
044            horzDelayTextField = new javax.swing.JTextField();
045            vertDelayPanel = new javax.swing.JPanel();
046            vertDelaySlider = new javax.swing.JSlider();
047            vertDelayTextField = new javax.swing.JTextField();
048    
049            setTitle("Advanced Etch Controls");
050            setResizable(false);
051            addWindowListener(new java.awt.event.WindowAdapter() {
052                public void windowClosing(java.awt.event.WindowEvent evt) {
053                    exitForm(evt);
054                }
055            });
056    
057            centerPanel.setLayout(new java.awt.GridBagLayout());
058    
059            centerPanel.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(4, 4, 4, 4)));
060            edgePanel.setLayout(new java.awt.GridLayout(4, 1));
061    
062            edgePanel.setBorder(new javax.swing.border.TitledBorder(null, "Edge Mode", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 10)));
063            stickyRadioButton.setSelected(true);
064            stickyRadioButton.setText("Sticky");
065            edgeControlButtonGroup.add(stickyRadioButton);
066            edgePanel.add(stickyRadioButton);
067    
068            bounceRadioButton.setText("Bouncing");
069            edgeControlButtonGroup.add(bounceRadioButton);
070            edgePanel.add(bounceRadioButton);
071    
072            wrapRadioButton.setText("Wraparound");
073            edgeControlButtonGroup.add(wrapRadioButton);
074            edgePanel.add(wrapRadioButton);
075    
076            circularRadioButton.setText("Circular");
077            edgeControlButtonGroup.add(circularRadioButton);
078            edgePanel.add(circularRadioButton);
079    
080            gridBagConstraints = new java.awt.GridBagConstraints();
081            gridBagConstraints.gridx = 1;
082            gridBagConstraints.gridy = 0;
083            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
084            gridBagConstraints.weightx = 1.0;
085            centerPanel.add(edgePanel, gridBagConstraints);
086    
087            movementPanel.setLayout(new java.awt.GridLayout(3, 1));
088    
089            movementPanel.setBorder(new javax.swing.border.TitledBorder(null, "Movement Mode", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 10)));
090            posRadioButton.setSelected(true);
091            posRadioButton.setText("Position");
092            controlModeButtonGroup.add(posRadioButton);
093            posRadioButton.addActionListener(new java.awt.event.ActionListener() {
094                public void actionPerformed(java.awt.event.ActionEvent evt) {
095                    posRadioButtonActionPerformed(evt);
096                }
097            });
098    
099            movementPanel.add(posRadioButton);
100    
101            velRadioButton.setText("Velocity");
102            controlModeButtonGroup.add(velRadioButton);
103            velRadioButton.addActionListener(new java.awt.event.ActionListener() {
104                public void actionPerformed(java.awt.event.ActionEvent evt) {
105                    velRadioButtonActionPerformed(evt);
106                }
107            });
108    
109            movementPanel.add(velRadioButton);
110    
111            accelRatioButton.setText("Acceleration");
112            controlModeButtonGroup.add(accelRatioButton);
113            accelRatioButton.addActionListener(new java.awt.event.ActionListener() {
114                public void actionPerformed(java.awt.event.ActionEvent evt) {
115                    accelRatioButtonActionPerformed(evt);
116                }
117            });
118    
119            movementPanel.add(accelRatioButton);
120    
121            gridBagConstraints = new java.awt.GridBagConstraints();
122            gridBagConstraints.gridx = 0;
123            gridBagConstraints.gridy = 0;
124            gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
125            gridBagConstraints.weightx = 1.0;
126            centerPanel.add(movementPanel, gridBagConstraints);
127    
128            horzDelayPanel.setLayout(new java.awt.GridBagLayout());
129    
130            horzDelayPanel.setBorder(new javax.swing.border.TitledBorder(null, "Horizontal Delay", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 10)));
131            horzDelaySlider.setMaximum(1000);
132            horzDelaySlider.setMinimum(10);
133            horzDelaySlider.setValue(100);
134            horzDelaySlider.addChangeListener(new javax.swing.event.ChangeListener() {
135                public void stateChanged(javax.swing.event.ChangeEvent evt) {
136                    horzDelaySliderStateChanged(evt);
137                }
138            });
139    
140            gridBagConstraints = new java.awt.GridBagConstraints();
141            gridBagConstraints.gridx = 0;
142            gridBagConstraints.gridy = 0;
143            gridBagConstraints.gridwidth = 2;
144            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
145            gridBagConstraints.weightx = 1.0;
146            horzDelayPanel.add(horzDelaySlider, gridBagConstraints);
147    
148            horzDelayTextField.setColumns(4);
149            horzDelayTextField.setText("100");
150            horzDelayTextField.addActionListener(new java.awt.event.ActionListener() {
151                public void actionPerformed(java.awt.event.ActionEvent evt) {
152                    horzDelayTextFieldActionPerformed(evt);
153                }
154            });
155    
156            horzDelayPanel.add(horzDelayTextField, new java.awt.GridBagConstraints());
157    
158            gridBagConstraints = new java.awt.GridBagConstraints();
159            gridBagConstraints.gridx = 0;
160            gridBagConstraints.gridy = 2;
161            gridBagConstraints.gridwidth = 2;
162            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
163            centerPanel.add(horzDelayPanel, gridBagConstraints);
164    
165            vertDelayPanel.setLayout(new java.awt.GridBagLayout());
166    
167            vertDelayPanel.setBorder(new javax.swing.border.TitledBorder(null, "Vertical Delay", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 10)));
168            vertDelaySlider.setMaximum(1000);
169            vertDelaySlider.setMinimum(10);
170            vertDelaySlider.setValue(100);
171            vertDelaySlider.addChangeListener(new javax.swing.event.ChangeListener() {
172                public void stateChanged(javax.swing.event.ChangeEvent evt) {
173                    vertDelaySliderStateChanged(evt);
174                }
175            });
176    
177            gridBagConstraints = new java.awt.GridBagConstraints();
178            gridBagConstraints.gridx = 0;
179            gridBagConstraints.gridy = 0;
180            gridBagConstraints.gridwidth = 2;
181            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
182            gridBagConstraints.weightx = 1.0;
183            vertDelayPanel.add(vertDelaySlider, gridBagConstraints);
184    
185            vertDelayTextField.setColumns(4);
186            vertDelayTextField.setText("100");
187            vertDelayTextField.addActionListener(new java.awt.event.ActionListener() {
188                public void actionPerformed(java.awt.event.ActionEvent evt) {
189                    vertDelayTextFieldActionPerformed(evt);
190                }
191            });
192    
193            vertDelayPanel.add(vertDelayTextField, new java.awt.GridBagConstraints());
194    
195            gridBagConstraints = new java.awt.GridBagConstraints();
196            gridBagConstraints.gridx = 0;
197            gridBagConstraints.gridy = 3;
198            gridBagConstraints.gridwidth = 2;
199            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
200            centerPanel.add(vertDelayPanel, gridBagConstraints);
201    
202            getContentPane().add(centerPanel, java.awt.BorderLayout.CENTER);
203    
204            pack();
205        }//GEN-END:initComponents
206    
207        private void vertDelayTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vertDelayTextFieldActionPerformed
208            // Add your handling code here:
209                    try {
210                vertDelaySlider.setValue(Integer.
211                    parseInt(vertDelayTextField.getText()));
212            } catch (NumberFormatException nfe) {
213                vertDelayTextField.setText(vertDelaySlider.getValue()+"");
214            }
215        }//GEN-LAST:event_vertDelayTextFieldActionPerformed
216    
217        private void horzDelayTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_horzDelayTextFieldActionPerformed
218            // Add your handling code here:
219            try {
220                horzDelaySlider.setValue(Integer.
221                    parseInt(horzDelayTextField.getText()));
222            } catch (NumberFormatException nfe) {
223                horzDelayTextField.setText(horzDelaySlider.getValue()+"");
224            }
225        }//GEN-LAST:event_horzDelayTextFieldActionPerformed
226    
227        private void vertDelaySliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_vertDelaySliderStateChanged
228            // Add your handling code here:
229            vertDelayTextField.setText(vertDelaySlider.getValue()+"");
230        }//GEN-LAST:event_vertDelaySliderStateChanged
231    
232        private void horzDelaySliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_horzDelaySliderStateChanged
233            // Add your handling code here:
234            horzDelayTextField.setText(horzDelaySlider.getValue()+"");
235        }//GEN-LAST:event_horzDelaySliderStateChanged
236    
237        private void accelRatioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_accelRatioButtonActionPerformed
238            // Add your handling code here:
239        }//GEN-LAST:event_accelRatioButtonActionPerformed
240    
241        private void velRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_velRadioButtonActionPerformed
242            // Add your handling code here:
243       
244        }//GEN-LAST:event_velRadioButtonActionPerformed
245    
246        private void posRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_posRadioButtonActionPerformed
247            // Add your handling code here:
248    
249        }//GEN-LAST:event_posRadioButtonActionPerformed
250        
251        /** Exit the Application */
252        private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
253            System.exit(0);
254        }//GEN-LAST:event_exitForm
255        
256        /** For test viewing purposes only. Will be removed once this code is integrated with the
257         * problem set.
258         *
259         * @param args the command line arguments
260         */
261        public static void main(String args[]) {
262            new AdvEtchControls().show();
263        }
264        
265        
266        // Variables declaration - do not modify//GEN-BEGIN:variables
267        private javax.swing.JRadioButton circularRadioButton;
268        private javax.swing.JSlider vertDelaySlider;
269        private javax.swing.JPanel movementPanel;
270        private javax.swing.JRadioButton accelRatioButton;
271        private javax.swing.JPanel horzDelayPanel;
272        private javax.swing.JTextField vertDelayTextField;
273        private javax.swing.JSlider horzDelaySlider;
274        private javax.swing.JTextField horzDelayTextField;
275        private javax.swing.JRadioButton bounceRadioButton;
276        private javax.swing.JPanel centerPanel;
277        private javax.swing.ButtonGroup edgeControlButtonGroup;
278        private javax.swing.JRadioButton wrapRadioButton;
279        private javax.swing.JPanel vertDelayPanel;
280        private javax.swing.JRadioButton velRadioButton;
281        private javax.swing.JRadioButton posRadioButton;
282        private javax.swing.JRadioButton stickyRadioButton;
283        private javax.swing.JPanel edgePanel;
284        private javax.swing.ButtonGroup controlModeButtonGroup;
285        // End of variables declaration//GEN-END:variables
286        
287    }
288    
289    /*
290     * $Log: AdvEtchControls.java,v $
291     * Revision 1.3  2003/01/14 19:40:28  gus
292     * added a doc comment
293     *
294     * Revision 1.2  2003/01/14 16:42:48  gus
295     * Remove Movement Input and switch the position of Movement mode with
296     * Edge Mode.
297     *
298     * Revision 1.1  2003/01/14 00:45:38  gus
299     * Swing based class to replace AdvEnv (for use with EtchControl).
300     * Also contains sliders to adjust the delay of the X and Y threads.
301     *
302     */