001: /*
002: * $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/utils/vpbehaviors/FlyControlDialog.java,v 1.1 2005/04/20 21:05:13 paulby Exp $
003: *
004: * Sun Public License Notice
005: *
006: * The contents of this file are subject to the Sun Public License Version
007: * 1.0 (the "License"). You may not use this file except in compliance with
008: * the License. A copy of the License is available at http://www.sun.com/
009: *
010: * The Original Code is Java 3D(tm) Fly Through.
011: * The Initial Developer of the Original Code is Paul Byrne.
012: * Portions created by Paul Byrne are Copyright (C) 2002.
013: * All Rights Reserved.
014: *
015: * Contributor(s): Paul Byrne.
016: *
017: **/
018: package org.jdesktop.j3dfly.utils.vpbehaviors;
019:
020: import org.jdesktop.j3dfly.utils.gui.FloatDocument;
021:
022: /**
023: *
024: * @author Paul Byrne
025: * @version 1.5 01/18/02
026: */
027: public class FlyControlDialog extends javax.swing.JDialog {
028:
029: private boolean userCancel = true; // Did user cancel dialog ?
030:
031: /** Creates new form FlyControlDialog */
032: public FlyControlDialog(java.awt.Frame parent, boolean modal) {
033: super (parent, modal);
034: initComponents();
035: pack();
036:
037: int x = parent.getWidth() / 2 - this .getWidth() / 2;
038: int y = parent.getHeight() / 2 - this .getHeight() / 2;
039:
040: setLocation(x, y);
041: }
042:
043: /** This method is called from within the constructor to
044: * initialize the form.
045: * WARNING: Do NOT modify this code. The content of this method is
046: * always regenerated by the FormEditor.
047: */
048: private void initComponents() {//GEN-BEGIN:initComponents
049: jPanel1 = new javax.swing.JPanel();
050: jLabel1 = new javax.swing.JLabel();
051: jLabel2 = new javax.swing.JLabel();
052: stepTF = new javax.swing.JTextField();
053: angleTF = new javax.swing.JTextField();
054: jLabel3 = new javax.swing.JLabel();
055: jLabel4 = new javax.swing.JLabel();
056: jPanel2 = new javax.swing.JPanel();
057: okB = new javax.swing.JButton();
058: cancelB = new javax.swing.JButton();
059: addWindowListener(new java.awt.event.WindowAdapter() {
060: public void windowClosing(java.awt.event.WindowEvent evt) {
061: closeDialog(evt);
062: }
063: });
064:
065: jPanel1.setLayout(new java.awt.GridBagLayout());
066: java.awt.GridBagConstraints gridBagConstraints1;
067:
068: jLabel1.setText("Step size");
069: gridBagConstraints1 = new java.awt.GridBagConstraints();
070: gridBagConstraints1.insets = new java.awt.Insets(0, 0, 0, 4);
071: gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST;
072: jPanel1.add(jLabel1, gridBagConstraints1);
073:
074: jLabel2.setText("Angle Size");
075: gridBagConstraints1 = new java.awt.GridBagConstraints();
076: gridBagConstraints1.gridx = 0;
077: gridBagConstraints1.gridy = 1;
078: gridBagConstraints1.insets = new java.awt.Insets(0, 0, 0, 4);
079: gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST;
080: jPanel1.add(jLabel2, gridBagConstraints1);
081:
082: stepTF.setPreferredSize(new java.awt.Dimension(60, 21));
083: stepTF
084: .setToolTipText("The maximum distance view will move per frame when mouse pointer is at the window limit");
085: stepTF.setText("jTextField1");
086: stepTF.setMinimumSize(new java.awt.Dimension(60, 21));
087: stepTF.setDocument(new FloatDocument());
088: gridBagConstraints1 = new java.awt.GridBagConstraints();
089: jPanel1.add(stepTF, gridBagConstraints1);
090:
091: angleTF.setPreferredSize(new java.awt.Dimension(60, 21));
092: angleTF
093: .setToolTipText("The maximum rotation angle the view will move per frame");
094: angleTF.setText("jTextField2");
095: angleTF.setMinimumSize(new java.awt.Dimension(60, 21));
096: angleTF.setDocument(new FloatDocument());
097: gridBagConstraints1 = new java.awt.GridBagConstraints();
098: gridBagConstraints1.gridx = 1;
099: gridBagConstraints1.gridy = 1;
100: jPanel1.add(angleTF, gridBagConstraints1);
101:
102: jLabel3.setText("m.");
103: gridBagConstraints1 = new java.awt.GridBagConstraints();
104: gridBagConstraints1.insets = new java.awt.Insets(0, 4, 0, 0);
105: gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
106: jPanel1.add(jLabel3, gridBagConstraints1);
107:
108: jLabel4.setText("deg.");
109: gridBagConstraints1 = new java.awt.GridBagConstraints();
110: gridBagConstraints1.gridx = 2;
111: gridBagConstraints1.gridy = 1;
112: gridBagConstraints1.insets = new java.awt.Insets(0, 4, 0, 0);
113: gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
114: jPanel1.add(jLabel4, gridBagConstraints1);
115:
116: getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
117:
118: okB.setText("OK");
119: okB.addActionListener(new java.awt.event.ActionListener() {
120: public void actionPerformed(java.awt.event.ActionEvent evt) {
121: okBActionPerformed(evt);
122: }
123: });
124: jPanel2.add(okB);
125:
126: cancelB.setText("Cancel");
127: cancelB.addActionListener(new java.awt.event.ActionListener() {
128: public void actionPerformed(java.awt.event.ActionEvent evt) {
129: cancelBActionPerformed(evt);
130: }
131: });
132: jPanel2.add(cancelB);
133:
134: getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
135:
136: }//GEN-END:initComponents
137:
138: private void cancelBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBActionPerformed
139: // Add your handling code here:
140: setVisible(false);
141: userCancel = true;
142: }//GEN-LAST:event_cancelBActionPerformed
143:
144: private void okBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okBActionPerformed
145: // Add your handling code here:
146: setVisible(false);
147: userCancel = false;
148: }//GEN-LAST:event_okBActionPerformed
149:
150: /** Closes the dialog */
151: private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
152: setVisible(false);
153: dispose();
154: userCancel = true;
155: }//GEN-LAST:event_closeDialog
156:
157: /**
158: * User cancelled dialog
159: *
160: * @return false if the OK button was pressed, false otherwise
161: */
162: public boolean userCancelled() {
163: return userCancel;
164: }
165:
166: /**
167: * Returns the angle from the dialog
168: */
169: public float getAngle() {
170: try {
171: return Float.parseFloat(angleTF.getText());
172: } catch (NumberFormatException e) {
173: e.printStackTrace();
174: return 3f;
175: }
176: }
177:
178: public void setAngle(float angle) {
179: angleTF.setText(Float.toString(angle));
180: }
181:
182: /**
183: * Returns the step from the dialog
184: */
185: public float getStep() {
186: try {
187: return Float.parseFloat(stepTF.getText());
188: } catch (NumberFormatException e) {
189: e.printStackTrace();
190: return 10f;
191: }
192: }
193:
194: public void setStep(float step) {
195: stepTF.setText(Float.toString(step));
196: }
197:
198: // Variables declaration - do not modify//GEN-BEGIN:variables
199: private javax.swing.JPanel jPanel1;
200: private javax.swing.JLabel jLabel1;
201: private javax.swing.JLabel jLabel2;
202: private javax.swing.JTextField stepTF;
203: private javax.swing.JTextField angleTF;
204: private javax.swing.JLabel jLabel3;
205: private javax.swing.JLabel jLabel4;
206: private javax.swing.JPanel jPanel2;
207: private javax.swing.JButton okB;
208: private javax.swing.JButton cancelB;
209: // End of variables declaration//GEN-END:variables
210:
211: }
|