com.sun.j3d.utils.behaviors.vp
Class OrbitBehavior

java.lang.Object
  |
  +--javax.media.j3d.SceneGraphObject
        |
        +--javax.media.j3d.Node
              |
              +--javax.media.j3d.Leaf
                    |
                    +--javax.media.j3d.Behavior
                          |
                          +--com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
                                |
                                +--com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
                                      |
                                      +--com.sun.j3d.utils.behaviors.vp.OrbitBehavior
All Implemented Interfaces:
java.util.EventListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

public class OrbitBehavior
extends ViewPlatformAWTBehavior

Moves the View around a point of interest. Includes rotation, translation and zoom actions. This behavior must be added to the ViewingPlatform using the addViewPlatformBehavior method. The view can be manipulated either by the Mouse.

Since:
Java 3D 1.2.1

Field Summary
static int DISABLE_ROTATE
          Constructor flag to disable rotate
static int DISABLE_TRANSLATE
          Constructor flag to disable translate
static int DISABLE_ZOOM
          Constructor flag to disable zoom
static int PROPORTIONAL_ZOOM
          Constructor flag to use proportional zoom, which determines how much you zoom based on view's distance from the center of rotation.
static int REVERSE_ALL
          Constructor flag to reverse all the behaviors
static int REVERSE_ROTATE
          Constructor flag to reverse the rotate behavior
static int REVERSE_TRANSLATE
          Constructor flag to reverse the translate behavior
static int REVERSE_ZOOM
          Constructor flag to reverse the zoom behavior
static int STOP_ZOOM
          Constructor flag that indicates zoom should stop when it reaches the minimum orbit radius set by setMinRadius().
 
Fields inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
frameWakeup, KEY_LISTENER, motion, MOUSE_LISTENER, MOUSE_MOTION_LISTENER, POST_ID, postWakeup, targetTransform
 
Fields inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
targetTG, vp
 
Fields inherited from class javax.media.j3d.Node
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
 
Constructor Summary
OrbitBehavior(Canvas3D c)
          Creates a new OrbitBehavior
OrbitBehavior(Canvas3D c, int flags)
          Creates a new OrbitBehavior
 
Method Summary
 double getMinRadius()
          Returns the minimum orbit radius.
 boolean getRotateEnable()
          Retrieves the state of rotate enabled
 void getRotationCenter(Point3d center)
          Places the value of the center around which the View rotates into the Point3d.
 double getRotXFactor()
          Returns the x rotation movement multiplier
 double getRotYFactor()
          Returns the y rotation movement multiplier
 boolean getTranslateEnable()
          Retrieves the state of translate enabled
 double getTransXFactor()
          Returns the x translation movement multiplier
 double getTransYFactor()
          Returns the y translation movement multiplier
 boolean getZoomEnable()
          Retrieves the state of zoom enabled
 double getZoomFactor()
          Returns the zoom movement multiplier
protected  void integrateTransforms()
          Called once per frame (if the view is moving) to calculate the new view platform transform
protected  void processAWTEvents(java.awt.AWTEvent[] events)
          This is called once per frame if there are any AWT events to process.
protected  void processMouseEvent(java.awt.event.MouseEvent evt)
           
 void setMinRadius(double r)
          Sets the minimum radius for the OrbitBehavior.
 void setRotateEnable(boolean enabled)
          Enables or disables rotation.
 void setRotationCenter(Point3d center)
          Sets the center around which the View rotates.
 void setRotFactors(double xfactor, double yfactor)
          Sets the rotation x and y factors.
 void setRotXFactor(double xfactor)
          Sets the rotation x factor.
 void setRotYFactor(double yfactor)
          Sets the rotation y factor.
 void setTransFactors(double xfactor, double yfactor)
          Sets the translation x and y factors.
 void setTranslateEnable(boolean enabled)
          Enables or disables translate.
 void setTransXFactor(double xfactor)
          Sets the translation x factor.
 void setTransYFactor(double yfactor)
          Sets the translation y factor.
 void setViewingPlatform(ViewingPlatform vp)
          Sets the ViewingPlatform for this behavior.
 void setZoomEnable(boolean enabled)
          Enables or disables zoom.
 void setZoomFactor(double zfactor)
          Sets the zoom factor.
 
