## com.sun.j3d.utils.behaviors.mouse
Class MouseBehavior

    java.lang.Object
      javax.media.j3d.SceneGraphObject
          javax.media.j3d.Node
              javax.media.j3d.Leaf
                  javax.media.j3d.Behavior
                      com.sun.j3d.utils.behaviors.mouse.MouseBehavior

All Implemented Interfaces:
  java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener

Direct Known Subclasses:
  MouseRotate, MouseTranslate, MouseWheelZoom, MouseZoom

    public abstract class MouseBehavior

extends Behavior
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener

Base class for all mouse manipulators (see MouseRotate, MouseZoom and MouseTranslate for examples of how to extend this base class).

Field Summary
`protected boolean` `buttonPress`
`protected Transform3D` `currXform`
`protected boolean` `enable`
`protected int` `flags`
`protected boolean` `invert`
`static int` `INVERT_INPUT` Set this flag if you want to invert the inputs.
`static int` `MANUAL_WAKEUP` Set this flag if you want to manually wakeup the behavior.
`protected WakeupOr` `mouseCriterion`
`protected WakeupCriterion[]` `mouseEvents`
`protected java.util.LinkedList` `mouseq`
`protected boolean` `reset`
`protected TransformGroup` `transformGroup`
`protected Transform3D` `transformX`
`protected Transform3D` `transformY`
`protected boolean` `wakeUp`
`protected int` `x`
`protected int` `x_last`
`protected int` `y`
`protected int` `y_last`

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
`MouseBehavior(java.awt.Component c, int format)` Creates a mouse behavior that uses AWT listeners and behavior posts rather than WakeupOnAWTEvent.
`MouseBehavior(java.awt.Component c, TransformGroup transformGroup)` Creates a mouse behavior that uses AWT listeners and behavior posts rather than WakeupOnAWTEvent.
`MouseBehavior(int format)` Initializes standard fields.
`MouseBehavior(TransformGroup transformGroup)` Creates a mouse behavior object with a given transform group.

Method Summary
`void` `addListener(java.awt.Component c)` Adds this behavior as a MouseListener, mouseWheelListener and MouseMotionListener to the specified component.
`TransformGroup` `getTransformGroup()` Return the transformGroup on which this node is operating
`void` `initialize()` Initializes the behavior.
`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` `processMouseEvent(java.awt.event.MouseEvent evt)` Handles mouse events
`abstract void` `processStimulus(java.util.Enumeration criteria)` All mouse manipulators must implement this.
`void` `setEnable(boolean state)` Enables or disables this Behavior.
`void` `setTransformGroup(TransformGroup transformGroup)` Swap a new transformGroup replacing the old one.
`void` `wakeup()` Manually wake up the behavior.

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

### mouseEvents

    protected WakeupCriterion[] mouseEvents

### mouseCriterion

    protected WakeupOr mouseCriterion

### x

    protected int x

### y

    protected int y

### x_last

    protected int x_last

### y_last

    protected int y_last

### transformGroup

    protected TransformGroup transformGroup

### transformX

    protected Transform3D transformX

### transformY

    protected Transform3D transformY

### currXform

    protected Transform3D currXform

### buttonPress

    protected boolean buttonPress

### reset

    protected boolean reset

### invert

    protected boolean invert

### wakeUp

    protected boolean wakeUp

### flags

    protected int flags

### mouseq

    protected java.util.LinkedList mouseq

### enable

    protected boolean enable

### MANUAL_WAKEUP

    public static final int MANUAL_WAKEUP

  Set this flag if you want to manually wakeup the behavior.

  See Also:
    Constant Field Values

### INVERT_INPUT

    public static final int INVERT_INPUT

  Set this flag if you want to invert the inputs. This is useful when the transform for the view platform is being changed instead of the transform for the object.

  See Also:
    Constant Field Values

Constructor Detail

### MouseBehavior

    public MouseBehavior(TransformGroup transformGroup)

  Creates a mouse behavior object with a given transform group.

  Parameters:
    `transformGroup` - The transform group to be manipulated.

### MouseBehavior

    public MouseBehavior(int format)

  Initializes standard fields. Note that this behavior still needs a transform group to work on (use setTransformGroup(tg)) and the transform group must add this behavior.

  Parameters:
    `format` - flags

### MouseBehavior

    public MouseBehavior(java.awt.Component c,
                         TransformGroup transformGroup)

  Creates a mouse behavior that uses AWT listeners and behavior posts rather than WakeupOnAWTEvent. The behaviors is added to the specified Component and works on the given TransformGroup. A null component can be passed to specify the behaviors should use listeners. Components can then be added to the behavior with the addListener(Component c) method.

  Parameters:
    `c` - The Component to add the MouseListener and MouseMotionListener to.
    `transformGroup` - The TransformGroup to operate on.
  Since:
    Java 3D 1.2.1

### MouseBehavior

    public MouseBehavior(java.awt.Component c,
                         int format)

  Creates a mouse behavior that uses AWT listeners and behavior posts rather than WakeupOnAWTEvent. The behavior is added to the specified Component. A null component can be passed to specify the behavior should use listeners. Components can then be added to the behavior with the addListener(Component c) method. Note that this behavior still needs a transform group to work on (use setTransformGroup(tg)) and the transform group must add this behavior.

  Parameters:
    `format` - interesting flags (wakeup conditions).
  Since:
    Java 3D 1.2.1

Method Detail

### setTransformGroup

    public void setTransformGroup(TransformGroup transformGroup)

  Swap a new transformGroup replacing the old one. This allows manipulators to operate on different nodes.

  Parameters:
    `transformGroup` - The *new* transform group to be manipulated.

### getTransformGroup

    public TransformGroup getTransformGroup()

  Return the transformGroup on which this node is operating

### initialize

    public void initialize()

  Initializes the behavior.

  Specified by:
    `initialize` in class `Behavior`

### wakeup

    public void wakeup()

  Manually wake up the behavior. If MANUAL_WAKEUP flag was set upon creation, you must wake up this behavior each time it is handled.

### processMouseEvent

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

  Handles mouse events

### processStimulus

    public abstract void processStimulus(java.util.Enumeration criteria)

  All mouse manipulators must implement this.

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

### addListener

    public void addListener(java.awt.Component c)

  Adds this behavior as a MouseListener, mouseWheelListener and MouseMotionListener to the specified component. This method can only be called if the behavior was created with one of the constructors that takes a Component as a parameter.

  Parameters:
    `c` - The component to add the MouseListener, MouseWheelListener and MouseMotionListener to.
  Throws:
    `java.lang.IllegalStateException` - if the behavior was not created as a listener
  Since:
    Java 3D 1.2.1

### 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`

### setEnable

    public void setEnable(boolean state)

  Description copied from class: `Behavior`
  Enables or disables this Behavior. The default state is enabled.

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

### mouseWheelMoved

    public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)

  Specified by:
    `mouseWheelMoved` in interface `java.awt.event.MouseWheelListener`

Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.