public abstract class AbstractPathfinderNode extends java.lang.Object implements java.lang.Comparable<AbstractPathfinderNode>
| Modifier and Type | Field and Description |
|---|---|
protected double |
g
Distance from the starting node to this node following the current path
|
protected double |
h
Estimated distance from this node to the destination node
|
protected RectCoordinates |
location
Used to give an x, y, and z position of the node in 3D space.
|
protected AbstractPathfinderNode |
parent
Holds the parent node that will help with following the path
|
| Constructor and Description |
|---|
AbstractPathfinderNode(int x,
int y,
int z)
Class constructor
|
AbstractPathfinderNode(RectCoordinates location)
Class constructor taking in pre-made RectCoordinates location.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(AbstractPathfinderNode another)
Calculates the f values of both nodes, which is just the addition
of the g and h values, to determine whether the other node
is farther or closer to the destination while following the current
path.
|
double |
getG()
Returns the distance from the node to the start node in the path
search taking the current path that reaches this node.
|
double |
getH()
Returns the approximate distance from this node to the destination
node in the path search.
|
RectCoordinates |
getLocation()
Returns the location of the node in the grid
|
AbstractPathfinderNode |
getParent()
Gets the parent node of this node
|
void |
setG(double val)
Sets the g value for this node.
|
void |
setH(double val)
Sets the h value for this node.
|
void |
setParent(AbstractPathfinderNode parent)
Sets the parent of this node.
|
java.lang.String |
toString()
Returns a formatted String holding the location of the node.
|
protected RectCoordinates location
protected AbstractPathfinderNode parent
protected double g
protected double h
public AbstractPathfinderNode(int x,
int y,
int z)
x - the column the node is located in the gridy - the row the node is located in the gridz - the aisle the node is located in the gridpublic AbstractPathfinderNode(RectCoordinates location)
location - the index of the node in the gridpublic RectCoordinates getLocation()
public AbstractPathfinderNode getParent()
public void setParent(AbstractPathfinderNode parent)
parent - new parentpublic double getG()
public void setG(double val)
val - new value of Gpublic double getH()
public void setH(double val)
val - new value of Hpublic int compareTo(AbstractPathfinderNode another)
compareTo in interface java.lang.Comparable<AbstractPathfinderNode>another - the other AbstractPathfinderNode being compared to this onepublic java.lang.String toString()
toString in class java.lang.Object