dip.gui.map
Class MapMetadata

java.lang.Object
  extended bydip.gui.map.MapMetadata

public class MapMetadata
extends java.lang.Object

Extracts map information, and SVG Elements, from the SVG file. Metadata (jDip-specific, in its own XML namespace) is also extracted.


Nested Class Summary
static class MapMetadata.InfoEntry
          Stores coordinate information for Symbol placement within a province.
static class MapMetadata.SymbolSize
          Textual width/height of a symbol, as valid SVG dimensions.
 
Field Summary
static java.lang.String ATT_COLOR
          jDip namespace attribute: power colors: color name/value
static java.lang.String ATT_DELTA_RADIUS
          jDip namespace attribute: order drawing: deltaRadius
static java.lang.String ATT_FILTERID
          jDip namespace attribute: order drawing: filter ID
static java.lang.String ATT_HEIGHT
          jDip namespace attribute: symbol size: symbol height
static java.lang.String ATT_HILIGHT_CLASS
          jDip namespace attribute: order drawing: highlight class
static java.lang.String ATT_HILIGHT_OFFSET
          jDip namespace attribute: order drawing: highlight offset (float)
static java.lang.String ATT_LABELS_BRIEF
          jDip namespace attributes: display: labels
static java.lang.String ATT_LABELS_FULL
          jDip namespace attributes: display: labels
static java.lang.String ATT_MARKERID
          jDip namespace attribute: order drawing: marker ID
static java.lang.String ATT_NAME
          jDip namespace attributes: province, symbolsize
static java.lang.String ATT_POWER
          jDip namespace attribute: power colors: power name
static java.lang.String ATT_SHADOW_WIDTHS
          jDip namespace attribute: order drawing: order shadow line widths
static java.lang.String ATT_STROKESTYLE
          jDip namespace attribute: order drawing: stroke CSS style
static java.lang.String ATT_WIDTH
          jDip namespace attribute: symbol size: symbol width
static java.lang.String ATT_WIDTHS
          jDip namespace attribute: order drawing: order line widths
static java.lang.String ATT_X
          jDip namespace attributes: province
static java.lang.String ATT_Y
          jDip namespace attributes: province
static java.lang.String ATT_ZOOM_FACTOR
          jDip namespace attributes: display: zoom
static java.lang.String ATT_ZOOM_MAX
          jDip namespace attributes: display: zoom
static java.lang.String ATT_ZOOM_MIN
          jDip namespace attributes: display: zoom
static java.lang.String EL_BUILD
          Build order drawing parameter element
static java.lang.String EL_CONVOY
          Convoy order drawing parameter element
static java.lang.String EL_DISBAND
          Disband order drawing parameter element
static java.lang.String EL_DISLODGED_UNIT
          jDip namespace element: for province metadata: dislodged units
static java.lang.String EL_DISPLAY
          jDip namespace element: for display control
static java.lang.String EL_HOLD
          Hold order drawing parameter element
static java.lang.String EL_LABELS
          jDip namespace element: for display control (labels)
static java.lang.String EL_MOVE
          Move order drawing parameter element
static java.lang.String EL_ORDERDRAWING
          jDip namespace for Order metadata
static java.lang.String EL_POWERCOLOR
          Power Color item
static java.lang.String EL_POWERCOLORS
          Power Colors group
static java.lang.String EL_PROVINCE
          jDip namespace element: for province metadata: province
static java.lang.String EL_PROVINCE_DATA
          jDip namespace element: for province metadata (main grouping)
static java.lang.String EL_REMOVE
          Remove order drawing parameter element
static java.lang.String EL_RETREAT
          Retreat order drawing parameter element
static java.lang.String EL_SC
          jDip namespace element: for province metadata: supply centers
static java.lang.String EL_SUPPORT
          Support order drawing parameter element
static java.lang.String EL_SYMBOLSIZE
          Symbol Size element
static java.lang.String EL_UNIT
          jDip namespace element: for province metadata: units
