Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## path
Class GridNode

    java.lang.Object
      path.AStarNode
          path.GridNode

All Implemented Interfaces:
  java.io.Serializable, java.lang.Comparable

    public class GridNode

extends AStarNode

Node that represents a square in the walkable area grid. This node is then used for A* path finding.

Author:
  Frank Bruns
See Also:
  Serialized Form

Constructor Summary
`GridNode(double x, double y, int width, int height)` Creates a new grid node with the specified parameters

Method Summary
`void` | `addNeighbor(GridNode node)` Adds a neighbour to the list of neighbours of this grid node
`boolean` | `containsPoint(double x, double y)` Checks, if the specified coordinates lay in this grid node's bounds
`float` | `getCost(AStarNode node)` Gets the cost between this node and the specified adjacent (aka "neighbor" or "child") node.
`float` | `getEstimatedCost(AStarNode node)` Gets the estimated cost between this node and the specified node.
`int` | `getHeight()` Returns the height of the grid node
`double` | `getMidX()` Returns the x coordinate of the center point of the grid node
`double` | `getMidY()` Returns the y coordinate of the center point of the grid node
`java.util.List<GridNode>` | `getNeighbors()` Gets the children (aka "neighbors" or "adjacent nodes") of this node.
`int` | `getWidth()` Returns the width of the grid node
`double` | `getX()` Returns the x coordinate of the grid node
`double` | `getY()` Returns the y coordinate of the grid node
`boolean` | `isNeighbor(GridNode node)` Determines whether the grid node is a neighbour of the specified node.
`boolean` | `isWalkable()` Determines whether the grid node is walkable
`void` | `setWalkable(boolean walkable)` Sets the walkable status for the grid node

Methods inherited from class path.AStarNode
`compareTo, getCost, sign`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### GridNode

    public GridNode(double x,
                    double y,
                    int width,
                    int height)

  Creates a new grid node with the specified parameters

  Parameters:
    `x` - x coordinate of the grid node
    `y` - y coordinate of the grid node
    `width` - width of the grid node
    `height` - height of the grid node

Method Detail

### setWalkable

    public void setWalkable(boolean walkable)

  Sets the walkable status for the grid node

  Parameters:
    `walkable` - set walkable? --> true=yes, false=no

### getMidX

    public double getMidX()

  Returns the x coordinate of the center point of the grid node

  Returns:
    center point's x coordinate

### getMidY

    public double getMidY()

  Returns the y coordinate of the center point of the grid node

  Returns:
    center point's y coordinate

### containsPoint

    public boolean containsPoint(double x,
                                 double y)

  Checks, if the specified coordinates lay in this grid node's bounds

  Parameters:
    `x` - x coordinates
    `y` - y coordinates
  Returns:
    are coordinates within grid node's bounds? --> true=yes, false=no

### isNeighbor

    public boolean isNeighbor(GridNode node)

  Determines whether the grid node is a neighbour of the specified node.

  Parameters:
    `node` - node to check, if naighbour
  Returns:
    is neighbour? --> true=yes, false=no

### getHeight

    public int getHeight()

  Returns the height of the grid node

  Returns:
    height of the grid node

### getWidth

    public int getWidth()

  Returns the width of the grid node

  Returns:
    width of the grid node

### getX

    public double getX()

  Returns the x coordinate of the grid node

  Returns:
    x coordinate of the grid node

### getY

    public double getY()

  Returns the y coordinate of the grid node

  Returns:
    y coordinate of the grid node

### isWalkable

    public boolean isWalkable()

  Determines whether the grid node is walkable

  Returns:
    is grid node walkable? --> true=yes, false=no

### addNeighbor

    public void addNeighbor(GridNode node)

  Adds a neighbour to the list of neighbours of this grid node

  Parameters:
    `node` - grid node neighbour node to add

### getCost

    public float getCost(AStarNode node)

  Description copied from class: `AStarNode`
  Gets the cost between this node and the specified adjacent (aka "neighbor" or "child") node.

  Specified by:
    `getCost` in class `AStarNode`

### getEstimatedCost

    public float getEstimatedCost(AStarNode node)

  Description copied from class: `AStarNode`
  Gets the estimated cost between this node and the specified node. The estimated cost should never exceed the true cost. The better the estimate, the more effecient the search.

  Specified by:
    `getEstimatedCost` in class `AStarNode`

### getNeighbors

    public java.util.List<GridNode> getNeighbors()

  Description copied from class: `AStarNode`
  Gets the children (aka "neighbors" or "adjacent nodes") of this node.

  Specified by:
    `getNeighbors` in class `AStarNode`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD