From 279c29b62e072da39600011b37e2d331fa21c7c1 Mon Sep 17 00:00:00 2001 From: kcr Date: Fri, 6 Jan 2006 23:33:53 +0000 Subject: Merged changes between root-1_5 and exp-1_4_0-beta3 into dev-1_5 branch --- src/HelloUniverse/HelloUniverse.html | 15 ---- src/HelloUniverse/HelloUniverse.java | 106 +++++++++++++++++++--------- src/HelloUniverse/HelloUniverse_plugin.html | 39 ---------- src/HelloUniverse/build.xml | 2 +- 4 files changed, 74 insertions(+), 88 deletions(-) delete mode 100644 src/HelloUniverse/HelloUniverse.html delete mode 100644 src/HelloUniverse/HelloUniverse_plugin.html (limited to 'src/HelloUniverse') diff --git a/src/HelloUniverse/HelloUniverse.html b/src/HelloUniverse/HelloUniverse.html deleted file mode 100644 index 93b044c..0000000 --- a/src/HelloUniverse/HelloUniverse.html +++ /dev/null @@ -1,15 +0,0 @@ - - -Hello, Universe! - - - -
-
-If you were using a Java-capable browser, -you would see Hello Universe! instead of this paragraph. -
-
-
- - diff --git a/src/HelloUniverse/HelloUniverse.java b/src/HelloUniverse/HelloUniverse.java index 7616a88..de8f783 100644 --- a/src/HelloUniverse/HelloUniverse.java +++ b/src/HelloUniverse/HelloUniverse.java @@ -1,7 +1,7 @@ /* * $RCSfile$ * - * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * 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 @@ -42,20 +42,20 @@ * $State$ */ -import java.applet.Applet; -import java.awt.BorderLayout; -import java.awt.event.*; -import java.awt.GraphicsConfiguration; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.ColorCube; import com.sun.j3d.utils.universe.*; +import com.sun.j3d.utils.geometry.ColorCube; import javax.media.j3d.*; import javax.vecmath.*; +import java.awt.GraphicsConfiguration; -public class HelloUniverse extends Applet { +/** + * Simple Java 3D example program to display a spinning cube. + */ +public class HelloUniverse extends javax.swing.JFrame { + + private SimpleUniverse univ = null; + private BranchGroup scene = null; - private SimpleUniverse u = null; - public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); @@ -91,37 +91,77 @@ public class HelloUniverse extends Applet { return objRoot; } - public HelloUniverse() { - } - - public void init() { - setLayout(new BorderLayout()); - GraphicsConfiguration config = - SimpleUniverse.getPreferredConfiguration(); + private Canvas3D createUniverse() { + // Get the preferred graphics configuration for the default screen + GraphicsConfiguration config = + SimpleUniverse.getPreferredConfiguration(); + // Create a Canvas3D using the preferred configuration Canvas3D c = new Canvas3D(config); - add("Center", c); - // Create a simple scene and attach it to the virtual universe - BranchGroup scene = createSceneGraph(); - u = new SimpleUniverse(c); + // 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(); - // This will move the ViewPlatform back a bit so the - // objects in the scene can be viewed. - u.getViewingPlatform().setNominalViewingTransform(); + // Ensure at least 5 msec per frame (i.e., < 200Hz) + univ.getViewer().getView().setMinimumFrameCycleTime(5); - u.addBranchGraph(scene); + return c; } - public void destroy() { - u.cleanup(); + /** + * Creates new form HelloUniverse + */ + public HelloUniverse() { + // Initialize the GUI components + initComponents(); + + // Create Canvas3D and SimpleUniverse; add canvas to drawing panel + Canvas3D c = createUniverse(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + + // Create the content branch and add it to the universe + scene = createSceneGraph(); + univ.addBranchGraph(scene); } - // - // The following allows HelloUniverse to be run as an application - // as well as an applet - // - public static void main(String[] args) { - new MainFrame(new HelloUniverse(), 256, 256); + // ---------------------------------------------------------------- + + /** 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. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + drawingPanel = new javax.swing.JPanel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("HelloUniverse"); + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(250, 250)); + getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); + + pack(); + }// //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 HelloUniverse().setVisible(true); + } + }); } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel drawingPanel; + // End of variables declaration//GEN-END:variables + } diff --git a/src/HelloUniverse/HelloUniverse_plugin.html b/src/HelloUniverse/HelloUniverse_plugin.html deleted file mode 100644 index 947a59b..0000000 --- a/src/HelloUniverse/HelloUniverse_plugin.html +++ /dev/null @@ -1,39 +0,0 @@ - - -Hello, Universe! - - - - - - - - - - -</COMMENT> -<blockquote> -<hr> -If you were using a Java-capable browser, -you would see Hello Universe! instead of this paragraph. -<hr> -</blockquote> - - - - - - - - diff --git a/src/HelloUniverse/build.xml b/src/HelloUniverse/build.xml index 47e5a36..4e57328 100644 --- a/src/HelloUniverse/build.xml +++ b/src/HelloUniverse/build.xml @@ -4,7 +4,7 @@ /* * $RCSfile$ * - * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * 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 -- cgit v1.2.3