cad.simcad.maps
Class CellGroup

java.lang.Object
  |
  +--cad.simcad.maps.CellGroup
All Implemented Interfaces:
java.util.Comparator, PathPlace
Direct Known Subclasses:
BreachedCellGroup, CellRectangle

public abstract class CellGroup
extends java.lang.Object
implements PathPlace

A CellGroup is a set of cell

Version:
1.0
Author:
Charles-Philip Bentley

Field Summary
protected  MapUnit[] _art
           
protected  CellMap _cellMap
           
protected  int _cellNum
           
protected  Cell[][] _cells
           
protected  int _maxHeight
           
protected  int _maxWidth
           
protected  Cell _ref
          This is the Cell from which any Cell from this CellGroup can be reached by adding to a maximum of _maxHeight and _maxWidth
protected  double _value
           
protected  double _z
           
 
Constructor Summary
CellGroup(CellMap cellMap, Cell[][] cells)
          Creates new CellGroup Ref = lower and west cell of group cell The array given represents a rectangle of cells
CellGroup(CellMap cellMap, Cell[][] cells, Cell ref)
           
 
Method Summary
 boolean belongsTo(Cell c)
          This method should be constant time O(c) PRE : A Cell POST : True if the cell belongs to the Cellgroup, false otherwise.
 boolean contained(PathPlace pp)
           
 boolean contains(PathPlace pp)
           
 boolean containsMapUnit(MapUnit mu)
          Returns true if the PathPlace contains the MapUnit given in argument
abstract  CellGroup createInstance(CellMap cellMap, Cell[][] newCells)
           
abstract  CellGroup createInstance(CellMap cellMap, Cell[][] newCells, Cell ref)
           
 PathPlace[] getAdjacentPathPlaces()
          Returns the array of adjacent PathPlace to this one.
 int getAverageAltitude()
           
 int getBiggestXLength()
           
 int getBiggestYLength()
           
 Cell[][] getCells()
           
abstract  double getCostToReachFrom(PathPlace pp, PathUser pu)
           
 MapUnit[] getDifference(PathPlace pp)
          Return the MapUnits of the PathPlace that are not contained in the given PathPlace
 int getEastX()
           
 double getElevation()
           
 int getGroupHeight()
           
 int getGroupWidth()
          return the width of the group cells
 java.lang.Object getImplementingObject()
           
abstract  MapUnit[] getInnerMapUnitBoundary()
          Returns an Array of MapUnits that make the inner boundary of the PathPlace This method applied to a MapUnit PathPlace returns itself
 MapUnit[] getIntersection(PathPlace pp)
          Return the MapUnit contained in both PathPlaces( argument and object)
 AbstractMap getMap()
           
 MapUnit[] getMyAdjacentMapUnits(PathPlace pp)
          Returns the MapUnits of this PathPlace adjacent to the PathPlace given in argument
 int getNorthY()
          POST : the biggest Y position of the CellGroup
 MapUnit[] getNotMyAdjacentMapUnits(PathPlace pp)
          Returns the MapUnits of the PathPlace given in argument adjacent to this PathPlace If the PathPlace in argument contains
 int getNumberOfCells()
           
 MapUnit[] getOuterMapUnitBoundary()
          Returns an Array of MapUnits that make the outer boundary of the PathPlace This method applied to a MapUnit PathPlace returns the same MapUnits
 int getRatio(double d)
          Returns the steepness of the slope as a percentage It is rounded down.
 int getResolution()
           
 int getSouthY()
           
