edu.washington.NVisF.viewer
Class PlotEnvironment

java.lang.Object
  |
  +--edu.washington.NVisF.viewer.PlotEnvironment

public class PlotEnvironment
extends java.lang.Object

The PlotEnvironment class provides the viewer that displays 3D objects and various utility methods to aid viewing. This includes: (1) setting up all the windows; (2) maintaining a list of 3-D object groups whose visibility can be toggled; (3) adding utility mouse behaviors for rotating, translating, and zooming from the com.sun.j3d.utils.behaviors.mouse package; (4) providing a few utility methods for rotating the view and adjusting some view parameters. This somewhat disorganized class will be significantly revamped and extended in later versions.


Field Summary
static int maxObjectGroups
           
 int viewerSize
           
 
Constructor Summary
PlotEnvironment()
           
 
Method Summary
 int addObjectGroup(ObjectGroup targetGroup, boolean visible)
          Adds the specified ObjectGroup to a private list of known ObjectGroups.
 void initUniverse()
          Calls initUniverse(int viewerSize) with a default viewer size of 512x512.
 void initUniverse(int viewerSize)
          This method sets up the viewer and should be called before accessing any of the other methods.
 boolean removeObjectGroup(int index)
          removes the ObjectGroup specified by index from the private list.
 void resetRotation()
          Undoes any accumulated rotations, but preserves translates and zooms.
 void resetUniverse()
          Undoes all rotations, translates, and zooms, returning the view to its initial state.
 void rotX(double radians)
          Rotates the universe by the given angle about the X axis (that is, rotate down).
 void rotY(double radians)
          Rotates the universe by the given angle about the Y axis (that is, rotate right).
 void rotZ(double radians)
          Rotates the universe by the given angle about the Z axis (that is, rotate counter-clockwise).
 boolean setObjectGroupVisible(int index, boolean visible)
          sets the visibility of the ObjectGroup specified by index according to the visible flag.
 void setScaleFactor(double factor)
          Seta a scale factor for the universe.
 void setViewParams(float vx, float vy, float vz, float frontclip, float backclip)
          Sets various viewing parameters.
 boolean showObjectGroup(int index)
          sets the specified group to be visible.
 boolean turnOffObjectGroup(int index)
          sets the specified group to be not visible.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxObjectGroups

public static final int maxObjectGroups

viewerSize

public int viewerSize
Constructor Detail

PlotEnvironment

public PlotEnvironment()
Method Detail

initUniverse

public void initUniverse()
Calls initUniverse(int viewerSize) with a default viewer size of 512x512.

initUniverse

public void initUniverse(int viewerSize)
This method sets up the viewer and should be called before accessing any of the other methods. In particular, it creates all the windows of the system and sets up the Java3D universe. It is not run at creation time in order that references to this PlotEnvironment can be made after creation, but the extensive work of setting up the view can be delayed until needed. Once this method runs once, later calls will do nothing (and thus are safe).

setViewParams

public void setViewParams(float vx,
                          float vy,
                          float vz,
                          float frontclip,
                          float backclip)
Sets various viewing parameters. (vx,vy,vz) are the new coordinates of the viewing camera, and frontclip and backclip are the values for the front and back clipping distances. See the Java3D documentation for a discussion of the universe coordinate system and clipping issues.

setScaleFactor

public void setScaleFactor(double factor)
Seta a scale factor for the universe. Everything will be expanded or contracted uniformly by the given factor. This is useful for making a view a reasonable size. This is also needed since the amount of translation or zooming provided by the default mouse behaviors is fixed. Thus, adjusting this parameter effectively speeds up or slows down the rate of translation and zoom.
Parameters:
factor - the scale factor

resetUniverse

public void resetUniverse()
Undoes all rotations, translates, and zooms, returning the view to its initial state.

resetRotation

public void resetRotation()
Undoes any accumulated rotations, but preserves translates and zooms.

rotX

public void rotX(double radians)
Rotates the universe by the given angle about the X axis (that is, rotate down). Use negative values to rotate up.

rotY

public void rotY(double radians)
Rotates the universe by the given angle about the Y axis (that is, rotate right). Use negative values to roate left.

rotZ

public void rotZ(double radians)
Rotates the universe by the given angle about the Z axis (that is, rotate counter-clockwise). Use negative values to rotate clockwise.

addObjectGroup

public int addObjectGroup(ObjectGroup targetGroup,
                          boolean visible)
Adds the specified ObjectGroup to a private list of known ObjectGroups. The visible flag determines whether the BranchGroup contained within this group should immediately be made visible (that is, attached to the active scene graph). The return value is a unique identifier allowing later access to this ObjectGroup. The return value is -1 if the input is null or the list of ObjectGroups is full.
Parameters:
targetGroup - the ObjectGroup to add
visible - boolean flag controlling visibility
Returns:
int unique identifier, or -1 on error
See Also:
ObjectGroup

showObjectGroup

public boolean showObjectGroup(int index)
sets the specified group to be visible.
Parameters:
index - the unique identifier returned from addObjectGroup()
Returns:
boolean true if successful; false otherwise

turnOffObjectGroup

public boolean turnOffObjectGroup(int index)
sets the specified group to be not visible.
Parameters:
index - the unique identifier returned from addObjectGroup()
Returns:
boolean true if successful; false otherwise

setObjectGroupVisible

public boolean setObjectGroupVisible(int index,
                                     boolean visible)
sets the visibility of the ObjectGroup specified by index according to the visible flag. If the requested operation succeeds, the return value is true, otherwise this returns false.
Parameters:
index - the unique identifier returned from addObjectGroup()
Returns:
boolean true if successful; false otherwise

removeObjectGroup

public boolean removeObjectGroup(int index)
removes the ObjectGroup specified by index from the private list. The group is also removed from the active view if currently visible. The return value is true if the operation succeeds, false otherwise.
Parameters:
index - the unique identifier returned from addObjectGroup()