Class KMLAbstractFeature
- java.lang.Object
-
- gov.nasa.worldwind.util.xml.AbstractXMLEventParser
-
- gov.nasa.worldwind.ogc.kml.KMLAbstractObject
-
- 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 theKMLRenderable
interface, but does not actually render anything. Subclasses should override the methods
anddoPreRender(gov.nasa.worldwind.ogc.kml.impl.KMLTraversalContext, gov.nasa.worldwind.render.DrawContext)
to render their contents. If thedoRender(gov.nasa.worldwind.ogc.kml.impl.KMLTraversalContext, gov.nasa.worldwind.render.DrawContext)
visibility
property is set tofalse
, this does not calldoPreRender
anddoRender
during rendering.
-
-
Field Summary
Fields Modifier and Type Field Description 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 java.util.List<KMLAbstractStyleSelector>
styleSelectors
The style selectors specified in the KML Feature element.protected java.lang.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
Constructors Modifier Constructor Description protected
KMLAbstractFeature(java.lang.String namespaceURI)
Construct an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addStyleSelector(KMLAbstractStyleSelector o)
void
applyChange(KMLAbstractObject sourceValues)
protected void
doAddEventContent(java.lang.Object o, XMLEventParserContext ctx, javax.xml.stream.events.XMLEvent event, java.lang.Object... args)
protected void
doPreRender(KMLTraversalContext tc, DrawContext dc)
Called frompreRender
if thisKMLAbstractFeature
'svisibility
is not set tofalse
.protected void
doRender(KMLTraversalContext tc, DrawContext dc)
Called fromrender
if thisKMLAbstractFeature
'svisibility
is not set tofalse
.java.lang.String
getAddress()
XALAddressDetails
getAddressDetails()
AtomPerson
getAuthor()
Balloon
getBalloon()
Get the balloon associated with this feature, if any.java.lang.String
getDescription()
KMLExtendedData
getExtendedData()
AtomLink
getLink()
java.lang.String
getName()
java.lang.Boolean
getOpen()
java.lang.String
getPhoneNumber()
KMLRegion
getRegion()
java.lang.Object
getSnippet()
java.lang.String
getSnippetText()
java.util.List<KMLAbstractStyleSelector>
getStyleSelectors()
KMLStyleUrl
getStyleUrl()
KMLAbstractSubStyle
getSubStyle(KMLAbstractSubStyle subStyle, java.lang.String styleState)
Obtains the effective values for a specified sub-style (IconStyle, ListStyle, etc.) and state (normal or highlight).KMLAbstractTimePrimitive
getTimePrimitive()
KMLAbstractView
getView()
java.lang.Boolean
getVisibility()
Indicates whether thisKMLAbstractFeature
is enabled for rendering.boolean
hasStyle()
boolean
hasStyleSelectors()
protected boolean
isFeatureActive(KMLTraversalContext tc, DrawContext dc)
Indicates whether thisKMLAbstractFeature
is active and should be rendered on the specifiedDrawContext
.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
associated with this KML feature.Balloon
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(java.lang.Boolean visibility)
Specifies whether thisKMLAbstractFeature
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, setNamespaceURI, setParent
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
-
-
-
-
Field Detail
-
styleSelectors
protected java.util.List<KMLAbstractStyleSelector> styleSelectors
The style selectors specified in the KML Feature element. Is empty if no selectors were specified.
-
visibility
protected java.lang.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 thefields
table.
-
region
protected KMLRegion region
The region specified in the KML Feature element. Is null if no region was specified.
-
balloon
protected Balloon balloon
A balloon explicitly associated with this feature by the client. This is not a KML field of the Feature element.
-
-
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
-
getName
public java.lang.String getName()
-
getVisibility
public java.lang.Boolean getVisibility()
Indicates whether thisKMLAbstractFeature
is enabled for rendering. This returnsnull
if no visibility is specified. This indicates the default visibility oftrue
should be used.- Returns:
true
ornull
to draw feature shape, otherwisefalse
. The default value istrue
.- See Also:
setVisibility(Boolean)
-
setVisibility
public void setVisibility(java.lang.Boolean visibility)
Specifies whether thisKMLAbstractFeature
is enabled for rendering.- Parameters:
visibility
-true
ornull
to draw this feature, otherwisefalse
. The default value istrue
.- See Also:
getVisibility()
-
getOpen
public java.lang.Boolean getOpen()
-
getAuthor
public AtomPerson getAuthor()
-
getLink
public AtomLink getLink()
-
getAddress
public java.lang.String getAddress()
-
getAddressDetails
public XALAddressDetails getAddressDetails()
-
getPhoneNumber
public java.lang.String getPhoneNumber()
-
getSnippet
public java.lang.Object getSnippet()
-
getSnippetText
public java.lang.String getSnippetText()
-
getDescription
public java.lang.String getDescription()
-
setView
protected void setView(KMLAbstractView o)
-
getView
public KMLAbstractView getView()
-
setTimePrimitive
protected void setTimePrimitive(KMLAbstractTimePrimitive o)
-
getTimePrimitive
public KMLAbstractTimePrimitive getTimePrimitive()
-
getStyleUrl
public KMLStyleUrl getStyleUrl()
-
addStyleSelector
protected void addStyleSelector(KMLAbstractStyleSelector o)
-
getStyleSelectors
public java.util.List<KMLAbstractStyleSelector> getStyleSelectors()
-
hasStyleSelectors
public boolean hasStyleSelectors()
-
hasStyle
public boolean hasStyle()
-
getRegion
public KMLRegion getRegion()
-
setRegion
protected void setRegion(KMLRegion region)
-
getExtendedData
public KMLExtendedData getExtendedData()
-
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.
-
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.
-
preRender
public void preRender(KMLTraversalContext tc, DrawContext dc)
Pre-render this element.- Specified by:
preRender
in interfaceKMLRenderable
- 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 interfaceKMLRenderable
- Parameters:
tc
- the current KML traversal context.dc
- the current draw context.
-
isFeatureActive
protected boolean isFeatureActive(KMLTraversalContext tc, DrawContext dc)
Indicates whether thisKMLAbstractFeature
is active and should be rendered on the specifiedDrawContext
. This returnstrue
if the following conditions are alltrue
:- This feature's
visibility
is unspecified (null
) or is set totrue
. - This feature as no Region and does not inherit a Region from an ancestor, or its
Region is active for the specified
DrawContext
.
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 itsvisibility
flag. A Region is considered active if it is visible, and theDrawContext
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, otherwisefalse
.
- This feature's
-
doPreRender
protected void doPreRender(KMLTraversalContext tc, DrawContext dc)
Called frompreRender
if thisKMLAbstractFeature
'svisibility
is not set tofalse
. 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 fromrender
if thisKMLAbstractFeature
'svisibility
is not set tofalse
. Subclasses should override this method to render their content.- Parameters:
tc
- the current KML traversal context.dc
- the current draw context.
-
renderBalloon
protected void renderBalloon(KMLTraversalContext tc, DrawContext dc)
Draws the
associated with this KML feature. This does nothing if there is noBalloon
Balloon
associated with this feature.- Parameters:
tc
- the current KML traversal context.dc
- the current draw context.
-
getSubStyle
public KMLAbstractSubStyle getSubStyle(KMLAbstractSubStyle subStyle, java.lang.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 asKMLIconStyle
. 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.
-
applyChange
public void applyChange(KMLAbstractObject sourceValues)
- Overrides:
applyChange
in classKMLAbstractObject
-
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.
-
-