org.jscience.computing.ai
Class AStarMap

java.lang.Object
  extended by org.jscience.computing.ai.util.StandardMap2D
      extended by org.jscience.computing.ai.AStarMap
All Implemented Interfaces:
Navigable, Visualizable

public class AStarMap
extends StandardMap2D

AStarMap is simply derived from StandardMap2D to provide further functionality to visualize the A algorithm. It displays the map, start/goal positions, the best route as well as open and closed lists.


Field Summary
protected  AStarPathfinder aStar
          The pathfinder (used for drawing the routes).
protected  Gradient closedGradient
          The closed list gradient (blue).
protected  int gx
          Goal x-position.
protected  int gy
          Goal y-position.
protected  Gradient openGradient
          The open list gradient (red).
protected  int sx
          Start x-position.
protected  int sy
          Start y-position.
 
Fields inherited from class org.jscience.computing.ai.util.StandardMap2D
height, mapValues, renderSize, width
 
Constructor Summary
AStarMap()
          Creates a new instance of AStarMap
AStarMap(java.awt.image.BufferedImage img)
          Creates a new instance from a BufferedImage.
AStarMap(int width, int height)
          Creates a new instance with dimensional information.
 
Method Summary
 AStarPathfinder getPathfinder()
          Return the pathfinder being used.
 void render(java.awt.Graphics g, int ww, int hh)
          Render the map.
 void setPathfinder(AStarPathfinder as)
          Set the pathfinder to display.
 
Methods inherited from class org.jscience.computing.ai.util.StandardMap2D
createNodeID, getCost, getDistance, getHeight, getRenderSize, getWidth, isValid, isValid, setMapAt, setRenderSize, writeImage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sx

protected int sx
Start x-position.


sy

protected int sy
Start y-position.


gx

protected int gx
Goal x-position.


gy

protected int gy
Goal y-position.


openGradient

protected Gradient openGradient
The open list gradient (red).


closedGradient

protected Gradient closedGradient
The closed list gradient (blue).


aStar

protected AStarPathfinder aStar
The pathfinder (used for drawing the routes).

Constructor Detail

AStarMap

public AStarMap()
Creates a new instance of AStarMap


AStarMap

public AStarMap(int width,
                int height)
Creates a new instance with dimensional information.

Parameters:
width - the width of the map.
height - the height of the map.

AStarMap

public AStarMap(java.awt.image.BufferedImage img)
Creates a new instance from a BufferedImage.

Parameters:
img - the image to be used as the map values.
Method Detail

setPathfinder

public void setPathfinder(AStarPathfinder as)
Set the pathfinder to display.

Parameters:
as - the pathfinder to display.

getPathfinder

public AStarPathfinder getPathfinder()
Return the pathfinder being used.

Returns:
the pathfinder.

render

public void render(java.awt.Graphics g,
                   int ww,
                   int hh)
Render the map.

Specified by:
render in interface Visualizable
Overrides:
render in class StandardMap2D
Parameters:
g - the graphics context.
ww - the content width.
hh - the context height.
See Also:
StandardMap2D.render(java.awt.Graphics, int,int)