cad.simcad.maps
Class ClassicCellMap

java.lang.Object
  |
  +--cad.simcad.maps.CellMap
        |
        +--cad.simcad.maps.ClassicCellMap
All Implemented Interfaces:
AbstractMap, PathFindable, java.io.Serializable
Direct Known Subclasses:
ClassicCellMapNoDiag

public class ClassicCellMap
extends CellMap

Map where cells at the top and bottom of viewable portion are not adjacent Map where cells at the right and left of viewable portion are not adjacent Conclusion : It is a chessboard map

Version:
1.0
Author:
Charles-Philip Bentley
See Also:
Serialized Form

Field Summary
 
Fields inherited from class cad.simcad.maps.CellMap
_abstractMapEventListeners, _art, _cell, _cex, _cgex, _fillerServer, _h, _heurFactor, _mapResolution, _name, _objects, _pathPlaceEventListeners, _regions, _statServer, _w
 
Constructor Summary
ClassicCellMap(java.lang.Integer w, java.lang.Integer h, int res, FillerServer fs, StatServer ss)
          Creates new ClassicCellMap
ClassicCellMap(int w, int h, int res, FillerServer fs, StatServer ss)
          Creates new ClassicCellMap
 
Method Summary
 boolean areAdjacent(MapUnit mu1, MapUnit mu2)
           
 double computeHeuristic(PathPlace origin, PathPlace dest)
          calculates the heuristic for the Cell C The heuristic depends on the Map.
 double computeHeuristic(PathPlace origin, PathPlace dest, double factor)
          calculates the heuristic for the Cell C The heuristic depends on the Map.
 Cell[] getAdjacent(Cell c)
           
 CellGroup[] getAdjacent(CellGroup g)
          Returns every possible CellGroups adjacent to the CellGroup given in argument It depends of the resolution
 MapUnit[] getAdjacent(MapUnit c)
          Returns
 MapUnit[] getAdjacentUnits(MapUnit mu)
           
 MapUnit[] getAdjacentUnits(MapUnit[] mu)
           
 java.lang.Object[][] getMapObjects(int xcenter, int ycenter, int halfWidth, int halfHeight)
          Return a window of Objects around the (xcenter,ycenter) point.
 java.lang.Object[][] getMapObjectsFromRef(int x, int y, int width, int height)
           
 MapUnit[][] getMapUnit(int xcenter, int ycenter, int halfWidth, int halfHeight)
          This method is abstract because you need specific knowledge of the map
 MapUnit[][] getMapUnitsFromRef(int x, int y, int width, int height)
           
 java.lang.String getName()
          Returns the name of the Map
 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
 java.lang.String toString()
           
 
Methods inherited from class cad.simcad.maps.CellMap
addAbstractMapListener, addPathPlaceEventListener, clearAll, fastFindShortestPath, fillMap, findShortestPath, findShortestPath, firePathComputation, firePathPlaceChange, flushAllObjects, generateBlankMap, getAbstractMapListener, getAdjacent, getAllMapUnits, getCell, getCostToReach, getDefaultFiller, getFillerServer, getFillerTypes, getMapHeight, getMapResolution, getMapUnit, getMapWidth, getMoveStat, getObject, getObjects, getPathPlaceEventListeners, getResolution, getStatServer, getSteepRatio, getSteepRatio, getXFactor, getYFactor, getZFactor, populateMap, removeAbstractMapListener, removeAllListeners, removePathPlaceEventListener, resetAllCells, resetAllCellsValue, resetAllUnits, setHeuristicFactor, setName, setObject, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassicCellMap

public ClassicCellMap(int w,
                      int h,
                      int res,
                      FillerServer fs,
                      StatServer ss)
Creates new ClassicCellMap


ClassicCellMap

public ClassicCellMap(java.lang.Integer w,
                      java.lang.Integer h,
                      int res,
                      FillerServer fs,
                      StatServer ss)
Creates new ClassicCellMap

Method Detail

areAdjacent

public boolean areAdjacent(MapUnit mu1,
                           MapUnit mu2)
Specified by:
areAdjacent in class CellMap

getAdjacent

public MapUnit[] getAdjacent(MapUnit c)
Returns

