com.hdcookbook.grin.input
Class SEVisualRCHandler

java.lang.Object
  extended by com.hdcookbook.grin.input.RCHandler
      extended by com.hdcookbook.grin.input.VisualRCHandler
          extended by com.hdcookbook.grin.input.SEVisualRCHandler
All Implemented Interfaces:
SERCHandler, Node, SENode, SEScalableNode

public class SEVisualRCHandler
extends VisualRCHandler
implements SENode, SEScalableNode, SERCHandler


Field Summary
 
Fields inherited from class com.hdcookbook.grin.input.VisualRCHandler
activateCommands, activateFeatures, assembly, GRID_ACTIVATE, gridAlternateNames, MASK, mouseRects, mouseRectStates, rightLeft, rightLeftAlternates, selectCommands, selectFeatures, startSelected, stateNames, timeout, timeoutCommands, upDown, upDownAlternates
 
Fields inherited from class com.hdcookbook.grin.input.RCHandler
name, show
 
Constructor Summary
SEVisualRCHandler(SEShow show, VisualRCHandlerHelper helper)
           
SEVisualRCHandler(java.lang.String name, java.lang.String[] gridAlternateNames, java.lang.String[] stateNames, int[][] upDownAlternates, int[][] rightLeftAlternates, Command[][] selectCommands, Command[][] activateCommands, java.awt.Rectangle[] mouseRects, int[] mouseRectStates, int timeout, Command[] timeoutCommands, boolean startSelected, VisualRCHandlerHelper helper)
           
 
Method Summary
 void accept(SEShowVisitor visitor)
          Calls the visit method corresponding to this node type.
 void changeFeatureReference(Feature from, Feature to)
          Change a feature reference from one feature to a new one.
 int getKeyPressedInterestMask()
          Get the bitmask formed by or-ing together the mask of all key pressed events we're interested in.
 int getKeyReleasedInterestMask()
          Get the bitmask formed by or-ing together the mask of all key released events we're interested in.
 int getKeyTypedInterestMask()
          Get the bitmask formed by or-ing together the mask of all key typed events we're interested in.
 java.lang.String getRuntimeClassName()
          Returns the class that should be constructed at Show runtime to represent this SENode.
 void postProcess(ShowBuilder builder)
          Do any needed post-processing in this show.
 void scaleBy(int xScale, int yScale, int xOffset, int yOffset)
          Scale this node by the given scale factor, and apply the given offset.
 void setup(Assembly assembly, Feature[] selectFeatures, Feature[] activateFeatures)
          Called from the parser
 java.lang.String toString()
          Give a developer-friendly string describing this handler.
 void writeInstanceData(GrinDataOutputStream out)
          Record this node information to the binary file format.
 
Methods inherited from class com.hdcookbook.grin.input.VisualRCHandler
activate, getActivated, getState, getStateName, handleKeyPressed, handleKeyReleased, handleKeyTyped, handleMouse, lookupGrid, lookupState, nextFrame, readInstanceData, setState, setState
 
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
 

Constructor Detail

SEVisualRCHandler

public SEVisualRCHandler(SEShow show,
                         VisualRCHandlerHelper helper)

SEVisualRCHandler

public SEVisualRCHandler(java.lang.String name,
                         java.lang.String[] gridAlternateNames,
                         java.lang.String[] stateNames,
                         int[][] upDownAlternates,
                         int[][] rightLeftAlternates,
                         Command[][] selectCommands,
                         Command[][] activateCommands,
                         java.awt.Rectangle[] mouseRects,
                         int[] mouseRectStates,
                         int timeout,
                         Command[] timeoutCommands,
                         boolean startSelected,
                         VisualRCHandlerHelper helper)
Method Detail

setup

public void setup(Assembly assembly,
                  Feature[] selectFeatures,
                  Feature[] activateFeatures)
Called from the parser


getKeyPressedInterestMask

public int getKeyPressedInterestMask()
Get the bitmask formed by or-ing together the mask of all key pressed events we're interested in. This is used to determine if a Show is currently interested in receiving a keypress; a bit in the bitmask needen't be unique, if a set of keys go together as a group.

Specified by:
getKeyPressedInterestMask in interface SERCHandler
See Also:
Show.handleKeyPressed(int)

getKeyReleasedInterestMask

