|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--gecco.server.automaton.AutomatonMap
This class manages the map of automatons. It can create a map given an image.
| Field Summary | |
private Class |
automatonClass
Description of the Field |
byte[] |
initialMapRGB
The size of this array is 3*xsize*ysize. |
Automaton[][] |
theMap
The map |
private int |
xBound
Description of the Field |
private int |
yBound
Description of the Field |
| Constructor Summary | |
AutomatonMap(Class _automatonClass,
int x,
int y)
Constructor for the AutomatonMap object |
|
AutomatonMap(Class _automatonClass,
int x,
int y,
byte[] map,
HashMap colorToState)
Constructor for the AutomatonMap object |
|
AutomatonMap(Class _automatonClass,
int x,
int y,
Image map,
HashMap colorToState)
Constructor for the AutomatonMap object |
|
AutomatonMap(Class _automatonClass,
int x,
int y,
Reader map)
Constructor for the AutomatonMap object |
|
AutomatonMap(Class _automatonClass,
int x,
int y,
String imageFileName,
HashMap colorToState)
Constructor for the AutomatonMap object |
|
AutomatonMap(Class _automatonClass,
int x,
int y,
URL map,
HashMap colorToState)
Constructor for the AutomatonMap object |
|
| Method Summary | |
boolean |
areValidCoordinates(int x,
int y)
Returns true if the given coordinates exist on the map. |
private int |
calculateDistance(Color c1,
Color c2)
Calculates the distance between two colors. |
Automaton |
getAutomaton(int x,
int y)
Gets an automaton at a given location. |
byte[] |
getInitialMap()
Gets the InitialMap attribute of the AutomatonMap object |
protected Color |
getNearestColor(HashMap colorToState,
Color color)
Gets the nearest color that exists on the map, given a certain color. |
int[][] |
getNeighbourStates(int centerX,
int centerY)
Gets the states of the automatons at a 3x3 region around a given location. |
private Automaton |
getNewAutomaton(int initialState)
Allocates a new automaton. |
int |
getXBound()
Gets the XBound attribute of the AutomatonMap object |
int |
getYBound()
Gets the YBound attribute of the AutomatonMap object |
protected void |
initMap(Image map,
HashMap colorToState)
Allocates all automatons on the map. |
protected void |
initMap(String map)
Allocates all automatons on the map. |
void |
setImage(byte[] map,
HashMap colorToState)
Sets the Image attribute of the AutomatonMap object |
void |
setImage(Image map,
HashMap colorToState)
Sets the Image attribute of the AutomatonMap object |
void |
setImage(Reader stream)
Sets the Image attribute of the AutomatonMap object, by reading characters from a stream. |
void |
setImage(String imageFileName,
HashMap colorToState)
Sets the Image attribute of the AutomatonMap object |
void |
setImage(URL mapURL,
HashMap colorToState)
Sets the Image attribute of the AutomatonMap object |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
public Automaton[][] theMap
public byte[] initialMapRGB
private Class automatonClass
private int xBound
private int yBound
| Constructor Detail |
public AutomatonMap(Class _automatonClass,
int x,
int y)
x - The width of the map.y - The height of the map._automatonClass - The implemented automaton class.
public AutomatonMap(Class _automatonClass,
int x,
int y,
URL map,
HashMap colorToState)
x - The width of the map.y - The height of the map.map - The map image.colorToState - The color conversion function._automatonClass - The implemented automaton class.
public AutomatonMap(Class _automatonClass,
int x,
int y,
Image map,
HashMap colorToState)
x - The width of the map.y - The height of the map.map - The map image.colorToState - The color conversion function._automatonClass - The implemented automaton class.
public AutomatonMap(Class _automatonClass,
int x,
int y,
Reader map)
x - The width of the map.y - The height of the map.map - The map image._automatonClass - The implemented automaton class.
public AutomatonMap(Class _automatonClass,
int x,
int y,
byte[] map,
HashMap colorToState)
x - The width of the map.y - The height of the map.map - The map image.colorToState - The color conversion function._automatonClass - The implemented automaton class.
public AutomatonMap(Class _automatonClass,
int x,
int y,
String imageFileName,
HashMap colorToState)
x - The width of the map.y - The height of the map.imageFileName - The map image.colorToState - The color conversion function._automatonClass - The implemented automaton class.| Method Detail |
public void setImage(URL mapURL,
HashMap colorToState)
mapURL - The new Image valuecolorToState - The color conversion function.
public void setImage(Image map,
HashMap colorToState)
map - The new Image valuecolorToState - The color conversion function.
public void setImage(byte[] map,
HashMap colorToState)
map - The new Image valuecolorToState - The color conversion function.
public void setImage(String imageFileName,
HashMap colorToState)
imageFileName - The new Image valuecolorToState - The color conversion function.public void setImage(Reader stream)
stream - The stream to get characters frompublic byte[] getInitialMap()
public Automaton getAutomaton(int x,
int y)
throws IllegalArgumentException
x - The x coordinate.y - The y coordinate.IllegalArgumentException - if the location does not exist.
public int[][] getNeighbourStates(int centerX,
int centerY)
centerX - The x coordinate of the center automaton.centerY - The x coordinate of the center automaton.public int getXBound()
public int getYBound()
public boolean areValidCoordinates(int x,
int y)
x - The x coordinate to check.y - The x coordinate to check.
protected Color getNearestColor(HashMap colorToState,
Color color)
colorToState - The color conversion function.color - The color to check.
protected void initMap(Image map,
HashMap colorToState)
map - The map image.colorToState - The color conversion function.protected void initMap(String map)
map - The map.private Automaton getNewAutomaton(int initialState)
initialState - The initial state of the automaton.
private int calculateDistance(Color c1,
Color c2)
c1 - The first color.c2 - The second color.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||