public class Node extends java.lang.Object implements BoardElement
| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
name
The name of this node.
|
COLOR_TOKEN, DESTINATION_TOKEN, LENGTH_TOKEN, LOCATION_TOKEN, NAME_TOKEN, X_TOKEN, Y_TOKEN| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object n)
Return true iff n is a Node and is equal to this one.
|
Board |
getBoard()
Return the board on which this Node belongs.
|
Circle |
getCircle()
Return the Circle that represents this node graphically.
|
java.awt.Color |
getColor()
Return the color of this Node.
|
Edge |
getConnect(Node other)
Return the road that this node shares with node other (null if not connected).
|
java.util.HashSet<Edge> |
getExits()
Return a copy of the set of edges leaving this node.
|
int |
getExitsSize()
Return the number of exits from this node.
|
java.lang.String |
getMappedName()
Return the string that is mapped when this Node is drawn.
|
java.util.HashMap<Node,java.lang.Integer> |
getNeighbors()
Return a map of neighboring nodes to the lengths of the edges connecting
them to this Node.
|
java.util.HashSet<Parcel> |
getParcels()
Return a copy of set of parcels on this Node (prevents editing the set)
|
Edge |
getRandomExit()
Return a random edge from leaving this node (its exists)
|
Parcel |
getRandomParcel()
Return a random parcel at this node.
|
int |
getRelativeX()
Return the x location that this Node's string is mapped to
relative to its top right coordinate.
|
int |
getRelativeY()
Return the y location that this Node's string is mapped to
relative to its top right coordinate.
|
java.lang.Object |
getUserData()
Return the userData stored in this Node.
|
int |
hashCode()
Return the hashCode of this node.
|
boolean |
isColorSignificant()
Return false - the color of Nodes is not significant
|
boolean |
isConnectedTo(Node destination)
Return false if destination.equals(this).
|
boolean |
isExit(Edge r)
Return true iff r is connected to this Node.
|
boolean |
isParcelHere()
Return true iff there is at least one parcel on this node
|
boolean |
isParcelHere(Parcel p)
Return true iff p is on this node.
|
boolean |
isTruckHere(Truck t)
Return true iff t is currently at this node.
|
boolean |
isTruckTravelingHere()
Return true iff some truck is traveling toward this node.
|
void |
setCircle(Circle c)
Set the Circle for this Node to c.
|
void |
setUserData(java.lang.Object uData)
Set the value of userData to uData.
|
java.lang.String |
toJSONString()
Return just this' name for the JSONString - relies on JSONs of Edges
and parcels to take care of themselves.
|
java.lang.String |
toString()
Return the name of this Node.
|
int |
trucksHere()
Return the number of trucks at this node.
|
void |
updateGUILocation(int x,
int y)
Update the circle graphic that represents this truck on the GUI.
|
public Board getBoard()
getBoard in interface BoardElementpublic java.util.HashSet<Edge> getExits()
public java.util.HashMap<Node,java.lang.Integer> getNeighbors()
public Edge getRandomExit()
public int getExitsSize()
public boolean isExit(Edge r)
public java.util.HashSet<Parcel> getParcels()
public Parcel getRandomParcel()
public boolean isParcelHere()
public boolean isParcelHere(Parcel p)
public boolean isConnectedTo(Node destination)
public Edge getConnect(Node other)
public java.lang.Object getUserData()
getUserData in interface UserDatapublic void setUserData(java.lang.Object uData)
setUserData in interface UserDatapublic Circle getCircle()
public void setCircle(Circle c)
public void updateGUILocation(int x,
int y)
updateGUILocation in interface BoardElementx - - the new X location of this Truck in the GUIy - - the new Y location of this Truck in the GUIpublic boolean equals(java.lang.Object n)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean isTruckHere(Truck t)
isTruckHere in interface BoardElementpublic int trucksHere()
trucksHere in interface BoardElementpublic boolean isTruckTravelingHere()
public java.awt.Color getColor()
public boolean isColorSignificant()
isColorSignificant in interface Colorablepublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getMappedName()
getMappedName in interface BoardElementpublic int getRelativeX()
getRelativeX in interface BoardElementpublic int getRelativeY()
getRelativeY in interface BoardElementpublic java.lang.String toJSONString()
toJSONString in interface org.json.JSONString