Methods inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
initialize, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, processStimulus, queueAWTEvent, setEnable
 
Methods inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
getViewingPlatform
 
Methods inherited from class javax.media.j3d.Behavior
getEnable, getSchedulingBoundingLeaf, getSchedulingBounds, getView, postId, setSchedulingBoundingLeaf, setSchedulingBounds, updateNodeReferences, wakeupOn
 
Methods inherited from class javax.media.j3d.Node
cloneNode, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
 
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, duplicateSceneGraphObject, getCapability, getUserData, isCompiled, isLive, setCapability, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVERSE_ROTATE

public static final int REVERSE_ROTATE
Constructor flag to reverse the rotate behavior

REVERSE_TRANSLATE

public static final int REVERSE_TRANSLATE
Constructor flag to reverse the translate behavior

REVERSE_ZOOM

public static final int REVERSE_ZOOM
Constructor flag to reverse the zoom behavior

REVERSE_ALL

public static final int REVERSE_ALL
Constructor flag to reverse all the behaviors

STOP_ZOOM

public static final int STOP_ZOOM
Constructor flag that indicates zoom should stop when it reaches the minimum orbit radius set by setMinRadius(). The minimus radius default is 0.0.

DISABLE_ROTATE

public static final int DISABLE_ROTATE
Constructor flag to disable rotate

DISABLE_TRANSLATE

public static final int DISABLE_TRANSLATE
Constructor flag to disable translate

DISABLE_ZOOM

public static final int DISABLE_ZOOM
Constructor flag to disable zoom

PROPORTIONAL_ZOOM

public static final int PROPORTIONAL_ZOOM
Constructor flag to use proportional zoom, which determines how much you zoom based on view's distance from the center of rotation. The percentage of distance that the viewer zooms is determined by the zoom factor.
Constructor Detail

OrbitBehavior

public OrbitBehavior(Canvas3D c)
Creates a new OrbitBehavior
Parameters:
c - The Canvas3D to add the behavior to

OrbitBehavior

public OrbitBehavior(Canvas3D c,
                     int flags)
Creates a new OrbitBehavior
Parameters:
c - The Canvas3D to add the behavior to
flags - The option flags
Method Detail

processAWTEvents

protected void processAWTEvents(java.awt.AWTEvent[] events)
Description copied from class: ViewPlatformAWTBehavior
This is called once per frame if there are any AWT events to process. The motion variable will be true when the method is called. If it is true when the method returns integrateTransforms will be called immediately. The AWTEvents are presented in the array in the order in which they arrived from AWT.
Overrides:
processAWTEvents in class ViewPlatformAWTBehavior

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent evt)

setViewingPlatform

public void setViewingPlatform(ViewingPlatform vp)
Sets the ViewingPlatform for this behavior. This method is called by the ViewingPlatform. If a sub-calls overrides this method, it must call super.setViewingPlatform(vp). NOTE: Applications should not call this method.
Overrides:
setViewingPlatform in class ViewPlatformAWTBehavior

integrateTransforms

protected void integrateTransforms()
Description copied from class: ViewPlatformAWTBehavior
Called once per frame (if the view is moving) to calculate the new view platform transform
Overrides:
integrateTransforms in class ViewPlatformAWTBehavior

setRotationCenter

public void setRotationCenter(Point3d center)
Sets the center around which the View rotates. The default is (0,0,0).
Parameters:
center - The Point3d to set the center of rotation to

getRotationCenter

public void getRotationCenter(Point3d center)
Places the value of the center around which the View rotates into the Point3d.
Parameters:
center - The Point3d

setRotFactors

public void setRotFactors(double xfactor,
                          double yfactor)
Sets the rotation x and y factors. The factors are used to determine how many degrees to rotate the view for each pixel of mouse movement. The view is rotated factor * 0.01 degrees for each pixel of mouse movement. The default factor is 1.0.
Parameters:
xfactor - The x movement multiplier
yfactor - The y movement multiplier