static java.lang.String EL_WAIVE
          Waive order drawing parameter element
static java.lang.String EL_ZOOM
          jDip namespace element: for display control (zoom)
static java.lang.String JDIP_NAMESPACE
          jDip namespace constant
 
Constructor Summary
MapMetadata(MapPanel mp, SymbolPack sp, boolean supressPlacementErrors)
          Create a MapMetadata Object, by parsing the SVG placement id group metadata If supressPlacementErrors are suppressed, using the appropriate boolean flag, only valid parsed placement data will be used.
 
Method Summary
 void close()
          Clean up any resources used by this object
 java.awt.geom.Point2D.Float getDislodgedUnitPt(Province key, Coast coast)
          Convenience method: get Dislodged Unit placement point for this Province
 boolean getDisplayParamBoolean(java.lang.String key, boolean defaultValue)
          Gets a boolean display metadata value
 float getDisplayParamFloat(java.lang.String key, float defaultValue)
          Gets a float metadata value
 int getDisplayParamInt(java.lang.String key, int defaultValue)
          Gets an int metadata value
 MapMetadata.InfoEntry getInfoEntry(Province key)
          Get an InfoEntry
 float getOrderParamFloat(java.lang.String orderElement, java.lang.String attribute)
          Gets the float version of a parameter.
 float[] getOrderParamFloatArray(java.lang.String orderElement, java.lang.String attribute)
          Gets the float array version of a parameter.
 java.lang.String getOrderParamString(java.lang.String orderElement, java.lang.String attribute)
          Gets the String version of a parameter.
 float getOrderRadius(java.lang.String orderElement, java.lang.String symbolName)
          Gets the adjusted radius for an order.
 java.lang.String getPowerColor(Power power)
          Get power color (the color of orders associated w/a power
 java.awt.geom.Point2D.Float getSCPt(Province key)
          Convenience method: get Supply Center placement point for this Province
 MapMetadata.SymbolSize getSymbolSize(java.lang.String symbolName)
          Gets the SymbolSize for a symbol; null if symbol is not recognized.
 java.awt.geom.Point2D.Float getUnitPt(Province key, Coast coast)
          Convenience method: get Unit placement point for this Province
 void setInfoEntry(Province key, MapMetadata.InfoEntry value)
          Set an InfoEntry This generally should NOT be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JDIP_NAMESPACE

public static final java.lang.String JDIP_NAMESPACE
jDip namespace constant

See Also:
Constant Field Values

EL_DISPLAY

public static final java.lang.String EL_DISPLAY
jDip namespace element: for display control

See Also:
Constant Field Values

EL_ZOOM

public static final java.lang.String EL_ZOOM
jDip namespace element: for display control (zoom)

See Also:
Constant Field Values

EL_LABELS

public static final java.lang.String EL_LABELS
jDip namespace element: for display control (labels)

See Also:
Constant Field Values

ATT_ZOOM_MIN

public static final java.lang.String ATT_ZOOM_MIN
jDip namespace attributes: display: zoom

See Also:
Constant Field Values

ATT_ZOOM_MAX

public static final java.lang.String ATT_ZOOM_MAX
jDip namespace attributes: display: zoom

See Also:
Constant Field Values

ATT_ZOOM_FACTOR

public static final java.lang.String ATT_ZOOM_FACTOR
jDip namespace attributes: display: zoom

See Also:
Constant Field Values

ATT_LABELS_BRIEF

public static final java.lang.String ATT_LABELS_BRIEF
jDip namespace attributes: display: labels

See Also:
Constant Field Values

ATT_LABELS_FULL

public static final java.lang.String ATT_LABELS_FULL
jDip namespace attributes: display: labels

See Also:
Constant Field Values

EL_PROVINCE_DATA

public static final java.lang.String EL_PROVINCE_DATA
jDip namespace element: for province metadata (main grouping)

See Also:
Constant Field Values

EL_PROVINCE

public static final java.lang.String EL_PROVINCE
jDip namespace element: for province metadata: province

See Also:
Constant Field Values

EL_UNIT

public static final java.lang.String EL_UNIT
jDip namespace element: for province metadata: units

See Also:
Constant Field Values

EL_DISLODGED_UNIT

public static final java.lang.String EL_DISLODGED_UNIT
jDip namespace element: for province metadata: dislodged units

See Also:
Constant Field Values

EL_SC

public static final java.lang.String EL_SC
jDip namespace element: for province metadata: supply centers

See Also:
Constant Field Values

ATT_X

public static final java.lang.String ATT_X
jDip namespace attributes: province

See Also:
Constant Field Values

ATT_Y

public static final java.lang.String ATT_Y
jDip namespace attributes: province

See Also:
Constant Field Values

ATT_NAME

public static final java.lang.String ATT_NAME
jDip namespace attributes: province, symbolsize

See Also:
Constant Field Values

EL_ORDERDRAWING

public static final java.lang.String EL_ORDERDRAWING
jDip namespace for Order metadata

See Also:
Constant Field Values

EL_HOLD

public static final java.lang.String EL_HOLD
Hold order drawing parameter element

See Also:
Constant Field Values

EL_DISBAND

public static final java.lang.String EL_DISBAND
Disband order drawing parameter element

See Also:
Constant Field Values

EL_REMOVE

public static final java.lang.String EL_REMOVE
Remove order drawing parameter element

See Also:
Constant Field Values

EL_BUILD

public static final java.lang.String EL_BUILD
Build order drawing parameter element

See Also:
Constant Field Values

EL_MOVE

public static final java.lang.String EL_MOVE
Move order drawing parameter element

See Also:
Constant Field Values

EL_RETREAT

public static final java.lang.String EL_RETREAT
Retreat order drawing parameter element

See Also:
Constant Field Values

EL_SUPPORT

public static final java.lang.String EL_SUPPORT
Support order drawing parameter element

See Also:
Constant Field Values

EL_CONVOY

public static final java.lang.String EL_CONVOY
Convoy order drawing parameter element

See Also:
Constant Field Values

EL_WAIVE

public static final java.lang.String EL_WAIVE
Waive order drawing parameter element

See Also:
Constant Field Values

EL_POWERCOLORS

public static final java.lang.String EL_POWERCOLORS
Power Colors group

See Also:
Constant Field Values

EL_POWERCOLOR

public static final java.lang.String EL_POWERCOLOR
Power Color item

See Also:
Constant Field Values

EL_SYMBOLSIZE

public static final java.lang.String EL_SYMBOLSIZE
Symbol Size element

See Also:
Constant Field Values

ATT_DELTA_RADIUS

public static final java.lang.String ATT_DELTA_RADIUS
jDip namespace attribute: order drawing: deltaRadius

See Also:
Constant Field Values

ATT_STROKESTYLE

public static final java.lang.String ATT_STROKESTYLE
jDip namespace attribute: order drawing: stroke CSS style

See Also:
Constant Field Values

ATT_FILTERID

public static final java.lang.String ATT_FILTERID
jDip namespace attribute: order drawing: filter ID

See Also:
Constant Field Values

ATT_MARKERID

public static final java.lang.String ATT_MARKERID
jDip namespace attribute: order drawing: marker ID

See Also:
Constant Field Values

ATT_POWER

public static final java.lang.String ATT_POWER
jDip namespace attribute: power colors: power name

See Also:
Constant Field Values

ATT_COLOR

public static final java.lang.String ATT_COLOR
jDip namespace attribute: power colors: color name/value

See Also:
Constant Field Values

ATT_HILIGHT_OFFSET

public static final java.lang.String ATT_HILIGHT_OFFSET
jDip namespace attribute: order drawing: highlight offset (float)

See Also:
Constant Field Values

ATT_HILIGHT_CLASS

public static final java.lang.String ATT_HILIGHT_CLASS
jDip namespace attribute: order drawing: highlight class

See Also:
Constant Field Values

ATT_WIDTHS

public static final java.lang.String ATT_WIDTHS
jDip namespace attribute: order drawing: order line widths

See Also:
Constant Field Values

ATT_SHADOW_WIDTHS

public static final java.lang.String ATT_SHADOW_WIDTHS
jDip namespace attribute: order drawing: order shadow line widths

See Also:
Constant Field Values

ATT_WIDTH

public static final java.lang.String ATT_WIDTH
jDip namespace attribute: symbol size: symbol width

See Also:
Constant Field Values

ATT_HEIGHT

public static final java.lang.String ATT_HEIGHT
jDip namespace attribute: symbol size: symbol height

See Also:
Constant Field Values
Constructor Detail

MapMetadata

public MapMetadata(MapPanel mp,
                   SymbolPack sp,
                   boolean supressPlacementErrors)
            throws MapException
Create a MapMetadata Object, by parsing the SVG placement id group metadata

If supressPlacementErrors are suppressed, using the appropriate boolean flag, only valid parsed placement data will be used. Data which is missing, or invalid, will be replaced with 0 values. Display and Order Drawing metadata parsing is unaffected by this flag.

Method Detail

close

public void close()
Clean up any resources used by this object


getInfoEntry

public MapMetadata.InfoEntry getInfoEntry(Province key)
Get an InfoEntry


setInfoEntry

public void setInfoEntry(Province key,
                         MapMetadata.InfoEntry value)
Set an InfoEntry

This generally should NOT be used. It is intended for map editors and what not.


getUnitPt

public java.awt.geom.Point2D.Float getUnitPt(Province key,
                                             Coast coast)
Convenience method: get Unit placement point for this Province


getDislodgedUnitPt

public java.awt.geom.Point2D.Float getDislodgedUnitPt(Province key,
                                                      Coast coast)
Convenience method: get Dislodged Unit placement point for this Province


getSCPt

public java.awt.geom.Point2D.Float getSCPt(Province key)
Convenience method: get Supply Center placement point for this Province


getSymbolSize

public MapMetadata.SymbolSize getSymbolSize(java.lang.String symbolName)
Gets the SymbolSize for a symbol; null if symbol is not recognized. Case sensitive.


getDisplayParamFloat

public float getDisplayParamFloat(java.lang.String key,
                                  float defaultValue)
Gets a float metadata value


getDisplayParamInt

public int getDisplayParamInt(java.lang.String key,
                              int defaultValue)
Gets an int metadata value


getDisplayParamBoolean

public boolean getDisplayParamBoolean(java.lang.String key,
                                      boolean defaultValue)
Gets a boolean display metadata value


getOrderParamString

public java.lang.String getOrderParamString(java.lang.String orderElement,
                                            java.lang.String attribute)
Gets the String version of a parameter. Throws an IllegalArgumentException if parameter is not found; will never return null.

Example usage: String id = getOrderParamString(EL_BUILD, ATT_FILTERID);


getOrderParamFloat

public float getOrderParamFloat(java.lang.String orderElement,
                                java.lang.String attribute)
Gets the float version of a parameter. Throws an IllegalArgumentException if parameter is not found.


getOrderRadius

public float getOrderRadius(java.lang.String orderElement,
                            java.lang.String symbolName)
Gets the adjusted radius for an order. This is a convenience method. It is equivalent to calling getOrderParamFloat(, ATT_DELTA_RADIUS) and passing that value into SymbolSize.getRadius().

symbolName is typically a Unit symbol name (e.g., "Wing", "Army", "DislodgedFleet", etc.).
orderElement is a order element constant (e.g., EL_HOLD, EL_MOVE).


getOrderParamFloatArray

public float[] getOrderParamFloatArray(java.lang.String orderElement,
                                       java.lang.String attribute)
Gets the float array version of a parameter. Throws an IllegalArgumentException if parameter is not found.


getPowerColor

public java.lang.String getPowerColor(Power power)
Get power color (the color of orders associated w/a power



Copyright 2002-2004 Zachary DelProposto / jDip Development Team. All Rights Reserved.