Class AbstractLayer
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.layers.AbstractLayer
-
- All Implemented Interfaces:
AVList
,Disposable
,MessageListener
,Layer
,Restorable
,WWObject
,java.beans.PropertyChangeListener
,java.util.EventListener
- Direct Known Subclasses:
AbstractAirspaceEditor
,AbstractGraticuleLayer
,AbstractShapeEditor
,AnnotationLayer
,CachedRenderableLayer
,CompassLayer
,CrosshairLayer
,GliderImageLayer
,IconLayer
,MarkerLayer
,MercatorTiledImageLayer
,PlaceNameLayer
,RenderableLayer
,ScalebarLayer
,SegmentPlaneEditor
,SkyGradientLayer
,StatusLayer
,TerrainProfileLayer
,TiledImageLayer
,WorldMapLayer
public abstract class AbstractLayer extends WWObjectImpl implements Layer
-
-
Constructor Summary
Constructors Constructor Description AbstractLayer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static org.w3c.dom.Element
createLayerConfigElements(AVList params, org.w3c.dom.Element context)
Appends layer configuration parameters as elements to the specified context.void
dispose()
Disposes of any internal resources allocated by the object.protected void
doPick(DrawContext dc, java.awt.Point point)
protected void
doPreRender(DrawContext dc)
protected abstract void
doRender(DrawContext dc)
FileStore
getDataFileStore()
long
getExpiryTime()
Returns the current expiry time.static AVList
getLayerConfigParams(org.w3c.dom.Element domElement, AVList params)
Parses layer configuration parameters from the specified DOM document.double
getMaxActiveAltitude()
Returns the maximum altitude at which to display the layer.java.lang.Double
getMaxEffectiveAltitude(java.lang.Double radius)
Indicates the altitude above which this layer likely has low value or is not expected to be active.double
getMinActiveAltitude()
Returns the minimum altitude at which the layer is displayed.java.lang.Double
getMinEffectiveAltitude(java.lang.Double radius)
Indicates the altitude below which this layer likely has low value or is not expected to be active.java.lang.String
getName()
Returns the layer's name, as specified in the most recent call toLayer.setName(java.lang.String)
.double
getOpacity()
Returns the layer's opacity, the degree to which it is blended with underlying layers.java.lang.String
getRestorableState()
Returns an XML document string describing the object's state.double
getScale()
Returns the map scale, in terms of the ratio of 1 to the value returned, e.g., 1:24000.protected ScreenCredit
getScreenCredit()
boolean
isAtMaxResolution()
Indicates whether the most recent rendering of the layer rendered the highest resolution imagery or other data available.boolean
isEnabled()
Indicates whether the layer is enabled for rendering and selection.boolean
isLayerActive(DrawContext dc)
Indicates whether the layer is active based on arbitrary criteria.static boolean
isLayerConfigDocument(org.w3c.dom.Element domElement)
Returns true if a specified DOM document is a Layer configuration document, and false otherwise.boolean
isLayerInView(DrawContext dc)
Indicates whether the layer is in the view.boolean
isMultiResolution()
Indicates whether the layer provides multiple resolutions of imagery or other data.boolean
isNetworkRetrievalEnabled()
Indicates whether the layer is allowed to retrieve data from the network.boolean
isPickEnabled()
Indicates whether the layer performs selection during picking.void
pick(DrawContext dc, java.awt.Point point)
Cause the layer to perform picking, which determines whether the object or its components intersect a given point on the screen.void
preRender(DrawContext dc)
Causes the layer to perform any actions necessary to subsequently render the layer.void
render(DrawContext dc)
Cause the layer to draw its representation.void
restoreState(java.lang.String stateInXml)
Restores the object's state to what is described in the specified XML document string.void
setDataFileStore(FileStore fileStore)
void
setEnabled(boolean enabled)
Controls whether the layer is enabled for rendering and selection.void
setExpiryTime(long expiryTime)
Specifies the time of the layer's most recent dataset update.void
setMaxActiveAltitude(double maxActiveAltitude)
Specifies the maximum altitude at which to display the layer.void
setMinActiveAltitude(double minActiveAltitude)
Specifies the minimum altitude at which to display the layer.void
setName(java.lang.String name)
Set the layer's name.void
setNetworkRetrievalEnabled(boolean networkDownloadEnabled)
Controls whether the layer is allowed to retrieve data from the network.void
setOpacity(double opacity)
Sets the layer's opacity, the degree to which it is blended with underlying layers.void
setPickEnabled(boolean pickable)
Controls whether the layer should perform picking.protected void
setScreenCredit(ScreenCredit screenCredit)
java.lang.String
toString()
-
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, propertyChange
-
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
-
-
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
Description copied from interface:Layer
Indicates whether the layer is enabled for rendering and selection.
-
isPickEnabled
public boolean isPickEnabled()
Description copied from interface:Layer
Indicates whether the layer performs selection during picking.Most layers enable picking by default. However, this becomes inconvenient for
SurfaceImage
andSurfaceImageLayer
} when the image covers a large area because the view input handlers detect the surface image rather than the terrain as the top picked object, and will not respond to the user's attempts at navigation. The solution is to disable picking for the layer.- Specified by:
isPickEnabled
in interfaceLayer
- Returns:
true
if picking is enabled, elsefalse
.
-
setPickEnabled
public void setPickEnabled(boolean pickable)
Description copied from interface:Layer
Controls whether the layer should perform picking.- Specified by:
setPickEnabled
in interfaceLayer
- Parameters:
pickable
-true
if the layer should perform picking, elsefalse
.
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from interface:Layer
Controls whether the layer is enabled for rendering and selection.- Specified by:
setEnabled
in interfaceLayer
- Parameters:
enabled
-true
if the layer is enabled, elsefalse
.
-
getName
public java.lang.String getName()
Description copied from interface:Layer
Returns the layer's name, as specified in the most recent call toLayer.setName(java.lang.String)
.
-
setName
public void setName(java.lang.String name)
Description copied from interface:Layer
Set the layer's name. The name is a convenience attribute typically used to identify the layer in user interfaces. By default, a layer has no name.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getOpacity
public double getOpacity()
Description copied from interface:Layer
Returns the layer's opacity, the degree to which it is blended with underlying layers.Many layers apply special usage of opacity, and some ignore it in favor of the opacity settings of their internal renderables. See the description of this method in specific layers to determine usage there.
- Specified by:
getOpacity
in interfaceLayer
- Returns:
- The layer's opacity, a value between 0 and 1.
-
setOpacity
public void setOpacity(double opacity)
Description copied from interface:Layer
Sets the layer's opacity, the degree to which it is blended with underlying layers.Many layers apply special usage of opacity, and some ignore it in favor of the opacity settings of their internal renderables. See the description of this method in specific layers to determine usage there.
- Specified by:
setOpacity
in interfaceLayer
- Parameters:
opacity
- The layer opacity, a value between 0 and 1. 0 indicates non-opaque (fully transparent), 1 indicates fully opaque. Values between 0 and 1 indicate partial opacity.
-
getMinActiveAltitude
public double getMinActiveAltitude()
Description copied from interface:Layer
Returns the minimum altitude at which the layer is displayed.- Specified by:
getMinActiveAltitude
in interfaceLayer
- Returns:
- the minimum altitude at which the layer is displayed.
-
setMinActiveAltitude
public void setMinActiveAltitude(double minActiveAltitude)
Description copied from interface:Layer
Specifies the minimum altitude at which to display the layer.- Specified by:
setMinActiveAltitude
in interfaceLayer
- Parameters:
minActiveAltitude
- the minimum altitude at which to display the layer.
-
getMaxActiveAltitude
public double getMaxActiveAltitude()
Description copied from interface:Layer
Returns the maximum altitude at which to display the layer.- Specified by:
getMaxActiveAltitude
in interfaceLayer
- Returns:
- the maximum altitude at which to display the layer.
-
setMaxActiveAltitude
public void setMaxActiveAltitude(double maxActiveAltitude)
Description copied from interface:Layer
Specifies the maximum altitude at which to display the layer.- Specified by:
setMaxActiveAltitude
in interfaceLayer
- Parameters:
maxActiveAltitude
- the maximum altitude at which to display the layer.
-
getMinEffectiveAltitude
public java.lang.Double getMinEffectiveAltitude(java.lang.Double radius)
Description copied from interface:Layer
Indicates the altitude below which this layer likely has low value or is not expected to be active. This value is independent of the minimum active altitude,Layer.setMinActiveAltitude(double)
and does not reflect it.The returned altitude is valid when the field of view indicated by
View.getFieldOfView()
is set to its default value. Changing the field of view to any value other than the default may change this layer's minimum effective altitude, but the returned altitude will not reflect that change.- Specified by:
getMinEffectiveAltitude
in interfaceLayer
- Parameters:
radius
- the radius of theGlobe
the layer is associated with. May be null, in which case the Earth's equatorial radius is used,Earth.WGS84_EQUATORIAL_RADIUS
.- Returns:
- the layer's minimum effective altitude.
-
getMaxEffectiveAltitude
public java.lang.Double getMaxEffectiveAltitude(java.lang.Double radius)
Description copied from interface:Layer
Indicates the altitude above which this layer likely has low value or is not expected to be active. This value is independent of the maximum active altitude,Layer.setMaxActiveAltitude(double)
and does not reflect it.The returned altitude is valid when the field of view indicated by
View.getFieldOfView()
is set to its default value. Changing the field of view to any value other than the default may change this layer's maximum effective altitude, but the returned altitude will not reflect that change.- Specified by:
getMaxEffectiveAltitude
in interfaceLayer
- Parameters:
radius
- the radius of theGlobe
the layer is associated with. May be null, in which case the Earth's equatorial radius is used,Earth.WGS84_EQUATORIAL_RADIUS
.- Returns:
- the layer's maximum effective altitude.
-
getScale
public double getScale()
Description copied from interface:Layer
Returns the map scale, in terms of the ratio of 1 to the value returned, e.g., 1:24000.
-
isNetworkRetrievalEnabled
public boolean isNetworkRetrievalEnabled()
Description copied from interface:Layer
Indicates whether the layer is allowed to retrieve data from the network. Many layers have no need to retrieve data from the network. This state is meaningless for such layers.- Specified by:
isNetworkRetrievalEnabled
in interfaceLayer
- Returns:
true
if the layer is enabled to retrieve network data, elsefalse
.
-
setNetworkRetrievalEnabled
public void setNetworkRetrievalEnabled(boolean networkDownloadEnabled)
Description copied from interface:Layer
Controls whether the layer is allowed to retrieve data from the network. Many layers have no need for data from the network. This state may be set but is meaningless for such layers.- Specified by:
setNetworkRetrievalEnabled
in interfaceLayer
- Parameters:
networkDownloadEnabled
-true
if network retrieval is allowed, elsefalse
.
-
getDataFileStore
public FileStore getDataFileStore()
-
setDataFileStore
public void setDataFileStore(FileStore fileStore)
-
isLayerInView
public boolean isLayerInView(DrawContext dc)
Description copied from interface:Layer
Indicates whether the layer is in the view. The method implemented here is a default indicating the layer is in view. Subclasses able to determine their presence in the view should override this implementation.- Specified by:
isLayerInView
in interfaceLayer
- Parameters:
dc
- the current draw context- Returns:
true
if the layer is in the view,false
otherwise.
-
isLayerActive
public boolean isLayerActive(DrawContext dc)
Description copied from interface:Layer
Indicates whether the layer is active based on arbitrary criteria. The method implemented here is a default indicating the layer is active if the current altitude is within the layer's min and max active altitudes. Subclasses able to consider more criteria should override this implementation.- Specified by:
isLayerActive
in interfaceLayer
- Parameters:
dc
- the current draw context- Returns:
true
if the layer is active,false
otherwise.
-
preRender
public void preRender(DrawContext dc)
Description copied from interface:Layer
Causes the layer to perform any actions necessary to subsequently render the layer. The layer has exclusive access to the frame buffer during the call, and may use it to generate images or other information that is subsequently used to render the layer's contents. Upon return, the OpenGL state must be restored to its original.
-
render
public void render(DrawContext dc)
Description copied from interface:Layer
Cause the layer to draw its representation.
-
pick
public void pick(DrawContext dc, java.awt.Point point)
Description copied from interface:Layer
Cause the layer to perform picking, which determines whether the object or its components intersect a given point on the screen. Objects that intersect that point are added to the draw context's pick list and are conveyed to the application via selection events or by a direct query ofWorldWindow.getObjectsAtCurrentPosition()
.- Specified by:
pick
in interfaceLayer
- Parameters:
dc
- the current draw context for rendering.point
- the screen coordinate point- See Also:
SelectEvent
-
doPick
protected void doPick(DrawContext dc, java.awt.Point point)
-
dispose
public void dispose()
Description copied from interface:Disposable
Disposes of any internal resources allocated by the object.- Specified by:
dispose
in interfaceDisposable
-
doPreRender
protected void doPreRender(DrawContext dc)
-
doRender
protected abstract void doRender(DrawContext dc)
-
isAtMaxResolution
public boolean isAtMaxResolution()
Description copied from interface:Layer
Indicates whether the most recent rendering of the layer rendered the highest resolution imagery or other data available. Some layers do not track resolution. For those layers this value will always betrue
. Typically such layers also returnfalse
fromLayer.isMultiResolution()
.- Specified by:
isAtMaxResolution
in interfaceLayer
- Returns:
true
if the layer is at maximum resolution, otherwisefalse
.
-
isMultiResolution
public boolean isMultiResolution()
Description copied from interface:Layer
Indicates whether the layer provides multiple resolutions of imagery or other data.- Specified by:
isMultiResolution
in interfaceLayer
- Returns:
true
if the layer provides multiple resolutions, elsefalse
.
-
getRestorableState
public java.lang.String getRestorableState()
Description copied from interface:Restorable
Returns an XML document string describing the object's state. This state can be restored later by callingrestoreState
and passing the XML document.- Specified by:
getRestorableState
in interfaceRestorable
- Returns:
- an XML document string describing the object's state.
-
restoreState
public void restoreState(java.lang.String stateInXml)
Description copied from interface:Restorable
Restores the object's state to what is described in the specified XML document string.- Specified by:
restoreState
in interfaceRestorable
- Parameters:
stateInXml
- an XML document string describing an object's state.
-
setExpiryTime
public void setExpiryTime(long expiryTime)
Description copied from interface:Layer
Specifies the time of the layer's most recent dataset update. If greater than zero, the layer ignores and eliminates any previously cached data older than the time specified, and requests new information from the data source. If zero, the layer uses any expiry times intrinsic to the layer, typically initialized at layer construction. The default expiry time is 0, thereby enabling a layer's intrinsic expiration criteria.- Specified by:
setExpiryTime
in interfaceLayer
- Parameters:
expiryTime
- the expiry time of any cached data, expressed as a number of milliseconds beyond the epoch.- See Also:
for a description of milliseconds beyond the epoch.
-
getExpiryTime
public long getExpiryTime()
Description copied from interface:Layer
Returns the current expiry time.- Specified by:
getExpiryTime
in interfaceLayer
- Returns:
- the current expiry time.
-
getScreenCredit
protected ScreenCredit getScreenCredit()
-
setScreenCredit
protected void setScreenCredit(ScreenCredit screenCredit)
-
isLayerConfigDocument
public static boolean isLayerConfigDocument(org.w3c.dom.Element domElement)
Returns true if a specified DOM document is a Layer configuration document, and false otherwise.- Parameters:
domElement
- the DOM document in question.- Returns:
- true if the document is a Layer configuration document; false otherwise.
- Throws:
java.lang.IllegalArgumentException
- if document is null.
-
createLayerConfigElements
public static org.w3c.dom.Element createLayerConfigElements(AVList params, org.w3c.dom.Element context)
Appends layer configuration parameters as elements to the specified context. This appends elements for the following parameters:Append Elements Parameter Element Path Type AVKey.DISPLAY_NAME
DisplayName String AVKey.OPACITY
Opacity Double AVKey.MAX_ACTIVE_ALTITUDE
ActiveAltitudes/@max Double AVKey.MIN_ACTIVE_ALTITUDE
ActiveAltitudes/@min Double AVKey.NETWORK_RETRIEVAL_ENABLED
NetworkRetrievalEnabled Boolean AVKey.MAP_SCALE
MapScale Double AVKey.SCREEN_CREDIT
ScreenCredit ScreenCredit - Parameters:
params
- the key-value pairs which define the layer configuration parameters.context
- the XML document root on which to append layer configuration elements.- Returns:
- a reference to context.
- Throws:
java.lang.IllegalArgumentException
- if either the parameters or the context are null.
-
getLayerConfigParams
public static AVList getLayerConfigParams(org.w3c.dom.Element domElement, AVList params)
Parses layer configuration parameters from the specified DOM document. This writes output as key-value pairs to params. If a parameter from the XML document already exists in params, that parameter is ignored. Supported key and parameter names are:Supported Names Parameter Element Path Type AVKey.DISPLAY_NAME
DisplayName String AVKey.OPACITY
Opacity Double AVKey.MAX_ACTIVE_ALTITUDE
ActiveAltitudes/@max Double AVKey.MIN_ACTIVE_ALTITUDE
ActiveAltitudes/@min Double AVKey.NETWORK_RETRIEVAL_ENABLED
NetworkRetrievalEnabled Boolean AVKey.MAP_SCALE
MapScale Double AVKey.SCREEN_CREDIT
ScreenCredit ScreenCredit
- Parameters:
domElement
- the XML document root to parse for layer configuration elements.params
- the output key-value pairs which recieve the layer configuration parameters. A null reference is permitted.- Returns:
- a reference to params, or a new AVList if params is null.
- Throws:
java.lang.IllegalArgumentException
- if the document is null.
-
-