|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.hagenah.diplomacy.map.MapData
public final class MapData
The MapData class represents a map like Standard or Crowded. It only represents the map data that doesn't change and not game or turn specific data.
| Field Summary | |
|---|---|
static java.awt.Color |
COLOR_LAND
Color for land |
static java.awt.Color |
COLOR_NEUTRAL
Color for neutral |
static java.awt.Color |
COLOR_SEA
Color for sea |
static java.awt.Color |
COLOR_TEXT
Color for text |
static int |
HOME_CENTERS_ALL
All centers are home centers |
static int |
HOME_CENTERS_PHASE
The centers of the specified phase are the home centers |
static int |
HOME_CENTERS_SPECIAL
The home centers are explicitly specified |
static int |
HOME_CENTERS_START
The start centers are the home centers, too |
static java.lang.String |
NAME_1897
The name of the 1897 map |
static java.lang.String |
NAME_1898
The name of the 1898 map |
static java.lang.String |
NAME_ASIA
The name of the Asia map |
static java.lang.String |
NAME_BRITAIN
The name of the Britain map |
static java.lang.String |
NAME_CHAOS
The name of the Chaos map |
static java.lang.String |
NAME_COLONIAL
The name of the Colonial map |
static java.lang.String |
NAME_COLONIAL96
The name of the Colonial96 map |
static java.lang.String |
NAME_CROWDED
The name of the Crowded map |
static java.lang.String |
NAME_CROWDED_1898
The name of the Crowded 1898 map |
static java.lang.String |
NAME_FLEET_ROME
The name of the Fleet Rome map |
static java.lang.String |
NAME_HUNDRED_1
The name of the Hundred map (first version) |
static java.lang.String |
NAME_HUNDRED_2
The name of the Hundred map (second version) |
static java.lang.String |
NAME_SAILHO
The name of the Sail Ho! |
static java.lang.String |
NAME_SAILHO_CROWDED
The name of the Sail Ho! |
static java.lang.String |
NAME_SAILHO2
The name of the Sail Ho! |
static java.lang.String |
NAME_SHIFT_AROUND
The name of the Shift Around map |
static java.lang.String |
NAME_SHIFT_LEFT
The name of the Shift Left map |
static java.lang.String |
NAME_SHIFT_RIGHT
The name of the Shift Right map |
static java.lang.String |
NAME_STANDARD
The name of the Standard map |
| Method Summary | |
|---|---|
int |
compareTo(java.lang.Object obj)
Compares two Maps by Name ignoring case |
byte[] |
createPNG(int width,
int height,
java.util.Map centers,
java.util.Collection units,
java.util.Collection orders,
boolean uniticons,
boolean unitcolor,
boolean abbreviations,
int brightness)
Creates a png file |
boolean |
equals(java.lang.Object obj)
Compares two Maps by Name ignoring case |
java.util.SortedSet |
getCenters()
Returns all centers (Province objects) |
java.lang.String |
getComment()
Returns the comment of the map (can be null). |
java.util.SortedSet |
getCountries()
Returns all countries |
Country |
getCountry(java.lang.String name)
Retrieves the Country with the specified name. |
java.lang.String |
getDescription()
Returns a description for the map. |
java.util.SortedSet |
getHomeCenters(Country country,
java.util.Map specialcenters)
Returns the home centers for a country |
Phase |
getHomeCentersPhase()
Returns the special phase if getHomeCentersType() returns HOME_CENTERS_PHASE |
int |
getHomeCentersType()
Returns the home centers type |
java.lang.String |
getMapBy()
Returns the author of the map (can be null). |
java.lang.String |
getName()
Returns the name of the map. |
java.awt.Rectangle |
getOrderBounds(java.awt.Graphics g,
java.awt.geom.Rectangle2D rect,
Order order)
Returns a bounding rectangle for an order. |
Person |
getPerson(java.lang.String name)
Retrieves the person (country, master, or observer) with the specified name. |
java.util.SortedSet |
getPersons()
Returns all persons (countries, master, and observer). |
Province |
getProvince(java.lang.String name)
Retrieves the Province with the specified name. |
java.awt.Rectangle |
getProvinceBounds(java.awt.geom.Rectangle2D rect,
java.util.Collection provinces)
Returns a bounding rectangle for the specified provinces. |
java.util.SortedSet |
getProvinces()
Returns all countries |
java.util.Map |
getProvinces(java.lang.String namestart)
Returns all provinces that start with the specified string. |
Phase |
getStartPhase()
Returns the start phase of the map. |
SubProvince |
getSubProvince(java.awt.geom.Rectangle2D rect,
java.awt.geom.Point2D pos)
Retrieves the SubProvince in which pos lies. |
SubProvince |
getSubProvince(java.awt.geom.Rectangle2D rect,
java.awt.geom.Point2D pos,
boolean sea)
Retrieves the SubProvince in which pos lies. |
SubProvince |
getSubProvince(java.lang.String name,
int coast)
Retrieves the SubProvince with the specified name and coast. |
SubProvince |
getSubProvince(java.lang.String name,
java.lang.String coast)
Retrieves the SubProvince with the specified name and coast. |
java.lang.String |
getVariantBy()
Returns the author of the variant (can be null). |
int |
hashCode()
Returns a hashcode for this MapData. |
boolean |
isHomeCenter(Country country,
Province center,
java.util.Map specialcenters)
Tests whether the specified center is a home center of the specified country. |
boolean |
isOverUnit(java.awt.geom.Rectangle2D rect,
java.awt.geom.Point2D pos,
SubProvince subprovince,
boolean uniticons)
Is pos over the unit in subprovince? |
void |
paint(java.awt.Graphics g,
java.awt.geom.Rectangle2D rect,
java.util.Map centers,
java.util.Collection units,
java.util.Collection orders,
java.util.Collection highlighted,
boolean uniticons,
boolean unitcolor,
boolean abbreviations,
int brightness,
int highlighting,
boolean unitantialiasing,
boolean linetextantialiasing)
Draws the Map into the rectangle rect |
static MapData |
read(java.io.File input)
Reads a map from a XML file (see Map.dtd). |
static MapData |
read(java.lang.String input)
Reads a map from a XML file (see Map.dtd). |
java.lang.String |
toString()
Returns the name of the map |
void |
updateColors(MapData newmap)
Updates the colors of this map. |
void |
updateTSR()
Update Colonial TSR SpecialCountry from version 2.0 |
void |
write(java.io.OutputStream stream)
Writes a map to a XML file (see Map.dtd). |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.awt.Color COLOR_LAND
public static final java.awt.Color COLOR_SEA
public static final java.awt.Color COLOR_NEUTRAL
public static final java.awt.Color COLOR_TEXT
public static final int HOME_CENTERS_START
public static final int HOME_CENTERS_SPECIAL
public static final int HOME_CENTERS_ALL
public static final int HOME_CENTERS_PHASE
public static final java.lang.String NAME_1897
public static final java.lang.String NAME_1898
public static final java.lang.String NAME_ASIA
public static final java.lang.String NAME_BRITAIN
public static final java.lang.String NAME_CHAOS
public static final java.lang.String NAME_COLONIAL
public static final java.lang.String NAME_COLONIAL96
public static final java.lang.String NAME_CROWDED
public static final java.lang.String NAME_CROWDED_1898
public static final java.lang.String NAME_FLEET_ROME
public static final java.lang.String NAME_HUNDRED_1
public static final java.lang.String NAME_HUNDRED_2
public static final java.lang.String NAME_SAILHO
public static final java.lang.String NAME_SAILHO2
public static final java.lang.String NAME_SAILHO_CROWDED
public static final java.lang.String NAME_SHIFT_AROUND
public static final java.lang.String NAME_SHIFT_LEFT
public static final java.lang.String NAME_SHIFT_RIGHT
public static final java.lang.String NAME_STANDARD
| Method Detail |
|---|
public java.lang.String getName()
public Phase getStartPhase()
public java.lang.String getMapBy()
public java.lang.String getVariantBy()
public java.lang.String getComment()
public java.util.SortedSet getCountries()
public java.util.SortedSet getPersons()
public java.util.SortedSet getProvinces()
public java.util.SortedSet getCenters()
public static MapData read(java.io.File input)
throws org.xml.sax.SAXException,
java.io.IOException
input - The XML file
org.xml.sax.SAXException
java.io.IOException
public static MapData read(java.lang.String input)
throws org.xml.sax.SAXException,
java.io.IOException
input - The URI of the XML file
org.xml.sax.SAXException
java.io.IOException
public void write(java.io.OutputStream stream)
throws java.io.IOException
stream - A Writer for the output. It is not closed at the end.
java.io.IOException
public Country getCountry(java.lang.String name)
throws java.lang.IllegalArgumentException
name - Name or abbreviation of the country (!=null).
java.lang.IllegalArgumentException
public Person getPerson(java.lang.String name)
throws java.lang.IllegalArgumentException
name - Name or abbreviation of the person (!=null).
java.lang.IllegalArgumentException
public Province getProvince(java.lang.String name)
throws java.lang.IllegalArgumentException
name - A name of the province (!=null).
java.lang.IllegalArgumentExceptionpublic java.util.Map getProvinces(java.lang.String namestart)
namestart - The start of the name (case is ignored)
public SubProvince getSubProvince(java.lang.String name,
int coast)
throws java.lang.IllegalArgumentException
name - A Name of the province (!=null).coast - The coast of the province.
java.lang.IllegalArgumentException
public SubProvince getSubProvince(java.lang.String name,
java.lang.String coast)
throws java.lang.IllegalArgumentException
name - A name of the province (!=null).coast - The coast of the province (!=null).
java.lang.IllegalArgumentException
public SubProvince getSubProvince(java.awt.geom.Rectangle2D rect,
java.awt.geom.Point2D pos)
pos - Position in Bounds
public SubProvince getSubProvince(java.awt.geom.Rectangle2D rect,
java.awt.geom.Point2D pos,
boolean sea)
rect - The rectangle of the whole mappos - Position in rectsea - Type of the searched SubProvince
public boolean isOverUnit(java.awt.geom.Rectangle2D rect,
java.awt.geom.Point2D pos,
SubProvince subprovince,
boolean uniticons)
rect - The rect into which to map is drawnpos - A positionsubprovince - A subprovince
public java.awt.Rectangle getProvinceBounds(java.awt.geom.Rectangle2D rect,
java.util.Collection provinces)
rect - The rect into which to map is drawnprovinces - A collection with the provinces
public java.awt.Rectangle getOrderBounds(java.awt.Graphics g,
java.awt.geom.Rectangle2D rect,
Order order)
rect - The rect into which to map is drawnorder - The order
public int getHomeCentersType()
public Phase getHomeCentersPhase()
throws java.lang.IllegalStateException
java.lang.IllegalStateException - If the home centers type is not HOME_CENTERS_PHASE
public java.util.SortedSet getHomeCenters(Country country,
java.util.Map specialcenters)
country - The countryspecialcenters - The current centers (Province → Country). If the home centers type
is HOME_CENTERS_PHASE and the special home centers phase is before the
current phase the centers for the special home centers phase.
public boolean isHomeCenter(Country country,
Province center,
java.util.Map specialcenters)
country - The countrycenter - The centerspecialcenters - The current centers (Province → Country). If the home centers type
is HOME_CENTERS_PHASE and the special home centers phase is before the
current phase the centers for the special home centers phase.
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int compareTo(java.lang.Object obj)
compareTo in interface java.lang.Comparablepublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getDescription()
public byte[] createPNG(int width,
int height,
java.util.Map centers,
java.util.Collection units,
java.util.Collection orders,
boolean uniticons,
boolean unitcolor,
boolean abbreviations,
int brightness)
public void paint(java.awt.Graphics g,
java.awt.geom.Rectangle2D rect,
java.util.Map centers,
java.util.Collection units,
java.util.Collection orders,
java.util.Collection highlighted,
boolean uniticons,
boolean unitcolor,
boolean abbreviations,
int brightness,
int highlighting,
boolean unitantialiasing,
boolean linetextantialiasing)
public void updateColors(MapData newmap)
newmap - The colors from this map are used. The maps must have the same
countries.public void updateTSR()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||