Feature
Java Feature — Graph3D
Visualizing data using Java3D
May. 23, 2006 01:00 PM
Installing Java3D
To run Graph3D, you'll have to have Java3D installed on your computer. Java3D can be downloaded at java.sun.com/products/java-media/3D/downloads.
If your computer is a PC, you may have to install OpenGL or DirectX.
Most PCs automatically come with OpenGL or DirectX installed, but if
yours doesn't, see www.microsoft.com/downloads. To run Java3D on Unix workstations see the workstation maker Web site for Java3D support.
Running Graph3D
To compile the Graph3D application, type the following command in a DOS window from the directory containing the source code:
javac -classpath .; *.java
To run Graph3D as a standalone application in a DOS window, type the following command from the source code directory:
java -classpath .; Standalone
As with computer games, the quality of the Java3D
display depends heavily on the quality of the graphics board installed
in the computer. Low-end boards tend to leave out parts of the display
like lines, surfaces, and text.
Running from a Browser
Java3D can be run from both
Netscape and Microsoft Internet Explorer (IE) web browsers. When
installing the latest version of the Java JDK, the install process
automatically points your web browser to the developer's kit. As long
as you installed Java3D to this version of the JDK, all the work is
done for you. To verify which version of the JDK your browser will use,
go to the "Control Panel" on your PC and click on the Java menu.
To run Graph3D from one of these browsers, open the file
AppletGraph3D.html (included in the source code) from your browser.
Since Graph3D is expecting input from a data file on your local PC,
you'll have to grant "read" file permission to the file plot3D.dat in
the java.policy file. This is located in the
"jdk_install_directory/jre/lib/security" directory. The syntax for
granting permissions is:
grant codeBase "file:/C:/source_code " {
permission java.io.FilePermission "C:/source_code/plot3D.dat",read";
};
Granting permissions this way lets any applet running in
the browser access your local file. So do this for demonstration
purposes only. Realistically, a browser running the Graph3D applet
won't use data from a file on the local computer. The user must change
Graph3D appropriately to get the data from the server and format it.
Please view the Author's Source code
Summary
There are many fine commercial
off-the-shelf (COTS) graphing packages available. While they may
currently solve your particular graphing needs, writing your own
graphing software gives you total control and lets you change it in any
fashion desired. This will be beneficial in the long run since it will
be totally portable and there will be no need for licenses, upgrades,
or maintenance fees. Besides, the vendor may not incorporate any bug
fixes or desired features not currently in a COTS package any time
soon. Graph3D provides the core classes and technology for Java3D
programming and can be used as a starting point for developing your own
graphing application. As you've seen, Graph3D isn't a complex
application and hopefully you'll consider using Java3D in your current
or future projects.
About Valor DoddValor Dodd is a Java-certified senior software engineer at Lockheed Martin in Denver, Colorado. He has more than 20 years of software experience developing computer graphics and GUI applications for the telephone and defense industries.