abstract  int getSteepRatio(MapUnit mu)
           
 MapUnit[] getUnits()
          Returns an array of the MapUnit making up the PathPlace
 double getValue()
           
 int getWestX()
           
 int getX()
           
 int getY()
           
 MapUnit[] intersection(PathPlace pp)
          Return the MapUnit contained in both PathPlaces( argument and object)
 boolean isAdjacent(PathPlace pp)
          Returns true if the PathPlace given in argument is adjacent returns false otherwise
 CellGroup moveEast()
           
 CellGroup moveNorth()
          Return a new CellGroup.
 CellGroup moveNorthEast()
           
 CellGroup moveNorthWest()
           
 CellGroup moveSouth()
          Return a new CellGroup.
 CellGroup moveSouthEast()
           
 CellGroup moveSouthWest()
           
 CellGroup moveWest()
          For performance reason, this method does not check for consistency
 void setValue(double value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cad.simcad.objectserver.spec.pathfinding.PathPlace
equals, getNumberOfUnits
 
Methods inherited from interface java.util.Comparator
compare, equals
 

Field Detail

_cellNum

protected int _cellNum

_cellMap

protected CellMap _cellMap

_cells

protected Cell[][] _cells

_maxHeight

protected int _maxHeight

_maxWidth

protected int _maxWidth

_value

protected double _value

_z

protected double _z

_art

protected MapUnit[] _art

_ref

protected Cell _ref
This is the Cell from which any Cell from this CellGroup can be reached by adding to a maximum of _maxHeight and _maxWidth

Constructor Detail

CellGroup

public CellGroup(CellMap cellMap,
                 Cell[][] cells)
Creates new CellGroup Ref = lower and west cell of group cell The array given represents a rectangle of cells


CellGroup

public CellGroup(CellMap cellMap,
                 Cell[][] cells,
                 Cell ref)
Method Detail

getNumberOfCells

public int getNumberOfCells()

belongsTo

public boolean belongsTo(Cell c)
This method should be constant time O(c) PRE : A Cell POST : True if the cell belongs to the Cellgroup, false otherwise.


getCells

public Cell[][] getCells()

getGroupWidth

public int getGroupWidth()
return the width of the group cells


getGroupHeight

public int getGroupHeight()

getNorthY

public int getNorthY()
POST : the biggest Y position of the CellGroup

Specified by:
getNorthY in interface PathPlace

getX

public int getX()
Specified by:
getX in interface PathPlace
Post:
return an approximation x position

getY

public int getY()
Specified by:
getY in interface PathPlace
Post:
return the approximative y position of the PathPlace on the Map

getEastX

public int getEastX()
Specified by:
getEastX in interface PathPlace

getSouthY

public int getSouthY()
Specified by:
getSouthY in interface PathPlace

getWestX

public int getWestX()
Specified by:
getWestX in interface PathPlace

createInstance

public abstract CellGroup createInstance(CellMap cellMap,
                                         Cell[][] newCells,
                                         Cell ref)

createInstance

public abstract CellGroup createInstance(CellMap cellMap,
                                         Cell[][] newCells)

moveWest

public CellGroup moveWest()
For performance reason, this method does not check for consistency

Pre:
current position of the CellGroup on the Map allows for a West move.

moveNorth

public CellGroup moveNorth()
Return a new CellGroup. The CellGroup is one unit north of this CellGroup


moveSouth

public CellGroup moveSouth()
Return a new CellGroup. The CellGroup is one unit north of this CellGroup


moveEast

public CellGroup moveEast()

moveNorthWest

public CellGroup moveNorthWest()

moveSouthEast

public CellGroup moveSouthEast()

moveNorthEast

public CellGroup moveNorthEast()

moveSouthWest

public CellGroup moveSouthWest()

getInnerMapUnitBoundary

public abstract MapUnit[] getInnerMapUnitBoundary()
Returns an Array of MapUnits that make the inner boundary of the PathPlace This method applied to a MapUnit PathPlace returns itself

Specified by:
getInnerMapUnitBoundary in interface PathPlace

containsMapUnit

public boolean containsMapUnit(MapUnit mu)
Returns true if the PathPlace contains the MapUnit given in argument

Specified by:
containsMapUnit in interface PathPlace

intersection

public MapUnit[] intersection(PathPlace pp)
Return the MapUnit contained in both PathPlaces( argument and object)


getMyAdjacentMapUnits

public MapUnit[] getMyAdjacentMapUnits(PathPlace pp)
Returns the MapUnits of this PathPlace adjacent to the PathPlace given in argument

Specified by:
getMyAdjacentMapUnits in interface PathPlace
Pre:
A PathPlace
Post:
an array of the MapUnits contained in the current PathPlace adjacent the PathPlace given in argument

getIntersection

public MapUnit[] getIntersection(PathPlace pp)
Return the MapUnit contained in both PathPlaces( argument and object)

Specified by:
getIntersection in interface PathPlace

contains

public boolean contains(PathPlace pp)
Specified by:
contains in interface PathPlace
Post:
true if the object contains entirely the given PathPlace

contained

public boolean contained(PathPlace pp)
Specified by:
contained in interface PathPlace
Post:
true if the object is contained entirely in the PathPlace

getRatio

public int getRatio(double d)
Returns the steepness of the slope as a percentage It is rounded down. Give in argument the difference of altitude of one cell movement D should rarely be over 1, except for cliffs and steep slopes


getResolution

public int getResolution()

getImplementingObject

public java.lang.Object getImplementingObject()

setValue

public void setValue(double value)
Specified by:
setValue in interface PathPlace

getValue

public double getValue()

getElevation

public double getElevation()

getSteepRatio

public abstract int getSteepRatio(MapUnit mu)

getCostToReachFrom

public abstract double getCostToReachFrom(PathPlace pp,
                                          PathUser pu)
Specified by:
getCostToReachFrom in interface PathPlace

getAverageAltitude

public int getAverageAltitude()

isAdjacent

public boolean isAdjacent(PathPlace pp)
Description copied from interface: PathPlace
Returns true if the PathPlace given in argument is adjacent returns false otherwise

Specified by:
isAdjacent in interface PathPlace
Post:
true if this cell is adjacent to the given PathPlace

getAdjacentPathPlaces

public PathPlace[] getAdjacentPathPlaces()
Description copied from interface: PathPlace
Returns the array of adjacent PathPlace to this one.

Specified by:
getAdjacentPathPlaces in interface PathPlace

getNotMyAdjacentMapUnits

public MapUnit[] getNotMyAdjacentMapUnits(PathPlace pp)
Returns the MapUnits of the PathPlace given in argument adjacent to this PathPlace If the PathPlace in argument contains

Specified by:
getNotMyAdjacentMapUnits in interface PathPlace

getUnits

public MapUnit[] getUnits()
Returns an array of the MapUnit making up the PathPlace

Specified by:
getUnits in interface PathPlace

getMap

public AbstractMap getMap()
Specified by:
getMap in interface PathPlace

getOuterMapUnitBoundary

public MapUnit[] getOuterMapUnitBoundary()
Returns an Array of MapUnits that make the outer boundary of the PathPlace This method applied to a MapUnit PathPlace returns the same MapUnits

Specified by:
getOuterMapUnitBoundary in interface PathPlace

getBiggestXLength

public int getBiggestXLength()
Specified by:
getBiggestXLength in interface PathPlace

getBiggestYLength

public int getBiggestYLength()
Specified by:
getBiggestYLength in interface PathPlace

getDifference

public MapUnit[] getDifference(PathPlace pp)
Return the MapUnits of the PathPlace that are not contained in the given PathPlace

Specified by:
getDifference in interface PathPlace

Logo

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