edu.princeton.cs.algs4.growingtree.framework
Class DeleteBSTAnimation<P extends NodeProperties>

java.lang.Object
  extended by edu.princeton.cs.algs4.growingtree.framework.AbstractAnimation
      extended by edu.princeton.cs.algs4.growingtree.framework.DeleteBSTAnimation<P>
All Implemented Interfaces:
Animation, AnimationListener, java.util.EventListener

public class DeleteBSTAnimation<P extends NodeProperties>
extends AbstractAnimation
implements AnimationListener

The Animation object that defines the Deletion of a node in a BSTTree. Two constructors exist, one setting the animator and line paints(preferred), the other using defaults. The animation builds RotationBSTAnimations as it goes, keeping only one currently animating rotation and allowing rewinding only to the previous rotation.

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

Field Summary
 
Fields inherited from class edu.princeton.cs.algs4.growingtree.framework.AbstractAnimation
DEFAULT_CONVERSION, DEFAULT_STEP
 
Fields inherited from interface edu.princeton.cs.algs4.growingtree.framework.Animation
ANIMATION_MESSAGE, BEGIN, FINISH, PAUSE, PLAY, REDRAW, REWIND, STEP, STOP
 
Constructor Summary
DeleteBSTAnimation(GrowingTreeNode<P> erasingNode)
          The constructor which initiates the status and sets the line paints to null.
DeleteBSTAnimation(GrowingTreeNode<P> erasingNode, PaintSettings RightLinePaintSettings, PaintSettings LeftLinePaintSettings, java.lang.String startingCmd, int stepTime)
          The constructor which initiates the status and prepares the line paints.
 
Method Summary
 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).
 GrowingTreeNode<P> getErasingNode()
          Gets the node being deleted during the deletion.
 PaintSettings getLeftLinePaintSettings()
          Gets the paint for the left line of the partition for deletion.
 GrowingTreeNode<P> getReplacingNode()
          Gets the node being replaced during the deletion.
 PaintSettings getRightLinePaintSettings()
          Gets the PaintSettings for the right line of the partition for deletion.
 void setErasingNode(GrowingTreeNode<P> node)
          Sets the node being deleted during the Deletion.
 void setLeftLinePaintSettings(PaintSettings leftPaintSettings)
          Sets the paint for the left line of the partition for deletion.
 void setReplacingNode(GrowingTreeNode<P> node)
          Sets the node being replaced during the Deletion.
 void setRightLinePaintSettings(PaintSettings rightPaintSettings)
          Sets the PaintSettings for the right line of the partition for deletion.
 
Methods inherited from class edu.princeton.cs.algs4.growingtree.framework.AbstractAnimation
addAnimationListener, addDescription, drawAnimation, getDescription, getListeners, getStatus, getStep, getStepTime, removeAnimationListener, setStatus, setStep, setStepTime
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeleteBSTAnimation

public DeleteBSTAnimation(GrowingTreeNode<P> erasingNode,
                          PaintSettings RightLinePaintSettings,
                          PaintSettings LeftLinePaintSettings,
                          java.lang.String startingCmd,
                          int stepTime)
The constructor which initiates the status and prepares the line paints. The node which is being deleted must be passed.

Parameters:
erasingNode - the BSTTree which is being deleted.
RightLinePaintSettings - the paint for the right line when drawing the deletion.
LeftLinePaintSettings - the paint for the left line when drawing the deletion
startingCmd - the Animation command that this should start.
stepTime - the time for each step of the Animation. Sets the initial value.

DeleteBSTAnimation

public DeleteBSTAnimation(GrowingTreeNode<P> erasingNode)
The constructor which initiates the status and sets the line paints to null.

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

getErasingNode

public GrowingTreeNode<P> getErasingNode()
Gets the node being deleted during the deletion.

Returns:
BSTTree of the node being deleted.

getReplacingNode

public GrowingTreeNode<P> getReplacingNode()
Gets the node being replaced during the deletion.

Returns:
BSTTree of the node being replaced.

getRightLinePaintSettings

public PaintSettings getRightLinePaintSettings()
Gets the PaintSettings for the right line of the partition for deletion.

Returns:
PaintSettings for the right line of the deletion.

getLeftLinePaintSettings

public PaintSettings getLeftLinePaintSettings()
Gets the paint for the left line of the partition for deletion.

Returns:
Paint for the left line of the deletion.

setErasingNode

public void setErasingNode(GrowingTreeNode<P> node)
Sets the node being deleted during the Deletion.

Parameters:
GrowingTreeNode - of the node being deleted.

setReplacingNode

public void setReplacingNode(GrowingTreeNode<P> node)
Sets the node being replaced during the Deletion.

Parameters:
GrowingTreeNode - of the node being replaced.

setRightLinePaintSettings

public void setRightLinePaintSettings(PaintSettings rightPaintSettings)
Sets the PaintSettings for the right line of the partition for deletion.

Parameters:
rightPaintSettings - for the right line of the deletion.

setLeftLinePaintSettings

public void setLeftLinePaintSettings(PaintSettings leftPaintSettings)
Sets the paint for the left line of the partition for deletion.


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. BSTTreeHead calls: 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.

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.