OrbitBehaviorPivot

org.interactivemesh.pivot.wtk.j3d.nav
Class ViewPlatformEventBehaviorPivot

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 org.interactivemesh.pivot.wtk.j3d.nav.ViewPlatformBehaviorPivot
                      extended by org.interactivemesh.pivot.wtk.j3d.nav.ViewPlatformEventBehaviorPivot
All Implemented Interfaces:
org.apache.pivot.wtk.ComponentMouseButtonListener, org.apache.pivot.wtk.ComponentMouseListener, org.apache.pivot.wtk.ComponentMouseWheelListener
Direct Known Subclasses:
OrbitBehaviorPivot

public abstract class ViewPlatformEventBehaviorPivot
extends ViewPlatformBehaviorPivot
implements org.apache.pivot.wtk.ComponentMouseListener, org.apache.pivot.wtk.ComponentMouseButtonListener, org.apache.pivot.wtk.ComponentMouseWheelListener

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


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseListener
org.apache.pivot.wtk.ComponentMouseListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseButtonListener
org.apache.pivot.wtk.ComponentMouseButtonListener.Adapter
 
Field Summary
protected  org.apache.pivot.wtk.Component component
          The Component from which this Behavior gets events
protected  javax.media.j3d.WakeupOnElapsedFrames frameWakeup
          The different criterion for the behavior to wakeup
protected  boolean motion
          Boolean for whether the mouse is in motion
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
protected static int POST_ID
          Behavior PostId used in this behavior
protected  javax.media.j3d.WakeupOnBehaviorPost postWakeup
          The Or of the different criterion for the behavior to wakeup
protected  javax.media.j3d.Transform3D targetTransform
          The target Transform3D for this behavior
 
Fields inherited from class org.interactivemesh.pivot.wtk.j3d.nav.ViewPlatformBehaviorPivot
homeRotCenter, homeTransform, targetTG
 
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
protected ViewPlatformEventBehaviorPivot()
          Parameterless constructor for this behavior.
protected ViewPlatformEventBehaviorPivot(int listenerFlags)
          Construct a behavior which listens for events specified by the given flags.
 
Method Summary
 void initialize()
          Initializes the behavior.
protected abstract  void integrateTransforms()
          Called once per frame (if the view is moving) to calculate the new view platform transform
 boolean mouseClick(org.apache.pivot.wtk.Component component, org.apache.pivot.wtk.Mouse.Button button, int x, int y, int count)
           
 boolean mouseDown(org.apache.pivot.wtk.Component component, org.apache.pivot.wtk.Mouse.Button button, int x, int y)
           
 boolean mouseMove(org.apache.pivot.wtk.Component component, int x, int y)
           
 void mouseOut(org.apache.pivot.wtk.Component component)
           
 void mouseOver(org.apache.pivot.wtk.Component component)
           
 boolean mouseUp(org.apache.pivot.wtk.Component component, org.apache.pivot.wtk.Mouse.Button button, int x, int y)
           
 boolean mouseWheel(org.apache.pivot.wtk.Component component, org.apache.pivot.wtk.Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int x, int y)
           
protected abstract  void processEvents(org.interactivemesh.pivot.wtk.j3d.nav.OrbitEvent[] events)
          This is called once per frame if there are any events to process.
 void processStimulus(java.util.Enumeration behEnum)
          Process a stimulus meant for this behavior.
protected  void queueEvent(org.interactivemesh.pivot.wtk.j3d.nav.OrbitEvent e)
          Queue events in a thread safe manner.
 void setComponent(org.apache.pivot.wtk.Component c)
          Sets the Component used to listen for mouse, mouse motion, and mouse wheel events.
 void setEnable(boolean state)
          Overload setEnable from Behavior.
protected  void setListenerFlags(int listenerFlags)
          Sets listener flags for this behavior.
 void setViewingTransformGroup(javax.media.j3d.TransformGroup tg)
          Sets the ViewPlatform's TransformGroup for this behavior.
 
Methods inherited from class org.interactivemesh.pivot.wtk.j3d.nav.ViewPlatformBehaviorPivot
getHomeRotationCenter, getHomeTransform, getViewingTransformGroup, goHome, goHome, setHomeRotationCenter, setHomeTransform
 
Methods inherited from class javax.media.j3d.Behavior
getEnable, getNumSchedulingIntervals, getSchedulingBoundingLeaf, getSchedulingBounds, getSchedulingInterval, getView, getWakeupCondition, postId, setSchedulingBoundingLeaf, setSchedulingBounds, setSchedulingInterval, updateNodeReferences, wakeupOn
 
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, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

POST_ID

protected static final int POST_ID
Behavior PostId used in this behavior

