net.java.joglutils.msg.misc
Class State

java.lang.Object
  extended by net.java.joglutils.msg.misc.State

public class State
extends Object

Represents a collection of state elements, which are updated by actions during scene graph traversal.


Constructor Summary
State()
          This constructor should only be used for the default State for a given Action subclass.
State(State defaults)
          This constructor should be used to create the concrete State instances for each Action instance.
 
Method Summary
 State getDefaults()
          Returns the default State, or this State if it corresponds to the defaults for a given Action subclass.
 Element getElement(StateIndex index)
          Gets the state element at the given index.
 void pop()
          Pops the state, restoring the state to just before the last push().
 void push()
          Pushes (saves) the current state until a pop() restores it.
static StateIndex registerElementType()
          Should be called by Element subclasses to register themselves with the State class.
 void setElement(StateIndex index, Element element)
          Sets the element at the given state index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

State

public State()
This constructor should only be used for the default State for a given Action subclass.


State

public State(State defaults)
This constructor should be used to create the concrete State instances for each Action instance. The default State given should be that for the particular Action class.

Method Detail

getDefaults

public State getDefaults()
Returns the default State, or this State if it corresponds to the defaults for a given Action subclass.


getElement

public Element getElement(StateIndex index)
Gets the state element at the given index.


setElement

public void setElement(StateIndex index,
                       Element element)
Sets the element at the given state index. This should only be used by Action, Element and Node subclasses to initialize the default state for a given Action class.


push

public void push()
Pushes (saves) the current state until a pop() restores it. The push is done lazily: this just increments the depth in the state. When an element is accessed with getElement() and its depth is less than the current depth, it is then pushed individually.


pop

public void pop()
Pops the state, restoring the state to just before the last push().


registerElementType

public static StateIndex registerElementType()
Should be called by Element subclasses to register themselves with the State class. This provides them a StateIndex with which they can index into the State.