com.hdcookbook.grin
Class Segment

java.lang.Object
  extended by com.hdcookbook.grin.Segment
All Implemented Interfaces:
Node

public class Segment
extends java.lang.Object
implements Node

A segment within a show. A show is composed of segments, and at all times exactly one segment is active. When a segment is active, its features are showing, and its remote control handlers receive events. When a new feature is activated, any features that are active in both segments are not re-initialized, so that animations will just continue, for example.

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

Field Summary
protected  Feature[] activeFeatures
           
protected  int keyTypedInterest
          This bitmask is formed by or-ing the set of key typed events this segment has handlers for.
protected  java.lang.String name
           
protected  Command[] nextCommands
           
protected  boolean nextOnSetupDone
           
protected  Command[] onEntryCommands
           
protected  RCHandler[] rcHandlers
           
protected  int rcPressedInterest
          The bitmask is formed by or-ing the set of remote control key presses this segment has handlers for.
protected  int rcReleasedInterest
          The bitmask is formed by or-ing the set of remote control key releases this segment has handlers for.
protected  Feature[] settingUpFeatures
           
protected  Show show
           
 
Constructor Summary
Segment()
           
 
Method Summary
 Feature[] getActiveFeatures()
          Get the list of active features of this segment.
 java.lang.String getName()
          Get the name of this segment.
 Command[] getNextCommands()
          Give the commands in our next clause.
 boolean getNextOnSetupDone()
          Do we trigger the commands in our next clause when all of the features in our setup clause have finished loading?
 Command[] getOnEntryCommands()
          Get the list of commands that are called when this segment is activated.
 RCHandler[] getRCHandlers()
          Give the set of remote control handlers for this segment.
 Feature[] getSetupFeatures()
          Get the list of features in the setup clause of this segment.
 Show getShow()
           
 void initialize()
          Initialize up this segment.
 void readInstanceData(GrinDataInputStream in, int length)
          Reads in this node information from the binary file format.
 void setName(java.lang.String name)
          Set this segment's name.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

show

protected Show show

activeFeatures

protected Feature[] activeFeatures

settingUpFeatures

protected Feature[] settingUpFeatures

onEntryCommands

protected Command[] onEntryCommands

nextOnSetupDone

protected boolean nextOnSetupDone

nextCommands

protected Command[] nextCommands

rcHandlers

protected RCHandler[] rcHandlers

rcPressedInterest

protected int rcPressedInterest
The bitmask is formed by or-ing the set of remote control key presses this segment has handlers for.


rcReleasedInterest

protected int rcReleasedInterest
The bitmask is formed by or-ing the set of remote control key releases this segment has handlers for.


keyTypedInterest

protected int keyTypedInterest
This bitmask is formed by or-ing the set of key typed events this segment has handlers for.

Constructor Detail

Segment

public Segment()
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getName

public java.lang.String getName()
Get the name of this segment. Public segments all have names. Private segments may have names -- as of this writing, the binary writer always wrote out all segment names, because this doesn't cost much and it's so useful for debugging. However, it would be valid to have a null name.


setName

public void setName(java.lang.String name)
Set this segment's name. This should only be called when a Segment is first created, and should probably never be called by GRIN client code.

Parameters:
name - The segment's name (possibly null)

getShow

public Show getShow()

initialize

public void initialize()
Initialize up this segment. This is called on show initialization. A show will initialize all of its features after it initializes the segments.


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)

getActiveFeatures

public Feature[] getActiveFeatures()
Get the list of active features of this segment. Normally client code shouldn't call this, but it is needed for building debugging tools, like grinview.


getSetupFeatures

public Feature[] getSetupFeatures()
Get the list of features in the setup clause of this segment. Normally client code shouldn't call this, but it is needed for building debugging tools, like grinview.


getOnEntryCommands

public Command[] getOnEntryCommands()
Get the list of commands that are called when this segment is activated. Normally client code shouldn't call this, but it is needed for building debugging tools, like grinview.


getNextOnSetupDone

public boolean getNextOnSetupDone()
Do we trigger the commands in our next clause when all of the features in our setup clause have finished loading?

Returns:
the answer to that question.

getNextCommands

public Command[] getNextCommands()
Give the commands in our next clause. This can be triggered by setup being done, or by a segment_done command. Normally client code shouldn't call this, but it is needed for building debugging tools, like grinview.

See Also:
getNextOnSetupDone(), Show.segmentDone()

getRCHandlers

public RCHandler[] getRCHandlers()
Give the set of remote control handlers for this segment. Normally client code shouldn't call this, but it is needed for building debugging tools, like grinview.