Package gov.nasa.worldwind.ogc.kml
Class KMLStyleMap
- java.lang.Object
-
- gov.nasa.worldwind.util.xml.AbstractXMLEventParser
-
- gov.nasa.worldwind.ogc.kml.KMLAbstractObject
-
- gov.nasa.worldwind.ogc.kml.KMLAbstractStyleSelector
-
- gov.nasa.worldwind.ogc.kml.KMLStyleMap
-
- All Implemented Interfaces:
MessageListener
,XMLEventParser
public class KMLStyleMap extends KMLAbstractStyleSelector
Represents the KML StyleMap element and provides access to its contents.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<KMLPair>
pairs
-
Fields inherited from class gov.nasa.worldwind.ogc.kml.KMLAbstractObject
MSG_BOX_CHANGED, MSG_GEOMETRY_CHANGED, MSG_LINK_CHANGED, MSG_STYLE_CHANGED, MSG_TIME_CHANGED, MSG_VIEW_CHANGED
-
Fields inherited from class gov.nasa.worldwind.util.xml.AbstractXMLEventParser
CHARACTERS_CONTENT, fields, namespaceURI, parent
-
-
Constructor Summary
Constructors Constructor Description KMLStyleMap(java.lang.String namespaceURI)
Construct an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addPair(KMLPair pair)
void
applyChange(KMLAbstractObject sourceValues)
protected void
doAddEventContent(java.lang.Object o, XMLEventParserContext ctx, javax.xml.stream.events.XMLEvent event, java.lang.Object... args)
java.util.List<KMLPair>
getPairs()
KMLAbstractStyleSelector
getStyleFromMap(java.lang.String styleState)
Returns a specified style from the style map.KMLStyleUrl
getStyleUrlFromMap(java.lang.String styleState)
Returns a specified style URL from the style map.protected void
mergePairs(KMLStyleMap sourceMap)
Merge a list of incoming pairs with the current list.KMLAbstractSubStyle
mergeSubStyles(KMLAbstractSubStyle subStyle, java.lang.String styleState)
Obtains the map's effective style for a specified style type (IconStyle, ListStyle, etc.) and state (normal or highlight).-
Methods inherited from class gov.nasa.worldwind.ogc.kml.KMLAbstractStyleSelector
markUnresolved, mergeSubStyles, mergeSubStyles
-
Methods inherited from class gov.nasa.worldwind.ogc.kml.KMLAbstractObject
getId, getRoot, getTargetId, onChange, onMessage
-
Methods inherited from class gov.nasa.worldwind.util.xml.AbstractXMLEventParser
allocate, doAddCharacters, doAddEventAttribute, doParseEventAttributes, doParseEventContent, freeResources, getAConstructor, getCharacters, getField, getField, getFields, getNamespaceURI, getParent, hasField, hasField, hasFields, mergeFields, newInstance, overrideFields, parse, parseCharacterContent, removeField, setField, setField, setFields, setNamespaceURI, setParent
-
-
-
-
Field Detail
-
pairs
protected java.util.List<KMLPair> pairs
-
-
Method Detail
-
doAddEventContent
protected void doAddEventContent(java.lang.Object o, XMLEventParserContext ctx, javax.xml.stream.events.XMLEvent event, java.lang.Object... args) throws javax.xml.stream.XMLStreamException
- Overrides:
doAddEventContent
in classAbstractXMLEventParser
- Throws:
javax.xml.stream.XMLStreamException
-
getPairs
public java.util.List<KMLPair> getPairs()
-
addPair
protected void addPair(KMLPair pair)
-
getStyleFromMap
public KMLAbstractStyleSelector getStyleFromMap(java.lang.String styleState)
Returns a specified style from the style map.- Parameters:
styleState
- the style key, eitherKMLConstants.NORMAL
orKMLConstants.HIGHLIGHT
. If null,KMLConstants.NORMAL
is used.- Returns:
- the requested style, or null if it does not exist in the map.
-
getStyleUrlFromMap
public KMLStyleUrl getStyleUrlFromMap(java.lang.String styleState)
Returns a specified style URL from the style map.- Parameters:
styleState
- the style key, eitherKMLConstants.NORMAL
orKMLConstants.HIGHLIGHT
. If null,KMLConstants.NORMAL
is used.- Returns:
- the requested style URL, or null if it does not exist in the map.
-
mergeSubStyles
public KMLAbstractSubStyle mergeSubStyles(KMLAbstractSubStyle subStyle, java.lang.String styleState)
Obtains the map's effective style for a specified style type (IconStyle, ListStyle, etc.) and state (normal or highlight). The returned style is the result of merging values from the map's style selectors and style URL for the indicated sub-style type, with precedence given to style selectors.Remote styleUrls that have not yet been resolved are not included in the result. In this case the returned sub-style is marked with the value
AVKey.UNRESOLVED
.- Parameters:
styleState
- the style mode, either \"normal\" or \"highlight\".subStyle
- an instance of theKMLAbstractSubStyle
class desired, such asKMLIconStyle
. The effective style values are accumulated and merged into this instance. The instance should not be one from within the KML document because its values may be overridden and augmented. The instance specified is the return value of this method.- Returns:
- the sub-style values for the specified type and state. The reference returned is the same one passed in
as the
subStyle
argument.
-
applyChange
public void applyChange(KMLAbstractObject sourceValues)
- Overrides:
applyChange
in classKMLAbstractObject
-
mergePairs
protected void mergePairs(KMLStyleMap sourceMap)
Merge a list of incoming pairs with the current list. If an incoming pair has the same ID as an existing one, replace the existing one, otherwise just add the incoming one.- Parameters:
sourceMap
- the incoming pairs.
-
-