Class ResetFeatureCommand

  extended by com.hdcookbook.grin.commands.Command
      extended by com.hdcookbook.grin.commands.ResetFeatureCommand
All Implemented Interfaces:

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).

Bill Foote (

Field Summary
protected  Feature feature
Fields inherited from class com.hdcookbook.grin.commands.Command
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


protected Feature feature
Constructor Detail


public ResetFeatureCommand(Show show)
Method Detail


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.

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


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


public void readInstanceData(GrinDataInputStream in,
                             int length)
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
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: - if error occurs.
See Also:
GrinDataInputStream.readSuperClassData(Feature), GrinDataInputStream.readSuperClassData(RCHandler), GrinDataInputStream.readSuperClassData(Segment), GrinDataInputStream.readSuperClassData(Command)