|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcalculation.Vertex
public class Vertex
This is a Vertex class, to represents the nodes in the graph.
Field Summary | |
---|---|
private Vertex[] |
adj
Adjacent vertices. |
private boolean |
available
Is this vertex available? |
private int |
bestDir
Tells if this vertex is in the best direction for aStar. |
private double |
distCost
Cost to goal vertex of aStar as a straight line distance. |
static int |
EAST
Possible direction of adjacent Vertex. |
private double |
gCost
Cost from start vertex of aStar to this vertex. |
private double |
hCost
Cost to goal vertex of aStar. |
private double |
lat
Latitude coordinate. |
private double |
lon
Longitude coordinate. |
static int |
NORTH
Possible direction of adjacent Vertex. |
static int |
NORTHEAST
Possible direction of adjacent Vertex. |
static int |
NORTHWEST
Possible direction of adjacent Vertex. |
static int |
ON_CLOSED_SET
Value for the field "state". |
static int |
ON_OPEN_SET
Value for the field "state". |
private Vertex |
parent
Parent vertex in a tree aStar is creating. |
private int |
pathSafety
Tells if this vertex is in path safety area, value identifies path number. |
static int |
SOUTH
Possible direction of adjacent Vertex. |
static int |
SOUTHEAST
Possible direction of adjacent Vertex. |
static int |
SOUTHWEST
Possible direction of adjacent Vertex. |
private int |
state
How A* sees this vertex. |
private boolean |
storm
Is this a storm vertex? |
private boolean |
stormSafety
Tells if this vertex is in storm safety distance area. |
static int |
UNVISITED
Value for the field "state". |
static int |
WEST
Possible direction of adjacent Vertex. |
private int |
x
X-coordinate in a graph. |
private int |
y
Y-coordinate in a graph. |
Constructor Summary | |
---|---|
Vertex(double lon,
double lat,
int x,
int y,
boolean available,
Vertex nullVertex)
Constructor. |
Method Summary | |
---|---|
double |
calculateDir(Vertex goal)
Calculates the angle between this and a certain Vertex. |
double |
calculateDirCost(Vertex dirStart,
double rightDir)
Compares the given double value with the direction from a given Vertex to this vertex. |
int |
compareTo(Vertex other)
Comparable interface needs this to find out which vertex is "better" for aStar method. |
double |
distanceTo(Vertex other)
Calculates the straight line distance to other vertex in the graph. |
Vertex |
getAdjacent(int direction)
Returns the adjacent Vertex of this Vertex in a certain direction. |
int |
getAdjacentNumber(Vertex vertex)
Returns the integer direction of follower vertex given in parameters. |
Vertex[] |
getAdjacents()
This method is used as a handle to the list of adjacent vertices. |
int |
getBestDir()
Returns the bestDir value of this Vertex. |
double |
getDistCost()
Returns the distCost of this Vertex. |
double |
getGCost()
Returns the gCost of this Vertex. |
double |
getHCost()
Returns the hCost of this vertex. |
double |
getLat()
Returns the latitude coordinate of this Vertex. |
double |
getLon()
Returns the longitude coordinate of this Vertex. |
Vertex |
getParent()
Returns the parent of this Vertex. |
int |
getPathSafety()
Returns integer value telling on which path safety area this vertex is in. |
int |
getState()
Returns the state of this vertex. |
boolean |
getStorm()
Is this Vertex a storm Vertex? |
boolean |
getStormSafety()
Returns true if this vertex is in storm safety area. |
int |
getX()
Returns the X-coordinate of this Vertex. |
int |
getY()
Returns the Y-coordinate of this Vertex. |
double |
graphDistanceTo(Vertex other)
Calculates the distance to other vertex in a Graph. |
boolean |
isAvailable()
Is this Vertex is available for aStar? |
void |
reset()
Resets fields that aStar method uses. |
void |
setAdjacent(int direction,
Vertex other)
Adds a vertex to the adjacent list. |
void |
setAvailable(boolean value)
Sets new boolean value for available field. |
void |
setBestDir(boolean value)
Sets a new BestDir value to this Vertex. |
void |
setDistCost(Vertex goal)
Sets the distCost of this Vertex. |
void |
setGCost(double newCost)
Sets a new gCost to this Vertex. |
void |
setHCost(Vertex goal)
Sets a new hCost to this Vertex. |
void |
setParent(Vertex newParent)
Sets a new parent to this Vertex. |
void |
setPathSafety(int isPathSafety)
Sets this.pathSafety to be as parameter value. |
void |
setState(int newState)
Sets new state to this vertex. |
void |
setStorm(boolean value)
Marks this Vertex to be a storm Vertex. |
void |
setStormSafety(boolean isStormSafety)
Sets parameter value to be value of this.stormSafety. |
java.lang.String |
toString()
Returns representation of x- and y-coordinates of this Vertex. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private Vertex[] adj
private boolean available
private int bestDir
private double distCost
public static final int EAST
private double gCost
private double hCost
private final double lat
private final double lon
public static final int NORTH
public static final int NORTHEAST
public static final int NORTHWEST
public static final int ON_CLOSED_SET
public static final int ON_OPEN_SET
private Vertex parent
private int pathSafety
public static final int SOUTH
public static final int SOUTHEAST
public static final int SOUTHWEST
private int state
private boolean storm
private boolean stormSafety
public static final int UNVISITED
public static final int WEST
private final int x
private final int y
Constructor Detail |
---|
public Vertex(double lon, double lat, int x, int y, boolean available, Vertex nullVertex)
lon
- Longitude coordinatelat
- Latitude coordinatex
- X-coordinatey
- Y-coordinateavailable
- Is this Vertex available?nullVertex
- default adjacent VertexMethod Detail |
---|
public double calculateDir(Vertex goal)
goal
- given Vertex
public double calculateDirCost(Vertex dirStart, double rightDir)
dirStart
- Vertex from which the direction to this
Vertex is measuredrightDir
- double value with which the calculated
direction is compared
public final int compareTo(Vertex other)
compareTo
in interface java.lang.Comparable<Vertex>
other
- vertex to compare to.
public double distanceTo(Vertex other)
other
- the other vertex.
public Vertex getAdjacent(int direction)
direction
- tells which direction to return. public int getAdjacentNumber(Vertex vertex)
vertex
- possible follower
public Vertex[] getAdjacents()
public int getBestDir()
public double getDistCost()
public double getGCost()
public double getHCost()
public double getLat()
public double getLon()
public Vertex getParent()
public int getPathSafety()
public int getState()
public boolean getStorm()
public boolean getStormSafety()
public int getX()
public int getY()
public double graphDistanceTo(Vertex other)
other
- the other vertex
public boolean isAvailable()
public void reset()
public void setAdjacent(int direction, Vertex other)
direction
- direction where this new adjacent vertex is. 0 if it is in
north, 1 if in northeast, ... and 7 if in northwest.other
- the vertex to be added.
java.lang.IllegalArgumentException
- if direction is not between 0 and 7.public void setAvailable(boolean value)
value
- true if this vertex should be available, false if notpublic void setBestDir(boolean value)
value
- true if this vertex is in the best direction for aStar,
false if notpublic void setDistCost(Vertex goal)
goal
- goal vertex of aStarpublic void setGCost(double newCost)
newCost
- new gCostpublic void setHCost(Vertex goal)
goal
- the goal vertex of aStarpublic void setParent(Vertex newParent)
newParent
- new parentpublic void setPathSafety(int isPathSafety)
isPathSafety
- new pathSafety valuepublic void setState(int newState)
newState
- new state
java.lang.IllegalArgumentException
- if new state is not between 0 and 2public void setStorm(boolean value)
value
- true marks this to be a storm Vertex, false marks this
not to be a storm Vertex.public void setStormSafety(boolean isStormSafety)
isStormSafety
- new stormSafety valuepublic java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |