## org.j3d.geom.overlay
Class AWTEventBehavior

class AWTEventBehavior
extends javax.media.j3d.Behavior
implements org.j3d.geom.overlay.InputRequester

  A Java3D behaviour that traps and funnels AWT events to overlays.

Version:
  $Revision: 1.4 $
Author:
  Justin Couch

Field Detail

### REBUILD_ID

    private static final int REBUILD_ID

  Value of the rebuild criteria post ID

### awtCondition

    private javax.media.j3d.WakeupOnAWTEvent awtCondition

  The wakeup condition to force the update

### mouseOverlays

    private java.util.ArrayList mouseOverlays

  Listener for dealing with mouse events

### mouseListeners

    private java.util.HashMap mouseListeners

  Mapping of overlays to their mouse listeners

### motionOverlays

    private java.util.ArrayList motionOverlays

  Listener for dealing with mouse motion events

### motionListeners

    private java.util.HashMap motionListeners

  Mapping of overlays to their mouse motion listeners

### currentKey

    private java.awt.event.KeyListener currentKey

  Current listener for dealing with key events

### keyListeners

    private java.util.HashMap keyListeners

  Map of all the keys to the focus listeners

### postCondition

    private javax.media.j3d.WakeupOnBehaviorPost postCondition

  Condition for when we want to change the events we are listening for

### bothConditions

    private javax.media.j3d.WakeupCondition bothConditions

  The condition to use each frame as needed

### currentMouseOverlay

    private org.j3d.geom.overlay.Overlay currentMouseOverlay

  The last found mouse overlay for optimisation purposes

### lastMouse

    private java.awt.event.MouseListener lastMouse

  The last found mouse listener for optimisation purposes

### lastMouseOverlay

    private org.j3d.geom.overlay.Overlay lastMouseOverlay

  Previous mouse overlay for the event before this

### currentMotionOverlay

    private org.j3d.geom.overlay.Overlay currentMotionOverlay

  The last found mouse motion overlay for optimisation purposes

### lastMotion

    private java.awt.event.MouseMotionListener lastMotion

  The last found mouse motion listener for optimisation purposes

### lastMotionOverlay

    private org.j3d.geom.overlay.Overlay lastMotionOverlay

  Previous mouse motion listener to their corresponding overlay

### inDrag

    private boolean inDrag

  Flag to say if we are in a drag currently and should be tracking the mouse.

Constructor Detail

### AWTEventBehavior

    public AWTEventBehavior()

  Create a new behavior that manages the update of a single entity

Parameters:
  `entity` - The entity to process update requests for

Method Detail

### requestFocus

    public void requestFocus(java.lang.Object key)

  Request that keyboard focus be sent to this listener object now.

Parameters:
  `key` - The key of the object requesting focus now

### addMouseListener

    public void addMouseListener(java.awt.event.MouseListener l,
                                 org.j3d.geom.overlay.Overlay ovl)

  Request that the given listener enable mouse events being sent. If the listener instance is null, this request is ignored.

Parameters:
  `l` - The listener to manage events for
  `ovl` - The overlay to base the mouse bounds handling on

### removeMouseListener

    public void removeMouseListener(java.awt.event.MouseListener l,
                                    org.j3d.geom.overlay.Overlay ovl)

  Request that the given listener disable mouse events being sent. If the listener instance is null, this request is ignored.

Parameters:
  `l` - The listener to manage events for
  `ovl` - The overlay to base the mouse bounds handling on

### addMouseMotionListener

    public void addMouseMotionListener(java.awt.event.MouseMotionListener l,
                                       org.j3d.geom.overlay.Overlay ovl)

  Request that the given listener enable mouse motion events being sent. If the listener instance is null, this request is ignored.

Parameters:
  `l` - The listener to manage events for
  `ovl` - The overlay to base the mouse bounds handling on

### removeMouseMotionListener

    public void removeMouseMotionListener(java.awt.event.MouseMotionListener l,
                                          org.j3d.geom.overlay.Overlay ovl)

  Request that the given listener disable mouse motion events being sent. If the listener instance is null, this request is ignored.

Parameters:
  `l` - The listener to manage events for
  `ovl` - The overlay to base the mouse bounds handling on

### addKeyListener

    public void addKeyListener(java.awt.event.KeyListener l,
                               java.lang.Object key)

  Request that the given listener enable key events being sent. If the listener instance is null, this request is ignored.

Parameters:
  `l` - The listener to manage events for
  `ovl` - The overlay to base the mouse bounds handling on

### removeKeyListener

    public void removeKeyListener(java.awt.event.KeyListener l,
                                  java.lang.Object key)

  Request that the given listener disable key events being sent. If the listener instance is null, this request is ignored.

Parameters:
  `l` - The listener to manage events for
  `ovl` - The overlay to base the mouse bounds handling on

### initialize

    public void initialize()

  Initialize the behavior to start working now. Sets up the initial wakeup condition.

### processStimulus

    public void processStimulus(java.util.Enumeration conditions)

  Process the behavior that has been woken up by the given set of conditions.

Parameters:
  `conditions` - The list of conditions satisfied

### rebuildCriteria

    private void rebuildCriteria()

  Check the various input criteria and see what we should be using currently.

### getMouseListener

    private java.awt.event.MouseListener getMouseListener(java.awt.Point p)

  returns the first overlay that contains the specified point. If the windows are stacked then the top most overlay will be picked.

Parameters:
  `p` - The point to get the mouse overlay for
Returns:
  The mouse listener for the overlay under this point or null

### getMotionListener

    private java.awt.event.MouseMotionListener getMotionListener(java.awt.Point p)

  returns the first overlay that contains the specified point. If the windows are stacked then the top most overlay will be picked.

Parameters:
  `p` - The point to get the mouse overlay for
Returns:
  The mouse listener for the overlay under this point or null

### cloneEvent

    private java.awt.event.MouseEvent cloneEvent(java.awt.event.MouseEvent evt,
                                                 boolean exit)

  Convenience method to create a new clone of a mouse event, but setting the ID field to either enter or exit.

Parameters:
  `evt` - The source event to copy data from
  `exit` - true if this is an exit event, false for enter
Returns:
  A cloned, new instance of the event

### adjustMousePosition

    private void adjustMousePosition(java.awt.event.MouseEvent evt,
                                     org.j3d.geom.overlay.Overlay overlay)

  Adjust the event's position to offset it by the location of the overlay. This is so the mouse's coordinates appear to be in overlay coordinate system, not the entire window.

Parameters:
  `evt` - The event to be translated
  `overlay` - The targetted overlay to use