civquest
Class FlatMapData

java.lang.Object
  extended bycivquest.MapData
      extended bycivquest.FlatMapData
All Implemented Interfaces:
java.io.Serializable

public class FlatMapData
extends MapData

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class civquest.MapData
MapData.Configuration
 
Field Summary
 
Fields inherited from class civquest.MapData
EQUAL_TO, fields, GREATER_THAN, mapHeight, mapRegistry, mapWidth, moveCalcRegistry, SMALLER_THAN
 
Constructor Summary
FlatMapData(int width, int height, boolean nflatearth, int nminbigriverwf, Registry registry)
           
 
Method Summary
 Coordinate adjustToMapSize(Coordinate coord)
          Adjusts the given coordinate to mapsize.
 boolean areNeighborCoords(Coordinate coord1, Coordinate coord2)
          Returns if the two given Coordinates are neighbor-Coordinates
 Coordinate getAreaCoord(Rectangle rect, Coordinate coord)
          Translates the given Coordinate (by map-sizes) to be in the specified rectangle.
 int getArrayHeight()
          Returns the height of the internal array that stores the Fields.
 int getArrayWidth()
          Returns the width of the internal array that stores the Fields.
 MapData.Configuration getConfiguration()
           
 int getNeighborFieldDist(Field f1, Field f2)
          Returns the distance between the two given _neighbor_-fields.
 FieldDistanceInfo[] getNeighborFieldDists(Field field)
          Returns an array with FieldDistanceInfo-objects for each neighbor-field of the given Field.
 Field[] getNeighborFields(Field field)
           
 Coordinate getRandomCoordinate()
          Returns a random map-coordinate.
 boolean isArrayCoordOnMap(Coordinate coord)
           
 boolean isArrayCoordOnMap(int x, int y)
           
 boolean isOnEastEdge(Coordinate coord)
          See isOnNorthEdge
 boolean isOnMap(Coordinate coord)
           
 boolean isOnMap(int x, int y)
           
 boolean isOnNorthEdge(Coordinate coord)
          A coordinate is on the northern edge if there is no map-coordinate that is north, northeast or northwest of it.
 boolean isOnSouthEdge(Coordinate coord)
          See isOnNorthEdge
 boolean isOnWestEdge(Coordinate coord)
          See isOnNorthEdge
 Coordinate mapCoordinate(Coordinate coord)
           
 
Methods inherited from class civquest.MapData
addCity, addMapChangeListener, addUnit, adjustsToLand, adjustsToSea, adjustToMapSize, areIncompleteMovesAllowed, calculateDistanceFromCoast, calculateDistanceFromSea, distanceFromHeightLevel, getCity, getCityIterator, getCoasts, getField, getField, getMapHeight, getMapWidth, getMinBigRiverWaterFlow, getMoveCalculator, getUnit, getUnitIterator, hasNeighborFieldDistanceToCoast, hasNeighborFieldDistanceToSea, isFlatEarth, isOnMapEdge, isPressureUsed, setCityOwner, setHeightLevel, setMinBigRiverWaterFlow, setPressureUsed, setUnitOwner, setUnitPosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlatMapData

public FlatMapData(int width,
                   int height,
                   boolean nflatearth,
                   int nminbigriverwf,
                   Registry registry)
Method Detail

getArrayWidth

public int getArrayWidth()
Description copied from class: MapData
Returns the width of the internal array that stores the Fields. Useful for loops.

Specified by:
getArrayWidth in class MapData

getArrayHeight

public int getArrayHeight()
Description copied from class: MapData
Returns the height of the internal array that stores the Fields. Useful for loops.

Specified by:
getArrayHeight in class MapData

adjustToMapSize

public Coordinate adjustToMapSize(Coordinate coord)
Description copied from class: MapData
Adjusts the given coordinate to mapsize. This means: If coord already is a map-coordinate, it is returned unchanged. If coord is north/south of the northern/southern edge of map, null is returned. If earth is flat, the same applies to west/east, otherwise, a translation by x * mapWidth is performed and a valid map-coordinate returned. This function is especially useful for recursive functions that are called for some neighbor-coordinates of the original field.

Specified by:
adjustToMapSize in class MapData

isArrayCoordOnMap

public boolean isArrayCoordOnMap(Coordinate coord)
Specified by:
isArrayCoordOnMap in class MapData

isArrayCoordOnMap

public boolean isArrayCoordOnMap(int x,
                                 int y)
Specified by:
isArrayCoordOnMap in class MapData

isOnMap

public boolean isOnMap(Coordinate coord)
Specified by:
isOnMap in class MapData

isOnMap

public boolean isOnMap(int x,
                       int y)
Specified by:
isOnMap in class MapData

isOnNorthEdge

public boolean isOnNorthEdge(Coordinate coord)
Description copied from class: MapData
A coordinate is on the northern edge if there is no map-coordinate that is north, northeast or northwest of it. The same applies to isOnEastEdge, isOnSouthEdge, isOnWestEdge.

Specified by:
isOnNorthEdge in class MapData

isOnEastEdge

public boolean isOnEastEdge(Coordinate coord)
Description copied from class: MapData
See isOnNorthEdge

Specified by:
isOnEastEdge in class MapData

isOnSouthEdge

public boolean isOnSouthEdge(Coordinate coord)
Description copied from class: MapData
See isOnNorthEdge

Specified by:
isOnSouthEdge in class MapData

isOnWestEdge

public boolean isOnWestEdge(Coordinate coord)
Description copied from class: MapData
See isOnNorthEdge

Specified by:
isOnWestEdge in class MapData

getAreaCoord

public Coordinate getAreaCoord(Rectangle rect,
                               Coordinate coord)
Description copied from class: MapData
Translates the given Coordinate (by map-sizes) to be in the specified rectangle. Returns the translated coordinate, if this is possible, null otherwise. NOTE: Do NOT ALTER either rect nor coord within the implementation. CLONE it instead!!!

Specified by:
getAreaCoord in class MapData

getRandomCoordinate

public Coordinate getRandomCoordinate()
Description copied from class: MapData
Returns a random map-coordinate.

Specified by:
getRandomCoordinate in class MapData

mapCoordinate

public Coordinate mapCoordinate(Coordinate coord)
Specified by:
mapCoordinate in class MapData

areNeighborCoords

public boolean areNeighborCoords(Coordinate coord1,
                                 Coordinate coord2)
Returns if the two given Coordinates are neighbor-Coordinates

Specified by:
areNeighborCoords in class MapData

getNeighborFieldDist

public int getNeighborFieldDist(Field f1,
                                Field f2)
Description copied from class: MapData
Returns the distance between the two given _neighbor_-fields. NOTE: If f1 and f2 are not neighbor-fields, the return-value of this function is undefined!!!

Specified by:
getNeighborFieldDist in class MapData
Parameters:
f1 - any Field
f2 - any Field
Returns:
distance between f1 and f2 as described

getNeighborFields

public Field[] getNeighborFields(Field field)
Specified by:
getNeighborFields in class MapData

getNeighborFieldDists

public FieldDistanceInfo[] getNeighborFieldDists(Field field)
Description copied from class: MapData
Returns an array with FieldDistanceInfo-objects for each neighbor-field of the given Field. The array may contain null-values for non-existent Fields.

Specified by:
getNeighborFieldDists in class MapData
Parameters:
field - any Field
Returns:
an array of FieldDistanceInfo-objects as described

getConfiguration

public MapData.Configuration getConfiguration()
Specified by:
getConfiguration in class MapData