gumbo.graphic.input
Class AbstractKeyboardSensor

java.lang.Object
  |
  +--gumbo.util.AbstractDisposable
        |
        +--gumbo.graphic.input.AbstractKeyboardSensor
All Implemented Interfaces:
Disposable, KeyboardSensor
Direct Known Subclasses:
SwingKeyboardSensor

public abstract class AbstractKeyboardSensor
extends AbstractDisposable
implements KeyboardSensor

Provides objects for maintaining keyboard key state, and event out nodes initialized with an immutable view of the the state object. Upon receiving a keyboard input this sensor should update the state object, check isKeyRepeat(), and then invoke send(), as needed, on the corresponding event out node to send an immutable state snapshot.

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

Constructor Summary
AbstractKeyboardSensor()
          Creates an instance, with keyRepeat false.
AbstractKeyboardSensor(boolean keyRepeat)
          Creates an instance.
 
Method Summary
protected abstract  void addedSensorTarget(SpaceNode target)
          Called by the system when a non-duplicate target is added, after updating the graphic map.
 void addKeyboardTarget(SpaceNode target)
          Updates the graphic-to-target map, then calls addTargetSpace().
protected  java.util.Map getGraphicMap()
          Returns an immutable view of the graphic (Object) to target (SpaceNode) map.
 CharField.EventOut getKeyboardCharOut()
          Sends an event each time a valid character is typed (or repeats) while this sensor is active.
 StateSetField.EventOut getKeyboardKeysOut()
          Sends an immutable view of getKeyState().
protected  StateSet getKeyState()
          Returns a reference to the object maintaining key state.
 boolean isKeyRepeat()
          Returns true if a key out event is sent even if the value does not change (a key repeat).
protected abstract  void removedSensorTarget(SpaceNode target)
          Called by the system when a non-missing target is removed, after updating the graphic map.
 void removeKeyboardTarget(SpaceNode target)
          Updates the graphic-to-target map, then calls removeTargetSpace().
 
Methods inherited from class gumbo.util.AbstractDisposable
dispose, implDispose, isDisposed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gumbo.graphic.input.KeyboardSensor
getKeyboardActiveOut, getKeyboardEnableIn, getKeyboardFocusIn, getKeyboardSpaceOut
 
Methods inherited from interface gumbo.util.Disposable
dispose, isDisposed
 

Constructor Detail

AbstractKeyboardSensor

public AbstractKeyboardSensor()
Creates an instance, with keyRepeat false.


AbstractKeyboardSensor

public AbstractKeyboardSensor(boolean keyRepeat)
Creates an instance. Master constructor.

Parameters:
keyRepeat - If false, a key out event is sent only if its data value changes.
Method Detail

isKeyRepeat

public boolean isKeyRepeat()
Returns true if a key out event is sent even if the value does not change (a key repeat).


getKeyState

protected StateSet getKeyState()
Returns a reference to the object maintaining key state.

Returns:
The object. Never null.

getGraphicMap

protected java.util.Map getGraphicMap()
Returns an immutable view of the graphic (Object) to target (SpaceNode) map.

Returns:
The map. Never null.

addedSensorTarget

protected abstract void addedSensorTarget(SpaceNode target)
Called by the system when a non-duplicate target is added, after updating the graphic map.

Parameters:
target - Reference to the target. Never null.

removedSensorTarget

protected abstract void removedSensorTarget(SpaceNode target)
Called by the system when a non-missing target is removed, after updating the graphic map.

Parameters:
target - Reference to the target. Never null.

addKeyboardTarget

public final void addKeyboardTarget(SpaceNode target)
Updates the graphic-to-target map, then calls addTargetSpace(). Does nothing if the target is duplicate. Throws an exception if the graphic is duplicate.

Specified by:
addKeyboardTarget in interface KeyboardSensor
Parameters:
target - Reference to the target. Never null. Duplicates are ignored.

removeKeyboardTarget

public final void removeKeyboardTarget(SpaceNode target)
Updates the graphic-to-target map, then calls removeTargetSpace(). Does nothing if the target is missing. Throws an exception if the graphic is missing.

Specified by:
removeKeyboardTarget in interface KeyboardSensor
Parameters:
target - Reference to the target. Never null. Missing are ignored.

getKeyboardKeysOut

public StateSetField.EventOut getKeyboardKeysOut()
Sends an immutable view of getKeyState().

Specified by:
getKeyboardKeysOut in interface KeyboardSensor

getKeyboardCharOut

public CharField.EventOut getKeyboardCharOut()
Description copied from interface: KeyboardSensor
Sends an event each time a valid character is typed (or repeats) while this sensor is active.

Specified by:
getKeyboardCharOut in interface KeyboardSensor