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

java.lang.Object
  extended by javax.media.j3d.SceneGraphObject
      extended by javax.media.j3d.Node
          extended by javax.media.j3d.Leaf
              extended by javax.media.j3d.Behavior
                  extended by com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
                      extended by com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener
Direct Known Subclasses:
OrbitBehavior

public abstract class ViewPlatformAWTBehavior
extends ViewPlatformBehavior
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener, java.awt.event.MouseWheelListener

Abstract class which implements much of the event tracking and state updating in a thread safe manner. AWT Events are captured and placed in a queue. While there are pending events or motion the behavior will wake up every frame, call processAWTEvents and integrateTransforms.

Since:
Java 3D 1.2.1

Field Summary
static int KEY_LISTENER
          Flag indicating Behavior should listen for Key Events
static int MOUSE_LISTENER
          Flag indicating Behavior should listen for Mouse Events
static int MOUSE_MOTION_LISTENER
          Flag indicating Behavior should listen for Mouse Motion Events
static int MOUSE_WHEEL_LISTENER
          Flag indicating Behavior should listen for MouseWheel Events
 
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_LOCALE_READ, ALLOW_PARENT_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
 
Constructor Summary
ViewPlatformAWTBehavior(Canvas3D c, int listenerFlags)
          Constructs a new ViewPlatformAWTBehavior.
 
Method Summary
 void initialize()
          Initializes the behavior.
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
           
 void processStimulus(java.util.Enumeration behEnum)
          Process a stimulus meant for this behavior.
 void setEnable(boolean state)
          Overload setEnable from Behavior.
 void setViewingPlatform(ViewingPlatform vp)
          Sets the ViewingPlatform for this behavior.
 
Methods inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
getHomeTransform, getViewingPlatform, goHome, setHomeTransform
 
Methods inherited from class javax.media.j3d.Behavior
getEnable, getNumSchedulingIntervals, getSchedulingBoundingLeaf, getSchedulingBounds, getSchedulingInterval, postId, setSchedulingBoundingLeaf, setSchedulingBounds, setSchedulingInterval, updateNodeReferences
 
Methods inherited from class javax.media.j3d.Node
cloneNode, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
 
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MOUSE_LISTENER

public static final int MOUSE_LISTENER
Flag indicating Behavior should listen for Mouse Events

See Also:
Constant Field Values

MOUSE_MOTION_LISTENER

public static final int MOUSE_MOTION_LISTENER
Flag indicating Behavior should listen for Mouse Motion Events

See Also:
Constant Field Values

KEY_LISTENER

public static final int KEY_LISTENER
Flag indicating Behavior should listen for Key Events

See Also:
Constant Field Values

MOUSE_WHEEL_LISTENER

public static final int MOUSE_WHEEL_LISTENER
Flag indicating Behavior should listen for MouseWheel Events

See Also:
Constant Field Values
Constructor Detail

ViewPlatformAWTBehavior

public ViewPlatformAWTBehavior(Canvas3D c,
                               int listenerFlags)
Constructs a new ViewPlatformAWTBehavior.

Parameters:
c - The Canvas3D on which to listen for events. If this is null a NullPointerException will be thrown.
listenerFlags - Indicates which listener should be registered, one or more of MOUSE_LISTENER, MOUSE_MOTION_LISTENER, KEY_LISTENER, MOUSE_WHEEL_LISTENER
Method Detail

initialize

public void initialize()
Initializes the behavior. NOTE: Applications should not call this method. It is called by the Java 3D behavior scheduler.

Specified by:
initialize in class Behavior

processStimulus

public void processStimulus(java.util.Enumeration behEnum)
Process a stimulus meant for this behavior. NOTE: Applications should not call this method. It is called by the Java 3D behavior scheduler.

Specified by:
processStimulus in class Behavior
Parameters:
behEnum - an enumeration of triggered wakeup criteria for this behavior

setEnable

public void setEnable(boolean state)
Overload setEnable from Behavior. Adds/Removes the AWT listeners depending on the requested state.

Overrides:
setEnable in class Behavior
Parameters:
state - true or false to enable or disable this Behavior

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 ViewPlatformBehavior
Parameters:
vp - the target ViewingPlatform for this behavior

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener