aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/org/jdesktop/j3d
diff options
context:
space:
mode:
authorjada <jada@28c7f869-5b4e-e670-f602-82bfaf57f300>2006-02-23 04:29:41 +0000
committerjada <jada@28c7f869-5b4e-e670-f602-82bfaf57f300>2006-02-23 04:29:41 +0000
commit521df2f4b6deb4154eb15e4879c0132fba9bf5df (patch)
tree40a27f57bd571074368a8fafc44c23308549a8a6 /src/classes/org/jdesktop/j3d
parent2b150446831e7de4421a537b00709aecf5aa2764 (diff)
Converted DistorGlyphtest form MainFrame to JFrame.
Diffstat (limited to 'src/classes/org/jdesktop/j3d')
-rw-r--r--src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.form36
-rw-r--r--src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.java128
2 files changed, 111 insertions, 53 deletions
diff --git a/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.form b/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.form
new file mode 100644
index 0000000..22838dc
--- /dev/null
+++ b/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.form
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<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="DistortGlyphTest"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ <AuxValue name="designerSize" 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,44,0,0,1,-112"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="drawingPanel">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[700, 700]"/>
+ </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.DesignBorderLayout"/>
+ </Container>
+ </SubComponents>
+</Form>
diff --git a/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.java b/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.java
index afada2e..add3002 100644
--- a/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.java
+++ b/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.java
@@ -44,43 +44,21 @@
package org.jdesktop.j3d.examples.distort_glyph;
-import java.applet.Applet;
+import com.sun.j3d.utils.behaviors.mouse.*;
+import com.sun.j3d.utils.image.TextureLoader;
+import com.sun.j3d.utils.universe.*;
import java.awt.Font;
-import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
+import javax.media.j3d.*;
+import javax.vecmath.*;
+import org.jdesktop.j3d.examples.Resources;
-import javax.media.j3d.AmbientLight;
-import javax.media.j3d.Appearance;
-import javax.media.j3d.BoundingSphere;
-import javax.media.j3d.BranchGroup;
-import javax.media.j3d.Canvas3D;
-import javax.media.j3d.DirectionalLight;
-import javax.media.j3d.Font3D;
-import javax.media.j3d.FontExtrusion;
-import javax.media.j3d.GeometryArray;
-import javax.media.j3d.GraphicsConfigTemplate3D;
-import javax.media.j3d.Light;
-import javax.media.j3d.Material;
-import javax.media.j3d.PointLight;
-import javax.media.j3d.Shape3D;
-import javax.media.j3d.TexCoordGeneration;
-import javax.media.j3d.Texture;
-import javax.media.j3d.TransformGroup;
-
-import javax.vecmath.Color3f;
-import javax.vecmath.Point3d;
-import javax.vecmath.Point3f;
-import javax.vecmath.Vector3f;
-
-import com.sun.j3d.utils.applet.MainFrame;
-import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
-import com.sun.j3d.utils.behaviors.mouse.MouseTranslate;
-import com.sun.j3d.utils.behaviors.mouse.MouseZoom;
-import com.sun.j3d.utils.image.TextureLoader;
-import com.sun.j3d.utils.universe.SimpleUniverse;
+public class DistortGlyphTest extends javax.swing.JFrame {
+
+ private SimpleUniverse univ = null;
+ private BranchGroup scene = null;
-public class DistortGlyphTest extends Applet {
// get a nice graphics config
private static GraphicsConfiguration getGraphicsConfig() {
GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
@@ -88,7 +66,7 @@ public class DistortGlyphTest extends Applet {
GraphicsConfiguration gcfg = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(template);
return gcfg;
}
-
+
private void setupLights(BranchGroup root) {
// set up the BoundingSphere for all the lights
BoundingSphere bounds = new BoundingSphere(new Point3d(), 100.0);
@@ -117,7 +95,7 @@ public class DistortGlyphTest extends Applet {
pointLight2.setInfluencingBounds(bounds);
root.addChild(pointLight2);
}
-
+
public BranchGroup createSceneGraph() {
// Create the root of the branch graph
BranchGroup objRoot = new BranchGroup();
@@ -135,7 +113,7 @@ public class DistortGlyphTest extends Applet {
Color3f objColor = new Color3f(1.0f, 0.7f, 0.8f);
Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
app.setMaterial(new Material(objColor, black, objColor, black, 80.0f));
- Texture txtr = new TextureLoader("gold.jpg",this).getTexture();
+ Texture txtr = new TextureLoader(Resources.getResource("resources/images/gold.jpg"),this).getTexture();
app.setTexture(txtr);
TexCoordGeneration tcg = new TexCoordGeneration(TexCoordGeneration.SPHERE_MAP,TexCoordGeneration.TEXTURE_COORDINATE_2);
app.setTexCoordGeneration(tcg);
@@ -180,31 +158,75 @@ public class DistortGlyphTest extends Applet {
return objRoot;
}
+
+ private Canvas3D createUniverse() {
+
+ // Create a Canvas3D using a nice configuration
+ Canvas3D c = new Canvas3D(getGraphicsConfig());
- // Create a simple scene and attach it to the virtual universe
- public DistortGlyphTest() {
- //setLayout(new BorderLayout());
- GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
+ // Create simple universe with view branch
+ univ = new SimpleUniverse(c);
+
+ // This will move the ViewPlatform back a bit so the
+ // objects in the scene can be viewed.
+ univ.getViewingPlatform().setNominalViewingTransform();
- Canvas3D canvas3D = new Canvas3D(getGraphicsConfig());
- canvas3D.setBounds(0, 0, 800, 600);
- add("Center", canvas3D);
+ // Ensure at least 5 msec per frame (i.e., < 200Hz)
+ univ.getViewer().getView().setMinimumFrameCycleTime(5);
- BranchGroup scene = createSceneGraph();
+ return c;
+ }
- // SimpleUniverse is a Convenience Utility class
- SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
+ /**
+ * Creates new form DistortGlyphTest2
+ */
+ public DistortGlyphTest() {
+ // Initialize the GUI components
+ initComponents();
- // This will move the ViewPlatform back a bit so the
- // objects in the scene can be viewed.
- simpleU.getViewingPlatform().setNominalViewingTransform();
+ // Create Canvas3D and SimpleUniverse; add canvas to drawing panel
+ Canvas3D c = createUniverse();
+ drawingPanel.add(c, java.awt.BorderLayout.CENTER);
- simpleU.addBranchGraph(scene);
+ // Create the content branch and add it to the universe
+ scene = createSceneGraph();
+ univ.addBranchGraph(scene);
}
- // The following allows this to be run as an application
- // as well as an applet
- public static void main(String[] args) {
- Frame frame = new MainFrame(new DistortGlyphTest(), 800, 600);
+ // ----------------------------------------------------------------
+
+ /** 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() {
+ drawingPanel = new javax.swing.JPanel();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ setTitle("DistortGlyphTest");
+ drawingPanel.setLayout(new java.awt.BorderLayout());
+
+ drawingPanel.setPreferredSize(new java.awt.Dimension(700, 700));
+ getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER);
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String args[]) {
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new DistortGlyphTest().setVisible(true);
+ }
+ });
}
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel drawingPanel;
+ // End of variables declaration//GEN-END:variables
+
}