summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.form195
-rw-r--r--src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.java146
-rw-r--r--src/classes/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorld.java114
3 files changed, 184 insertions, 271 deletions
diff --git a/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.form b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.form
index 80874ae..661f402 100644
--- a/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.form
+++ b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.form
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<Form version="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+<Form version="1.0" 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="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,1,-110,0,0,3,-4"/>
<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_i18nAutoMode" 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"/>
@@ -20,15 +20,12 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
- <Container class="javax.swing.JSplitPane" name="jSplitPane1">
+ <Container class="javax.swing.JSplitPane" name="splitPane">
<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">
@@ -38,7 +35,7 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
- <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <Container class="javax.swing.JScrollPane" name="scrollPane">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="left"/>
@@ -47,124 +44,77 @@
<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>
+ <Container class="javax.swing.JPanel" name="panel">
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
- <Container class="javax.swing.JTabbedPane" name="jTabbedPane1">
+ <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.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
- <BorderConstraints direction="Center"/>
+ <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>
-
- <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>
+ </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="2" 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="selected" type="boolean" value="true"/>
+ <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>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="interactiveCheckBoxActionPerformed"/>
+ </Events>
+ <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="2" 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="randomCheckBox">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Random start angle"/>
+ <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="enabled" type="boolean" value="false"/>
+ <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="3" gridWidth="1" gridHeight="1" fill="2" 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>
</SubComponents>
@@ -174,6 +124,9 @@
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="c9" green="99" red="99" type="rgb"/>
</Property>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[300, 300]"/>
+ </Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
diff --git a/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.java b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.java
index 198e605..a68bbe6 100644
--- a/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.java
+++ b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.java
@@ -44,16 +44,16 @@
package org.jdesktop.j3d.examples.jcanvas3d;
-import java.awt.Toolkit;
-import javax.swing.table.DefaultTableModel;
/**
- *
- * @author pepe
+ * Simple Java 3D example program that displays universes within lightweight swing components, layed in JInternalFrame objects.
*/
+import java.awt.Toolkit;
+import javax.swing.table.DefaultTableModel;
+
public class JCanvas3DExample extends javax.swing.JFrame implements java.awt.event.ActionListener
{
-
+
/**
* Creates new form JCanvas3DExample
*/
@@ -63,7 +63,7 @@ public class JCanvas3DExample extends javax.swing.JFrame implements java.awt.eve
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
@@ -73,101 +73,71 @@ public class JCanvas3DExample extends javax.swing.JFrame implements java.awt.eve
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();
+ splitPane = new javax.swing.JSplitPane();
+ scrollPane = new javax.swing.JScrollPane();
+ panel = 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();
+ randomCheckBox = new javax.swing.JCheckBox();
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());
+ splitPane.setDividerLocation(300);
+ splitPane.setDividerSize(8);
+ splitPane.setContinuousLayout(true);
+ splitPane.setOneTouchExpandable(true);
+ panel.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());
+ panel.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);
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ panel.add(delayCheckBox, gridBagConstraints);
+ interactiveCheckBox.setSelected(true);
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));
+ interactiveCheckBox.addActionListener(this);
+
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);
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ panel.add(interactiveCheckBox, gridBagConstraints);
- jPanel1.add(jTabbedPane1, java.awt.BorderLayout.CENTER);
+ randomCheckBox.setText("Random start angle");
+ randomCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ randomCheckBox.setEnabled(false);
+ randomCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 3;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ panel.add(randomCheckBox, gridBagConstraints);
- jScrollPane1.setViewportView(jPanel1);
- jPanel1.getAccessibleContext().setAccessibleName("parameter panel");
- jPanel1.getAccessibleContext().setAccessibleDescription("panel used to set parameters and create internal frames");
+ scrollPane.setViewportView(panel);
- jSplitPane1.setLeftComponent(jScrollPane1);
+ splitPane.setLeftComponent(scrollPane);
desktopPane.setBackground(new java.awt.Color(153, 153, 201));
- jSplitPane1.setRightComponent(desktopPane);
+ desktopPane.setPreferredSize(new java.awt.Dimension(300, 300));
+ splitPane.setRightComponent(desktopPane);
- getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER);
+ getContentPane().add(splitPane, java.awt.BorderLayout.CENTER);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
- setBounds((screenSize.width-1010)/2, (screenSize.height-715)/2, 1010, 715);
+ setBounds((screenSize.width-1020)/2, (screenSize.height-402)/2, 1020, 402);
}
// Code for dispatching events from components to event handlers.
@@ -176,26 +146,28 @@ public class JCanvas3DExample extends javax.swing.JFrame implements java.awt.eve
if (evt.getSource() == addButton) {
JCanvas3DExample.this.addButtonActionPerformed(evt);
}
+ else if (evt.getSource() == interactiveCheckBox) {
+ JCanvas3DExample.this.interactiveCheckBoxActionPerformed(evt);
+ }
}// </editor-fold>//GEN-END:initComponents
- private void addButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_addButtonActionPerformed
- {//GEN-HEADEREND:event_addButtonActionPerformed
+ private void interactiveCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_interactiveCheckBoxActionPerformed
+ randomCheckBox.setEnabled( interactiveCheckBox.isSelected() ? false:true );
+ }//GEN-LAST:event_interactiveCheckBoxActionPerformed
+
+ private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST: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() );
-// }
+ // we create an internal world to be added within the JDesktop.
+ iWorld = new JInternalWorld( interactiveCheckBox.isSelected(),
+ this.randomCheckBox.isSelected() && ( false == 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
*/
@@ -209,20 +181,16 @@ public class JCanvas3DExample extends javax.swing.JFrame implements java.awt.eve
}
});
}
-
+
// 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;
+ private javax.swing.JPanel panel;
+ private javax.swing.JCheckBox randomCheckBox;
+ private javax.swing.JScrollPane scrollPane;
+ private javax.swing.JSplitPane splitPane;
// 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
index 7193dc9..6bfa32d 100644
--- a/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorld.java
+++ b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorld.java
@@ -41,97 +41,93 @@
* $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.Rectangle;
+import java.awt.geom.Rectangle2D;
+
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!
+ * This is a JInternalFrame holding an universe, which can be configured to
+ * be interactive -that is, where user can interact with object- or automatic
+ * -where the object spins only-. When in automatic mode, spinning speed is
+ * changed so that they look less the same. Changing the spinning start angle
+ * helps unsynchronizing the rotations too.
*
* @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!
+ * @param isInteractive tells the world to be constructed as interactive
+ * @param isDelayed tells the rotator to start at a random alpha.
*/
- public JInternalWorld(boolean isDelayed, boolean isInteractive, DefaultTableModel model) {
+ public JInternalWorld(boolean isInteractive, boolean isDelayed) {
+ super();
setSize(256, 256);
setClosable(true);
- this.model = model;
- model.addRow( new Object[]{new Integer( hashCode()), Integer.valueOf(0) });
- c = new JCanvas3D();
+ JCanvas3D canvas = new JCanvas3D(new GraphicsConfigTemplate3D());
if (true == isDelayed) {
- c.setResizeMode(c.RESIZE_DELAYED);
+ canvas.setResizeMode(canvas.RESIZE_DELAYED);
}
- setComp(c);
+ comp = canvas;
+
Dimension dim = new Dimension(256, 256);
- getComp().setPreferredSize( dim );
- getComp().setSize( dim );
+ comp.setPreferredSize(dim);
+ comp.setSize(dim);
getContentPane().setLayout(new BorderLayout());
- getContentPane().add(getComp(), BorderLayout.CENTER);
+ getContentPane().add(comp, 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
+ BranchGroup scene = createSceneGraph(isInteractive, isDelayed);
+ SimpleUniverse universe = new SimpleUniverse(canvas.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
+ universe.getViewingPlatform().setNominalViewingTransform();
+ universe.getViewer().getView().setMinimumFrameCycleTime(30);
+ universe.addBranchGraph(scene);
}
/**
- * DOCUMENT ME!
+ * Creates the world. Only exists to cleanup the source a bit
*
- * @param isInteractive DOCUMENT ME!
+ * @param isInteractive tells the world to be constructed as interactive
+ * @param isDelayed tells the rotator to start at a random alpha.
*
- * @return DOCUMENT ME!
+ * @return a global branchgroup containing the world, as desired.
*/
- public BranchGroup createSceneGraph(boolean isInteractive) {
+ private BranchGroup createSceneGraph(boolean isInteractive,
+ boolean isDelayed) {
// Create the root of the branch graph
BranchGroup objRoot = new BranchGroup();
@@ -141,12 +137,13 @@ public class JInternalWorld extends JInternalFrame {
// the root of the subgraph.
TransformGroup objTrans = new TransformGroup();
Transform3D t3dTrans = new Transform3D();
- t3dTrans.setTranslation( new Vector3d( 0, 0, -1 ) );
- objTrans.setTransform( t3dTrans );
+ 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 );
+ objTrans.addChild(objRot);
// Create a simple Shape3D node; add it to the scene graph.
ColorCube cube = new ColorCube(0.75);
@@ -156,7 +153,7 @@ public class JInternalWorld extends JInternalFrame {
100.0);
if (true == isInteractive) {
- MouseRotate mr = new MouseRotate(getComp(), objRot);
+ MouseRotate mr = new MouseRotate(comp, objRot);
mr.setSchedulingBounds(bounds);
mr.setSchedulingInterval(1);
objRoot.addChild(mr);
@@ -165,11 +162,23 @@ public class JInternalWorld extends JInternalFrame {
// 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.)));
+
+ // rotation speed is randomized a bit so that it does not go at the same speed on every canvases,
+ // which will make it more natural and express the differences between every present universes
+ int duration = Math.max(2000, (int) (Math.random() * 8000.));
+ Alpha rotationAlpha = null;
+
+ if (true == isDelayed) {
+ rotationAlpha = new Alpha(-1,
+ (int) ((double) duration * Math.random()), 0, duration,
+ 0, 0);
+ } else {
+ rotationAlpha = new Alpha(-1, duration);
+ }
RotationInterpolator rotator = new RotationInterpolator(rotationAlpha,
objRot, yAxis, 0.0f, (float) Math.PI * 2.0f);
+
rotator.setSchedulingBounds(bounds);
objRoot.addChild(rotator);
}
@@ -177,21 +186,4 @@ public class JInternalWorld extends JInternalFrame {
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;
- }
}