setRotXFactor

public void setRotXFactor(double xfactor)
Sets the rotation x factor. The factors are used to determine how many degrees to rotate the view for each pixel of mouse movement. The view is rotated factor * 0.01 degrees for each pixel of mouse movement. The default factor is 1.0.
Parameters:
xfactor - The x movement multiplier

setRotYFactor

public void setRotYFactor(double yfactor)
Sets the rotation y factor. The factors are used to determine how many degrees to rotate the view for each pixel of mouse movement. The view is rotated factor * 0.01 degrees for each pixel of mouse movement. The default factor is 1.0.
Parameters:
yfactor - The y movement multiplier

setTransFactors

public void setTransFactors(double xfactor,
                            double yfactor)
Sets the translation x and y factors. The factors are used to determine how many units to translate the view for each pixel of mouse movement. The view is translated factor * 0.01 units for each pixel of mouse movement. The default factor is 1.0.
Parameters:
xfactor - The x movement multiplier
yfactor - The y movement multiplier

setTransXFactor

public void setTransXFactor(double xfactor)
Sets the translation x factor. The factors are used to determine how many units to translate the view for each pixel of mouse movement. The view is translated factor * 0.01 units for each pixel of mouse movement. The default factor is 1.0.
Parameters:
xfactor - The x movement multiplier

setTransYFactor

public void setTransYFactor(double yfactor)
Sets the translation y factor. The factors are used to determine how many units to translate the view for each pixel of mouse movement. The view is translated factor * 0.01 units for each pixel of mouse movement. The default factor is 1.0.
Parameters:
yfactor - The y movement multiplier

setZoomFactor

public void setZoomFactor(double zfactor)
Sets the zoom factor. The factor is used to determine how many units to zoom the view for each pixel of mouse movement. The view is zoomed factor * 0.01 units for each pixel of mouse movement. For proportional zoom, the view is zoomed factor * 1% of the distance from the center of rotation for each pixel of mouse movement. The default factor is 1.0.
Parameters:
zfactor - The movement multiplier

getRotXFactor

public double getRotXFactor()
Returns the x rotation movement multiplier
Returns:
The movement multiplier for x rotation

getRotYFactor

public double getRotYFactor()
Returns the y rotation movement multiplier
Returns:
The movement multiplier for y rotation

getTransXFactor

public double getTransXFactor()
Returns the x translation movement multiplier
Returns:
The movement multiplier for x translation

getTransYFactor

public double getTransYFactor()
Returns the y translation movement multiplier
Returns:
The movement multiplier for y translation

getZoomFactor

public double getZoomFactor()
Returns the zoom movement multiplier
Returns:
The movement multiplier for zoom

setRotateEnable

public void setRotateEnable(boolean enabled)
Enables or disables rotation. The default is true.
Parameters:
enabled - true or false to enable or disable rotate

setZoomEnable

public void setZoomEnable(boolean enabled)
Enables or disables zoom. The default is true.
Parameters:
enabled - true or false to enable or disable zoom

setTranslateEnable

public void setTranslateEnable(boolean enabled)
Enables or disables translate. The default is true.
Parameters:
enabled - true or false to enable or disable translate

getRotateEnable

public boolean getRotateEnable()
Retrieves the state of rotate enabled
Returns:
the rotate enable state

getZoomEnable

public boolean getZoomEnable()
Retrieves the state of zoom enabled
Returns:
the zoom enable state

getTranslateEnable

public boolean getTranslateEnable()
Retrieves the state of translate enabled
Returns:
the translate enable state

setMinRadius

public void setMinRadius(double r)
Sets the minimum radius for the OrbitBehavior. The zoom will stop at this distance from the center of rotation. The default is 0.0. The minimum will have no affect if the STOP_ZOOM constructor flag is not set.
Parameters:
r - the minimum radius
Throws:
java.lang.IllegalArgumentException - if the radius is less than 0.0

getMinRadius

public double getMinRadius()
Returns the minimum orbit radius. The zoom will stop at this distance from the center of rotation if the STOP_ZOOM constructor flag is set.
Returns:
the minimum radius