|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.generation5.util.StandardMap2D
Implements a standard 2D map. For efficiency purposes, distance is implemented as Manhattan distance. Map values are specified between 0 and 255 (rendered as black to white). A position on the map is valid if the map value is less than 32. Cost is determined as (255 - map_value) + 1, although a small additional bias is added if the movement is diagonal.
| Field Summary | |
protected int |
height
The height of the map. |
protected int[][] |
mapValues
The value of the map. |
protected int |
renderSize
The render size of the map. |
protected int |
width
The width of the map. |
| Constructor Summary | |
StandardMap2D()
Creates a new instance of Map2D |
|
StandardMap2D(int width,
int height)
Create a new instance of StandardMap2D with dimensional information. |
|
| Method Summary | |
int |
createNodeID(Pathfinder.Node node)
Create the node ID from positional information. |
double |
getCost(Pathfinder.Node parent,
Pathfinder.Node node)
Return the cost to travel from node 1 to node 2. |
double |
getDistance(Pathfinder.Node goal,
Pathfinder.Node node)
Return the distance between the node 1 and node 2. |
int |
getHeight()
Return the height of the map. |
int |
getRenderSize()
Return the render size of the map. |
int |
getWidth()
Return the width of the map. |
boolean |
isValid(int x,
int y)
|
boolean |
isValid(Pathfinder.Node node)
Determines whether the given node is valid. |
void |
render(java.awt.Graphics g,
int ww,
int hh)
Render the map. |
void |
setMapAt(int x,
int y,
int value)
Set the map at the given location with the given value. |
void |
setRenderSize(int rs)
Set the render size of the map. |
void |
writeImage(java.lang.String s,
int width,
int height)
Write an image of the map. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int renderSize
protected int width
protected int height
protected int[][] mapValues
| Constructor Detail |
public StandardMap2D()
public StandardMap2D(int width,
int height)
width - the width of the map.height - the height of the map.| Method Detail |
public int getWidth()
public int getHeight()
public int getRenderSize()
public void setRenderSize(int rs)
rs - the new render size.
public void setMapAt(int x,
int y,
int value)
x - the x-position.y - the y-position.value - the new map value.public int createNodeID(Pathfinder.Node node)
node.getX() * width + node.getY()
createNodeID in interface Navigablenode - the node to calculate.
public double getCost(Pathfinder.Node parent,
Pathfinder.Node node)
Navigable
getCost in interface Navigableparent - the first node.node - the second node.
public double getDistance(Pathfinder.Node goal,
Pathfinder.Node node)
Navigable
getDistance in interface Navigablegoal - the first node.node - the second node.
public boolean isValid(int x,
int y)
public boolean isValid(Pathfinder.Node node)
Navigable
isValid in interface Navigablenode - the node.
public void render(java.awt.Graphics g,
int ww,
int hh)
render in interface Visualizableg - the graphics context.ww - the width of the context.hh - the height of the context.
public void writeImage(java.lang.String s,
int width,
int height)
writeImage in interface Visualizables - the filename.width - the width of the image.height - the height of the image.
|
This documentation is part of the Generation5 JDK.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||