|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.princeton.cs.algs4.growingtree.framework.GrowingTreeNode<P>
edu.princeton.cs.algs4.growingtree.framework.MovingBSTTree<P>
public class MovingBSTTree<P extends NodeProperties>
The class provides the base structure for a BSTTree
that can move to a new position
in the Binary Search Tree. For that reason, it extends the BSTTree class.
Field Summary | |
---|---|
static int |
DOWN_LEFT
Defines moving down and to the left. |
static int |
DOWN_RIGHT
Defines moving down and to the right. |
static int |
FOLLOW_NODE
Defines following the node passed as a follower. |
static int |
FOLLOW_PARENT_LEFT
Defines following the parent as its left child. |
static int |
FOLLOW_PARENT_RIGHT
Defines following the parent, as its right child. |
static int |
NULL_MOVEMENT
Defines a null movement. |
static int |
UP_LEFT
Defines moving up and to the left. |
static int |
UP_RIGHT
Defines moving up and to the right. |
Fields inherited from class edu.princeton.cs.algs4.growingtree.framework.GrowingTreeNode |
---|
ANIMATING_BST_TREE_TYPE, BST_TREE_TYPE, DRAWING_BST_TREE_TYPE |
Constructor Summary | |
---|---|
MovingBSTTree(GrowingTreeNode<P> node)
Constructor without a parent passed, indicating that FOLLOW_PARENT_LEFT and FOLLOW_PARENT_RIGHT
are not accesible unless a parent is set. |
|
MovingBSTTree(GrowingTreeNode<P> node,
MovingBSTTree<P> movingParent)
Constructor with a parent passed. |
Method Summary | |
---|---|
void |
drawFollowLeft(java.awt.Graphics2D g2)
Draws the moving node in the given Graphics2D to follow its parent as if it were the left child. |
void |
drawFollowNode(java.awt.Graphics2D g2,
double step)
Draws the moving node in the given Graphics2D to follow the location of the imitating node. |
void |
drawFollowNode(java.awt.Graphics2D g2,
double step,
boolean bottomLinks)
Draws the moving node in the given Graphics2D to follow the location of the imitating node. |
void |
drawFollowRight(java.awt.Graphics2D g2)
Draws the moving node in the given Graphics2D to follow its parent as if it were the right child. |
void |
drawNodeAndLink(java.awt.Graphics2D g2,
double step)
Draws the node and link of the tree to the given Graphics2D. |
int |
getEndLevel()
Gets the ending level for the moving of the node. |
java.awt.geom.AffineTransform |
getEndTransform()
Gets the ending transform for the moving of the node. |
int |
getMovePosition()
Gets the move position for the moving node. |
MovingBSTTree<P> |
getMovingParent()
Gets the moving parent of the MovingBSTTree . |
double |
getMovingSectionHeight()
Gets the section height for the drawing of the node. |
GrowingTreeNode<P> |
getNode()
Gets the node that the MovingBSTTree is imitating. |
int |
getStartLevel()
Gets the starting level for the moving of the node. |
java.awt.geom.AffineTransform |
getStartTransform()
Gets the starting transform for the moving of the node. |
void |
initMovingBSTTree()
Initiliazes the node with the move position defined within the node. |
void |
initMovingBSTTree(int movePosition)
Initiliazes the node with the move position passed. |
void |
makeNode(java.awt.Graphics2D g2,
double step)
Sets the node of the tree in the given Graphics2D, by setting the AffineTransform. |
void |
setEndLevel(int endLevel)
Sets the ending level for the moving of the node. |
void |
setEndTransform(java.awt.geom.AffineTransform endTransform)
Sets the ending transform for the moving of the node. |
void |
setFollowLeftMovingTransform(java.awt.Graphics2D g2)
Sets the current transform for a given following node. |
void |
setFollowNodeMovingTransform(java.awt.Graphics2D g2,
double step)
Sets the current transform for a given following node. |
void |
setFollowRightMovingTransform(java.awt.Graphics2D g2)
Sets the current transform for a given following node. |
void |
setMovePosition(int m)
Sets the move position for the moving node. |
void |
setMovingParent(MovingBSTTree<P> movingParent)
Sets the moving parent of the MovingBSTTree . |
void |
setMovingSectionHeight(double height)
Sets the section height for the drawing of the node. |
void |
setNode(GrowingTreeNode<P> node)
Sets the node that the MovingBSTTree imitates. |
void |
setStartLevel(int startLevel)
Sets the starting level for the moving of the node. |
void |
setStartTransform(java.awt.geom.AffineTransform startTransform)
Sets the starting transform for the moving of the node. |
void |
setTreeType(int treeType)
Sets the tree type for the BSTTree. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NULL_MOVEMENT
public static final int DOWN_RIGHT
public static final int DOWN_LEFT
public static final int UP_RIGHT
public static final int UP_LEFT
public static final int FOLLOW_PARENT_RIGHT
public static final int FOLLOW_PARENT_LEFT
public static final int FOLLOW_NODE
Constructor Detail |
---|
public MovingBSTTree(GrowingTreeNode<P> node)
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.
node
- BSTTree node that the MovingBSTTree imitates.public MovingBSTTree(GrowingTreeNode<P> node, MovingBSTTree<P> movingParent)
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.
node
- BSTTree node that the MovingBSTTree imitates.movingParent
- MovingBSTTree that is the parent of the current node, allowing the follow parent move positions.Method Detail |
---|
public GrowingTreeNode<P> getNode()
MovingBSTTree
is imitating.
MovingBSTTree
is imitating.public MovingBSTTree<P> getMovingParent()
MovingBSTTree
.
MovingBSTTree
parent .public double getMovingSectionHeight()
public java.awt.geom.AffineTransform getStartTransform()
MovingBSTTree
.public java.awt.geom.AffineTransform getEndTransform()
MovingBSTTree
.public int getStartLevel()
MovingBSTTree
.public int getEndLevel()
MovingBSTTree
.public int getMovePosition()
public void setNode(GrowingTreeNode<P> node)
MovingBSTTree
imitates. The key and value are set according
to the given node.
node
- BSTTree node that the MovingBSTTree imitates.public void setMovingParent(MovingBSTTree<P> movingParent)
MovingBSTTree
. After the parent is set,
the movements FOLLOW_PARENT_RIGHT
and FOLLOW_PARENT_LEFT
are allowed.
movingParent
- MovingBSTTree
parent for the node.public void setMovingSectionHeight(double height)
height
- the section height used for the moving node.public void setStartTransform(java.awt.geom.AffineTransform startTransform)
startTransform
- starting transform for the MovingBSTTree
.public void setEndTransform(java.awt.geom.AffineTransform endTransform)
setMovePosition
.
endTransform
- ending transform for the MovingBSTTree
.public void setStartLevel(int startLevel)
startLevel
- starting level for the MovingBSTTree
.public void setEndLevel(int endLevel)
setMovePosition
.
endLevel
- ending transform for the MovingBSTTree
.public void setMovePosition(int m)
drawNodeAndLink
is called.
m
- integer representing a predefined move position.public void setTreeType(int treeType)
setTreeType
in class GrowingTreeNode<P extends NodeProperties>
treeType
- setting for the tree (no affect).public void makeNode(java.awt.Graphics2D g2, double step)
FOLLOW_PARENT_RIGHT
, FOLLOW_PARENT_LEFT
, and FOLLOW_NODE
do not initialize but must be reconfigured every call to the method. The other movements
are not changed after the first initlization.
g2
- graphics to which the node is drawn.step
- double value [0,1] which indicates the progress of the drawing.public void drawNodeAndLink(java.awt.Graphics2D g2, double step)
FOLLOW_PARENT_RIGHT
, FOLLOW_PARENT_LEFT
, and FOLLOW_NODE
do not initialize but must be reconfigured every call to the method. The other movements
are not changed after the first initlization.
g2
- graphics to which the node is drawn.step
- double value [0,1] which indicates the progress of the drawing.public void initMovingBSTTree(int movePosition)
movePostition
- the move position set for the node and initialized to.public void initMovingBSTTree()
DOWN_RIGHT
DOWN_LEFT
UP_RIGHT
UP_LEFT
public void drawFollowRight(java.awt.Graphics2D g2)
g2
- Graphics2D to which to node is drawn.public void drawFollowLeft(java.awt.Graphics2D g2)
g2
- Graphics2D to which to node is drawn.public void drawFollowNode(java.awt.Graphics2D g2, double step)
FOLLOW_NODE
movement simply starts at the start transform and ends at the current transform of the imitating node.
g2
- Graphics2D to which to node is drawn.step
- double value [0,1] which indicates the progress of the drawing.public void drawFollowNode(java.awt.Graphics2D g2, double step, boolean bottomLinks)
FOLLOW_NODE
movement simply starts at the start transform and ends at the current transform of the imitating node.
g2
- Graphics2D to which to node is drawn.step
- double value [0,1] which indicates the progress of the drawing.bottomLinks
- boolean whether the bottom links should be drawn.public void setFollowNodeMovingTransform(java.awt.Graphics2D g2, double step)
g2
- Graphics2D to which to node is drawn.step
- double value [0,1] which indicates the progress of the drawing.public void setFollowRightMovingTransform(java.awt.Graphics2D g2)
g2
- Graphics2D to which to node is drawn.public void setFollowLeftMovingTransform(java.awt.Graphics2D g2)
g2
- Graphics2D to which to node is drawn.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |