com.hdcookbook.grin.commands
Class ResetFeatureCommand

java.lang.Object
  extended by com.hdcookbook.grin.commands.Command
      extended by com.hdcookbook.grin.commands.ResetFeatureCommand
All Implemented Interfaces:
Node
Direct Known Subclasses:
SEResetFeatureCommand

public class ResetFeatureCommand
extends Command
implements Node

A GRIN command to reset a feature to the state it is in when activated. Grouping features, like Group and Assembly, reset their children as appropriate (e.g. an Assembly resets its active sub-feature).

Author:
Bill Foote (http://jovial.com)

Field Summary
protected  Feature feature
           
 
Fields inherited from class com.hdcookbook.grin.commands.Command
show
 
Constructor Summary
ResetFeatureCommand(Show show)
           
 
Method Summary
 Command cloneIfNeeded(java.util.HashMap featureClones)
          Return this command, or if needed, a copy of this command.
 void execute()
          Execute the command.
 void readInstanceData(GrinDataInputStream in, int length)
          Reads in this node information from the binary file format.
 
Methods inherited from class com.hdcookbook.grin.commands.Command
deferNextCommands, execute, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

feature

protected Feature feature
Constructor Detail

ResetFeatureCommand

public ResetFeatureCommand(Show show)
Method Detail

cloneIfNeeded

public Command cloneIfNeeded(java.util.HashMap featureClones)
Return this command, or if needed, a copy of this command.

Most commands don't have any data members that contain mutable state, that is, data memebers whose values are modified (e.g. when the command is executed). Also, most commands don't refer to part of a scene graph. For this reason, when a subtree of a scene graph is cloned, most of the cloned features can just re-use the same Command objects in their endCommands arrays.

However, some commands to contain references to features. If a command in a subtree being cloned refers to a feature in that subtree, then the cloned command should refer to the cloned feature. Commands that do this should override this method to provide a copy of the command, with the feature references mapeped over.

Further, it's possible that a command subclass might contain a data member that gets modified, e.g. during command execution. This is probably bad form, and none of the GRIN commands do this, but if you make a command subclass that does, you should override this method so that cloned commands get a new instance of your command subclass.

The default implementation of this method returns the current instances.

Overrides:
cloneIfNeeded in class Command
Parameters:
featureClones - HashMap mapping an original feature to its clone.

execute

public void execute()
Description copied from class: Command
Execute the command. This causes the command to take whatever action it was created to do.

Specified by:
execute in class Command

readInstanceData

public void readInstanceData(GrinDataInputStream in,
                             int length)
                      throws java.io.IOException
Description copied from interface: Node
Reads in this node information from the binary file format.

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.

Specified by:
readInstanceData in interface Node
Parameters:
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.
Throws:
java.io.IOException - if error occurs.
See Also:
GrinDataInputStream.readSuperClassData(Feature), GrinDataInputStream.readSuperClassData(RCHandler), GrinDataInputStream.readSuperClassData(Segment), GrinDataInputStream.readSuperClassData(Command)