Class MovingBSTTreeAnimation

java.lang.Object
  |
  +--AbstractAnimation
        |
        +--MovingBSTTreeAnimation
All Implemented Interfaces:
Animation

public class MovingBSTTreeAnimation
extends AbstractAnimation

The Animation object that defines the Moving of a MovingBSTTree. Two constructors exist, one setting the animator and animation color Schemes. This animation is the core of many other animations that involve moving (Rotation).

The object restores all values changed in the given nodes, however, if the object is never allowed to finish, the restoring of values becomes impossible. On any exception occuring elsewhere, the object may not restore the conditions correctly.


Field Summary
 
Fields inherited from class AbstractAnimation
DEFAULT_CONVERSION, DEFAULT_STEP, listeners
 
Fields inherited from interface Animation
ANIMATION_MESSAGE, BEGIN, FINISH, PAUSE, PLAY, REDRAW, REWIND, STEP, STOP
 
Constructor Summary
MovingBSTTreeAnimation()
          The constructor which initiates the status as Animation.PLAY, default step size, the default NodeAnimationScheme and KeyAnimationScheme.
MovingBSTTreeAnimation(NodeSettings NodeAnimationScheme, KeySettings KeyAnimationScheme)
          The constructor which initiates the status as Animation.PLAY, default step size, the given NodeAnimationScheme and KeyAnimationScheme.
MovingBSTTreeAnimation(NodeSettings NodeAnimationScheme, KeySettings KeyAnimationScheme, java.lang.String startingCmd, int stepTime)
          The constructor which initiates the status and prepares the color Schemes.
 
Method Summary
 void add(MovingBSTTree movingNode, BSTTree node)
          Adds the movingBSTTree along with the BSTTree node as a pair.
protected  void animationAction(java.lang.String cmd, java.lang.String description)
          Calls all of the listeners of the current Animation and passed information regarding the progress and status of the current Animation.
 void drawAnimation(java.awt.Graphics2D g2, java.lang.String startingStatus)
          Draws the animation of the next step, using the status of the animation (Animation.PLAY, Animation.PAUSE and so forth).
 NodeSettings getAnimationScheme()
          Gets the NodeSettings for the animation of the moving node.
 MovingBSTTree getFirstMovingNode()
          Gets the first moving node in the list.
 KeySettings getKeyAnimationScheme()
          Gets the KeySettings for the animation key for the moving node.
 MovingBSTTree getMovingNode(BSTTree node)
          Gets the moving node within the Animation that imitates the passed BSTTree node.
 java.util.LinkedList getMovingNodes()
          Gets the moving nodes used in the Animation.
 NodeSettings getNodeAnimationScheme()
          Gets the node Animationg scheme for each moving node.
 java.util.LinkedList getNodes()
          Gets the BSTTree nodes used in the Animation.
 boolean isEmpty()
          Returns true if the moving node list is empty.
 void makeAnimation(java.awt.Graphics2D g2, java.lang.String startingStatus)
          Makes the animation of the next step, using the status of the animation (Animation.PLAY, Animation.PAUSE and so forth).
 void setAnimationScheme(NodeSettings nodeScheme, KeySettings keyScheme)
          Sets the animation scheme for each moving node.
 void setKeyAnimationScheme(KeySettings scheme)
          Sets the KeySettings for the animation key for the moving node.
 void setNodeAnimationScheme(NodeSettings scheme)
          Sets the NodeSettings for the animation of the moving node.
 
Methods inherited from class AbstractAnimation
addAnimationListener, addDescription, animationAction, animationAction, drawAnimation, getDescription, getListeners, getStartingCommand, getStatus, getStep, getStepConversion, getStepSize, getStepTime, messageAction, removeAnimationListener, setStartingCommand, setStatus, setStep, setStepConversion, setStepSize, setStepTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MovingBSTTreeAnimation

public MovingBSTTreeAnimation()
The constructor which initiates the status as Animation.PLAY, default step size, the default NodeAnimationScheme and KeyAnimationScheme.


MovingBSTTreeAnimation

public MovingBSTTreeAnimation(NodeSettings NodeAnimationScheme,
                              KeySettings KeyAnimationScheme)
The constructor which initiates the status as Animation.PLAY, default step size, the given NodeAnimationScheme and KeyAnimationScheme.

Parameters:
NodeAnimationScheme - the NodeSettings which the nodes uses during animation.
KeyAnimationScheme - the KeySettings which the key in each moving node is drawn.

