edu.princeton.cs.algs4.growingtree.framework
Interface Animation

All Known Implementing Classes:
AbstractAnimation, BalanceBSTAnimation, DeleteBSTAnimation, DisplayChangeAnimation, FreezeAnimation, InsertBSTAnimation, MovingBSTTreeAnimation, PartitionBSTAnimation, RotationBSTAnimation, RotationDoubleBSTAnimation, SearchBSTAnimation, SelectionBSTAnimation, SwapBSTAnimation, SwapNodesBSTAnimation, TraverseBSTAnimation

public interface Animation

The Animation interface that must be used for all Animations. All methods must be implemented to allow the Animation Object to be used in all animation applications.

Status fields are provided for usage in Animation objects involving status and mesages. Others may be added if necessary.

Version:
1.5 9/15/01
Author:
Corey Sanders

Field Summary
static java.lang.String ANIMATION_MESSAGE
          Constant for the MESSAGE status.
static java.lang.String BEGIN
          Constant for the BEGIN status.
static java.lang.String FINISH
          Constant for the FINISH status.
static java.lang.String PAUSE
          Constant for the PAUSE status.
static java.lang.String PLAY
          Constant for the PLAY status.
static java.lang.String REDRAW
          Constant for the REDRAW status.
static java.lang.String REWIND
          Constant for the REVERSE status.
static java.lang.String STEP
          Constant for the STEP status.
static java.lang.String STOP
          Constant for the STOP status.
 
Method Summary
 void addAnimationListener(AnimationListener l)
          Adds an animationListener that recieves meaningful events from the animation, according to the Animation interface and the AnimationEvent.
 void addDescription(java.lang.String d)
          Adds a description that may be used to describe to the listener the type of event occuring.
 void drawAnimation(java.awt.Graphics2D g2)
          Draws the animation of the next step, using the status of the animation (Animation.PLAY, Animation.PAUSE and so forth).
 void drawAnimation(java.awt.Graphics2D g2, java.lang.String status)
          Draws the animation of the next step, using the status of the animation (Animation.PLAY, Animation.PAUSE and so forth).
 java.lang.String getDescription()
          Gets the description added with addDescription and should be accessed through the listener.
 java.lang.String getStatus()
          Gets the status of the Animation using a command within Animation interface.
 boolean getStep()
          Gets whether the current animation is in stepping mode or not.
 int getStepTime()
          Gets the step size for the animation.
 void removeAnimationListener(AnimationListener l)
          Removes an animationListener from the animation, according to the Animation interface and the AnimationEvent.
 void setStatus(java.lang.String cmd)
          Sets the status of the Animation using a command within Animation interface.
 void setStep(boolean b)
          Sets whether the current animation is in stepping mode or not.
 void setStepTime(int t)
          Sets the step size for the animation.
 

Field Detail

BEGIN

static final java.lang.String BEGIN
Constant for the BEGIN status.

See Also:
Constant Field Values

STOP

static final java.lang.String STOP
Constant for the STOP status.

See Also:
Constant Field Values

PLAY

static final java.lang.String PLAY
Constant for the PLAY status.

See Also:
Constant Field Values

REWIND

static final java.lang.String REWIND
Constant for the REVERSE status.

See Also:
Constant Field Values

PAUSE

static final java.lang.String PAUSE
Constant for the PAUSE status.

See Also:
Constant Field Values

FINISH

static final java.lang.String FINISH
Constant for the FINISH status.

See Also:
Constant Field Values

REDRAW

static final java.lang.String REDRAW
Constant for the REDRAW status.

See Also:
Constant Field Values

STEP

static final java.lang.String STEP
Constant for the STEP status.

See Also:
Constant Field Values

ANIMATION_MESSAGE

static final java.lang.String ANIMATION_MESSAGE
Constant for the MESSAGE status.

See Also:
Constant Field Values
Method Detail

setStepTime

void setStepTime(int t)
Sets the step size for the animation.

Parameters:
t - the step size

getStepTime

int getStepTime()
Gets the step size for the animation.

Returns:
int step size

addAnimationListener

void addAnimationListener(AnimationListener l)
Adds an animationListener that recieves meaningful events from the animation, according to the Animation interface and the AnimationEvent.

Parameters:
l - the listener for the AnimationEvents occuring within this Animation.

removeAnimationListener

void removeAnimationListener(AnimationListener l)
Removes an animationListener from the animation, according to the Animation interface and the AnimationEvent.

Parameters:
l - the listener removed from recieving the AnimationEvents occuring within this Animation.

addDescription

void addDescription(java.lang.String d)
Adds a description that may be used to describe to the listener the type of event occuring. The value of teh description may be retrieved through getDescription.

Parameters:
d - the string defining the description.

getDescription

java.lang.String getDescription()
Gets the description added with addDescription and should be accessed through the listener.

Returns:
the string defining the description.

setStep

void setStep(boolean b)
Sets whether the current animation is in stepping mode or not. Step mode indicates skipping the intermediary drawings in the animation and going instantly from one step to the next. Generally useful for fast-forward.

Parameters:
b - boolean defining whether it is skipping.

getStep

boolean getStep()
Gets whether the current animation is in stepping mode or not. Step mode indicates skipping the intermediary drawings in the animation and going instantly from one step to the next. Generally useful for fast-forward.

Returns:
boolean defining whether it is skipping.

setStatus

void setStatus(java.lang.String cmd)
Sets the status of the Animation using a command within Animation interface.

Parameters:
cmd - cmd that the Animation's status is set to.

getStatus

java.lang.String getStatus()
Gets the status of the Animation using a command within Animation interface.

Returns:
the Animation's status.

drawAnimation

void drawAnimation(java.awt.Graphics2D g2)
Draws the animation of the next step, using the status of the animation (Animation.PLAY, Animation.PAUSE and so forth). After completing the drawing, the Animation sends an AnimationEvent to all its listeners, indicating any information that the listerners may wish to use.

The starting status of the animation is defined as Animation.PLAY

Parameters:
b - boolean defining whether it is skipping.

drawAnimation

void drawAnimation(java.awt.Graphics2D g2,
                   java.lang.String status)
Draws the animation of the next step, using the status of the animation (Animation.PLAY, Animation.PAUSE and so forth). After completing the drawing, the Animation sends an AnimationEvent to all its listeners, indicating any information that the listerners may wish to use.

Parameters:
g2 - the graphics to which the animation step should be drawn.
status - the starting status of the animation (what the animation is set to, if in a starting phase like BEGIN or STEP).