Post:
An array of Cell. Can contains null

getAdjacent

public CellGroup[] getAdjacent(CellGroup g)
Returns every possible CellGroups adjacent to the CellGroup given in argument It depends of the resolution

Specified by:
getAdjacent in class CellMap

computeHeuristic

public double computeHeuristic(PathPlace origin,
                               PathPlace dest)
calculates the heuristic for the Cell C The heuristic depends on the Map. On a

Specified by:
computeHeuristic in interface AbstractMap
Specified by:
computeHeuristic in class CellMap
Parameters:
origin - The PathPlace origin from which we want to compute the heuristic
dest - The PathPlace origin from which we want to compute the heuristic
Returns:
a double value

computeHeuristic

public double computeHeuristic(PathPlace origin,
                               PathPlace dest,
                               double factor)
calculates the heuristic for the Cell C The heuristic depends on the Map. On a

Specified by:
computeHeuristic in interface AbstractMap
Specified by:
computeHeuristic in class CellMap
Parameters:
origin - The PathPlace origin from which we want to compute the heuristic
dest - The PathPlace origin from which we want to compute the heuristic
factor - 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
Returns:
a double value

toString

public java.lang.String toString()
Specified by:
toString in class CellMap

getName

public java.lang.String getName()
Description copied from interface: AbstractMap
Returns the name of the Map

Specified by:
getName in interface AbstractMap
Overrides:
getName in class CellMap

getAdjacentUnits

public MapUnit[] getAdjacentUnits(MapUnit mu)
Specified by:
getAdjacentUnits in class CellMap

getAdjacent

public Cell[] getAdjacent(Cell c)
Specified by:
getAdjacent in class CellMap

getAdjacentUnits

public MapUnit[] getAdjacentUnits(MapUnit[] mu)
Specified by:
getAdjacentUnits in class CellMap

getMapUnit

public MapUnit[][] getMapUnit(int xcenter,
                              int ycenter,
                              int halfWidth,
                              int halfHeight)
This method is abstract because you need specific knowledge of the map

Specified by:
getMapUnit in interface AbstractMap
Specified by:
getMapUnit in class CellMap
Parameters:
xcenter - x coordinate
ycenter - y coordinate
halfWidth - the number of MapUnit we want to include.
halfHeight - the number of MapUnit we want to include
Pre:
a point on the map (xcenter,ycenter), halfWidth = the number of units to consider north/south halfHeight = the number of units to consider west/east
Returns:
a double Array of MapUnits
Post:
the MapUnits contained in the range defined by the arguments On this toroidal map, this method will always return (halfHeight*2+1) * (halfWidth*2+1) MapUnits

getMapUnitsFromRef

public MapUnit[][] getMapUnitsFromRef(int x,
                                      int y,
                                      int width,
                                      int height)

getMapObjects

public java.lang.Object[][] getMapObjects(int xcenter,
                                          int ycenter,
                                          int halfWidth,
                                          int halfHeight)
Description copied from interface: AbstractMap
Return a window of Objects around the (xcenter,ycenter) point. Radius in width is halfWidth, Radius in height is halfHeight. Please read the @post comment

Specified by:
getMapObjects in interface AbstractMap
Specified by:
getMapObjects in class CellMap
Parameters:
xcenter - x coordinate
ycenter - y coordinate
halfWidth - the number of Objects we want to include.
halfHeight - the number of Objects we want to include
Returns:
a double Array of MapUnits

getMapObjectsFromRef

public java.lang.Object[][] getMapObjectsFromRef(int x,
                                                 int y,
                                                 int width,
                                                 int height)

isThereRoom

public boolean isThereRoom(int x,
                           int y,
                           int xWidth,
                           int yHeight)
Description copied from interface: AbstractMap
Return true if there is no object in the range specified by the parameters. false if there is one

Specified by:
isThereRoom in interface AbstractMap
Specified by:
isThereRoom in class CellMap
Parameters:
x - x coordinate
y - y coordinate
xWidth - length in width of the Object
yHeight - length in height of the Object
Returns:
a boolean

Logo

With the help of www.sourceforge.net and www.info.ucl.ac.be