MovingBSTTreeAnimation

public MovingBSTTreeAnimation(NodeSettings NodeAnimationScheme,
                              KeySettings KeyAnimationScheme,
                              java.lang.String startingCmd,
                              int stepTime)
The constructor which initiates the status and prepares the color Schemes.

Parameters:
NodeAnimationScheme - the NodeSettings which the nodes uses during animation.
KeyAnimationScheme - the KeySettings which the key in each moving node is drawn.
startingCmd - the Animation command that this should start.
stepTime - the time for each step of the Animation. Sets the initial value.
Method Detail

getMovingNodes

public java.util.LinkedList getMovingNodes()
Gets the moving nodes used in the Animation. The return is the clone of the LinkedList used within the class. Cloning of a LinkedList is a shallow copy. return LinkedList representing the movingBSTTrees.


getNodeAnimationScheme

public NodeSettings getNodeAnimationScheme()
Gets the node Animationg scheme for each moving node.

Returns:
animation scheme for the moving nodes.

getNodes

public java.util.LinkedList getNodes()
Gets the BSTTree nodes used in the Animation. The return is the clone of the LinkedList used within the class. Cloning of a LinkedList is a shallow copy. return LinkedList representing the BSTTrees that the movingBSTTrees imitate.


getMovingNode

public MovingBSTTree getMovingNode(BSTTree node)
Gets the moving node within the Animation that imitates the passed BSTTree node. If the BSTTree node does not exist in the Animation, null is returned.

Parameters:
node - BSTTree node which the returning MovingBSTTree node imitates.
Returns:
MovingBSTTree which imitates the given node.

getFirstMovingNode

public MovingBSTTree getFirstMovingNode()
Gets the first moving node in the list.

Returns:
the first MovingBSTTree in the animation.

isEmpty

public boolean isEmpty()
Returns true if the moving node list is empty.

Returns:
true if the animation contains no moving nodes.

getAnimationScheme

public NodeSettings getAnimationScheme()
Gets the NodeSettings for the animation of the moving node.

Returns:
NodeSettings for the node animating.

getKeyAnimationScheme

public KeySettings getKeyAnimationScheme()
Gets the KeySettings for the animation key for the moving node.

Returns:
KeySettings for the key of the node animating.

setAnimationScheme

public void setAnimationScheme(NodeSettings nodeScheme,
                               KeySettings keyScheme)
Sets the animation scheme for each moving node.

Parameters:
nodeScheme - the NodeSettings for the animation of the moving node.
keyScheme - the KeySettings for the animationg of the key within the moving node.

add

public void add(MovingBSTTree movingNode,
                BSTTree node)
Adds the movingBSTTree along with the BSTTree node as a pair. The moving Node imitates the given nod.

Parameters:
movingNode - MovingBSTTree that is added to the animation.
node - BSTTree that is added to the animation.

setNodeAnimationScheme

public void setNodeAnimationScheme(NodeSettings scheme)
Sets the NodeSettings for the animation of the moving node.

Parameters:
scheme - NodeSettings for the node animating.

setKeyAnimationScheme

public void setKeyAnimationScheme(KeySettings scheme)
Sets the KeySettings for the animation key for the moving node.

Parameters:
scheme - KeySettings for the key of the node animating.

drawAnimation

public void drawAnimation(java.awt.Graphics2D g2,
                          java.lang.String startingStatus)
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.

Specified by:
drawAnimation in interface Animation
Overrides:
drawAnimation in class AbstractAnimation
Parameters:
g2 - the graphics to which the animation step should be drawn.
startingStatus - the starting status used if necessary.

makeAnimation

public void makeAnimation(java.awt.Graphics2D g2,
                          java.lang.String startingStatus)
Makes the animation of the next step, using the status of the animation (Animation.PLAY, Animation.PAUSE and so forth). After completing the making, nodeMade is set to true, so when the animation is actually drawn, it will not skip a step.

Parameters:
g2 - the graphics to which the animation step should be drawn.
startingStatus - the starting status used if necessary.

animationAction

protected void animationAction(java.lang.String cmd,
                               java.lang.String description)
Calls all of the listeners of the current Animation and passed information regarding the progress and status of the current Animation. Additionally, the id of the type of animation is passed. Within, the animationEventPerformed method is called.

Overrides:
animationAction in class AbstractAnimation
Parameters:
cmd - String Animation command passed instead of the current Status.
description - String description for messages.