movement.map
Class MapNode

java.lang.Object
  extended by movement.map.MapNode
All Implemented Interfaces:
java.lang.Comparable<MapNode>

public class MapNode
extends java.lang.Object
implements java.lang.Comparable<MapNode>

A node in a SimMap. Node has a location, 0-n neighbors that it is connected to and possibly a type identifier.


Field Summary
static int MAX_TYPE
          Biggest valid type of a node: 31
static int MIN_TYPE
          Smallest valid type of a node: 1
 
Constructor Summary
MapNode(Coord location)
          Constructor.
 
Method Summary
 void addNeighbor(MapNode node)
          Adds the node as this node's neighbour (unless the node is null)
 void addType(int type)
          Adds a type indicator to this node
 int compareTo(MapNode o)
          Compares two map nodes by their coordinates
 Coord getLocation()
          Returns the location of the node
 java.util.List<MapNode> getNeighbors()
          Returns the neighbors of this node.
 boolean isType(int type)
          Returns true if this node is of given type, false if none of node's type(s) match to given type or node doesn't have type at all
 boolean isType(int[] types)
          Returns true if the node's types match any of the given types
 java.lang.String toString()
          Returns a String representation of the map node
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_TYPE

public static final int MIN_TYPE
Smallest valid type of a node: 1

See Also:
Constant Field Values

MAX_TYPE

public static final int MAX_TYPE
Biggest valid type of a node: 31

See Also:
Constant Field Values
Constructor Detail

MapNode

public MapNode(Coord location)
Constructor. Creates a map node to a location.

Parameters:
location - The location of the node.
Method Detail

addType

public void addType(int type)
Adds a type indicator to this node

Parameters:
type - An integer from range [1, 31]

isType

public boolean isType(int type)
Returns true if this node is of given type, false if none of node's type(s) match to given type or node doesn't have type at all

Parameters:
type - The type (integer from range [1, 31])
Returns:
True if this node is of given type

isType

public boolean isType(int[] types)
Returns true if the node's types match any of the given types

Parameters:
types - The types to check (array of values in range [1, 31])
Returns:
True if at least one of the types matched, false if none of the types matched
See Also:
isType(int)

addNeighbor

public void addNeighbor(MapNode node)
Adds the node as this node's neighbour (unless the node is null)

Parameters:
node - The node to add or null for no action

getLocation

public Coord getLocation()
Returns the location of the node

Returns:
the location of the node

getNeighbors

public java.util.List<MapNode> getNeighbors()
Returns the neighbors of this node.

Returns:
the neighbors in a list

toString

public java.lang.String toString()
Returns a String representation of the map node

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the map node

compareTo

public int compareTo(MapNode o)
Compares two map nodes by their coordinates

Specified by:
compareTo in interface java.lang.Comparable<MapNode>
Parameters:
o - The other MapNode