NASA World Wind

gov.nasa.worldwind.ogc.kml
Class KMLAbstractContainer

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
              extended by gov.nasa.worldwind.ogc.kml.KMLAbstractContainer
All Implemented Interfaces:
MessageListener, KMLRenderable, XMLEventParser
Direct Known Subclasses:
KMLDocument, KMLFolder, KMLNetworkLink

public class KMLAbstractContainer
extends KMLAbstractFeature

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


Field Summary
protected  ArrayList<KMLAbstractFeature> features
           
 
Fields inherited from class gov.nasa.worldwind.ogc.kml.KMLAbstractFeature
balloon, region, styleSelectors, visibility
 
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 KMLAbstractContainer(String namespaceURI)
          Construct an instance.
 
Method Summary
 void addFeature(KMLAbstractFeature feature)
           
 void applyChange(KMLAbstractObject sourceValues)
           
protected  void beginRendering(KMLTraversalContext tc, DrawContext dc)
          Prepares this KML container for rendering.
protected  void doAddEventContent(Object o, XMLEventParserContext ctx, XMLEvent event, Object... args)
           
protected  void doPreRender(KMLTraversalContext tc, DrawContext dc)
          Pre-renders the KML features held by this KMLAbstractContainer.
protected  void doRender(KMLTraversalContext tc, DrawContext dc)
          Renders the KML features held by this KMLAbstractContainer.
protected  void endRendering(KMLTraversalContext tc, DrawContext dc)
          Restores any rendering state changed during rendering.
 List<KMLAbstractFeature> getFeatures()
           
protected  boolean isFeatureActive(KMLTraversalContext tc, DrawContext dc)
          Indicates whether this KMLAbstractContainer is active and should be rendered on the specified DrawContext.
protected  void mergeFeatures(KMLAbstractContainer sourceContainer)
          Merge a list of incoming features with the current list.
 void onMessage(Message msg)
          Invoked when a message is received.
protected  void preRenderFeatures(KMLTraversalContext tc, DrawContext dc)
          PreRenders this KML container's list of KML features, in the order they appear in the list.
 void removeFeature(KMLAbstractFeature feature)
           
protected  void renderFeatures(KMLTraversalContext tc, DrawContext dc)
          Draws this KML container's list of KML features, in the order they appear in the list.
 
Methods inherited from class gov.nasa.worldwind.ogc.kml.KMLAbstractFeature
addStyleSelector, getAddress, getAddressDetails, getAuthor, getBalloon, getDescription, getExtendedData, getLink, getName, getOpen, getPhoneNumber, getRegion, getSnippet, getSnippetText, getStyleSelectors, getStyleUrl, getSubStyle, getTimePrimitive, getView, getVisibility, hasStyle, hasStyleSelectors, mergeStyleSelectors, preRender, render, renderBalloon, setBalloon, setRegion, setTimePrimitive, setView, setVisibility
 
Methods inherited from class gov.nasa.worldwind.ogc.kml.KMLAbstractObject
getId, getRoot, getTargetId, onChange
 
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
 

Field Detail

features

protected ArrayList<KMLAbstractFeature> features
Constructor Detail

KMLAbstractContainer

protected KMLAbstractContainer(String namespaceURI)
Construct an instance.

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

addFeature

public void addFeature(KMLAbstractFeature feature)

applyChange

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

beginRendering

protected void beginRendering(KMLTraversalContext tc,
                              DrawContext dc)
Prepares this KML container for rendering. This pushes this container's Region on the KML traversal context's region stack. Descendant features use the KML traversal context's region stack to inherit Regions from parent containers. This must be followed by a call to endRendering.

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

doAddEventContent

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

doPreRender

protected void doPreRender(KMLTraversalContext tc,
                           DrawContext dc)
Pre-renders the KML features held by this KMLAbstractContainer.

Pushes this container's Region on the KML traversal context's region stack before rendering the features, and pops the Region off the stack afterward. Descendant features use the KML traversal context's region stack to inherit Regions from parent containers.

Overrides:
doPreRender in class KMLAbstractFeature
Parameters:
tc - the current KML traversal context.
dc - the current draw context.

doRender

protected void doRender(KMLTraversalContext tc,
                        DrawContext dc)
Renders the KML features held by this KMLAbstractContainer.

Pushes this container's Region on the KML traversal context's region stack before rendering the features, and pops the Region off the stack afterward. Descendant features use the KML traversal context's region stack to inherit Regions from parent containers.

Overrides:
doRender in class KMLAbstractFeature
Parameters:
tc - the current KML traversal context.
dc - the current draw context.

endRendering

protected void endRendering(KMLTraversalContext tc,
                            DrawContext dc)
Restores any rendering state changed during rendering. This pops this container's Region off the KML traversal context's region stack to restore the previous container's Region (if any). This must be preceded by a call to beginRendering.

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

getFeatures

public List<KMLAbstractFeature> getFeatures()

isFeatureActive

protected boolean isFeatureActive(KMLTraversalContext tc,
                                  DrawContext dc)
Indicates whether this KMLAbstractContainer is active and should be rendered on the specified DrawContext. This returns true if this container's visibility is unspecified (null) or is set to true.

Regions do not apply directly to KML containers, because a descendant features can override the container's Region with its own. Since a descendant Region may be larger or have a less restrictive LOD range than this container, we cannot determine the visibility of the entire tree based on this container's Region. A container's Region is inherited by any descendants that do not specify a Region, and Region visibility is determined at the leaf nodes.

Overrides:
isFeatureActive in class KMLAbstractFeature
Parameters:
tc - the current KML traversal context. This parameter is ignored.
dc - the draw context. This parameter is ignored.
Returns:
true if this container should be rendered, otherwise false.

mergeFeatures

protected void mergeFeatures(KMLAbstractContainer sourceContainer)
Merge a list of incoming features with the current list. If an incoming feature has the same ID as an existing one, replace the existing one, otherwise add the incoming one.

Parameters:
sourceContainer - the incoming container of features.

onMessage

public void onMessage(Message msg)
Description copied from interface: MessageListener
Invoked when a message is received.

Specified by:
onMessage in interface MessageListener
Overrides:
onMessage in class KMLAbstractObject
Parameters:
msg - The message that was received.

preRenderFeatures

protected void preRenderFeatures(KMLTraversalContext tc,
                                 DrawContext dc)
PreRenders this KML container's list of KML features, in the order they appear in the list. This does nothing if the list of features is empty.

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

removeFeature

public void removeFeature(KMLAbstractFeature feature)

renderFeatures

protected void renderFeatures(KMLTraversalContext tc,
                              DrawContext dc)
Draws this KML container's list of KML features, in the order they appear in the list. This does nothing if the list of features is empty.

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

NASA World Wind