de.matthiasmann.twl
Class AnimationState

java.lang.Object
  extended by de.matthiasmann.twl.AnimationState
All Implemented Interfaces:
AnimationState

public class AnimationState
extends java.lang.Object
implements AnimationState


Nested Class Summary
 
Nested classes/interfaces inherited from interface de.matthiasmann.twl.renderer.AnimationState
AnimationState.StateKey
 
Constructor Summary
AnimationState()
          Creates a new animation state without parent
AnimationState(AnimationState parent)
          Create a new animation state with optional parent.
AnimationState(AnimationState parent, int size)
          Create a new animation state with optional parent.
 
Method Summary
 void dontAnimate(AnimationState.StateKey stateKey)
          Clears the shouldAnimate flag of the specified animation state.
 void dontAnimate(java.lang.String stateName)
          Deprecated.  
 boolean getAnimationState(AnimationState.StateKey stateKey)
          Checks if the given state is active.
 int getAnimationTime(AnimationState.StateKey stateKey)
          Returns the time since the specified state has changed in ms.
 boolean getShouldAnimateState(AnimationState.StateKey stateKey)
          Checks if this state was changed based on user interaction or not.
 void resetAnimationTime(AnimationState.StateKey stateKey)
          Resets the animation time of the specified animation state.
 void resetAnimationTime(java.lang.String stateName)
          Deprecated.  
 void setAnimationState(AnimationState.StateKey stateKey, boolean active)
          Sets the specified animation state to the given value.
 void setAnimationState(java.lang.String stateName, boolean active)
          Deprecated.  
 void setGUI(GUI gui)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnimationState

public AnimationState(AnimationState parent,
                      int size)
Create a new animation state with optional parent. When a parent animation state is set, then any request for a state which has not been set (to either true or false) in this instance are forwarded to the parent.

Parameters:
parent - the parent animation state or null
size - the initial size of the state table (indexed by state IDs)

AnimationState

public AnimationState(AnimationState parent)
Create a new animation state with optional parent. When a parent animation state is set, then any request for a state which has not been set (to either true or false) in this instance are forwarded to the parent.

Parameters:
parent - the parent animation state or null

AnimationState

public AnimationState()
Creates a new animation state without parent

See Also:
AnimationState(de.matthiasmann.twl.AnimationState)
Method Detail

setGUI

public void setGUI(GUI gui)

getAnimationTime

public int getAnimationTime(AnimationState.StateKey stateKey)
Returns the time since the specified state has changed in ms. If the specified state was never changed then a free running time is returned.

Specified by:
getAnimationTime in interface AnimationState
Parameters:
stateKey - the state key.
Returns:
time since last state change is ms.

getAnimationState

public boolean getAnimationState(AnimationState.StateKey stateKey)
Checks if the given state is active.

Specified by:
getAnimationState in interface AnimationState
Parameters:
stateKey - the state key.
Returns:
true if the state is set

getShouldAnimateState

public boolean getShouldAnimateState(AnimationState.StateKey stateKey)
Checks if this state was changed based on user interaction or not. If this method returns false then the animation time should not be used for single shot animations.

Specified by:
getShouldAnimateState in interface AnimationState
Parameters:
stateKey - the state key.
Returns:
true if single shot animations should run or not.

setAnimationState

@Deprecated
public void setAnimationState(java.lang.String stateName,
                                         boolean active)
Deprecated. 

Equivalent to calling setAnimationState(StateKey.get(stateName), active);

Parameters:
stateName - the string specifying the state key
active - the new value
See Also:
setAnimationState(de.matthiasmann.twl.renderer.AnimationState.StateKey, boolean), AnimationState.StateKey.get(java.lang.String)

setAnimationState

public void setAnimationState(AnimationState.StateKey stateKey,
                              boolean active)
Sets the specified animation state to the given value. If the value is changed then the animation time is reset too.

Parameters:
stateKey - the state key
active - the new value
See Also:
getAnimationState(de.matthiasmann.twl.renderer.AnimationState.StateKey), resetAnimationTime(de.matthiasmann.twl.renderer.AnimationState.StateKey)

resetAnimationTime

@Deprecated
public void resetAnimationTime(java.lang.String stateName)
Deprecated. 

Equivalent to calling resetAnimationTime(StateKey.get(stateName));

Parameters:
stateName - the string specifying the state key
See Also:
resetAnimationTime(de.matthiasmann.twl.renderer.AnimationState.StateKey), AnimationState.StateKey.get(java.lang.String)

resetAnimationTime

public void resetAnimationTime(AnimationState.StateKey stateKey)
Resets the animation time of the specified animation state. Resetting the animation time also enables the shouldAnimate flag.

Parameters:
stateKey - the state key.
See Also:
getAnimationTime(de.matthiasmann.twl.renderer.AnimationState.StateKey), getShouldAnimateState(de.matthiasmann.twl.renderer.AnimationState.StateKey)

dontAnimate

@Deprecated
public void dontAnimate(java.lang.String stateName)
Deprecated. 

Equivalent to calling dontAnimate(StateKey.get(stateName));

Parameters:
stateName - the string specifying the state key
See Also:
dontAnimate(de.matthiasmann.twl.renderer.AnimationState.StateKey), AnimationState.StateKey.get(java.lang.String)

dontAnimate

public void dontAnimate(AnimationState.StateKey stateKey)
Clears the shouldAnimate flag of the specified animation state.

Parameters:
stateKey - the state key.
See Also:
getShouldAnimateState(de.matthiasmann.twl.renderer.AnimationState.StateKey)