NASA World Wind

gov.nasa.worldwind.ogc.kml
Class KMLAbstractFeature

java.lang.Object
  extended by gov.nasa.worldwind.util.xml.AbstractXMLEventParser
      extended by gov.nasa.worldwind.ogc.kml.KMLAbstractObject
          extended by gov.nasa.worldwind.ogc.kml.KMLAbstractFeature
All Implemented Interfaces:
MessageListener, KMLRenderable, XMLEventParser
Direct Known Subclasses:
GXTour, KMLAbstractContainer, KMLAbstractOverlay, KMLPlacemark

public abstract class KMLAbstractFeature
extends KMLAbstractObject
implements KMLRenderable

Represents the KML Feature element and provides access to its contents.

KMLAbstractFeature implements the KMLRenderable interface, but does not actually render anything. Subclasses should override the methods doPreRender(gov.nasa.worldwind.ogc.kml.impl.KMLTraversalContext, gov.nasa.worldwind.render.DrawContext) and doRender(gov.nasa.worldwind.ogc.kml.impl.KMLTraversalContext, gov.nasa.worldwind.render.DrawContext) to render their contents. If the visibility property is set to false, this does not call doPreRender and doRender during rendering.


Field Summary
protected  Balloon balloon
          A balloon explicitly associated with this feature by the client.
protected  KMLRegion region
          The region specified in the KML Feature element.
protected  List<KMLAbstractStyleSelector> styleSelectors
          The style selectors specified in the KML Feature element.
protected  Boolean visibility
          The visibility flag for the feature.
 
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
protected KMLAbstractFeature(String namespaceURI)
          Construct an instance.
 
Method Summary
protected  void addStyleSelector(KMLAbstractStyleSelector o)
           
 void applyChange(KMLAbstractObject sourceValues)
           
protected  void doAddEventContent(Object o, XMLEventParserContext ctx, XMLEvent event, Object... args)
           
protected  void doPreRender(KMLTraversalContext tc, DrawContext dc)
          Called from preRender if this KMLAbstractFeature's visibility is not set to false.
protected  void doRender(KMLTraversalContext tc, DrawContext dc)
          Called from render if this KMLAbstractFeature's visibility is not set to false.
 String getAddress()
           
 XALAddressDetails getAddressDetails()
           
 AtomPerson getAuthor()
           
 Balloon getBalloon()
          Get the balloon associated with this feature, if any.
 String getDescription()
           
 KMLExtendedData getExtendedData()
           
 AtomLink getLink()
           
 String getName()
           
 Boolean getOpen()
           
 String getPhoneNumber()
           
 KMLRegion getRegion()
           
 Object getSnippet()
           
 String getSnippetText()
           
 List<KMLAbstractStyleSelector> getStyleSelectors()
           
 KMLStyleUrl getStyleUrl()
           
 KMLAbstractSubStyle getSubStyle(KMLAbstractSubStyle subStyle, String styleState)
          Obtains the effective values for a specified sub-style (IconStyle, ListStyle, etc.) and state (normal or highlight).
 KMLAbstractTimePrimitive getTimePrimitive()
           
 KMLAbstractView getView()
           
 Boolean getVisibility()
          Indicates whether this KMLAbstractFeature is enabled for rendering.
 boolean hasStyle()
           
 boolean hasStyleSelectors()
           
protected  boolean isFeatureActive(KMLTraversalContext tc, DrawContext dc)
          Indicates whether this KMLAbstractFeature is active and should be rendered on the specified DrawContext.
protected  void mergeStyleSelectors(KMLAbstractFeature sourceFeature)
          Merge a list of incoming style selectors with the current list.
 void preRender(KMLTraversalContext tc, DrawContext dc)
          Pre-render this element.
 void render(KMLTraversalContext tc, DrawContext dc)
          Render this element.
protected  void renderBalloon(KMLTraversalContext tc, DrawContext dc)
          Draws the Balloon associated with this KML feature.
 void setBalloon(Balloon balloon)
          Set the balloon associated with this feature.
protected  void setRegion(KMLRegion region)
           
protected  void setTimePrimitive(KMLAbstractTimePrimitive o)
           
protected  void setView(KMLAbstractView o)
           
 void setVisibility(Boolean visibility)
          Specifies whether this KMLAbstractFeature is enabled for rendering.
 
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, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
 

Field Detail

balloon

protected Balloon balloon
A balloon explicitly associated with this feature by the client. This is not a KML field of the Feature element.


region

protected KMLRegion region
The region specified in the KML Feature element. Is null if no region was specified.


styleSelectors

protected List<KMLAbstractStyleSelector> styleSelectors
The style selectors specified in the KML Feature element. Is empty if no selectors were specified.


visibility

protected Boolean visibility
The visibility flag for the feature. This field is determined from the visibility element of the KML feature initially, but the client may set it directly, in which case it may then differ from the visibility field in the fields table.

Constructor Detail

KMLAbstractFeature

protected KMLAbstractFeature(String namespaceURI)
Construct an instance.

Parameters:
namespaceURI - the qualifying namespace URI. May be null to indicate no namespace qualification.
Method Detail

addStyleSelector

protected void addStyleSelector(KMLAbstractStyleSelector o)

applyChange

public void applyChange(KMLAbstractObject sourceValues)
Overrides:
applyChange in class KMLAbstractObject

doAddEventContent

protected void doAddEventContent(Object o,
                                 XMLEventParserContext ctx,
                                 XMLEvent event,
                                 Object... args)
                          throws XMLStreamException
