aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjada <jada@28c7f869-5b4e-e670-f602-82bfaf57f300>2006-03-06 21:11:48 +0000
committerjada <jada@28c7f869-5b4e-e670-f602-82bfaf57f300>2006-03-06 21:11:48 +0000
commitc677ffd9129f3fa0cee7881220a45a2918db0559 (patch)
tree4e2cd99f916a18f59d6de645a82fd2451ef89c33
parent729daffb47398c1d4920417ba44937fe39d18330 (diff)
1) Modified programs to use the new Resources.java to load resources.
2) PrintCanvas3D : Load a default geometry in no argument case.
-rw-r--r--build.xml14
-rw-r--r--src/classes/org/jdesktop/j3d/examples/oriented_shape3d/OrientedTest.java53
-rw-r--r--src/classes/org/jdesktop/j3d/examples/print_canvas3d/PrintCanvas3D.java20
3 files changed, 54 insertions, 33 deletions
diff --git a/build.xml b/build.xml
index 72c9ff0..899053c 100644
--- a/build.xml
+++ b/build.xml
@@ -286,6 +286,13 @@
</java>
</target>
+ <target name="run.OrientedTest" depends="init-run">
+ <java fork="true"
+ classname="org.jdesktop.j3d.examples.oriented_shape3d.OrientedTest">
+ <classpath refid="run.classpath"/>
+ </java>
+ </target>
+
<target name="run.MoveAppBoundingLeaf" depends="init-run">
<java fork="true"
classname="org.jdesktop.j3d.examples.sound.MoveAppBoundingLeaf">
@@ -301,6 +308,13 @@
</java>
</target>
+ <target name="run.PrintCanvas3D" depends="init-run">
+ <java fork="true"
+ classname="org.jdesktop.j3d.examples.print_canvas3d.PrintCanvas3D">
+ <classpath refid="run.classpath"/>
+ </java>
+ </target>
+
<target name="run.SamplerTestGLSL" depends="init-run">
<java fork="true"
classname="org.jdesktop.j3d.examples.glsl_shader.SamplerTestGLSL">
diff --git a/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/OrientedTest.java b/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/OrientedTest.java
index 191c375..f01baf8 100644
--- a/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/OrientedTest.java
+++ b/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/OrientedTest.java
@@ -46,7 +46,6 @@ package org.jdesktop.j3d.examples.oriented_shape3d;
import java.applet.Applet;
import java.awt.*;
-import java.awt.event.*;
import com.sun.j3d.utils.image.TextureLoader;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.*;
@@ -54,6 +53,7 @@ import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.behaviors.mouse.*;
+import org.jdesktop.j3d.examples.Resources;
public class OrientedTest extends Applet {
@@ -208,26 +208,18 @@ public class OrientedTest extends Applet {
public void init() {
// the paths to the image files for an applet
+ earthImage = Resources.getResource("resources/images/earth.jpg");
if (earthImage == null) {
- try {
- earthImage = new java.net.URL(getCodeBase().toString() +
- "../images/earth.jpg");
- }
- catch (java.net.MalformedURLException ex) {
- System.out.println(ex.getMessage());
- System.exit(1);
- }
- }
- if (stoneImage == null) {
- try {
- stoneImage = new java.net.URL(getCodeBase().toString() +
- "../images/stone.jpg");
- }
- catch (java.net.MalformedURLException ex) {
- System.out.println(ex.getMessage());
- System.exit(1);
- }
- }
+ System.err.println("resources/images/earth.jpg not found");
+ System.exit(1);
+ }
+
+ stoneImage = Resources.getResource("resources/images/stone.jpg");
+ if (stoneImage == null) {
+ System.err.println("resources/images/stone.jpg not found");
+ System.exit(1);
+ }
+
setLayout(new BorderLayout());
GraphicsConfiguration config =
SimpleUniverse.getPreferredConfiguration();
@@ -290,15 +282,18 @@ public class OrientedTest extends Applet {
public static void main(String[] args) {
java.net.URL earthURL = null;
java.net.URL stoneURL = null;
- try {
- // the paths to the image files for an application
- earthURL = new java.net.URL("file:../images/earth.jpg");
- stoneURL = new java.net.URL("file:../images/stone.jpg");
- }
- catch (java.net.MalformedURLException ex) {
- System.out.println(ex.getMessage());
- System.exit(1);
- }
+
+ earthURL = Resources.getResource("resources/images/earth.jpg");
+ if (earthURL == null) {
+ System.err.println("resources/images/earth.jpg not found");
+ System.exit(1);
+ }
+
+ stoneURL = Resources.getResource("resources/images/stone.jpg");
+ if (stoneURL == null) {
+ System.err.println("resources/images/stone.jpg not found");
+ System.exit(1);
+ }
new MainFrame(new OrientedTest(earthURL, stoneURL), 400, 400);
}
diff --git a/src/classes/org/jdesktop/j3d/examples/print_canvas3d/PrintCanvas3D.java b/src/classes/org/jdesktop/j3d/examples/print_canvas3d/PrintCanvas3D.java
index c40993a..884af67 100644
--- a/src/classes/org/jdesktop/j3d/examples/print_canvas3d/PrintCanvas3D.java
+++ b/src/classes/org/jdesktop/j3d/examples/print_canvas3d/PrintCanvas3D.java
@@ -45,6 +45,7 @@
package org.jdesktop.j3d.examples.print_canvas3d;
import com.sun.j3d.utils.universe.*;
+import java.net.MalformedURLException;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.awt.*;
@@ -56,9 +57,10 @@ import com.sun.j3d.loaders.ParsingErrorException;
import com.sun.j3d.loaders.IncorrectFormatException;
import com.sun.j3d.loaders.Scene;
import java.awt.image.BufferedImage;
-import java.awt.event.*;
import java.io.*;
import com.sun.j3d.utils.behaviors.mouse.*;
+import java.net.URL;
+import org.jdesktop.j3d.examples.Resources;
public class PrintCanvas3D extends javax.swing.JFrame {
@@ -67,7 +69,7 @@ public class PrintCanvas3D extends javax.swing.JFrame {
private static final double creaseAngle = 60.0;
private Canvas3D onScreenCanvas3D;
private OffScreenCanvas3D offScreenCanvas3D;
- private String filename = null;
+ private URL filename = null;
private static final int OFF_SCREEN_SCALE = 3;
private SimpleUniverse univ = null;
@@ -230,13 +232,23 @@ public class PrintCanvas3D extends javax.swing.JFrame {
public PrintCanvas3D(String args[]) {
if (args.length == 0) {
- usage();
+ filename = Resources.getResource("resources/geometry/beethoven.obj");
+ if (filename == null) {
+ System.err.println("resources/geometry/beethoven.obj not found");
+ System.exit(1);
+ }
} else {
for (int i = 0 ; i < args.length ; i++) {
if (args[i].startsWith("-")) {
System.err.println("Argument '" + args[i] + "' ignored.");
} else {
- filename = args[i];
+ try{
+ filename = new URL(args[i]);
+ }
+ catch (MalformedURLException e) {
+ System.err.println(e.getMessage());
+ System.exit(1);
+ }
}
}
}