rails.game
Class MapManager

java.lang.Object
  extended by rails.game.MapManager
All Implemented Interfaces:
ConfigurableComponentI

public class MapManager
extends java.lang.Object
implements ConfigurableComponentI

MapManager configures the map layout from XML


Field Summary
protected  MapHex[][] hexes
           
protected  boolean letterAHasEvenNumbers
           
protected  boolean lettersGoHorizontal
           
protected static org.apache.log4j.Logger log
           
protected  int maxCol
           
protected  int maxRow
           
protected  int maxX
           
protected  int maxY
           
protected  java.util.Map<java.lang.String,MapHex> mHexes
           
protected  int minCol
           
protected  int minRow
           
protected  int minX
           
protected  int minY
           
protected  java.util.SortedSet<java.lang.Integer> possibleTileCosts
           
protected  int tileOrientation
           
protected static int[] xDeltaNS
           
protected static int[] xYEvenDeltaEW
           
protected static int[] xYOddDeltaEW
           
protected static int[] yDeltaEW
           
protected static int[] yXEvenDeltaNS
           
protected static int[] yXOddDeltaNS
           
 
Constructor Summary
MapManager()
           
 
Method Summary
 void configureFromXML(Tag tag)
          Instructs the component to configure itself from the provided XML element.
 void finishConfiguration(GameManagerI gameManager)
          This method is intended to be called for each configurable component, to perforn any initialisation activities that require any other components to be initialised first.
 int getAdjacentX(int x, int y, int orientation)
           
 int getAdjacentY(int x, int y, int orientation)
           
 int[] getCityDistances(MapHex hex)
          Calculate the distances between a given tokenable city hex and all other tokenable city hexes.
 java.util.List<City> getCurrentStations()
           
 MapHex getHex(java.lang.String locationCode)
           
 int getHexDistance(MapHex hex1, MapHex hex2)
          Calculate the distance between two hexes as in 1835, i.e.
 MapHex[][] getHexes()
           
 java.util.List<MapHex> getHexesAsList()
           
 java.lang.String getMapUIClassName()
           
 int getMaxCol()
           
 int getMaxRow()
           
 int getMaxX()
           
 int getMaxY()
           
 int getMinCol()
           
 int getMinRow()
           
 int getMinX()
           
 int getMinY()
           
 java.util.SortedSet<java.lang.Integer> getPossibleTileCosts()
           
 int getTileOrientation()
           
 boolean letterAHasEvenNumbers()
           
 boolean lettersGoHorizontal()
           
 java.util.List<MapHex> parseLocations(java.lang.String locationCodes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tileOrientation

protected int tileOrientation

lettersGoHorizontal

protected boolean lettersGoHorizontal

letterAHasEvenNumbers

protected boolean letterAHasEvenNumbers

hexes

protected MapHex[][] hexes

mHexes

protected java.util.Map<java.lang.String,MapHex> mHexes

minX

protected int minX

minY

protected int minY

maxX

protected int maxX

maxY

protected int maxY

minCol

protected int minCol

maxCol

protected int maxCol

minRow

protected int minRow

maxRow

protected int maxRow

possibleTileCosts

protected java.util.SortedSet<java.lang.Integer> possibleTileCosts

xDeltaNS

protected static final int[] xDeltaNS

yXEvenDeltaNS

protected static final int[] yXEvenDeltaNS

yXOddDeltaNS

protected static final int[] yXOddDeltaNS

xYEvenDeltaEW

protected static final int[] xYEvenDeltaEW

xYOddDeltaEW

protected static final int[] xYOddDeltaEW

yDeltaEW

protected static final int[] yDeltaEW

log

protected static org.apache.log4j.Logger log
Constructor Detail

MapManager

public MapManager()
Method Detail

configureFromXML

public void configureFromXML(Tag tag)
                      throws ConfigurationException
Description copied from interface: ConfigurableComponentI
Instructs the component to configure itself from the provided XML element.

Specified by:
configureFromXML in interface ConfigurableComponentI
Throws:
ConfigurationException
See Also:
rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element)

finishConfiguration

public void finishConfiguration(GameManagerI gameManager)
                         throws ConfigurationException
Description copied from interface: ConfigurableComponentI
This method is intended to be called for each configurable component, to perforn any initialisation activities that require any other components to be initialised first. This includes creating any required relationships to other configured components and objects.

This method should be called where necessary after all XML file parsing has completed, so that all objects that need to be related to do exist.

Specified by:
finishConfiguration in interface ConfigurableComponentI
Parameters:
gameManager - The 'parent' configurable component is passed to allow the 'child' to access any other object without the need to resort to static calls where possible.
Throws:
ConfigurationException

letterAHasEvenNumbers

public boolean letterAHasEvenNumbers()
Returns:
Returns the letterAHasEvenNumbers.

lettersGoHorizontal

public boolean lettersGoHorizontal()
Returns:
Returns the lettersGoHorizontal.

getAdjacentX

public int getAdjacentX(int x,
                        int y,
                        int orientation)

getAdjacentY

public int getAdjacentY(int x,
                        int y,
                        int orientation)

getTileOrientation

public int getTileOrientation()
Returns:
Returns the currentTileOrientation.

getHexes

public MapHex[][] getHexes()
Returns:
Returns the hexes.

getHexesAsList

public java.util.List<MapHex> getHexesAsList()

getMinX

public int getMinX()

getMinY

public int getMinY()

getMaxX

public int getMaxX()

getMaxY

public int getMaxY()

getMaxCol

public int getMaxCol()

getMaxRow

public int getMaxRow()

getMinCol

public int getMinCol()

getMinRow

public int getMinRow()

getMapUIClassName

public java.lang.String getMapUIClassName()
Returns:
Returns the mapUIClassName.

getHex

public MapHex getHex(java.lang.String locationCode)

getCurrentStations

public java.util.List<City> getCurrentStations()

getPossibleTileCosts

public java.util.SortedSet<java.lang.Integer> getPossibleTileCosts()

parseLocations

public java.util.List<MapHex> parseLocations(java.lang.String locationCodes)
                                      throws ConfigurationException
Throws:
ConfigurationException

getHexDistance

public int getHexDistance(MapHex hex1,
                          MapHex hex2)
Calculate the distance between two hexes as in 1835, i.e. as "the crow without a passport flies".

Parameters:
hex1 -
hex2 -
Returns:

getCityDistances

public int[] getCityDistances(MapHex hex)
Calculate the distances between a given tokenable city hex and all other tokenable city hexes.

The array is cached, so it need be calculated only once.

Parameters:
hex - Start hex
Returns:
Sorted int array containing all occurring distances only once.