|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--cad.simcad.maps.CellMap
implementing class for the AbstractMap interface This class is abstract This class family is PathFindable, that is we can find a path on it This implementation represents a point on the Map with a Cell Object
Field Summary | |
protected java.util.Vector |
_abstractMapEventListeners
|
protected MapUnit[] |
_art
|
protected Cell[][] |
_cell
The array of cells making up the map |
protected Cell[] |
_cex
|
protected PathPlace[] |
_cgex
|
protected FillerServer |
_fillerServer
|
protected int |
_h
height of the map |
protected int |
_heurFactor
|
protected int |
_mapResolution
resolution of the map. 1 or higher. |
protected java.lang.String |
_name
The Name of the Map |
protected java.lang.Object[][] |
_objects
|
protected java.util.Vector |
_pathPlaceEventListeners
|
protected java.util.Vector |
_regions
|
protected StatServer |
_statServer
|
protected int |
_w
width of the map |
Constructor Summary | |
CellMap(int w,
int h,
int res,
FillerServer fs,
StatServer ss)
Creates new CellMap Initialize the array of cells. w*h cell objects are created A FillerServer that will be used to fill the Cell objects The map cells are filled with the DefaultFiller of this FillerServer A StatServer that will return movemodifiers |
Method Summary | |
void |
addAbstractMapListener(AbstractMapEventListener listener)
|
void |
addPathPlaceEventListener(PathPlaceEventListener listener)
|
abstract boolean |
areAdjacent(MapUnit mu1,
MapUnit mu2)
|
void |
clearAll()
Clear all Map Cells. |
abstract double |
computeHeuristic(PathPlace origin,
PathPlace dest)
Compute the heuristic for the two PathPlace s. |
abstract double |
computeHeuristic(PathPlace origin,
PathPlace dest,
double factor)
Compute the heuristic for the two PathPlaces |
PathPlaceSet |
fastFindShortestPath(PathPlace origin,
PathPlace dest,
PathUser pu)
Find the best Path with a productive algorithm |
void |
fillMap(Filler fil,
int layer)
Filler the whole map with the given filler |
PathPlaceSet |
findShortestPath(PathPlace origin,
PathPlace dest,
PathUser pu)
Find the best Path |
PathPlaceSet |
findShortestPath(PathPlace origin,
PathPlace dest,
PathUser pu,
java.util.Properties ap)
Find the best Path |
void |
firePathComputation(PathPlaceSet path)
Notice the Listeners and the PathUser that a Path has been computed |
void |
firePathPlaceChange(PathPlace mp)
Notify all map Place listeners that the state of a cell has changed PRE : A Cell. |
void |
flushAllObjects()
|
protected void |
generateBlankMap(int w,
int h,
Filler fil)
Need |
java.util.Vector |
getAbstractMapListener()
Returns the vector of AbstractMapListener |
abstract Cell[] |
getAdjacent(Cell c)
|
abstract CellGroup[] |
getAdjacent(CellGroup cg)
This method typically returns an array cells adjacent to the cell given in argument. |
PathPlace[] |
getAdjacent(PathPlace pp)
Returns the PathPlace adjacent to the given PathPlace |
abstract MapUnit[] |
getAdjacentUnits(MapUnit mu)
|
abstract MapUnit[] |
getAdjacentUnits(MapUnit[] mu)
|
MapUnit[][] |
getAllMapUnits()
Return as a double Array all the MapUnits making the Map at coordinate z=0 |
Cell |
getCell(int x,
int y)
Return Cell of absisse X and coordinate y |
double |
getCostToReach(PathPlace from,
PathPlace to,
PathUser pu)
PRE: Two adjacent PathPlace |
Filler |
getDefaultFiller()
|
FillerServer |
getFillerServer()
Returns the FillerServer of the Map |
Filler[] |
getFillerTypes()
|
int |
getMapHeight()
|
abstract java.lang.Object[][] |
getMapObjects(int xcenter,
int ycenter,
int halfWidth,
int halfHeight)
Return a window of Objects around the (xcenter,ycenter) point. |
int |
getMapResolution()
|
MapUnit |
getMapUnit(int xfactor,
int yfactor)
Return the MapUnit by the coordinate x and y. |
abstract MapUnit[][] |
getMapUnit(int xcenter,
int ycenter,
int halfWidth,
int halfHeight)
This method is abstract because you need specific knowledge of the map |
int |
getMapWidth()
|
double |
getMoveStat(PathUser pu,
Filler fil,
double steepratio)
|
java.lang.String |
getName()
Returns the name of the Map |
java.lang.Object |
getObject(int x,
int y)
Return the object on the x,y point, null if there no objects |
java.lang.Object[][] |
getObjects()
|
java.util.Vector |
getPathPlaceEventListeners()
Returns the vector of PathPlaceEventListeners |
int |
getResolution()
Return the resolution of the Map. |
StatServer |
getStatServer()
Returns the StatServer of the Map |
double |
getSteepRatio(int from,
int to)
|
double |
getSteepRatio(MapUnit from,
MapUnit to)
Returns the steepness of the slope as a percentage It is rounded down. |
int |
getXFactor()
Return the X factor of the Map, usually it is the width |
int |
getYFactor()
Return the Y factor of the Map, usually it is the height |
int |
getZFactor()
Return the Z factor of the Map. |
abstract boolean |
isThereRoom(int x,
int y,
int xWidth,
int yHeight)
Return true if there is no object in the range specified by the parameters. false if there is one |
void |
populateMap(Filler fil)
Populate the Map with the given Filler |
void |
removeAbstractMapListener(AbstractMapEventListener listener)
Removes the AbstractMapEventListener |
void |
removeAllListeners()
Removes all listeners, usually used for serialization |
void |
removePathPlaceEventListener(PathPlaceEventListener listener)
Removes the PathPlaceEventListener |
void |
resetAllCells()
Reset all Map Cells. |
void |
resetAllCellsValue()
Reset all the cell values |
void |
resetAllUnits()
Remove all objects from the Map |
void |
setHeuristicFactor(int i)
Set the heuristic factor for this map. |
void |
setName(java.lang.String name)
|
void |
setObject(java.lang.Object obj,
int x,
int y)
Put an object at the specified position |
void |
setValue(PathPlace pp,
double value)
Delegates the work of tagging the given PathPlace with a double value |
abstract java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected int _w
protected int _h
protected int _mapResolution
protected Cell[][] _cell
protected java.lang.Object[][] _objects
protected java.lang.String _name
protected java.util.Vector _abstractMapEventListeners
protected java.util.Vector _pathPlaceEventListeners
protected FillerServer _fillerServer
protected StatServer _statServer
protected MapUnit[] _art
protected Cell[] _cex
protected PathPlace[] _cgex
protected int _heurFactor
protected java.util.Vector _regions
Constructor Detail |
public CellMap(int w, int h, int res, FillerServer fs, StatServer ss)
Method Detail |
public abstract double computeHeuristic(PathPlace origin, PathPlace dest, double factor)
AbstractMap
computeHeuristic
in interface AbstractMap
origin
- The PathPlace origin from which we want to compute the heuristicdest
- The PathPlace origin from which we want to compute the heuristicfactor
- the factor by which we want to multiply the heuristic. Typically, more the factor is high, more we want to give weight to the heuristic
public abstract double computeHeuristic(PathPlace origin, PathPlace dest)
AbstractMap
PathPlace
s. Use the built-in heuristic factor. This factor can be change with the setHeuristicFactor
method
computeHeuristic
in interface AbstractMap
origin
- The PathPlace origin from which we want to compute the heuristicdest
- The PathPlace origin from which we want to compute the heuristic
public abstract CellGroup[] getAdjacent(CellGroup cg)
public abstract Cell[] getAdjacent(Cell c)
public abstract MapUnit[] getAdjacentUnits(MapUnit mu)
public abstract MapUnit[] getAdjacentUnits(MapUnit[] mu)
public abstract boolean areAdjacent(MapUnit mu1, MapUnit mu2)
public void resetAllUnits()
resetAllUnits
in interface AbstractMap
public void populateMap(Filler fil)
AbstractMap
populateMap
in interface AbstractMap
fil
- The Fillerpublic PathPlace[] getAdjacent(PathPlace pp)
PathFindable
getAdjacent
in interface PathFindable
pp
- the PathPlace
public abstract java.lang.String toString()
toString
in class java.lang.Object
public abstract MapUnit[][] getMapUnit(int xcenter, int ycenter, int halfWidth, int halfHeight)
getMapUnit
in interface AbstractMap
xcenter
- x coordinateycenter
- y coordinatehalfWidth
- the number of MapUnit we want to include.halfHeight
- the number of MapUnit we want to includepublic void setValue(PathPlace pp, double value)
PathFindable
setValue
in interface PathFindable
value
- pp
- public int getXFactor()
AbstractMap
getXFactor
in interface AbstractMap
public int getYFactor()
AbstractMap
getYFactor
in interface AbstractMap
public int getZFactor()
AbstractMap
getZFactor
in interface AbstractMap
public MapUnit getMapUnit(int xfactor, int yfactor)
AbstractMap
getMapUnit
in interface AbstractMap
yfactor
- y coordinatexfactor
- x coordinateMapUnit
public MapUnit[][] getAllMapUnits()
AbstractMap
getAllMapUnits
in interface AbstractMap
protected void generateBlankMap(int w, int h, Filler fil)
public double getSteepRatio(MapUnit from, MapUnit to)
public double getSteepRatio(int from, int to)
public double getMoveStat(PathUser pu, Filler fil, double steepratio)
public Filler getDefaultFiller()
public Filler[] getFillerTypes()
public int getMapResolution()
public int getResolution()
AbstractMap
getResolution
in interface AbstractMap
public StatServer getStatServer()
AbstractMap
getStatServer
in interface AbstractMap
public FillerServer getFillerServer()
AbstractMap
getFillerServer
in interface AbstractMap
public int getMapWidth()
public int getMapHeight()
public Cell getCell(int x, int y)
public void fillMap(Filler fil, int layer)
public PathPlaceSet findShortestPath(PathPlace origin, PathPlace dest, PathUser pu)
AbstractMap
findShortestPath
in interface AbstractMap
origin
- The Origin of the Pathdest
- The destination of the Pathpu
- The PathUser that will use the Path
PathPlaceSet
object. The set of PathPlace
s that make up the best Path for that PathUser
public PathPlaceSet findShortestPath(PathPlace origin, PathPlace dest, PathUser pu, java.util.Properties ap)
AbstractMap
findShortestPath
in interface AbstractMap
origin
- The Origin of the Pathdest
- The destination of the Pathpu
- The PathUser that will use the Pathap
- The properties relative to the Algorithm
PathPlaceSet
object. The set of PathPlace
s that make up the best Path for that PathUser
public void clearAll()
public void resetAllCells()
public void resetAllCellsValue()
resetAllCellsValue
in interface AbstractMap
public void setHeuristicFactor(int i)
AbstractMap
setHeuristicFactor
in interface AbstractMap
i
- the heuristic factorpublic void addAbstractMapListener(AbstractMapEventListener listener)
addAbstractMapListener
in interface AbstractMap
public void removeAbstractMapListener(AbstractMapEventListener listener)
AbstractMap
removeAbstractMapListener
in interface AbstractMap
public void firePathComputation(PathPlaceSet path)
firePathComputation
in interface AbstractMap
path
- The computed PathPlaceSet
public void addPathPlaceEventListener(PathPlaceEventListener listener)
addPathPlaceEventListener
in interface AbstractMap
public void removePathPlaceEventListener(PathPlaceEventListener listener)
AbstractMap
removePathPlaceEventListener
in interface AbstractMap
public void firePathPlaceChange(PathPlace mp)
firePathPlaceChange
in interface AbstractMap
mp
- The PathPlace that has been modifiedpublic java.lang.Object[][] getObjects()
public double getCostToReach(PathPlace from, PathPlace to, PathUser pu)
getCostToReach
in interface AbstractMap
from
- The originto
- the destinationpu
- The PathUser
public java.lang.String getName()
AbstractMap
getName
in interface AbstractMap
public void setName(java.lang.String name)
public abstract java.lang.Object[][] getMapObjects(int xcenter, int ycenter, int halfWidth, int halfHeight)
AbstractMap
getMapObjects
in interface AbstractMap
xcenter
- x coordinateycenter
- y coordinatehalfWidth
- the number of Objects we want to include.halfHeight
- the number of Objects we want to include
public void setObject(java.lang.Object obj, int x, int y)
AbstractMap
setObject
in interface AbstractMap
obj
- The object to putx
- x coordinatey
- y coordinatepublic java.lang.Object getObject(int x, int y)
getObject
in interface AbstractMap
x
- x coordinatey
- y coordinate
public abstract boolean isThereRoom(int x, int y, int xWidth, int yHeight)
AbstractMap
isThereRoom
in interface AbstractMap
x
- x coordinatey
- y coordinatexWidth
- length in width of the ObjectyHeight
- length in height of the Object
public void flushAllObjects()
public void removeAllListeners()
AbstractMap
removeAllListeners
in interface AbstractMap
public PathPlaceSet fastFindShortestPath(PathPlace origin, PathPlace dest, PathUser pu)
AbstractMap
fastFindShortestPath
in interface AbstractMap
origin
- The Origin of the Pathdest
- The destination of the Pathpu
- The PathUser that will use the Path
PathPlaceSet
object. The set of PathPlace
s that make up the best Path for that PathUser
public java.util.Vector getPathPlaceEventListeners()
AbstractMap
getPathPlaceEventListeners
in interface AbstractMap
public java.util.Vector getAbstractMapListener()
AbstractMap
getAbstractMapListener
in interface AbstractMap
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |