gumbo.graphic.input.impl.swing
Class SwingMouseSensor

java.lang.Object
  |
  +--gumbo.util.AbstractDisposable
        |
        +--gumbo.graphic.input.AbstractMouseSensor
              |
              +--gumbo.graphic.input.impl.swing.SwingMouseSensor
All Implemented Interfaces:
Disposable, MouseSensor

public class SwingMouseSensor
extends AbstractMouseSensor

An AWT/Swing 2D mouse sensor. Sensor targets must have a Component graphic. Senses mouse events when the mouse is over or captured (a mouse button went down while over and is still down whether, or not the mouse is still over the target).

The initial button state should be output when the mouse is over a target when the sensor becomes active. Unfortunately, AWT (at least on Windows) allows detection of a mouse button being down, but not the subsequent release of the button since the release event is sent to the capture target, which may not be a sensor target. As such, this sensor does not output the initial button state when the mouse enters a sensor target.

Version:
$Revision: 1.5 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Constructor Summary
SwingMouseSensor()
          Creates an instance with a single DisplaySpace sensor target.
 
Method Summary
protected  void addedSensorTarget(SpaceNode target)
          Throws an exception if target graphic not a Component.
 BooleanField.EventOut getMouseActiveOut()
          Sends an event when the sensor starts or stops being active on a given sensor target.
 BooleanField.EventOut getMouseCaptureOut()
          Sends an event when the sensor target captures or releases the mouse inputs (movement and buttons).
 BooleanField.EventIn getMouseEnableIn()
          Enables/disables this sensor.
 CollectionField.EventOut getMouseEnteredKeysOut()
          Sends an event containing the state (KeyboardSensors.KEY_???) of the keyboard modifier keys when a critical event occurs (new sensor target space, button change), before other outputs.
 BooleanField.EventOut getMouseOverOut()
          Sends an event when the mouse enters or exists a sensor target area.
 BooleanField.EventIn getMousePickActiveIn()
          If going true while this sensor is active, resends the mouse position and buttons.
 SpaceNodeField.EventOut getMouseSpaceOut()
          Sends an event when the sensor starts being active in a new sensor target space.
protected  void implDispose()
          Called by dispose() before the disposed flag is set, when it is time for subclasses to dispose themselves.
protected  void removedSensorTarget(SpaceNode target)
          Called by the system when a non-missing target is removed, after updating the graphic map.
 
Methods inherited from class gumbo.graphic.input.AbstractMouseSensor
addMouseTarget, getButtonState, getGraphicMap, getMouseButtonsOut, getMouseMoveOut, getMovePoint, removeMouseTarget
 
Methods inherited from class gumbo.util.AbstractDisposable
dispose, isDisposed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gumbo.util.Disposable
dispose, isDisposed
 

Constructor Detail

SwingMouseSensor

public SwingMouseSensor()
Creates an instance with a single DisplaySpace sensor target. Master constructor.

Method Detail

getMouseEnteredKeysOut

public CollectionField.EventOut getMouseEnteredKeysOut()
Sends an event containing the state (KeyboardSensors.KEY_???) of the keyboard modifier keys when a critical event occurs (new sensor target space, button change), before other outputs. Never null. This is needed since, in Swing, there is no way to obtain the key state upon gaining keyboard focus. Should be routed to SwingKeyboardSensor.getKeyboardFocusKeysIn() if mouse over triggers keyboard focus.


getMousePickActiveIn

public BooleanField.EventIn getMousePickActiveIn()
If going true while this sensor is active, resends the mouse position and buttons. This is needed for "click through", where picking may be activated as a result of a window becoming active (and gaining focus) as a result of a mouse click. Only needed if the picker's active input is not directly controlled by this mouse sensor, in which case it should be relayed to this input.


addedSensorTarget

protected void addedSensorTarget(SpaceNode target)
Throws an exception if target graphic not a Component.

Specified by:
addedSensorTarget in class AbstractMouseSensor
Parameters:
target - Reference to the target. Never null.

removedSensorTarget

protected void removedSensorTarget(SpaceNode target)
Description copied from class: AbstractMouseSensor
Called by the system when a non-missing target is removed, after updating the graphic map.

Specified by:
removedSensorTarget in class AbstractMouseSensor
Parameters:
target - Reference to the target. Never null.

getMouseEnableIn

public BooleanField.EventIn getMouseEnableIn()
Description copied from interface: MouseSensor
Enables/disables this sensor. When disabled, status outputs (active, over, capture) will go false if not already false. While disabled, mouse inputs are ignored and there are no outputs. The default is true.


getMouseOverOut

public BooleanField.EventOut getMouseOverOut()
Description copied from interface: MouseSensor
Sends an event when the mouse enters or exists a sensor target area. Note that over should work (and mouse movement and button events should be generated) even if the mouse is captured by another target; otherwise, the drop aspect of drag-and-drop implementations may be affected.


getMouseCaptureOut

public BooleanField.EventOut getMouseCaptureOut()
Description copied from interface: MouseSensor
Sends an event when the sensor target captures or releases the mouse inputs (movement and buttons). Should reflect the true system status as regards mouse capture (which typically starts when a drag starts while over a sensor target).


getMouseSpaceOut

public SpaceNodeField.EventOut getMouseSpaceOut()
Description copied from interface: MouseSensor
Sends an event when the sensor starts being active in a new sensor target space. Sent after active out but before any other output events. Never null while active.


getMouseActiveOut

public BooleanField.EventOut getMouseActiveOut()
Description copied from interface: MouseSensor
Sends an event when the sensor starts or stops being active on a given sensor target. While true, the sensor is actively sending events. Will go true before and false after all other output eventss. Based on the OR of mouse-over and mouse-capture.


implDispose

protected void implDispose()
Description copied from class: AbstractDisposable
Called by dispose() before the disposed flag is set, when it is time for subclasses to dispose themselves. Implentors should disconnect and/or dispose any relations (while the object is still valid), then null out any external references, and then call super.implDispose() to assure that the super class is disposed of properly.

Specified by:
implDispose in class AbstractDisposable