org.graffiti.plugin.algorithm.animation
Class ForwardAnimation

java.lang.Object
  extended by org.graffiti.plugin.algorithm.animation.AbstractAnimation
      extended by org.graffiti.plugin.algorithm.animation.ForwardAnimation
All Implemented Interfaces:
Animation

public class ForwardAnimation
extends AbstractAnimation

An animation that supports only forward steps. A forward animation implements the methods hasNextStep and nextStep using the state pattern with instances of interface Step being the states. A forward animation starts at a first step and delegates calls to hasNextStep and nextStep to a Step instance that changes upon every call to nextStep.

Version:
$Revision$ $Date$
Author:
Harald Frankenberger
See Also:
Step

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.graffiti.plugin.algorithm.animation.Animation
Animation.GraphModificationPolicy
 
Field Summary
 
Fields inherited from interface org.graffiti.plugin.algorithm.animation.Animation
EMPTY_ANIMATION
 
Constructor Summary
ForwardAnimation()
          Default constructor; does nothing.
ForwardAnimation(Step first)
          Initializes this animation with the specified initial step.
 
Method Summary
 boolean hasNextStep()
          Returns true if this animation has a next step.
 boolean isCleared()
          Returns true if this animation is cleared; i.e.
 boolean isReady()
          Returns true if the preconditions of the algorithm underlying this animation are satisfied.
 void performClear()
          Resets this animation to its initial state.
 void performNextStep()
          Computes the next state of the underlying algorithm; i.e.
 void setFirstStep(Step s)
          Sets the first step of this animation to the specified value.
 boolean supportsClear()
          Returns true if this animation supports clearing; i.e.
 
Methods inherited from class org.graffiti.plugin.algorithm.animation.AbstractAnimation
clear, getGraphModificationPolicy, getName, hasPreviousStep, nextStep, previousStep, supportsPreviousStep
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForwardAnimation

public ForwardAnimation()
Default constructor; does nothing. Note that as long as this animation's first step is not properly initialized (i.e. assigned a non-null value) every attempt to call hasNextStep or nextStep will throw IllegalStateException. You can initalize this animation's first step anytime this animation is in a cleared state, i.e. after initialization or after a call to clear as long as nextStep hasn't been called.

See Also:
setFirstStep(Step)

ForwardAnimation

public ForwardAnimation(Step first)
Initializes this animation with the specified initial step. Note that as long as this animation's first step is not properly initialized (i.e. assigned a non-null value) every attempt to call hasNextStep or nextStep will throw IllegalStateException. You can initalize this animation's first step anytime this animation is in a cleared state, i.e. after initialization or after a call to clear as long as nextStep hasn't been called.

Parameters:
first - the first step of this animation
See Also:
setFirstStep(Step)
Method Detail

isReady

public boolean isReady()
Returns true if the preconditions of the algorithm underlying this animation are satisfied.

This implementation always returns true.

Specified by:
isReady in interface Animation
Specified by:
isReady in class AbstractAnimation
Returns:
true if the preconditions of the algoritm underlying this animation are satisfied.

supportsClear

public boolean supportsClear()
Description copied from class: AbstractAnimation
Returns true if this animation supports clearing; i.e. a call to clear or isCleared will not throw UnsupportedOperationException.

Specified by:
supportsClear in interface Animation
Overrides:
supportsClear in class AbstractAnimation
Returns:
true if this animation supports clearing.
See Also:
AbstractAnimation.clear(), AbstractAnimation.isCleared()

isCleared

public boolean isCleared()
Description copied from class: AbstractAnimation
Returns true if this animation is cleared; i.e. it is newly created or clear has been called and no change of state has occured yet.

Specified by:
isCleared in interface Animation
Overrides:
isCleared in class AbstractAnimation
Returns:
true if this animation is cleared.
See Also:
AbstractAnimation.supportsClear(), AbstractAnimation.clear()

performClear

public void performClear()
Resets this animation to its initial state. After the call to clear finishes, the delegate for calls to hasNextStep and nextStep will be this animation's first step.

Overrides:
performClear in class AbstractAnimation
See Also:
AbstractAnimation.clear()

hasNextStep

public boolean hasNextStep()
Returns true if this animation has a next step.

Specified by:
hasNextStep in interface Animation
Specified by:
hasNextStep in class AbstractAnimation
Returns:
true if this animation has a next step.

performNextStep

public void performNextStep()
Computes the next state of the underlying algorithm; i.e. moves the animation one step forward.

See Also:
AbstractAnimation.nextStep()

setFirstStep

public void setFirstStep(Step s)
Sets the first step of this animation to the specified value.

Parameters:
s - the first step of this animation.
Throws:
IllegalStateException - if this animation is not in a cleared state, i.e. newly created or cleared by a call to clear and nextStep has not yet been called.


Generated at 2012-05-30 11:00:14 PM CEST