public class KMLNetworkLink extends KMLAbstractContainer implements java.beans.PropertyChangeListener
KMLNetworkLink
retrieves and loads its network resource whenever necessary. Upon a
successful retrieval, KMLNetworkLink
sends an AVKey.RETRIEVAL_STATE_SUCCESSFUL
property
change event to this link's property change listeners. Once retrieved and loaded, KMLNetworkLink
stores
its network resource by calling setNetworkResource
, draws its network resource during preRendering and
rendering, and forwards property change events from the network resource to its property change listeners.
During retrieval, KMLNetworkLink
attempts to use either the Link
or the Url
.
The Link
is the preferred method for encoding a KML NetworkLink's address since KML version 2.1,
therefore we give it priority over Url
.Modifier and Type | Class and Description |
---|---|
protected static class |
KMLNetworkLink.RequestTask
Attempts to find this network link resource file locally, and if that fails attempts to find it remotely.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.atomic.AtomicLong |
firstRetrievalTime |
protected boolean |
invalidTarget
Flag that is raised if the link retrieves a files that is not a KML document.
|
protected KMLLink |
link |
protected boolean |
linkFetched
Flag to indicate that the Link has been fetched from the hash map.
|
protected java.util.concurrent.atomic.AtomicReference<KMLRoot> |
networkResource
Indicates the network resource referenced by this
KMLNetworkLink . |
protected java.util.concurrent.atomic.AtomicLong |
networkResourceRetrievalTime
Time, in milliseconds since the Epoch, at which this
KMLNetworkLink's network resource was last
retrieved. |
protected KMLRoot |
root
Cache the root of this network link.
|
features
balloon, region, styleSelectors, visibility
MSG_BOX_CHANGED, MSG_GEOMETRY_CHANGED, MSG_LINK_CHANGED, MSG_STYLE_CHANGED, MSG_TIME_CHANGED, MSG_VIEW_CHANGED
CHARACTERS_CONTENT, fields, namespaceURI, parent
Constructor and Description |
---|
KMLNetworkLink(java.lang.String namespaceURI)
Construct an instance.
|
Modifier and Type | Method and Description |
---|---|
void |
applyChange(KMLAbstractObject sourceValues) |
protected long |
computeExpiryRefreshTime(KMLRoot root,
java.lang.String address)
Indicates the expiration time of a linked resource.
|
protected void |
doPreRender(KMLTraversalContext tc,
DrawContext dc)
Pre-renders the network resource referenced by this
KMLNetworkLink . |
protected void |
doRender(KMLTraversalContext tc,
DrawContext dc)
Renders the network resource referenced by this
KMLNetworkLink . |
java.lang.String |
getDescription() |
java.lang.Boolean |
getFlyToView() |
protected KMLLink |
getLinkOrUrl()
Returns this
NetworkLink's Link element or its Url element, depending on
which is available. |
java.lang.String |
getName() |
KMLLink |
getNetworkLink() |
KMLRoot |
getNetworkResource()
Indicates the network resource referenced by this
KMLNetworkLink . |
java.lang.Boolean |
getRefreshVisibility() |
KMLRoot |
getRoot()
Overridden to cache the root instead of climbing the parse tree each time.
|
java.lang.Object |
getSnippet() |
KMLLink |
getUrl() |
protected boolean |
hasNetworkLinkControl() |
protected boolean |
isFeatureActive(KMLTraversalContext tc,
DrawContext dc)
Indicates whether this
KMLAbstractContainer is active and should be rendered on the specified
DrawContext . |
boolean |
isLinkCacheable()
Indicates whether the network resource references by this
KMLNetworkLink should be retrieved to the
WorldWind cache or to a temporary location. |
protected boolean |
mustRetrieveNetworkResource()
Returns whether this
KMLNetworkLink must retrieve its network resource. |
void |
onChange(Message msg) |
void |
onMessage(Message msg)
Invoked when a message is received.
|
void |
propertyChange(java.beans.PropertyChangeEvent evt)
Forward property change events from the inner
KMLRoot to this object's parent KMLRoot. |
protected void |
requestResource(DrawContext dc)
Thread's off a task to determine whether the resource is local or remote and then retrieves it either from disk
cache or a remote server.
|
protected void |
reset() |
protected void |
retrieveNetworkResource(java.lang.String address)
Initiates a retrieval of the network resource referenced by this
KMLNetworkLink . |
void |
setNetworkResource(KMLRoot kmlRoot)
Specifies the network resource referenced by this
KMLNetworkLink , or null if this link
has no resource. |
addFeature, beginRendering, doAddEventContent, endRendering, getFeatures, mergeFeatures, preRenderFeatures, removeFeature, renderFeatures
addStyleSelector, getAddress, getAddressDetails, getAuthor, getBalloon, getExtendedData, getLink, getOpen, getPhoneNumber, getRegion, getSnippetText, getStyleSelectors, getStyleUrl, getSubStyle, getTimePrimitive, getView, getVisibility, hasStyle, hasStyleSelectors, mergeStyleSelectors, preRender, render, renderBalloon, setBalloon, setRegion, setTimePrimitive, setView, setVisibility
getId, getTargetId
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
protected java.util.concurrent.atomic.AtomicLong firstRetrievalTime
protected boolean invalidTarget
protected KMLLink link
protected boolean linkFetched
protected java.util.concurrent.atomic.AtomicReference<KMLRoot> networkResource
KMLNetworkLink
. Initially null
.protected java.util.concurrent.atomic.AtomicLong networkResourceRetrievalTime
KMLNetworkLink's
network resource was last
retrieved. Initially -1
, indicating that the network resource has not been retrieved.protected KMLRoot root
public KMLNetworkLink(java.lang.String namespaceURI)
namespaceURI
- the qualifying namespace URI. May be null to indicate no namespace qualification.public void applyChange(KMLAbstractObject sourceValues)
applyChange
in class KMLAbstractContainer
protected long computeExpiryRefreshTime(KMLRoot root, java.lang.String address)
root
- Root of target resource.address
- Address of linked resource.protected void doPreRender(KMLTraversalContext tc, DrawContext dc)
KMLNetworkLink
. If this link must retrieve its
network resource, this initiates a retrieval and does nothing until the resource is retrieved and loaded. Once
the network resource is retrieved and loaded, this calls setNetworkResource(KMLRoot)
to
specify this link's new network resource, and sends an AVKey.RETRIEVAL_STATE_SUCCESSFUL
property change event to this link's property change listeners.doPreRender
in class KMLAbstractContainer
tc
- the current KML traversal context.dc
- the current draw context.getNetworkResource()
protected void doRender(KMLTraversalContext tc, DrawContext dc)
KMLNetworkLink
. This does nothing if this link has
no network resource.doRender
in class KMLAbstractContainer
tc
- the current KML traversal context.dc
- the current draw context.public java.lang.String getDescription()
getDescription
in class KMLAbstractFeature
public java.lang.Boolean getFlyToView()
protected KMLLink getLinkOrUrl()
NetworkLink's
Link
element or its Url
element, depending on
which is available. Link
is the preferred method for encoding a NetworkLink
since KML
version 2.1, therefore we give it priority. If a Link
is not specified, the deprecated
Url
element is returned.NetworkLink's
Link
element, if one is specified. Otherwise, this
NetworkLink's
Url
element. Returns null
if neither
Link
or a Url
are specified.public java.lang.String getName()
getName
in class KMLAbstractFeature
public KMLLink getNetworkLink()
public KMLRoot getNetworkResource()
KMLNetworkLink
. This returns null
if
this link has no resource.null
to indicate that this link has no resource.setNetworkResource(KMLRoot)
public java.lang.Boolean getRefreshVisibility()
public KMLRoot getRoot()
getRoot
in class KMLAbstractObject
public java.lang.Object getSnippet()
getSnippet
in class KMLAbstractFeature
public KMLLink getUrl()
protected boolean hasNetworkLinkControl()
protected boolean isFeatureActive(KMLTraversalContext tc, DrawContext dc)
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. Overridden to apply region culling according to the same rules as in KMLAbstractFeature. This
prevents retrieving network links in inactive regions.isFeatureActive
in class KMLAbstractContainer
tc
- the current KML traversal context. This parameter is ignored.dc
- the draw context. This parameter is ignored.true
if this container should be rendered, otherwise false
.public boolean isLinkCacheable()
KMLNetworkLink
should be retrieved to the
WorldWind cache or to a temporary location. This returns true
if all of the following conditions
are met, and false
otherwise:
Link
or a Url
element.refreshMode
is not onInterval
or onExpire
.viewRefreshMode
is not onStop
.true
if this link's network resource can should be stored in a cache, or false
if it should be stored in a temporary location.protected boolean mustRetrieveNetworkResource()
KMLNetworkLink
must retrieve its network resource. This always returns
false
if this KMLNetworkLink
has no KMLLink
.true
if this KMLNetworkLink
must retrieve its network resource, otherwise
false
.public void onChange(Message msg)
onChange
in class KMLAbstractObject
public void onMessage(Message msg)
MessageListener
onMessage
in interface MessageListener
onMessage
in class KMLAbstractContainer
msg
- The message that was received.public void propertyChange(java.beans.PropertyChangeEvent evt)
KMLRoot
to this object's parent KMLRoot.propertyChange
in interface java.beans.PropertyChangeListener
evt
- Event to forward.protected void requestResource(DrawContext dc)
dc
- the current draw context.protected void reset()
protected void retrieveNetworkResource(java.lang.String address)
KMLNetworkLink
. Once the network
resource is retrieved and loaded, this calls setNetworkResource(KMLRoot)
to specify this
link's new network resource, and sends an AVKey.RETRIEVAL_STATE_SUCCESSFUL
property change event to this link's property change listeners.
This does nothing if this KMLNetworkLink
has no KMLLink
.address
- the address of the resource to retrievepublic void setNetworkResource(KMLRoot kmlRoot)
KMLNetworkLink
, or null
if this link
has no resource. If the specified kmlRoot
is not null
kmlRoot during preRendering and rendering, and forwards property change events from the
kmlRoot
to this link's property change listeners.kmlRoot
- the network resource referenced by this KMLNetworkLink
. May be null
.getNetworkResource()