diff options
Diffstat (limited to 'src/classes')
3 files changed, 618 insertions, 0 deletions
diff --git a/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.form b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.form new file mode 100644 index 0000000..80874ae --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.form @@ -0,0 +1,189 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + <Property name="title" type="java.lang.String" value="JCanvas3D Example"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-53,0,0,3,-14"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="2"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JSplitPane" name="jSplitPane1"> + <Properties> + <Property name="dividerLocation" type="int" value="300"/> + <Property name="dividerSize" type="int" value="8"/> + <Property name="continuousLayout" type="boolean" value="true"/> + <Property name="oneTouchExpandable" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1000, 685]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="left"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleName" type="java.lang.String" value="parameter panel"/> + <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" value="panel used to set parameters and create internal frames"/> + </AccessibilityProperties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JTabbedPane" name="jTabbedPane1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="Content Creation"> + <Property name="tabTitle" type="java.lang.String" value="Content Creation"/> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="addButton"> + <Properties> + <Property name="text" type="java.lang.String" value="Create New Frame"/> + <Property name="toolTipText" type="java.lang.String" value="Adds a new frame containing an universe into the desktop pane"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addButtonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JCheckBox" name="delayCheckBox"> + <Properties> + <Property name="text" type="java.lang.String" value="Resize Delayed"/> + <Property name="toolTipText" type="java.lang.String" value="Shows the effect of using a delayed resizing to the internal frames."/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JCheckBox" name="interactiveCheckBox"> + <Properties> + <Property name="text" type="java.lang.String" value="Interactive Cube"/> + <Property name="toolTipText" type="java.lang.String" value="Tests the use of AWT behaviors on the displayed component."/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="0" right="0" top="0"/> + </Border> + </Property> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 0, 0, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="Data Report"> + <Property name="tabTitle" type="java.lang.String" value="Data Report"/> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane2"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 100]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="dataTable"> + <Properties> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="2" rowCount="0"> + <Column editable="false" title="canvas" type="java.lang.Integer"/> + <Column editable="false" title="Title 2" type="java.lang.Long"/> + </Table> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JDesktopPane" name="desktopPane"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="c9" green="99" red="99" type="rgb"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="right"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JLayeredPaneSupportLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.java b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.java new file mode 100644 index 0000000..198e605 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.java @@ -0,0 +1,228 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any + * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY + * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL + * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF + * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS + * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR + * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, + * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND + * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR + * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed, licensed or + * intended for use in the design, construction, operation or + * maintenance of any nuclear facility. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package org.jdesktop.j3d.examples.jcanvas3d; + +import java.awt.Toolkit; +import javax.swing.table.DefaultTableModel; + +/** + * + * @author pepe + */ +public class JCanvas3DExample extends javax.swing.JFrame implements java.awt.event.ActionListener +{ + + /** + * Creates new form JCanvas3DExample + */ + public JCanvas3DExample() + { + initComponents(); + Toolkit.getDefaultToolkit().setDynamicLayout( true ); + setDefaultCloseOperation( EXIT_ON_CLOSE ); + } + + /** 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() { + java.awt.GridBagConstraints gridBagConstraints; + + jSplitPane1 = new javax.swing.JSplitPane(); + jScrollPane1 = new javax.swing.JScrollPane(); + jPanel1 = new javax.swing.JPanel(); + jTabbedPane1 = new javax.swing.JTabbedPane(); + jPanel2 = new javax.swing.JPanel(); + addButton = new javax.swing.JButton(); + delayCheckBox = new javax.swing.JCheckBox(); + interactiveCheckBox = new javax.swing.JCheckBox(); + jPanel3 = new javax.swing.JPanel(); + jScrollPane2 = new javax.swing.JScrollPane(); + dataTable = new javax.swing.JTable(); + desktopPane = new javax.swing.JDesktopPane(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("JCanvas3D Example"); + jSplitPane1.setDividerLocation(300); + jSplitPane1.setDividerSize(8); + jSplitPane1.setContinuousLayout(true); + jSplitPane1.setOneTouchExpandable(true); + jSplitPane1.setPreferredSize(new java.awt.Dimension(1000, 685)); + jPanel1.setLayout(new java.awt.BorderLayout()); + + jPanel2.setLayout(new java.awt.GridBagLayout()); + + addButton.setText("Create New Frame"); + addButton.setToolTipText("Adds a new frame containing an universe into the desktop pane"); + addButton.addActionListener(this); + + jPanel2.add(addButton, new java.awt.GridBagConstraints()); + + delayCheckBox.setText("Resize Delayed"); + delayCheckBox.setToolTipText("Shows the effect of using a delayed resizing to the internal frames."); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + jPanel2.add(delayCheckBox, gridBagConstraints); + + interactiveCheckBox.setText("Interactive Cube"); + interactiveCheckBox.setToolTipText("Tests the use of AWT behaviors on the displayed component."); + interactiveCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + interactiveCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + jPanel2.add(interactiveCheckBox, gridBagConstraints); + + jTabbedPane1.addTab("Content Creation", jPanel2); + + jPanel3.setLayout(new java.awt.BorderLayout()); + + jScrollPane2.setPreferredSize(new java.awt.Dimension(100, 100)); + dataTable.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + "canvas", "Title 2" + } + ) { + Class[] types = new Class [] { + java.lang.Integer.class, java.lang.Long.class + }; + boolean[] canEdit = new boolean [] { + false, false + }; + + public Class getColumnClass(int columnIndex) { + return types [columnIndex]; + } + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jScrollPane2.setViewportView(dataTable); + + jPanel3.add(jScrollPane2, java.awt.BorderLayout.CENTER); + + jTabbedPane1.addTab("Data Report", jPanel3); + + jPanel1.add(jTabbedPane1, java.awt.BorderLayout.CENTER); + + jScrollPane1.setViewportView(jPanel1); + jPanel1.getAccessibleContext().setAccessibleName("parameter panel"); + jPanel1.getAccessibleContext().setAccessibleDescription("panel used to set parameters and create internal frames"); + + jSplitPane1.setLeftComponent(jScrollPane1); + + desktopPane.setBackground(new java.awt.Color(153, 153, 201)); + jSplitPane1.setRightComponent(desktopPane); + + getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER); + + java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); + setBounds((screenSize.width-1010)/2, (screenSize.height-715)/2, 1010, 715); + } + + // Code for dispatching events from components to event handlers. + + public void actionPerformed(java.awt.event.ActionEvent evt) { + if (evt.getSource() == addButton) { + JCanvas3DExample.this.addButtonActionPerformed(evt); + } + }// </editor-fold>//GEN-END:initComponents + + private void addButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_addButtonActionPerformed + {//GEN-HEADEREND:event_addButtonActionPerformed + JInternalWorld iWorld; +// if ( true == filteredCheckBox.isSelected() ) +// { + iWorld = new JInternalWorld( delayCheckBox.isSelected(), interactiveCheckBox.isSelected(), (DefaultTableModel)dataTable.getModel() ); +// } +// else +// { +// iWorld = new JInternalWorldFiltered( delayCheckBox.isSelected(), interactiveCheckBox.isSelected() ); +// } + iWorld.setSize( 256, 256 ); + iWorld.setLocation( 50, 50 ); + iWorld.setResizable( true ); + desktopPane.add( iWorld ); + iWorld.setVisible(true); + }//GEN-LAST:event_addButtonActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) + { + java.awt.EventQueue.invokeLater(new Runnable() + { + public void run() + { + new JCanvas3DExample().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton addButton; + private javax.swing.JTable dataTable; + private javax.swing.JCheckBox delayCheckBox; + private javax.swing.JDesktopPane desktopPane; + private javax.swing.JCheckBox interactiveCheckBox; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JSplitPane jSplitPane1; + private javax.swing.JTabbedPane jTabbedPane1; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorld.java b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorld.java new file mode 100644 index 0000000..82b4beb --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorld.java @@ -0,0 +1,201 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any + * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY + * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL + * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF + * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS + * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR + * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, + * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND + * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR + * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed, licensed or + * intended for use in the design, construction, operation or + * maintenance of any nuclear facility. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package org.jdesktop.j3d.examples.jcanvas3d; + +import com.sun.j3d.exp.swing.JCanvas3D; +//import com.sun.j3d.exp.swing.Canvas3DWrapper; +import com.sun.j3d.utils.behaviors.mouse.MouseRotate; +import com.sun.j3d.utils.geometry.ColorCube; +import com.sun.j3d.utils.universe.SimpleUniverse; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GraphicsConfiguration; +import javax.media.j3d.Alpha; +import javax.media.j3d.BoundingSphere; +import javax.media.j3d.BranchGroup; +import javax.media.j3d.GraphicsConfigTemplate3D; +import javax.media.j3d.RotationInterpolator; +import javax.media.j3d.Transform3D; +import javax.media.j3d.TransformGroup; +import javax.swing.JInternalFrame; +import javax.swing.table.DefaultTableModel; +import javax.vecmath.Point3d; +import javax.vecmath.Vector3d; + + +/** + * DOCUMENT ME! + * + * @author pepe + */ +public class JInternalWorld extends JInternalFrame { + /** DOCUMENT ME! */ + JCanvas3D c; + + /** Creates a new instance of JInternalWorld */ + private SimpleUniverse u = null; + + /** DOCUMENT ME! */ + private Component comp; + + private DefaultTableModel model; + + /** + * Creates a new JInternalWorld object. + * + * @param isDelayed DOCUMENT ME! + * @param isInteractive DOCUMENT ME! + */ + public JInternalWorld(boolean isDelayed, boolean isInteractive, DefaultTableModel model) { + setSize(256, 256); + setClosable(true); + this.model = model; + model.addRow( new Object[]{new Integer( hashCode()), Integer.valueOf(0) }); + + GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); + + c = new JCanvas3D( new GraphicsConfigTemplate3D() ); + + if (true == isDelayed) { + c.setResizeMode(c.RESIZE_DELAYED); + } + + setComp(c); + Dimension dim = new Dimension(256, 256); + getComp().setPreferredSize( dim ); + getComp().setSize( dim ); + getContentPane().setLayout(new BorderLayout()); + getContentPane().add(getComp(), BorderLayout.CENTER); + pack(); + + // Create a simple scene and attach it to the virtual universe + BranchGroup scene = createSceneGraph(isInteractive); + u = new SimpleUniverse(c.getOffscreenCanvas3D());//TODO: this is awful and must not be done like that in final version + + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + u.getViewingPlatform().setNominalViewingTransform(); +// Canvas3DWrapper wrapper = new Canvas3DWrapper( c ); +// wrapper.setView( u.getViewer().getView() ); +// KeyNavigatorBehavior navig = new KeyNavigatorBehavior(u.getViewingPlatform().getViewPlatformTransform() ); +// BranchGroup navigBG = new BranchGroup(); +// navigBG.addChild( navig ); +// scene.addChild( navigBG ); + u.addBranchGraph(scene); +// c.getOffscreenCanvas3D().getView().setMinimumFrameCycleTime(200);//TODO: this is awful and must not be done like that in final version + } + + /** + * DOCUMENT ME! + * + * @param isInteractive DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public BranchGroup createSceneGraph(boolean isInteractive) { + // Create the root of the branch graph + BranchGroup objRoot = new BranchGroup(); + + // Create the TransformGroup node and initialize it to the + // identity. Enable the TRANSFORM_WRITE capability so that + // our behavior code can modify it at run time. Add it to + // the root of the subgraph. + TransformGroup objTrans = new TransformGroup(); + Transform3D t3dTrans = new Transform3D(); + t3dTrans.setTranslation( new Vector3d( 0, 0, -1 ) ); + objTrans.setTransform( t3dTrans ); + TransformGroup objRot = new TransformGroup(); + objRot.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); + objRoot.addChild(objTrans); + objTrans.addChild( objRot ); + + // Create a simple Shape3D node; add it to the scene graph. + ColorCube cube = new ColorCube(0.75); + objRot.addChild(cube); + + BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), + 100.0); + + if (true == isInteractive) { + MouseRotate mr = new MouseRotate(getComp(), objRot); + mr.setSchedulingBounds(bounds); + mr.setSchedulingInterval(1); + objRoot.addChild(mr); + } else { + // Create a new Behavior object that will perform the + // desired operation on the specified transform and add + // it into the scene graph. + Transform3D yAxis = new Transform3D(); + Alpha rotationAlpha = new Alpha(-1, + Math.max(2000, (int) (Math.random() * 8000.))); + + RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, + objRot, yAxis, 0.0f, (float) Math.PI * 2.0f); + rotator.setSchedulingBounds(bounds); + objRoot.addChild(rotator); + } + + return objRoot; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + protected Component getComp() { + return comp; + } + + /** + * DOCUMENT ME! + * + * @param comp DOCUMENT ME! + */ + protected void setComp(Component comp) { + this.comp = comp; + } +} |