public int getKeyReleasedInterestMask()
Get the bitmask formed by or-ing together the mask of all key released events we're interested in. This is used to determine if a Show is currently interested in receiving a keypress; a bit in the bitmask needen't be unique, if a set of keys go together as a group.

Specified by:
getKeyReleasedInterestMask in interface SERCHandler
See Also:
Show.handleKeyReleased(int)

getKeyTypedInterestMask

public int getKeyTypedInterestMask()
Get the bitmask formed by or-ing together the mask of all key typed events we're interested in. This is used to determine if a Show is currently interested in receiving a keypress; a bit in the bitmask needen't be unique, if a set of keys go together as a group.

Specified by:
getKeyTypedInterestMask in interface SERCHandler
See Also:
Show.handleKeyTyped(RCKeyEvent)

writeInstanceData

public void writeInstanceData(GrinDataOutputStream out)
                       throws java.io.IOException
Description copied from interface: SENode
Record this node information to the binary file format. An implementation of this method is recommended to call out.writeSuperClassData(this) as the first line of the method to write out data defined in the base class of this Node type.

Specified by:
writeInstanceData in interface SENode
Parameters:
out - The stream to write out.
Throws:
java.io.IOException - if error occurs.
See Also:
GrinDataOutputStream.writeSuperClassData(Feature), GrinDataOutputStream.writeSuperClassData(RCHandler), GrinDataOutputStream.writeSuperClassData(Segment), GrinDataOutputStream.writeSuperClassData(Command)

getRuntimeClassName

public java.lang.String getRuntimeClassName()
Description copied from interface: SENode
Returns the class that should be constructed at Show runtime to represent this SENode.

Specified by:
getRuntimeClassName in interface SENode
Returns:
String A fully qualified classname of a Node at xlet runtime.

accept

public void accept(SEShowVisitor visitor)
Description copied from interface: SENode
Calls the visit method corresponding to this node type.

If you are defining a user-defined feature, there are some restrictions that you'll want to follow. If your extension is a feature that has children, then you should make it a subclass of one of the built-in feature types, Assembly, Modifer or Group. That's because the GRIN compiler defines visitors that need to visit every node in the tree, but these built-in visitors don't know about your extension types. By making your extension type a subclass of one of the standard ones, and by making your accept() method call either visitAssembly(), visitGroup() or visitUserDefinedModifier(), as appropriate, you'll ensure that all the children get visited.

Specified by:
accept in interface SENode
Parameters:
visitor - SEShowVisitor object.
See Also:
SEShowVisitor

postProcess

public void postProcess(ShowBuilder builder)
                 throws java.io.IOException
Do any needed post-processing in this show. The grin compiler works as follows:

During the post-process phase, a node can add new features to the show, by calling ShowBuilder.addSyntheticFeature(), and it can insert a new feature as the parent of a given feature, by calling ShowBuilder.injectParent(). It can also add segments and handlers by calling the appropriate builder methods.

When a parent is injected, the ShowBuilder calls postProcess() on all nodes automatically, including nodes that are created during the execution of postProcess() in another node.

Specified by:
postProcess in interface SENode
Parameters:
builder - The builder that holds state for the show
Throws:
java.io.IOException - if an error is encountered
See Also:
ShowBuilder.addSyntheticFeature(Feature), ShowBuilder.injectParent(Feature, Feature)

changeFeatureReference

public void changeFeatureReference(Feature from,
                                   Feature to)
                            throws java.io.IOException
Change a feature reference from one feature to a new one. If your node has a reference to the feature from, it should be changed to refer to to. This is called for every node in an SEShow when SENode.injectParent is used.

The ShowBuilder calls changeFeatureReference() on all nodes automatically, including nodes that are created during the execution of postProcess().

Specified by:
changeFeatureReference in interface SENode
Throws:
java.io.IOException - If the operation can't be completed
See Also:
SENode.changeFeatureReference(Feature, Feature)

scaleBy

public void scaleBy(int xScale,
                    int yScale,
                    int xOffset,
                    int yOffset)
Scale this node by the given scale factor, and apply the given offset. This will change the size of the features and RC handlers within the show at compile time, so no special scaling action is required at runtime.

Specified by:
scaleBy in interface SEScalableNode
Parameters:
xScale - x scale factor in mills
yScale - y scale factor in mills
xOffset - x offset in pixels
yOffset - y offset in pixels

toString

public java.lang.String toString()
Give a developer-friendly string describing this handler. Useful for development.

Overrides:
toString in class VisualRCHandler