Class DeleteRedBlackAnimation

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

public class DeleteRedBlackAnimation
extends DeleteBSTAnimation

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


Field Summary
protected static int BEGIN_FIXUP
          The location for beginning of red-black deletion.
protected static int CASE_FOUR
          The location for case four in red-black deletion.
protected static int CASE_ONE
          The location for case one in red-black deletion.
protected static int CASE_THREE
          The location for case three in red-black deletion.
protected static int CASE_TWO
          The location for case two in red-black deletion.
protected  SelectionBSTAnimation currentSelection
          Refers to the current SelectionBSTAnimation being drawn.
protected  int END
          Defines the final move through the tree.
protected static int END_FIXUP
          The location for the end of red-black deletion.
protected  int FADE_NODE
          Constant that defines the fading of the erasing node.
protected  int FADE_NODE_REPLACE
          Defines the partitioning through the tree.
protected  int FINAL_MOVE
          Defines the final move through the tree.
protected  int FIX_UP
          Defines the final move through the tree.
protected  int REPLACE_NODE
          Defines the partitioning through the tree.
protected  int SELECTION_TREE
          Defines the partitioning through the tree.
protected  int START
          Constant that defines the starting location.
 
Fields inherited from class DeleteBSTAnimation
currentLocation, currentPartition, finalMovingNodes, PARTITION_TREE, previousLocation
 
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
DeleteRedBlackAnimation(BSTTree erasingNode)
          The constructor which initiates the status and sets the line paints to null.
DeleteRedBlackAnimation(BSTTree erasingNode, PaintSettings RightLinePaint, PaintSettings LeftLinePaint, java.lang.String startingCmd, int stepTime)
          The constructor which initiates the status and prepares the line paints.
 
Method Summary
protected  void addNode(RedBlackTree node, MovingBSTTreeAnimation animator, int movePosition, MovingRedBlackTree 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.
protected  void createFinalMovingNodes()
          Creates the moving nodes corresponding to the final moving of the nodes.
 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.
 RedBlackTree getChildNode()
          Gets the node being deleted during the replacing.
protected  void makeCurrentRotation()
          Constructs the current Rotation according to the current tree, and the defined rotationCheck.
 void setBlackChangeLinks()
          Fixes the blackChangeLinks by settings all the nodes links within the list to black.
 void setChildNode(RedBlackTree node)
          Sets the node being deleted during the Deletion.
 void setRedChangeLinks()
          Fixes the redChangeLinks by settings all the nodes links within the list to red.
 
Methods inherited from class DeleteBSTAnimation
addNode, animationEventPerformed, getErasingNode, getLeftLinePaintSettings, getReplacingNode, getRightLinePaintSettings, setErasingNode, setLeftLinePaintSettings, setReplacingNode, setRightLinePaintSettings
 
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

currentSelection

protected SelectionBSTAnimation currentSelection
Refers to the current SelectionBSTAnimation being drawn.


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

SELECTION_TREE

protected int SELECTION_TREE
Defines the partitioning through the tree.


FADE_NODE_REPLACE

protected int FADE_NODE_REPLACE
Defines the partitioning through the tree.


REPLACE_NODE

protected int REPLACE_NODE
Defines the partitioning through the tree.


FIX_UP

protected int FIX_UP
Defines the final move 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.


BEGIN_FIXUP

protected static final int BEGIN_FIXUP
The location for beginning of red-black deletion.

See Also:
Constant Field Values

CASE_ONE

protected static final int CASE_ONE
The location for case one in red-black deletion.

See Also:
Constant Field Values

CASE_TWO

protected static final int CASE_TWO
The location for case two in red-black deletion.

See Also:
Constant Field Values

CASE_THREE

protected static final int CASE_THREE
The location for case three in red-black deletion.

See Also:
Constant Field Values

CASE_FOUR

protected static final int CASE_FOUR
The location for case four in red-black deletion.

See Also:
Constant Field Values

END_FIXUP

protected static final int END_FIXUP
The location for the end of red-black deletion.

See Also:
Constant Field Values
Constructor Detail

DeleteRedBlackAnimation

public DeleteRedBlackAnimation(BSTTree erasingNode,
                               PaintSettings RightLinePaint,
                               PaintSettings LeftLinePaint,
                               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.
RightLinePaint - the paint for the right line when drawing the deletion.
LeftLinePaint - 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.

DeleteRedBlackAnimation

public DeleteRedBlackAnimation(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

getChildNode

public RedBlackTree getChildNode()
Gets the node being deleted during the replacing.

Returns:
RedBlackTree of the child node.

setChildNode

public void setChildNode(RedBlackTree node)
Sets the node being deleted during the Deletion.


createFinalMovingNodes

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

Overrides:
createFinalMovingNodes in class DeleteBSTAnimation

addNode

protected void addNode(RedBlackTree node,
                       MovingBSTTreeAnimation animator,
                       int movePosition,
                       MovingRedBlackTree 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 DeleteBSTAnimation
Parameters:
g2 - the graphics to which the animation step should be drawn.
startingStatus - the status used as the starting command of animation, if needed.

setRedChangeLinks

public void setRedChangeLinks()
Fixes the redChangeLinks by settings all the nodes links within the list to red. Then the nodes are removed from the list, always leaving it clear after this call.


setBlackChangeLinks

public void setBlackChangeLinks()
Fixes the blackChangeLinks by settings all the nodes links within the list to black. Then the nodes are removed from the list, always leaving it clear after this call.


makeCurrentRotation

protected void makeCurrentRotation()
Constructs the current Rotation according to the current tree, and the defined rotationCheck. This method follows the rules set by the deletion of a node in a red-black tree. Consequently, this method is one of the important methods in extending DeleteBSTAnimation.


drawDottedLine

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

Overrides:
drawDottedLine in class DeleteBSTAnimation
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 DeleteBSTAnimation
Parameters:
cmd - String Animation command passed instead of the current Status.
description - String description for messages.