See Also:
Constant Field Values

frameWakeup

protected javax.media.j3d.WakeupOnElapsedFrames frameWakeup
The different criterion for the behavior to wakeup


postWakeup

protected javax.media.j3d.WakeupOnBehaviorPost postWakeup
The Or of the different criterion for the behavior to wakeup


targetTransform

protected javax.media.j3d.Transform3D targetTransform
The target Transform3D for this behavior


motion

protected boolean motion
Boolean for whether the mouse is in motion


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

MOUSE_WHEEL_LISTENER

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

See Also:
Constant Field Values

component

protected org.apache.pivot.wtk.Component component
The Component from which this Behavior gets events

Constructor Detail

ViewPlatformEventBehaviorPivot

protected ViewPlatformEventBehaviorPivot()
Parameterless constructor for this behavior.


ViewPlatformEventBehaviorPivot

protected ViewPlatformEventBehaviorPivot(int listenerFlags)
Construct a behavior which listens for events specified by the given flags.

Parameters:
listenerFlags - Indicates which listener should be registered, one or more of MOUSE_LISTENER, MOUSE_MOTION_LISTENER, MOUSE_WHEEL_LISTENER
Method Detail

setListenerFlags

protected void setListenerFlags(int listenerFlags)
Sets listener flags for this behavior.

Parameters:
listenerFlags - Indicates which listener should be registered, one or more of MOUSE_LISTENER, MOUSE_MOTION_LISTENER, MOUSE_WHEEL_LISTENER

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 javax.media.j3d.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 javax.media.j3d.Behavior

setEnable

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

Overrides:
setEnable in class javax.media.j3d.Behavior

setComponent

public void setComponent(org.apache.pivot.wtk.Component c)
Sets the Component used to listen for mouse, mouse motion, and mouse wheel events. If a subclass overrides this method, it must call super.setComponent(c).

Parameters:
c - the source Component for this behavior

setViewingTransformGroup

public void setViewingTransformGroup(javax.media.j3d.TransformGroup tg)
Sets the ViewPlatform's TransformGroup for this behavior. If a subclass overrides this method, it must call super.setViewingTransformGroup(tg).

Overrides:
setViewingTransformGroup in class ViewPlatformBehaviorPivot
Parameters:
tg - the target TransformGroup for this behavior

processEvents

protected abstract void processEvents(org.interactivemesh.pivot.wtk.j3d.nav.OrbitEvent[] events)
This is called once per frame if there are any 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 events are presented in the array in the order in which they arrived.


integrateTransforms

protected abstract void integrateTransforms()
Called once per frame (if the view is moving) to calculate the new view platform transform


queueEvent

protected void queueEvent(org.interactivemesh.pivot.wtk.j3d.nav.OrbitEvent e)
Queue events in a thread safe manner. If subclasses override this method they must call super.queueEvent(e)


mouseMove

public boolean mouseMove(org.apache.pivot.wtk.Component component,
                         int x,
                         int y)
Specified by:
mouseMove in interface org.apache.pivot.wtk.ComponentMouseListener

mouseOver

public void mouseOver(org.apache.pivot.wtk.Component component)
Specified by:
mouseOver in interface org.apache.pivot.wtk.ComponentMouseListener

mouseOut

public void mouseOut(org.apache.pivot.wtk.Component component)
Specified by:
mouseOut in interface org.apache.pivot.wtk.ComponentMouseListener

mouseDown

public boolean mouseDown(org.apache.pivot.wtk.Component component,
                         org.apache.pivot.wtk.Mouse.Button button,
                         int x,
                         int y)
Specified by:
mouseDown in interface org.apache.pivot.wtk.ComponentMouseButtonListener

mouseUp

public boolean mouseUp(org.apache.pivot.wtk.Component component,
                       org.apache.pivot.wtk.Mouse.Button button,
                       int x,
                       int y)
Specified by:
mouseUp in interface org.apache.pivot.wtk.ComponentMouseButtonListener

mouseClick

public boolean mouseClick(org.apache.pivot.wtk.Component component,
                          org.apache.pivot.wtk.Mouse.Button button,
                          int x,
                          int y,
                          int count)
Specified by:
mouseClick in interface org.apache.pivot.wtk.ComponentMouseButtonListener

mouseWheel

public boolean mouseWheel(org.apache.pivot.wtk.Component component,
                          org.apache.pivot.wtk.Mouse.ScrollType scrollType,
                          int scrollAmount,
                          int wheelRotation,
                          int x,
                          int y)
Specified by:
mouseWheel in interface org.apache.pivot.wtk.ComponentMouseWheelListener

OrbitBehaviorPivot