|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectexe.VisNode
exe.TreeNode
public class TreeNode
This class maintains the information for a single node in the
Tree data structure. A TreeNode object inherits
from the VisNode class and adds additional data members and
methods to allow these nodes to be used in binary and general trees.
In order to use any of these tree classes in a script-producing program, the
script-producing program must import the package exe.
| Field Summary |
|---|
| Fields inherited from class exe.VisNode |
|---|
activated, cindex, closed, cost, heuristic, hexColor, pred, x, y |
| Constructor Summary | |
|---|---|
TreeNode()
Constructs a TreeNode with default values. |
|
TreeNode(java.lang.String v)
Constructs a TreeNode by specifying its value. |
|
TreeNode(java.lang.String v,
int i)
Constructs a TreeNode by giving its value and
id. |
|
TreeNode(java.lang.String v,
TreeNode p,
TreeNode c,
TreeNode s,
int i)
Constructs a TreeNode by passing in the values for
value, parent, child,
sibling, and id. |
|
TreeNode(VisNode copy)
Constructs a TreeNode that matches the information
contained within the VisNode copy. |
|
| Method Summary | |
|---|---|
TreeNode |
getChild()
Returns a reference to the child of this
TreeNode in the Tree structure. |
int |
getID()
Gives the id assigned to this TreeNode. |
TreeNode |
getLeftChild()
Returns a reference to this TreeNode's left child in a
binary Tree. |
Edge |
getLineToParent()
Returns a reference to the Edge that connects this
TreeNode to its parent in the
Tree. |
TreeNode |
getParent()
Returns a reference to the parent of this
TreeNode in the Tree structure. |
TreeNode |
getRightChild()
Returns a reference to this TreeNode's right child in a
binary Tree. |
TreeNode |
getSibling()
Returns a reference to the sibling of this
TreeNode in the Tree structure. |
java.lang.String |
getValue()
Retrieves the value stored within this
TreeNode. |
void |
insertLeftChild(TreeNode lc)
Adds a left child to this TreeNode in a binary
Tree. |
void |
insertRightChild(TreeNode rc)
Adds a right child to this TreeNode in a binary
Tree. |
boolean |
isLeftChild()
Indicates if this TreeNode is a left child in a binary
Tree. |
boolean |
isPlaceHolder()
Indicates if this TreeNode is a placeholder in a binary
Tree. |
boolean |
isRightChild()
Indicates if this TreeNode is a right child in a binary
Tree. |
void |
setChild(TreeNode c)
Assigns a reference to this TreeNode's child. |
void |
setChildWithEdge(TreeNode c)
Adds a child to this TreeNode and properly sets its
lineToParent with one method call. |
void |
setID(int i)
Sets the id for this TreeNode. |
void |
setLeftChild(boolean t)
Assigns the left child status of this TreeNode in a binary
Tree. |
void |
setLineToParent(Edge e)
Assigns a reference to this TreeNode's
lineToParent, the Edge that connects this
TreeNode with its parent in the Tree. |
void |
setParent(TreeNode p)
Assigns a reference to this TreeNode's parent. |
void |
setPlaceHolder(boolean t)
Assigns the placeholder status of this TreeNode in a binary
Tree. |
void |
setRightChild(boolean t)
Assigns the right child status of this TreeNode in a binary
Tree. |
void |
setSibling(TreeNode s)
Assigns a reference to this TreeNode's
sibling. |
void |
setSiblingWithEdge(TreeNode s)
Adds a sibling to this TreeNode and properly sets its
lineToParent with one method call. |
void |
setValue(java.lang.String v)
Sets this TreeNode's value that appears
inside the circular node when it is drawn on the screen. |
| Methods inherited from class exe.VisNode |
|---|
activate, clearNode, compareTo, compareToNoCost, deactivate, getChar, getCost, getHeuristic, getHexColor, getPred, getX, getY, isActivated, isClosed, setChar, setClosed, setCost, setHeuristic, setHexColor, setLimitedX, setLimitedY, setPred, setX, setY |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TreeNode()
TreeNode with default values.
public TreeNode(java.lang.String v)
TreeNode by specifying its value.
v - Specifies the label that appears within the circular node when
this TreeNode is output to the animation file. If
v contains multiple lines, this
TreeNode's label will have multiple lines.
public TreeNode(java.lang.String v,
int i)
TreeNode by giving its value and
id.
v - Indicates the value that appears within the circular node when
this TreeNode is output to the animation file. If
v contains multiple lines, this
TreeNode's label will have multiple lines.i - Sets the id for this TreeNode. Giving
each TreeNode in a Tree a unique
id makes it possible to find a specific
TreeNode in a Tree structure.
public TreeNode(java.lang.String v,
TreeNode p,
TreeNode c,
TreeNode s,
int i)
TreeNode by passing in the values for
value, parent, child,
sibling, and id.
v - Specifies the value that appears within the circular node when
this TreeNode is output to the animation file. If
v contains multiple lines, this
TreeNode's label will have multiple lines.p - Indicates the parent value for this
TreeNode. This is a reference to this
TreeNode's parent node in a Tree
structure.c - Sets the child value for this
TreeNode. This is a reference to this
TreeNode's left-most child in a Tree
structure.s - Gives the sibling value for this
TreeNode. This is a reference to the child to the
right of this TreeNode in a Tree
structure.i - Sets the id for this TreeNode. Giving
each TreeNode in a Tree a unique
id makes it possible to find a specific
TreeNode in a Tree structure.public TreeNode(VisNode copy)
TreeNode that matches the information
contained within the VisNode copy.
This method is useful for making TreeNodes that represent
the VisNodes in a VisualGraph, such as in the
visualization of graph-searching algorithms. After this method is used
create a TreeNode copy of the given VisNode,
the rest of this TreeNode's data can be set via method
calls to properly link the copied VisNode into a
Tree structure.
copy - Gives the VisNode that contains the information
that should be used to initialize the data that this
TreeNode inherits from the VisNode
class. The new TreeNode is constructed to be a
copy of copy.| Method Detail |
|---|
public java.lang.String getValue()
value stored within this
TreeNode.
String that appears inside this
TreeNode when it is displayed on the screen.public TreeNode getParent()
parent of this
TreeNode in the Tree structure.
TreeNode that is this
TreeNode's parent in the Tree. This
value is null if this TreeNode has no
parent.public TreeNode getChild()
child of this
TreeNode in the Tree structure.
TreeNode that is this
TreeNode's left-most child in the
Tree. This value is null if this
TreeNode has no child.public TreeNode getSibling()
sibling of this
TreeNode in the Tree structure.
TreeNode that is the child
to this right of this TreeNode in the
Tree. This value is null if this
TreeNode has no sibling.public int getID()
id assigned to this TreeNode.
id, used to uniquely
identify TreeNodes in a Tree.public Edge getLineToParent()
Edge that connects this
TreeNode to its parent in the
Tree.
Edge that connects this
TreeNode to its parent in the
Tree. If this TreeNode has no
parent or if no lineToParent has been
set for this TreeNode, the value returned will be
null.public boolean isLeftChild()
TreeNode is a left child in a binary
Tree.
true if this TreeNode
is a left child in a binary Tree. A value of
false is returned if this TreeNode is
a right child or a placeholder or if it is a node in a
general Tree.public boolean isRightChild()
TreeNode is a right child in a binary
Tree.
true if this TreeNode
is a right child in a binary Tree. Returns
false if this TreeNode is a left child
or a placeholder or if it is a node in a general
Tree.public boolean isPlaceHolder()
TreeNode is a placeholder in a binary
Tree.
true if this TreeNode is a
placeholder in a binary Tree. Returns
false if this TreeNode is a left child
or a right child or if it is a node in a general
Tree.public TreeNode getRightChild()
TreeNode's right child in a
binary Tree.
TreeNode's right child in
a binary tree. Returns null if this
TreeNode has no right child or if the
Tree is not a binary Tree.public TreeNode getLeftChild()
TreeNode's left child in a
binary Tree.
TreeNode's left child in
a binary tree. Returns null if this
TreeNode has no left child or if the
Tree is not a binary Tree.public void setValue(java.lang.String v)
TreeNode's value that appears
inside the circular node when it is drawn on the screen.
v - Specifies the value that should be displayed within this
TreeNode when it is displayed on the screen. If
v contains multiple lines, this
TreeNode's label will have multiple lines.public void setParent(TreeNode p)
TreeNode's parent.
p - Indicates the parent of this TreeNode in the
Tree. A reference to this parent is stored in this
TreeNode's parent variable.public void setChild(TreeNode c)
TreeNode's child.
c - Indicates the left-most child of this TreeNode in
the Tree. A reference to this child is stored in
this TreeNode's child variable.public void setSibling(TreeNode s)
TreeNode's
sibling.
s - Indicates the sibling of this TreeNode in the
Tree. A reference to this sibling is stored in
this TreeNode's sibling variable.public void setID(int i)
id for this TreeNode.
i - Specifies the unique int value that is used to
identify this TreeNode.public void setLineToParent(Edge e)
TreeNode's
lineToParent, the Edge that connects this
TreeNode with its parent in the Tree.
e - Indicates the Edge that connects this
TreeNode to its parent in the Tree.
A reference to this Edge is stored in this
TreeNode's lineToParent variable.public void setLeftChild(boolean t)
TreeNode in a binary
Tree.
t - Specifies the left child status of this TreeNode.
The value of t is assigned to
leftChild; a value of true means that
it is a left child, and a value of false means
that it is not a left child.public void setRightChild(boolean t)
TreeNode in a binary
Tree.
t - Specifies the right child status of this TreeNode.
The value of t is assigned to
rightChild; a value of true means
that it is a right child, and a value of false
means that it is not a right child.public void setPlaceHolder(boolean t)
TreeNode in a binary
Tree.
t - Specifies the placeholder status of this TreeNode.
The value of t is assigned to
placeHolder; a value of true means
that it is a placeholder, and a value of false
means that it is not a placeholder.public void insertRightChild(TreeNode rc)
TreeNode in a binary
Tree.
rc - Indicates the TreeNode that is to be inserted as
the right child of this TreeNode. A reference to
rc is assigned to the sibling
variable of the TreeNode referenced by this
TreeNode's child variable. If this
TreeNode has no child, a placeholder
left child will be assigned to child so that
rc can be added as its sibling.public void insertLeftChild(TreeNode lc)
TreeNode in a binary
Tree.
lc - Indicates the TreeNode that is to be inserted as
the left child of this TreeNode. A reference to
lc is assigned to this TreeNode's
child variable. If child already
contains a reference to a left child or placeholder, its
sibling link is copied to the new left child.public void setChildWithEdge(TreeNode c)
TreeNode and properly sets its
lineToParent with one method call. If this
TreeNode already has a child or children, the new child is
added as the right-most child of this TreeNode. Therefore,
this method is useful for building general trees as a program executes.
c - Indicates the TreeNode that should be inserted as
this TreeNode's right-most child.public void setSiblingWithEdge(TreeNode s)
TreeNode and properly sets its
lineToParent with one method call. If this
TreeNode already has a sibling, the new sibling is inserted
at the end of the sibling chain to become the right-most child of the
parent node. Therefore, this method is useful for building general trees
as a program executes.
s - Indicates the TreeNode that should be inserted as
this TreeNode's parent's right-most
child.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||