|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.hdcookbook.grin.input.RCHandler
com.hdcookbook.grin.input.VisualRCHandler
public class VisualRCHandler
A VisualRCHandler models interaction with the remote control and the mouse as a grid of cells. Each cell can contain a state, but it can instead contain an address of another cell. When the user navigates from one cell to another, he lands on the indicated state, or if he lands on a cell that contains the address of another cell, he goes to that cell. A given state can only occupy one cell.
No wrapping behavior is specified: If a user tries to navigate off the edge of the grid, the state remains unchanged. If that isn't the desired UI behavior, then simply create a grid where the border consists of cell addresses.
A visual handler may optionally be tied to an assembly. When this handler is activated, the handler is put into the state determined by the assembly, by finding the state that corresponding to the assembly's currently active part. Once a handler is active, it assumes that it's the only one in control fo the assembly; it doesn't check for the assembly changing state out from under it.
A handler can also optionally have commands associated with its states. These are invoked only when the handler changes state - a command is not sent for the current state when the handler is activated. When commands are used to maintain the scene graph's state, it's up to the application to ensure that the UI is in a state that matches the handler's state before the handler is activated.
The state of a handler is determined by the activated flag, and by the named state. It may be safely changed with a set_visual_rc command. Once the handler is activated, it stays in that state until reset by a set_visual_rc command, a call to setState(...), or the user navigating with the arrow keys. If the handler is activated and the user presses the enter key again, the handler is "re-activated;" the activation commands are executed again, and the assembly's state is set to selected then immediately to activated, in order to re-run any activation animation.
Field Summary | |
---|---|
protected Command[][] |
activateCommands
|
protected Feature[] |
activateFeatures
|
protected Assembly |
assembly
|
static int |
GRID_ACTIVATE
A special value in a grid that means to activate the current state |
protected java.lang.String[] |
gridAlternateNames
|
protected static int |
MASK
|
protected java.awt.Rectangle[] |
mouseRects
|
protected int[] |
mouseRectStates
|
protected int[] |
rightLeft
|
protected int[][] |
rightLeftAlternates
|
protected Command[][] |
selectCommands
|
protected Feature[] |
selectFeatures
|
protected boolean |
startSelected
Flag that, if true, makes the handler start out in the selected state. |
protected java.lang.String[] |
stateNames
|
protected int |
timeout
|
protected Command[] |
timeoutCommands
|
protected int[] |
upDown
|
protected int[][] |
upDownAlternates
|
Fields inherited from class com.hdcookbook.grin.input.RCHandler |
---|
name, show |
Constructor Summary | |
---|---|
VisualRCHandler()
|
Method Summary | |
---|---|
void |
activate(Segment s)
Called for handlers in s when s is activated |
boolean |
getActivated()
This is intended for applications that wish to query the UI state. |
int |
getState()
This is intended for applications that wish to query the UI state. |
java.lang.String |
getStateName(int stateNum)
Get the name of a numbered state. |
boolean |
handleKeyPressed(RCKeyEvent ke,
Show caller)
Handle a remote control key press. |
boolean |
handleKeyReleased(RCKeyEvent ke,
Show caller)
Handle a remote control key release. |
boolean |
handleKeyTyped(RCKeyEvent ke,
Show caller)
Handle a key typed event. |
boolean |
handleMouse(int x,
int y,
boolean activate)
|
int |
lookupGrid(java.lang.String gridAlternateName)
Look up an alternate grid by name. |
int |
lookupState(java.lang.String name)
Lookup a state number by name. |
void |
nextFrame()
Called by the show to let us know as the model progresses through time. |
void |
readInstanceData(GrinDataInputStream in,
int length)
Reads in this node information from the binary file format. |
void |
setState(int newState,
boolean newActivated,
boolean runCommands)
Called from InvokeVisualCellCommand, and from internal methods. |
void |
setState(int newState,
boolean newActivated,
boolean runCommands,
int gridAlternate)
Called from InvokeVisualCellCommand, and from internal methods. |
java.lang.String |
toString()
Give a developer-friendly string describing this handler. |
Methods inherited from class com.hdcookbook.grin.input.RCHandler |
---|
getName, setName, setShow |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int GRID_ACTIVATE
protected static int MASK
protected int[] upDown
protected int[] rightLeft
protected int[][] upDownAlternates
protected int[][] rightLeftAlternates
protected java.lang.String[] gridAlternateNames
protected java.lang.String[] stateNames
protected Assembly assembly
protected Feature[] selectFeatures
protected Command[][] selectCommands
protected Feature[] activateFeatures
protected Command[][] activateCommands
protected java.awt.Rectangle[] mouseRects
protected int[] mouseRectStates
protected int timeout
protected Command[] timeoutCommands
protected boolean startSelected
Constructor Detail |
---|
public VisualRCHandler()
Method Detail |
---|
public java.lang.String toString()
toString
in class RCHandler
public boolean getActivated()
public int getState()
public java.lang.String getStateName(int stateNum)
public int lookupState(java.lang.String name)
public int lookupGrid(java.lang.String gridAlternateName)
public boolean handleKeyPressed(RCKeyEvent ke, Show caller)
handleKeyPressed
in class RCHandler
public boolean handleKeyReleased(RCKeyEvent ke, Show caller)
handleKeyReleased
in class RCHandler
public boolean handleKeyTyped(RCKeyEvent ke, Show caller)
handleKeyTyped
in class RCHandler
public boolean handleMouse(int x, int y, boolean activate)
handleMouse
in class RCHandler
public void setState(int newState, boolean newActivated, boolean runCommands)
newState
- New state, -1 means "current"newActivated
- New value for activatedrunCommands
- If true, run the commands normally associated
with entering this state due to a keypress.public void setState(int newState, boolean newActivated, boolean runCommands, int gridAlternate)
newState
- New state, -1 means "current"newActivated
- New value for activatedrunCommands
- If true, run the commands normally associated
with entering this state due to a keypress.gridAlternate
- Alternate grid # to select, 0..max, or -1 to
leave grid unchanged.public void activate(Segment s)
activate
in class RCHandler
public void nextFrame()
nextFrame
in class RCHandler
public void readInstanceData(GrinDataInputStream in, int length) throws java.io.IOException
Node
An implementation of this method is recommended to call in.readSuperClassData(this) as the first line of the method to read in information that is defined in the base class of this Node type.
This should only be called while initializing this object.
readInstanceData
in interface Node
in
- InputStream to read data from.length
- the number of bytes that this node's information occupies
in the InputStream. The implementation of this method is expected to
read exactly this number of bytes from the stream. This can be used
for a debugging purpose.
java.io.IOException
- if error occurs.GrinDataInputStream.readSuperClassData(Feature)
,
GrinDataInputStream.readSuperClassData(RCHandler)
,
GrinDataInputStream.readSuperClassData(Segment)
,
GrinDataInputStream.readSuperClassData(Command)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |