ptolemy.actor.lib.gui
Class ArrowKeySensor
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.gui.ArrowKeySensor
- All Implemented Interfaces:
- Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable, TypedActor
- public class ArrowKeySensor
- extends TypedAtomicActor
Detect when the user presses or releases an arrow key and produce an
integer on the corresponding output.
When this actor is preinitialized, it pops up a new JFrame window on
the desktop, usually in the upper left hand corner of the screen.
When this JFrame has the focus (such as when it has been clicked on)
it is capable of sensing keystrokes.
This actor senses only the four non-numeric-pad arrow-key
keystrokes. This actor responds to key releases as well as key
presses. Upon each key press, the integer 1 is broadcast from the
corresponding output. Upon each key release, the integer 0 is output.
This actor contains a private inner class which generated the JFrame.
The frame sets up call-backs which react to the keystrokes. When called,
these call the director's fireAtCurrentTime() method. This causes
the director to call fire() on the actor. The actor then broadcasts
tokens from one or both outputs depending on which keystroke(s) have
occurred since the actor was last fired.
NOTE: This actor only works in the DE domain due to its reliance on
this director's fireAtCurrentTime() method.
- Since:
- Ptolemy II 2.0
- Version:
- $Id: ArrowKeySensor.java,v 1.31 2004/04/13 05:12:32 cxh Exp $
- Author:
- Winthrop Williams
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
|
Method Summary |
void |
fire()
Broadcast the integer value 1 for each key pressed and 0 for
each released. |
void |
initialize()
Create the JFrame window capable of detecting the key-presses. |
void |
wrapup()
Dispose of the JFrame, causing the window to vanish. |
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, clone, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate |
| Methods inherited from class ptolemy.kernel.Entity |
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables |
| Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
upArrow
public TypedIOPort upArrow
- Output port, which has type IntToken.
leftArrow
public TypedIOPort leftArrow
- Output port, which has type IntToken.
rightArrow
public TypedIOPort rightArrow
- Output port, which has type IntToken.
downArrow
public TypedIOPort downArrow
- Output port, which has type IntToken.
ArrowKeySensor
public ArrowKeySensor(CompositeEntity container,
java.lang.String name)
throws NameDuplicationException,
IllegalActionException
- Construct an actor with the given container and name.
- Parameters:
container - The container.name - The name of this actor.
- Throws:
IllegalActionException - If the actor cannot be contained
by the proposed container.
NameDuplicationException - If the container already has an
actor with this name.
fire
public void fire()
throws IllegalActionException
- Broadcast the integer value 1 for each key pressed and 0 for
each released.
- Specified by:
fire in interface Executable- Overrides:
fire in class AtomicActor
- Throws:
IllegalActionException - Not thrown in this base class.
initialize
public void initialize()
- Create the JFrame window capable of detecting the key-presses.
- Specified by:
initialize in interface Executable- Overrides:
initialize in class AtomicActor
wrapup
public void wrapup()
- Dispose of the JFrame, causing the window to vanish.
- Specified by:
wrapup in interface Executable- Overrides:
wrapup in class AtomicActor