visad.java3d
Class KeyboardBehaviorJ3D

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 visad.java3d.KeyboardBehaviorJ3D
All Implemented Interfaces:
KeyboardBehavior
Direct Known Subclasses:
CBMKeyboardBehaviorJ3D

public class KeyboardBehaviorJ3D
extends Behavior
implements KeyboardBehavior

KeyboardBehaviorJ3D is the VisAD class for keyboard control of rotation, translation, and zoom of display in Java3D.

Author:
Troy Sandblom NCAR/RAP May, 2000, Don Murray (adapted to VisAD with input from Curtis)

Field Summary
static int ROTATE_X_NEG
          Identifier for function to rotate negatively around the X viewing axis
static int ROTATE_X_POS
          Identifier for function to rotate positively around the X viewing axis
static int ROTATE_Y_NEG
          Identifier for function to rotate negatively around the Y viewing axis
static int ROTATE_Y_POS
          Identifier for function to rotate positively around the Y viewing axis
static int ROTATE_Z_NEG
          Identifier for function to rotate negatively around the Z viewing axis
static int ROTATE_Z_POS
          Identifier for function to rotate positively around the Z viewing axis
protected  WakeupCondition wakeupCondition
          Condition that causes this Behavior to wake up.
 
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
 
Fields inherited from interface visad.KeyboardBehavior
NO_MASK, RESET, TRANSLATE_DOWN, TRANSLATE_LEFT, TRANSLATE_RIGHT, TRANSLATE_UP, ZOOM_IN, ZOOM_OUT
 
Constructor Summary
KeyboardBehaviorJ3D(DisplayRendererJ3D r)
          Construct a new keyboard behavior for the DisplayRenderer.
KeyboardBehaviorJ3D(DisplayRendererJ3D r, int num_functions)
           
 
Method Summary
 void execFunction(int function)
          Executes the given function.
 void initialize()
          Initialize this behavior.
 void mapKeyToFunction(int function, int keycode, int modifiers)
          Maps key represented by keycode & modifiers to the given function.
 void processKeyEvent(KeyEvent event)
          Process a key event.
 void processStimulus(Enumeration criteria)
          Process a stimulus meant for this behavior.
 
Methods inherited from class javax.media.j3d.Behavior
getEnable, getNumSchedulingIntervals, getSchedulingBoundingLeaf, getSchedulingBounds, getSchedulingInterval, getView, getWakeupCondition, postId, setEnable, 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

ROTATE_Z_POS

public static final int ROTATE_Z_POS
Identifier for function to rotate positively around the Z viewing axis

See Also:
Constant Field Values

ROTATE_Z_NEG

public static final int ROTATE_Z_NEG
Identifier for function to rotate negatively around the Z viewing axis

See Also:
Constant Field Values

ROTATE_X_POS

public static final int ROTATE_X_POS
Identifier for function to rotate positively around the X viewing axis

See Also:
Constant Field Values

ROTATE_X_NEG

public static final int ROTATE_X_NEG
Identifier for function to rotate negatively around the X viewing axis

See Also:
Constant Field Values

ROTATE_Y_POS

public static final int ROTATE_Y_POS
Identifier for function to rotate positively around the Y viewing axis

See Also:
Constant Field Values

ROTATE_Y_NEG

public static final int ROTATE_Y_NEG
Identifier for function to rotate negatively around the Y viewing axis

See Also:
Constant Field Values

wakeupCondition

protected WakeupCondition wakeupCondition
Condition that causes this Behavior to wake up.

Constructor Detail

KeyboardBehaviorJ3D

public KeyboardBehaviorJ3D(DisplayRendererJ3D r)
Construct a new keyboard behavior for the DisplayRenderer. You need to add the behavior to the DisplayRenderer if you want to use it. Default key assignments use the arrow keys to simulate the default VisAD mouse behavior.

Rotation (3D renderer only):

Zoom: Rotate: Translate: Reset:

Parameters:
r - DisplayRenderer to use.
See Also:
DisplayRendererJ3D.addKeyboardBehavior(KeyboardBehaviorJ3D behavior), to change default key to function mappings

KeyboardBehaviorJ3D

public KeyboardBehaviorJ3D(DisplayRendererJ3D r,
                           int num_functions)
Method Detail

initialize

public void initialize()
Initialize this 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(Enumeration criteria)
Process a stimulus meant for this behavior. This method is invoked when a key is pressed. NOTE: Applications should not call this method. It is called by the Java 3D behavior scheduler.

Specified by:
processStimulus in class Behavior
Parameters:
criteria - an enumeration of triggered wakeup criteria

mapKeyToFunction

public void mapKeyToFunction(int function,
                             int keycode,
                             int modifiers)
Maps key represented by keycode & modifiers to the given function. Each function can only have one key/modifier combination assigned to it at a time.

Specified by:
mapKeyToFunction in interface KeyboardBehavior
Parameters:
function - keyboard function (ROTATE_X_POS, ZOOM_IN, etc)
keycode - KeyEvent virtual keycodes
modifiers - InputEvent key mask
See Also:
KeyEvent, InputEvent

processKeyEvent

public void processKeyEvent(KeyEvent event)
Process a key event. Determines whether a meaningful key was pressed.

Specified by:
processKeyEvent in interface KeyboardBehavior
Parameters:
event - KeyEvent stimulus

execFunction

public void execFunction(int function)
Executes the given function.

Specified by:
execFunction in interface KeyboardBehavior
Parameters:
function - function to perform (TRANSLATE_UP, ZOOM_IN, etc)