Class DeleteBSTAnimation

java.lang.Object
  |
  +--AbstractAnimation
        |
        +--DeleteBSTAnimation
All Implemented Interfaces:
Animation, AnimationListener, java.util.EventListener
Direct Known Subclasses:
DeleteRedBlackAnimation

public class DeleteBSTAnimation
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.


Field Summary
protected  double currentLocation
          Private doubles used to hold the current and previous location steps.
protected  PartitionBSTAnimation currentPartition
          Refers to the current PartitionBSTAnimation being drawn.
protected  int END
          Defines the final move through the tree.
protected  int FADE_NODE
          Constant that defines the fading of the erasing node.
protected  int FINAL_MOVE
          Defines the final move through the tree.
protected  MovingBSTTreeAnimation finalMovingNodes
          Refers to the final moving nodes.
protected  int PARTITION_TREE
          Defines the partitioning through the tree.
protected  double previousLocation
           
protected  int START
          Constant that defines the starting location.
 
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
DeleteBSTAnimation(BSTTree erasingNode)
          The constructor which initiates the status and sets the line paints to null.
DeleteBSTAnimation(BSTTree erasingNode, PaintSettings RightLinePaintSettings, PaintSettings LeftLinePaintSettings, java.lang.String startingCmd, int stepTime)
          The constructor which initiates the status and prepares the line paints.
 
Method Summary
protected  void addNode(BSTTree node, MovingBSTTreeAnimation animator, int movePosition, MovingBSTTree parent)
          Adds all children nodes to the animator list, setting the Moving node as its parent.
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.
protected  void createFinalMovingNodes()
          Creates the moving nodes corresponding to the descendant of the rotation.
 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).
protected  void drawDottedLine(java.awt.Graphics2D g2, double location)
          Draws a dotted line according to the current location within the graphics.
 BSTTree getErasingNode()
          Gets the node being deleted during the deletion.
 PaintSettings getLeftLinePaintSettings()
          Gets the paint for the left line of the partition for deletion.
 BSTTree 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(BSTTree 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(BSTTree 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 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
 

Field Detail

START

protected final int START
Constant that defines the starting location.

See Also:
Constant Field Values

FADE_NODE

protected final int FADE_NODE
Constant that defines the fading of the erasing node.

See Also:
Constant Field Values

PARTITION_TREE

protected int PARTITION_TREE
Defines the partitioning through the tree.


FINAL_MOVE

protected int FINAL_MOVE
Defines the final move through the tree.


END

protected int END
Defines the final move through the tree.


currentPartition

protected PartitionBSTAnimation currentPartition
Refers to the current PartitionBSTAnimation being drawn.


finalMovingNodes

protected MovingBSTTreeAnimation finalMovingNodes
Refers to the final moving nodes.


currentLocation

protected double currentLocation
Private doubles used to hold the current and previous location steps.


previousLocation

protected double previousLocation
Constructor Detail

DeleteBSTAnimation

public DeleteBSTAnimation(BSTTree 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(BSTTree 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 BSTTree getErasingNode()
Gets the node being deleted during the deletion.

Returns:
BSTTree of the node being deleted.

getReplacingNode

public BSTTree 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(BSTTree node)
Sets the node being deleted during the Deletion.


setReplacingNode

public void setReplacingNode(BSTTree node)
Sets the node being replaced during the Deletion.


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.

Returns:
leftPaint for the left line of the deletion.

createFinalMovingNodes

protected void createFinalMovingNodes()
Creates the moving nodes corresponding to the descendant of the rotation.


addNode

protected void addNode(BSTTree node,
                       MovingBSTTreeAnimation animator,
                       int movePosition,
                       MovingBSTTree parent)
Adds all children nodes to the animator list, setting the Moving node as its parent. The move position defines the moving of the new node.

Parameters:
node - the node which the MovingBSTTree made imitates.
animator - the MovingBSTTreeAnimation to which the new MovingBSTTree node is added.
parent - MovingBSTTree parent for the node, specifically for following the node.

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.

drawDottedLine

protected void drawDottedLine(java.awt.Graphics2D g2,
                              double location)
Draws a dotted line according to the current location within the graphics.

Parameters:
g2 - Graphics2D to which the line is drawn.
location - the double location of progress in the animation.

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.