Example code

<< Developer HowTos TOC

Below you can find a list of all the example java classes for download,
together with a short description.

  • Display_Content.java Demonstrates how to create a virtual universe and display an image stack as volume rendering, orthoslices, isosurface or surface plot.
  • Change_Attributes.java Demonstrates how to change attributes like color or transparency of a Content. Also discusses the meaning of these attributes for various display types.
  • Apply_Transformation.java Demonstrates how to modify the transformation of individual Contents.
  • Highlight_Points.java Demonstrates how to create named points for a Content and how to handle those landmark sets.
  • Movie_Recording.java Demonstrates how to animate the virtual universe and create a movie which can subsequently be embedded into presentations.
  • Volume_Rendering.java Shows how a VoltexGroup can be retrieved after displaying a stack as a volume rendering, and how the volume can be edited.
  • Orthoslices_.java Shows how a OrthoGroup can be retrieved after displaying a stack as orthoslices and how the displayed slices can be changed and hidden.
  • Surface_Plot.java Shows how a SurfacePlotGroup can be retrieved after displaying a stack as a surface plot and how to update the displayed slice.
  • Custom_Surface.java Shows how to create custom meshes, consisting of triangles, lines, points or quads, and how they are displayed in the universe.
  • Display_4D.java Shows how to load 4D data, visualize and animate in the universe.
  • Two_Canvasses.java Shows how to display one universe in two windows.
  • Custom_Behavior.java Shows how to catch and handle mouse and key events.

How to compile and run the examples as standalone applications.

Note: To compile and run the examples, make sure that the used JRE has Java 3D installed correctly.
Compile and run example XXX_.java from within an IDE,...
  • Within your IDE, create a new project
  • Create a new package 'examples' and copy the source files (e.g. XXX_.java) to that folder.
  • Include ij.jar and ImageJ_3D_Viewer.jar as external libraries.
  • Compile and run according to your IDE.
Compile and run example XXX_.java on the command line,...
  • Create a new folder, in the following called FOLDER.
  • Copy the file 'ij.jar' from an ImageJ installation to FOLDER.
  • Copy the file 'ImageJ_3D_Viewer.jar' to FOLDER.
  • To compile on the command line, enter that folder and type javac -classpath .:ij.jar:ImageJ_3D_Viewer.jar XXX_.java
    NOTE: On windows, you'll have to replace the ':' by ';'
  • To run the example on the command line, enter that folder and type java -Xmx512m -classpath .:ij.jar:ImageJ_3D_Viewer.jar XXX_
    NOTE: On windows, you'll have to replace the ':' by ';'