Overrides:
doAddEventContent in class AbstractXMLEventParser
Throws:
XMLStreamException

doPreRender

protected void doPreRender(KMLTraversalContext tc,
                           DrawContext dc)
Called from preRender if this KMLAbstractFeature's visibility is not set to false. Subclasses should override this method to pre-render their content.

Parameters:
tc - the current KML traversal context.
dc - the current draw context.

doRender

protected void doRender(KMLTraversalContext tc,
                        DrawContext dc)
Called from render if this KMLAbstractFeature's visibility is not set to false. Subclasses should override this method to render their content.

Parameters:
tc - the current KML traversal context.
dc - the current draw context.

getAddress

public String getAddress()

getAddressDetails

public XALAddressDetails getAddressDetails()

getAuthor

public AtomPerson getAuthor()

getBalloon

public Balloon getBalloon()
Get the balloon associated with this feature, if any.

Returns:
The balloon associated with the feature. Returns null if there is no associated balloon.

getDescription

public String getDescription()

getExtendedData

public KMLExtendedData getExtendedData()

getLink

public AtomLink getLink()

getName

public String getName()

getOpen

public Boolean getOpen()

getPhoneNumber

public String getPhoneNumber()

getRegion

public KMLRegion getRegion()

getSnippet

public Object getSnippet()

getSnippetText

public String getSnippetText()

getStyleSelectors

public List<KMLAbstractStyleSelector> getStyleSelectors()

getStyleUrl

public KMLStyleUrl getStyleUrl()

getSubStyle

public KMLAbstractSubStyle getSubStyle(KMLAbstractSubStyle subStyle,
                                       String styleState)
Obtains the effective values for a specified sub-style (IconStyle, ListStyle, etc.) and state (normal or highlight). The returned style is the result of merging values from this feature instance's style selectors and its styleUrl, if any, with precedence given to style selectors.

A remote styleUrl that has not yet been resolved is not included in the result. In this case the returned sub-style is marked with the value AVKey.UNRESOLVED. The same is true when a StyleMap style selector contains a reference to an external Style and that reference has not been resolved.

Parameters:
styleState - the style mode, either \"normal\" or \"highlight\".
subStyle - an instance of the sub-style desired, such as KMLIconStyle. The effective sub-style values are accumulated and merged into this instance. The instance should not be one from within the KML document because its values are overridden and augmented; it's just an independent variable in which to return the merged attribute values. For convenience, the instance specified is returned as the return value of this method.
Returns:
the sub-style values for the specified type and state. The reference returned is the one passed in as the subStyle argument.

getTimePrimitive

public KMLAbstractTimePrimitive getTimePrimitive()

getView

public KMLAbstractView getView()

getVisibility

public Boolean getVisibility()
Indicates whether this KMLAbstractFeature is enabled for rendering. This returns null if no visibility is specified. This indicates the default visibility of true should be used.

Returns:
true or null to draw feature shape, otherwise false. The default value is true.
See Also:
setVisibility(Boolean)

hasStyle

public boolean hasStyle()

hasStyleSelectors

public boolean hasStyleSelectors()

isFeatureActive

protected boolean isFeatureActive(KMLTraversalContext tc,
                                  DrawContext dc)
Indicates whether this KMLAbstractFeature is active and should be rendered on the specified DrawContext. This returns true if the following conditions are all true:

If this feature has no Region, this inherits the Region of its nearest ancestor by using the Region on the top of the KML traversal context's region stack (if any). If there is no ancestor Region this feature is assumed to be the DrawContext's view and is rendered according to its visibility flag. A Region is considered active if it is visible, and the DrawContext meets the Region's level of detail criteria.

Parameters:
tc - the current KML traversal context. Specifies an inherited Region (if any) and a detail hint.
dc - the current draw context. Used to determine whether this feature's Region is active.
Returns:
true if this feature should be rendered, otherwise false.

mergeStyleSelectors

protected void mergeStyleSelectors(KMLAbstractFeature sourceFeature)
Merge a list of incoming style selectors with the current list. If an incoming selector has the same ID as an existing one, replace the existing one, otherwise just add the incoming one.

Parameters:
sourceFeature - the incoming style selectors.

preRender

public void preRender(KMLTraversalContext tc,
                      DrawContext dc)
Pre-render this element.

Specified by:
preRender in interface KMLRenderable
Parameters:
tc - the current KML traversal context.
dc - the current draw context.

render

public void render(KMLTraversalContext tc,
                   DrawContext dc)
Render this element.

Specified by:
render in interface KMLRenderable
Parameters:
tc - the current KML traversal context.
dc - the current draw context.

renderBalloon

protected void renderBalloon(KMLTraversalContext tc,
                             DrawContext dc)
Draws the Balloon associated with this KML feature. This does nothing if there is no Balloon associated with this feature.

Parameters:
tc - the current KML traversal context.
dc - the current draw context.

setBalloon

public void setBalloon(Balloon balloon)
Set the balloon associated with this feature.

Note: Balloon is not a field in the KML Feature element. It's a direct field of this class and enables the client to associate a balloon with the feature.

Parameters:
balloon - New balloon.

setRegion

protected void setRegion(KMLRegion region)

setTimePrimitive

protected void setTimePrimitive(KMLAbstractTimePrimitive o)

setView

protected void setView(KMLAbstractView o)

setVisibility

public void setVisibility(Boolean visibility)
Specifies whether this KMLAbstractFeature is enabled for rendering.

Parameters:
visibility - true or null to draw this feature, otherwise false. The default value is true.
See Also:
getVisibility()

NASA World Wind