public class KMLLink extends KMLAbstractObject
getUpdateTime()
.Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
DEFAULT_VIEW_FORMAT |
protected java.lang.String |
finalHref
If this link's href does not need to be modified with a query string, this value is the resource address.
|
protected java.net.URL |
hrefURL
The
URL for the raw href. |
protected java.util.concurrent.ScheduledFuture |
refreshTask
Scheduled task that will update the when it runs.
|
protected java.util.concurrent.atomic.AtomicLong |
updateTime
The time, in milliseconds since the Epoch, at which the linked content was most recently updated.
|
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 |
---|
KMLLink(java.lang.String namespaceURI)
Construct an instance.
|
Modifier and Type | Method and Description |
---|---|
void |
applyChange(KMLAbstractObject sourceValues) |
protected java.lang.String |
buildQueryString(DrawContext dc)
This returns the concatenation of the query part of
href (if any), the viewFormat and
the httpQuery to form the link URL's query part. |
protected java.lang.Long |
computeRefreshTime() |
protected Sector |
computeVisibleBounds(DrawContext dc)
Returns a
Sector that specifies the current visible bounds on the globe. |
java.lang.String |
getAddress(DrawContext dc)
Returns the address of the resource specified by this KML link.
|
java.lang.String |
getHref() |
java.lang.String |
getHttpQuery() |
java.lang.Double |
getRefreshInterval() |
java.lang.String |
getRefreshMode() |
long |
getUpdateTime()
Returns the time at which the linked resource was last updated.
|
java.lang.Double |
getViewBoundScale() |
java.lang.String |
getViewFormat() |
java.lang.String |
getViewRefreshMode() |
java.lang.Double |
getViewRefreshTime() |
protected boolean |
isLocalReference(java.net.URL url)
Returns whether the resource specified by the
url is a local resource. |
void |
onMessage(Message msg)
Schedule the link to refresh when an
View.VIEW_STOPPED message is received, and the link's view refresh
mode is onStop . |
java.lang.Object |
parse(XMLEventParserContext ctx,
javax.xml.stream.events.XMLEvent inputEvent,
java.lang.Object... args)
Parse the event and initialize the parser's values to those found in the event.
|
protected java.util.concurrent.ScheduledFuture |
scheduleDelayedTask(java.lang.Runnable task,
long delay,
java.util.concurrent.TimeUnit timeUnit)
Schedule a task to mark a link as updated after a delay.
|
protected void |
scheduleRefreshIfNeeded()
Schedule a task to refresh the link if the refresh mode requires it.
|
void |
setExpirationTime(long time)
Specifies the time at which the linked resource expires.
|
void |
setField(java.lang.String keyName,
java.lang.Object value)
Overridden to mark
onChange links as updated when a field set. |
void |
setUpdateTime(long updateTime)
Specifies the time at which the linked resource was last updated.
|
getId, getRoot, getTargetId, onChange
allocate, doAddCharacters, doAddEventAttribute, doAddEventContent, doParseEventAttributes, doParseEventContent, freeResources, getAConstructor, getCharacters, getField, getField, getFields, getNamespaceURI, getParent, hasField, hasField, hasFields, mergeFields, newInstance, overrideFields, parseCharacterContent, removeField, setField, setFields, setNamespaceURI, setParent
protected static final java.lang.String DEFAULT_VIEW_FORMAT
protected java.lang.String finalHref
protected java.net.URL hrefURL
URL
for the raw href. Will be null if the href is not a remote URL or this link has a query stringprotected java.util.concurrent.ScheduledFuture refreshTask
onInterval
refresh mode.protected java.util.concurrent.atomic.AtomicLong updateTime
public KMLLink(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 KMLAbstractObject
protected java.lang.String buildQueryString(DrawContext dc)
href
(if any), the viewFormat
and
the httpQuery
to form the link URL's query part. This returns null
if this link's
href
does not specify a URL. This substitutes parameters in viewFormat
according to the
specified DrawContext
's current viewing parameters, and substitutes parameters in
httpQuery
according to the current Configuration
parameters.dc
- the DrawContext
used to determine the current view parameters.null
if this link does not specify a URL.protected java.lang.Long computeRefreshTime()
protected Sector computeVisibleBounds(DrawContext dc)
Sector
that specifies the current visible bounds on the globe. If this link specifies a
viewBoundScale
, this scales the visible bounds from its centroid by that factor, but limits the
bounds to [-90,90] latitude and [-180,180] longitude. This returns Sector.EMPTY_SECTOR
if the globe is not visible.dc
- the DrawContext
for which to compute the visible bounds.DrawContext
.public java.lang.String getAddress(DrawContext dc)
href
is a local resource, this returns only the href
, and ignores the
viewFormat
and httpQuery
. Otherwise, this returns the concatenation of the
href
, the viewFormat
and the httpQuery
for form an absolute URL string. If
the the href
contains a query string, the viewFormat
and httpQuery
are
appended to that string. If necessary, this inserts the &
character between the href
's
query string, the viewFormat
, and the httpQuery
.
This substitutes the following parameters in viewFormat
and httpQuery
: [bboxWest],[bboxSouth],[bboxEast],[bboxNorth]
- visible bounds of the globe, or 0 if the globe
is not visible. The visible bounds are scaled from their centroid by this link's
viewBoundScale
.[lookatLon], [lookatLat]
- longitude and latitude of the
position on the globe the view is looking at, or 0 if the view is not looking at the globe.[lookatRange]
- distance between view's eye position and the point on the globe the view is
looking at.[lookatTilt], [lookatHeading]
- view's tilt and heading.[lookatTerrainLon], [lookatTerrainLat], [lookatTerrainAlt]
- terrain position the view is
looking at, or 0 if the view is not looking at the terrain.[cameraLon], [cameraLat],
[cameraAlt]
- view's eye position.[horizFov], [vertFov]
- view's horizontal and
vertical field of view.[horizPixels], [vertPixels]
- width and height of the
viewport.[terrainEnabled]
- always true
[clientVersion]
- WorldWind client version.[clientName]
- WorldWind client name.[kmlVersion]
- KML version supported by WorldWind.[language]
- current
locale's language.viewFormat
is unspecified, and the viewRefreshMode
is one of onRequest
, onStop
or onRegion
, this automatically appends the
following information to the query string: BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]
. The
[clientName]
and [clientVersion]
parameters of the httpQuery
may be
specified in the configuration file using the keys AVKey.NAME
and
AVKey.VERSION
. If not specified, this uses default values of
Version.getVersionName()
and Version.getVersion()
for [clientName]
and [clientVersion]
,
respectively.dc
- the DrawContext
used to determine the current view parameters.java.lang.IllegalArgumentException
- if dc
is null
.getHref()
,
getViewFormat()
,
getHttpQuery()
,
Configuration
public java.lang.String getHref()
public java.lang.String getHttpQuery()
public java.lang.Double getRefreshInterval()
public java.lang.String getRefreshMode()
public long getUpdateTime()
System.currentTimeMillis()
for its numerical meaning of this timestamp.public java.lang.Double getViewBoundScale()
public java.lang.String getViewFormat()
public java.lang.String getViewRefreshMode()
public java.lang.Double getViewRefreshTime()
protected boolean isLocalReference(java.net.URL url)
url
is a local resource.url
- the URL to test.true
if the url
specifies a local resource, otherwise false
.public void onMessage(Message msg)
View.VIEW_STOPPED
message is received, and the link's view refresh
mode is onStop
.onMessage
in interface MessageListener
onMessage
in class KMLAbstractObject
msg
- The message that was received.public java.lang.Object parse(XMLEventParserContext ctx, javax.xml.stream.events.XMLEvent inputEvent, java.lang.Object... args) throws javax.xml.stream.XMLStreamException
onChange
if the refresh mode is not specified.parse
in interface XMLEventParser
parse
in class AbstractXMLEventParser
ctx
- a current parser context.inputEvent
- the event to parse.args
- an optional list of arguments that may by used by subclasses.this
, otherwise returns null.javax.xml.stream.XMLStreamException
- if an exception occurs during event-stream reading.protected java.util.concurrent.ScheduledFuture scheduleDelayedTask(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit timeUnit)
task
- Task to schedule.delay
- Delay to wait before executing the task. The time unit is determined by {code timeUnit}.timeUnit
- The time unit of delay
.protected void scheduleRefreshIfNeeded()
onInterval
and
onExpire
refresh modes, this method schedules a task to update the link after the refresh interval
elapses, but only if such a task has not already been scheduled (only one refresh task is active at a time).public void setExpirationTime(long time)
time
- Time, in milliseconds since the Epoch, at which the link expires. Zero indicates no expiration.public void setField(java.lang.String keyName, java.lang.Object value)
onChange
links as updated when a field set.setField
in class AbstractXMLEventParser
public void setUpdateTime(long updateTime)
updateTime
- The time at which the linked content was most recently updated. See System.currentTimeMillis()
for its numerical meaning of this timestamp.