001: /*
002: * $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/ControlFrame.java,v 1.1 2005/04/20 21:04:19 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;
019:
020: import java.awt.Cursor;
021: import java.util.ArrayList;
022:
023: import javax.swing.JFileChooser;
024: import javax.swing.JLabel;
025: import javax.swing.JComboBox;
026: import javax.swing.JOptionPane;
027: import javax.swing.SwingUtilities;
028: import javax.swing.ProgressMonitor;
029:
030: import javax.media.j3d.BranchGroup;
031: import javax.media.j3d.BoundingSphere;
032: import javax.media.j3d.Bounds;
033: import javax.media.j3d.TransformGroup;
034: import javax.media.j3d.View;
035: import javax.media.j3d.Transform3D;
036: import javax.media.j3d.BoundingSphere;
037: import javax.media.j3d.PolygonAttributes;
038: import javax.media.j3d.DirectionalLight;
039: import javax.media.j3d.Node;
040: import javax.media.j3d.ViewPlatform;
041:
042: import javax.vecmath.Point3d;
043: import javax.vecmath.Vector3d;
044: import javax.vecmath.Color3f;
045: import javax.vecmath.Vector3f;
046:
047: import com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior;
048: import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
049:
050: import org.jdesktop.j3dfly.warp.WarpSet;
051: import org.jdesktop.j3dfly.warp.WarpEditorDialog;
052:
053: import org.jdesktop.j3dfly.utils.loadercontrol.LoaderControl;
054: import org.jdesktop.j3dfly.utils.loadercontrol.LoaderControlListener;
055: import org.jdesktop.j3dfly.utils.vpbehaviors.HoverBehavior;
056: import org.jdesktop.j3dfly.utils.vpbehaviors.FlyBehavior;
057: import org.jdesktop.j3dfly.utils.vpbehaviors.VPCollisionBehavior;
058: import org.jdesktop.j3dfly.utils.vpbehaviors.VPDefaultCollision;
059: import org.jdesktop.j3dfly.utils.vpbehaviors.VPDriveCollision;
060: import org.jdesktop.j3dfly.utils.vpbehaviors.ViewUtils;
061: import org.jdesktop.j3dfly.utils.vpbehaviors.SimpleSweptVolume;
062:
063: import org.jdesktop.j3d.utils.scenegraph.traverser.ChangePolygonAttributes;
064: import org.jdesktop.j3d.utils.scenegraph.traverser.ChangeTextureAttributes;
065: import org.jdesktop.j3d.utils.scenegraph.traverser.TreeScan;
066: import org.jdesktop.j3d.utils.scenegraph.traverser.ChangeMaterial;
067: import org.jdesktop.j3d.utils.scenegraph.traverser.NodeChangeProcessor;
068: import org.jdesktop.j3d.utils.scenegraph.traverser.BehaviorSetEnable; //import com.sun.j3d.demos.utils.scenegraph.io.SceneGraphFileWriter;
069: import org.jdesktop.j3dfly.utils.loadercontrol.ExampleFileFilter;
070: import org.jdesktop.j3dfly.utils.loaderwrappers.J3fLoaderListener;
071: import org.jdesktop.j3dfly.utils.loaderwrappers.J3fLoader;
072: import org.jdesktop.j3dfly.utils.gui.StatsDialog;
073: import org.jdesktop.j3dfly.utils.gui.FloatDocument;
074: import org.jdesktop.j3dfly.utils.gui.WorkingDialog;
075: import org.jdesktop.j3dfly.utils.environment.J3dSky;
076:
077: import org.jdesktop.j3dfly.namecontrol.NameControl;
078: import org.jdesktop.j3dfly.event.EventProcessor;
079: import org.jdesktop.j3dfly.event.FileLoadEvent;
080:
081: /**
082: * @author Paul Byrne
083: * @version $Revision: 1.1 $
084: */
085: public class ControlFrame extends javax.swing.JFrame {
086:
087: private J3dFlyContext context;
088:
089: private StatsDialog statsDialog = null;
090: private Cursor normalCursor;
091: private int showAllAxis = 0;
092:
093: private J3dFlyController controller;
094:
095: /** Creates new form controlPanel */
096: public ControlFrame(J3dFlyContext context,
097: J3dFlyController controller) {
098: this .context = context;
099: this .controller = controller;
100: initComponents();
101:
102: javax.swing.ToolTipManager.sharedInstance()
103: .setLightWeightPopupEnabled(false);
104:
105: this .setTitle("Sun Java 3D(tm) Fly Through 2.0beta "
106: + Version.version);
107: pack();
108: }
109:
110: /**
111: * Return the Panel in which plugins can place tool bars
112: */
113: public javax.swing.JPanel getToolBarPanel() {
114: return toolBarPanel;
115: }
116:
117: /** This method is called from within the constructor to
118: * initialize the form.
119: * WARNING: Do NOT modify this code. The content of this method is
120: * always regenerated by the FormEditor.
121: */
122: private void initComponents() {//GEN-BEGIN:initComponents
123: toolBarPanel = new javax.swing.JPanel();
124:
125: getContentPane().setLayout(new java.awt.GridBagLayout());
126:
127: toolBarPanel.setLayout(new java.awt.BorderLayout());
128:
129: toolBarPanel.setMinimumSize(new java.awt.Dimension(400, 100));
130: toolBarPanel.setPreferredSize(new java.awt.Dimension(400, 100));
131: getContentPane().add(toolBarPanel,
132: new java.awt.GridBagConstraints());
133:
134: }//GEN-END:initComponents
135:
136: private void stripifyBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stripifyBActionPerformed
137: // Add your handling code here:
138: java.awt.Frame frame = (java.awt.Frame) javax.swing.SwingUtilities
139: .getAncestorOfClass(java.awt.Frame.class, this );
140:
141: StripifyWorker worker = new StripifyWorker(frame, context
142: .getLocale(), controller.getBranchGraphs(null),
143: statsDialog);
144: worker.start();
145: }//GEN-LAST:event_stripifyBActionPerformed
146:
147: private void saveBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBActionPerformed
148: // Add your handling code here:
149: controller.saveAsScene();
150: }//GEN-LAST:event_saveBActionPerformed
151:
152: private void backClipTFActionPerformed(
153: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backClipTFActionPerformed
154: }//GEN-LAST:event_backClipTFActionPerformed
155:
156: private void frontClipTFActionPerformed(
157: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_frontClipTFActionPerformed
158: }//GEN-LAST:event_frontClipTFActionPerformed
159:
160: private void backClipTFMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_backClipTFMouseExited
161: }//GEN-LAST:event_backClipTFMouseExited
162:
163: private void frontClipTFMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_frontClipTFMouseExited
164: }//GEN-LAST:event_frontClipTFMouseExited
165:
166: private void configureLoadersBActionPerformed(
167: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_configureLoadersBActionPerformed
168: // Add your handling code here:
169: controller.configureLoaders(findFrame(this ));
170: }//GEN-LAST:event_configureLoadersBActionPerformed
171:
172: /**
173: * Return the frame which contains the component
174: *
175: * If component is not in a frame null is returned
176: */
177: private java.awt.Frame findFrame(java.awt.Component component) {
178: java.awt.Frame ret = null;
179: java.awt.Component comp = component;
180:
181: while (ret == null && comp != null) {
182: if (comp instanceof java.awt.Frame) {
183: ret = (java.awt.Frame) comp;
184: } else {
185: comp = comp.getParent();
186: }
187: }
188:
189: return ret;
190: }
191:
192: /**
193: * Remove all geometry from the scenegraph
194: */
195: private void clearBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearBActionPerformed
196: // Add your handling code here:
197: /*
198: filenameTF.setText("");
199: controller.clearUniverse();
200:
201: saveB.setEnabled( true );
202: compileB.setEnabled( true );
203: stripifyB.setEnabled( true );
204:
205: controller.clearUniverse();
206: */
207: //if (statsDialog!=null)
208: // statsDialog.calcGeometryStats( (BranchGroup)null ); // Clear the stats
209: //universe.setLive(true);
210: }//GEN-LAST:event_clearBActionPerformed
211:
212: /**
213: * Compile the scenegraph.
214: * Disable all J3dFly features which are unavailable after compile
215: */
216: private void compileBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_compileBActionPerformed
217: // Add your handling code here:
218: int response = javax.swing.JOptionPane
219: .showConfirmDialog(
220: this .getParent(),
221: "Compiled Scene Graphs cannot be Serialized or changed.\n\nProceed ?",
222: "WARNING",
223: javax.swing.JOptionPane.YES_NO_OPTION,
224: javax.swing.JOptionPane.WARNING_MESSAGE);
225:
226: if (response == javax.swing.JOptionPane.YES_OPTION) {
227: Cursor origCursor = this .getParent().getCursor();
228: this .getParent().setCursor(
229: Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
230: context.getLocale().setLive(false);
231: BranchGroup[] graphs = controller.getBranchGraphs(null);
232: for (int i = 0; i < graphs.length; i++) {
233: ((BranchGroup) graphs[i]).compile();
234: }
235: context.getLocale().setLive(true);
236: this .getParent().setCursor(origCursor);
237: }
238: }//GEN-LAST:event_compileBActionPerformed
239:
240: /**
241: * Show the Statistics dialog
242: */
243: int distanceLOD = 0;
244:
245: private void statisticsBActionPerformed(
246: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_statisticsBActionPerformed
247: // Add your handling code here:
248: controller.showStatsDialog(this .getParent());
249: }//GEN-LAST:event_statisticsBActionPerformed
250:
251: /**
252: * Load some geometry into the SceneGraph
253: */
254: private void loadBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadBActionPerformed
255: // Add your handling code here:
256: controller.loadScene();
257: }//GEN-LAST:event_loadBActionPerformed
258:
259: /**
260: * Move the view platform so that all geometry fit inside view frustum
261: */
262: // Variables declaration - do not modify//GEN-BEGIN:variables
263: private javax.swing.JPanel toolBarPanel;
264: // End of variables declaration//GEN-END:variables
265:
266: }
|