Class MovingRedBlackTree
java.lang.Object
|
+--BSTTree
|
+--MovingBSTTree
|
+--MovingRedBlackTree
- All Implemented Interfaces:
- AnimatingTree, AnimationListener, DrawingTree, java.util.EventListener, Tree
- public class MovingRedBlackTree
- extends MovingBSTTree
The class provides the base structure for a RedBlackTree
that can move to a new position
in the Binary Search Tree. For that reason, it extends the BSTTree class.
The MovingRedBlackTree defines methods necessary to move a RedBlackTree from one location
in a Binary Search Tree to another. Because the methods are moving, they require animation.
Consequently, the extension must be from an AnimatingBSTTree. The constructor ensures
this construction, however, changes cannot be made. To protect the changes from occuring,
the methods have been overiden to have no affect.
Field Summary |
protected RedBlackTree |
node
Node that the moving node can follow or imitates. |
Method Summary |
protected void |
drawLeftLink(java.awt.Graphics2D g2,
double sectionHeight,
java.awt.geom.AffineTransform a,
double drawingLevel,
double powerLevel)
Draws just the left link according to the NodeSettings currently set. |
protected void |
drawRightLink(java.awt.Graphics2D g2,
double sectionHeight,
java.awt.geom.AffineTransform a,
double drawingLevel,
double powerLevel)
Draws just the right link according to the NodeSettings currently set. |
void |
setNode(RedBlackTree node)
Sets the node that the MovingBSTTree imitates. |
Methods inherited from class MovingBSTTree |
drawFollowLeft, drawFollowNode, drawFollowRight, drawNodeAndLink, getEndLevel, getEndTransform, getMovePosition, getMovingParent, getMovingSectionHeight, getNode, getStartLevel, getStartTransform, initMovingBSTTree, initMovingBSTTree, setEndLevel, setEndTransform, setMovePosition, setMovingParent, setMovingSectionHeight, setNode, setStartLevel, setStartTransform, setTreeType |
Methods inherited from class BSTTree |
addAnimator, animationEventPerformed, constructAnimatingBSTTree, constructBSTTree, constructDrawingBSTTree, copyBSTTree, drawNode, drawNode, drawNode, drawNodeAndLeftLink, drawNodeAndLink, drawNodeAndLink, drawNodeAndLink, drawNodeAndLink, drawNodeAndRightLink, drawTree, eraseNodeAndLink, findNode, fixLevel, fixTreeType, getAnimator, getChildren, getCurrentGraphics, getCurrentPower2, getCurrentShape, getCurrentTransform, getDrawingLevel, getHead, getKey, getKeyOriginRectangle, getLeftTree, getLevel, getNodeOriginShape, getParentTree, getPreviousTransform, getRightTree, getScreenBounds, getSectionHeight, getSettings, getTreeType, getTreeTypeString, getValue, insert, inTree, isAnimateDrawing, isAnimatingBSTTree, isDrawingBSTTree, isEmpty, isNodeAnimating, isSettingsSaved, join, makeInorderTree, makeInsertAnimation, makePostorderTree, makePreorderTree, makeSearchAnimation, makeSelectionAnimation, makeTree, partition, remove, restoreLeftSettings, restoreRightSettings, restoreSettings, restoreTransform, rotateLeft, rotateRight, saveLeftSettings, saveRightSettings, saveSettings, search, select, setAnimateDrawing, setCurrentGraphics, setCurrentPower2, setCurrentTransform, setDrawingLevel, setHead, setLeaf, setLeftTree, setLevel, setNode, setNodeSettings, setParentTree, setRightTree, setScreenBounds, setSettings, setSize, setTreeSettings, size |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
node
protected RedBlackTree node
- Node that the moving node can follow or imitates.
MovingRedBlackTree
public MovingRedBlackTree(BSTTree node)
- Constructor without a parent passed, indicating that
FOLLOW_PARENT_LEFT
and FOLLOW_PARENT_RIGHT
are not accesible unless a parent is set. The MovingBSTTree constructs as an empty ANIMATING_BST_TREE_TYPEM
, setting the value and key as the value and key of the given node. The MovingBSTTree imitates
the BSTTree
node given but does not affect the node.
- Parameters:
node
- BSTTree node that the MovingBSTTree imitates.
MovingRedBlackTree
public MovingRedBlackTree(BSTTree node,
MovingBSTTree movingParent)
- Constructor with a parent passed. The MovingBSTTree constructs as an empty
ANIMATING_BST_TREE_TYPEM
, setting the value and key as the value and key of the given node. The MovingBSTTree imitates
the BSTTree
node given but does not affect the node.
- Parameters:
node
- BSTTree node that the MovingBSTTree imitates.movingParent
- MovingBSTTree that is the parent of the current node, allowing the follow parent move positions.
setNode
public void setNode(RedBlackTree node)
- Sets the node that the
MovingBSTTree
imitates. The key and value are set according
to the given node.
- Parameters:
node
- BSTTree node that the MovingBSTTree imitates.
drawRightLink
protected void drawRightLink(java.awt.Graphics2D g2,
double sectionHeight,
java.awt.geom.AffineTransform a,
double drawingLevel,
double powerLevel)
- Draws just the right link according to the NodeSettings currently set.
- Overrides:
drawRightLink
in class BSTTree
- Parameters:
g2
- graphics to which the node and links are drawn.sectionHeight
- the height of the tree' section, to draw the correct lengths for the links.a
- transfrom to draw the node and links.drawingLevel
- the level in the tree to which the node is currently being drawn.powerLevel
- the power to which the links extend, depending on how many links are present.
drawLeftLink
protected void drawLeftLink(java.awt.Graphics2D g2,
double sectionHeight,
java.awt.geom.AffineTransform a,
double drawingLevel,
double powerLevel)
- Draws just the left link according to the NodeSettings currently set.
- Overrides:
drawLeftLink
in class BSTTree
- Parameters:
g2
- graphics to which the node and links are drawn.sectionHeight
- the height of the tree' section, to draw the correct lengths for the links.a
- transfrom to draw the node and links.drawingLevel
- the level in the tree to which the node is currently being drawn.powerLevel
- the power to which the links extend, depending on how many links are present.