Class RotationDoubleBSTAnimation

java.lang.Object
  |
  +--AbstractAnimation
        |
        +--RotationDoubleBSTAnimation
All Implemented Interfaces:
Animation, AnimationListener, java.util.EventListener

public class RotationDoubleBSTAnimation
extends AbstractAnimation
implements AnimationListener

The Animation object that defines a double rotation of a node in a BSTTree. The animation builds two RotationBSTAnimations as it goes, keeping only one currently animating and allowing rewinding only to the previous rotation.

The Object implements the Animation interface, and should consequently be used only in that context. 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
RotationDoubleBSTAnimation(BSTTree node)
          The constructor which initiates the status and sets the color schemes to null.
RotationDoubleBSTAnimation(BSTTree node, java.lang.String startingCmd, int stepTime)
          The constructor which initiates the status and prepares the color schemes.
 
Method Summary
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 animationEventPerformed(AnimationEvent e)
          Implements AnimationListener which requires the following method.
 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).
 BSTTree getNode()
          Gets the node from which the partitioning takes place.
 void setNode(BSTTree node)
          Sets the node from which the partitioning takes place.
 
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

RotationDoubleBSTAnimation

public RotationDoubleBSTAnimation(BSTTree node,
                                  java.lang.String startingCmd,
                                  int stepTime)
The constructor which initiates the status and prepares the color schemes. The node which is being deleted must be passed.

Parameters:
node - the BSTTree from which the partition takes place.
startingCmd - the Animation command that this should start.
stepTime - the time for each step of the Animation. Sets the initial value.

RotationDoubleBSTAnimation

public RotationDoubleBSTAnimation(BSTTree node)
The constructor which initiates the status and sets the color schemes to null. No colors will be change using this animation. The node which is animating must be passed.

Parameters:
node - the BSTTree which is deleted during the deletion.
Method Detail

getNode

public BSTTree getNode()
Gets the node from which the partitioning takes place.

Returns:
BSTTree of the node currently being partitioned at the KeySelect.

setNode

public void setNode(BSTTree node)
Sets the node from which the partitioning takes place.

Parameters:
node - BSTTree of the node currently being partitioned at the KeySelect.

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. Other Animation Objects used:

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 status used as the starting command of animation, if needed.

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.

animationEventPerformed

public void animationEventPerformed(AnimationEvent e)
Implements AnimationListener which requires the following method. The only status of animation it listens for is Animation.ANIMATION_MESSAGE, to pass the message on.

Specified by:
animationEventPerformed in interface AnimationListener
Parameters:
e - AnimationEvent that represents the information of the Animation.