|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectexe.VisNode
public class VisNode
This class maintains the information for a single node in the
VisualGraph data structure. A VisNode object
contains label, color, and position information, as well as other data
members that might be useful to a node in a graph.
In order to use any of these graph classes in a script-producing program,
the script-producing program must import the package exe.
| Field Summary | |
|---|---|
protected boolean |
activated
Maintains the status of this VisNode in a
VisualGraph. |
protected char |
cindex
Stores this VisNode's unique identifier and label. |
protected boolean |
closed
Tracks if this VisNode is on the closed list in a
graph-searching algorithm. |
protected int |
cost
Contains the length of the current shortest path to this VisNode. |
protected int |
heuristic
Stores the heuristic value for this VisNode. |
protected java.lang.String |
hexColor
Holds the hexadecimal color String for this
VisNode of the form #123456. |
protected char |
pred
Stores the name of the VisNode that is the predecessor of
this VisNode on the current shortest path to this
VisNode. |
protected double |
x
Contains the Cartesian x-coordinate of the center of this VisNode in [0,1] space. |
protected double |
y
Contains the Cartesian y-coordinate of the center of this VisNode in [0,1] space. |
| Constructor Summary | |
|---|---|
VisNode()
Constructs a new VisNode with default information. |
|
VisNode(char label,
java.lang.String color,
double x,
double y)
Constructs a new VisNode by specifying its unique
name/label, hexadecimal color String, and Cartesian
coordinates. |
|
VisNode(VisNode copy)
Constructs a new VisNode that is a copy of
copy. |
|
| Method Summary | |
|---|---|
void |
activate()
Sets this VisNode to active, meaning that it will be
displayed when the VisualGraph to which it belongs is
displayed. |
void |
clearNode()
Resets this VisNode's data members to their default values. |
int |
compareTo(java.lang.Object compare)
Compares two VisNode objects. |
int |
compareToNoCost(java.lang.Object compare)
Compares two VisNode objects. |
void |
deactivate()
Sets this VisNode to inactive, meaning that it will not be
displayed when the VisualGraph to which it belongs is
displayed. |
char |
getChar()
Returns the name/label for this VisNode. |
int |
getCost()
Returns the current shortest cost to this VisNode. |
int |
getHeuristic()
Returns the heuristic value for this VisNode. |
java.lang.String |
getHexColor()
Gives the hexadecimal String that defines the color for
this VisNode. |
char |
getPred()
Returns the name of the predecessor on the shortest path to this VisNode. |
double |
getX()
Returns the Cartesian x-coordinate in [0,1] space for the center of this VisNode. |
double |
getY()
Returns the Cartesian y-coordinate in [0,1] space for the center of this VisNode. |
boolean |
isActivated()
Gives the current activation status of this VisNode in a
VisualGraph. |
boolean |
isClosed()
Gives the closed status of this VisNode. |
void |
setChar(char my_c)
Assigns the name/label for this VisNode. |
void |
setClosed(boolean newClosed)
Sets closed status of this VisNode in a graph-searching
algorithm. |
void |
setCost(int newCost)
Sets the length of the current shortest path to this VisNode. |
void |
setHeuristic(int newHeuristic)
Assigns the heuristic value for this VisNode. |
void |
setHexColor(java.lang.String c)
Sets the color that is displayed within this VisNode. |
void |
setLimitedX(double my_x)
Changes the Cartesian x-coordinate in [0,1] space for the center of this VisNode, ensuring that the new x-coordinate is in the range
[0,1]. |
void |
setLimitedY(double my_y)
Changes the Cartesian y-coordinate in [0,1] space for the center of this VisNode, ensuring that the new y-coordinate is in the range
[0,1]. |
void |
setPred(char pred)
Assigns the name of the predecessor VisNode to this
VisNode on the current lowest-cost path. |
void |
setX(double my_x)
Changes the Cartesian x-coordinate in [0,1] space for the center of this VisNode. |
void |
setY(double my_y)
Changes the Cartesian y-coordinate in [0,1] space for the center of this VisNode. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected char cindex
VisNode's unique identifier and label.
protected java.lang.String hexColor
String for this
VisNode of the form #123456.
protected int cost
VisNode. This is used in graph-searching algorithms.
protected int heuristic
VisNode. This is used
in informed graph searches.
protected boolean closed
VisNode is on the closed list in a
graph-searching algorithm.
protected char pred
VisNode that is the predecessor of
this VisNode on the current shortest path to this
VisNode. This is used in graph-searching algorithms.
protected double x
VisNode in [0,1] space.
protected double y
VisNode in [0,1] space.
protected boolean activated
VisNode in a
VisualGraph. A value of true means this
node is part of the graph and should be displayed, and
false indicates it is not active and should not be
displayed.
| Constructor Detail |
|---|
public VisNode()
VisNode with default information.
public VisNode(char label,
java.lang.String color,
double x,
double y)
VisNode by specifying its unique
name/label, hexadecimal color String, and Cartesian
coordinates.
All other data members are assigned default values and must be set with
the corresponding method calls. This newly constructed
VisNode is inactive until the activate method
is called.
label - Indicates the unique name/label for this
VisNode.color - Gives the hexadecimal String of the form
#123456 that defines the color for this
VisNode.x - Specifies the Cartesian x-coordinate in [0,1] space for the
center of this VisNode.y - Specifies the Cartesian y-coordinate in [0,1] space for the
center of this VisNode.public VisNode(VisNode copy)
VisNode that is a copy of
copy.
copy - Gives a VisNode containing information with
which this VisNode should be initialized.| Method Detail |
|---|
public void clearNode()
VisNode's data members to their default values.
public char getChar()
VisNode.
cindex, the unique
label for this VisNode.public java.lang.String getHexColor()
String that defines the color for
this VisNode.
String of the form #123456.public int getCost()
VisNode.
cost.public int getHeuristic()
VisNode.
heuristic.public boolean isClosed()
VisNode.
true if this VisNode is on the
closed list in a graph search or false if it is not
on the closed list.public char getPred()
VisNode.
pred.public double getX()
VisNode.
x.public double getY()
VisNode.
y.public boolean isActivated()
VisNode in a
VisualGraph.
true if this VisNode
is a part of the VisualGraph and should be
displayed or false if it should not be displayed.public void setChar(char my_c)
VisNode.
my_c - Specifies the name/label that is to appear within this
VisNode when it is displayed. This value is
assigned to cindex.public void setHexColor(java.lang.String c)
VisNode.
c - Indicates the color that appears within this
VisNode when it is displayed. The value must be a
six-digit hexadecimal color String of the form
#123456.public void setCost(int newCost)
VisNode.
newCost - Specifies the current lowest cost to reach this
VisNode in a VisualGraph.public void setHeuristic(int newHeuristic)
VisNode.
newHeuristic - Indicates the heuristic value for this
VisNode in an informed graph search.public void setClosed(boolean newClosed)
VisNode in a graph-searching
algorithm.
newClosed - Gives a value that indicates if this
VisNode is on the closed list;
true means it appears on the closed list
while false indicates that it does not.public void setPred(char pred)
VisNode to this
VisNode on the current lowest-cost path.
pred - Indicates the name/label of the VisNode that is
the predecessor to this VisNode along its
current shortest path. This value is useful for retracing
the path to this VisNode in a graph-searching
algorithm.public void setX(double my_x)
VisNode.
my_x - Specifies the new x-coordinate for this
VisNode.public void setY(double my_y)
VisNode.
my_y - Specifies the new y-coordinate for this
VisNode.public void setLimitedX(double my_x)
VisNode, ensuring that the new x-coordinate is in the range
[0,1].
my_x - Specifies the new x-coordinate for this
VisNode. If the value is less than 0, the
x-coordinate is set as 0, and, if the value is greater than
1, the x-coordinate is set as 1.public void setLimitedY(double my_y)
VisNode, ensuring that the new y-coordinate is in the range
[0,1].
my_y - Specifies the new y-coordinate for this
VisNode. If the value is less than 0, the
y-coordinate is set as 0, and, if the value is greater than
1, the y-coordinate is set as 1.public void activate()
VisNode to active, meaning that it will be
displayed when the VisualGraph to which it belongs is
displayed.
public void deactivate()
VisNode to inactive, meaning that it will not be
displayed when the VisualGraph to which it belongs is
displayed.
public int compareTo(java.lang.Object compare)
VisNode objects.
The two objects are compared using the sums of their cost
and heuristic values. If one of them has a lower sum of
these two values, it is considered less than the other. When these sums
are equal, if one of the objects has a heuristic value of 0
(and the other has a value not equal to 0), it is considered less than
the other. If the least of the two VisNodes still has not
been found at this point, they are compared using the alphabetical order
of their cindex values (their names/labels). If, at this
point, their cindex values are identical, both objects are
considered equal by this method.
This method is ideal as a comparison function for use when inserting
VisNode objects into an open priority queue in
graph-searching algorithms. Note that this comparison method still works
for algorithms that do not use a heuristic because, in these cases, the
value of each object's heuristic data member will be the
default of 0 and will not affect the comparison.
compareTo in interface java.lang.Comparablecompare - Indicates the VisNode to which this
VisNode is to be compared.
-1 if the calling object is
less than compare, 0 if the two
objects are equal, and 1 if the calling
object is greater than compare.public int compareToNoCost(java.lang.Object compare)
VisNode objects.
The two objects are compared using only their heuristic
values. The node with the lower heuristic value is
considered less than the other. When the nodes have the same
heuristic values, they are compared using the alphabetical
order of their cindex values (their names/labels). If, at
this point, their cindex values are identical, both objects
are considered equal by this method.
compare - Indicates the VisNode to which this
VisNode is to be compared.
-1 if the calling object is
less than compare, 0 if the two
objects are equal, and 1 if the calling
object is greater than compare.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||