Package gov.nasa.worldwind.layers
Class IconLayer
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.layers.AbstractLayer
-
- gov.nasa.worldwind.layers.IconLayer
-
- All Implemented Interfaces:
AVList
,Disposable
,MessageListener
,Layer
,Restorable
,WWObject
,java.beans.PropertyChangeListener
,java.util.EventListener
public class IconLayer extends AbstractLayer
TheIconLayer
class manages a collection ofWWIcon
objects for rendering and picking.IconLayer
delegates to its internalIconRenderer
for rendering and picking operations.- See Also:
WWIcon
,IconRenderer
-
-
Field Summary
Fields Modifier and Type Field Description protected long
frameId
protected IconRenderer
iconRenderer
protected BasicQuadTree<WWIcon>
icons
protected java.lang.Iterable<WWIcon>
iconsOverride
protected java.util.HashMap<GlobeStateKey,java.util.Set<WWIcon>>
lastActiveIconsLists
-
Constructor Summary
Constructors Constructor Description IconLayer()
Creates a newIconLayer
with an empty collection of Icons.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addIcon(WWIcon icon)
Adds the specifiedicon
to this layer's internal collection.void
addIcons(java.lang.Iterable<WWIcon> icons)
Adds the contents of the specifiedicons
to this layer's internal collection.protected void
clearIcons()
protected void
doPick(DrawContext dc, java.awt.Point pickPoint)
protected void
doRender(DrawContext dc)
protected java.lang.Iterable<WWIcon>
getActiveIcons(DrawContext dc)
Returns the Iterable of currently active Icons.java.lang.Iterable<WWIcon>
getIcons()
Returns the Iterable of Icons currently in use by this layer.double
getOpacity()
Returns the layer's opacity value, which is ignored by this layer the icon's image is assumed to indicate its opacity.Pedestal
getPedestal()
Returns thePedestal
used by this layers internalIconRenderer
.boolean
isAllowBatchPicking()
Indicates whether icons are picked as a batch and therefore aSelectEvent
will contain only one icon from the layer.boolean
isAlwaysUseAbsoluteElevation()
Indicates whether an icon's elevation is treated as an offset from the terrain or an absolute elevation above sea level.boolean
isHorizonClippingEnabled()
Indicates whether horizon clipping is performed.boolean
isPickFrustumClippingEnabled()
Indicates whether picking volume clipping is performed.boolean
isRegionCulling()
Indicates whether the layer culls icons whose latitude-longitude location is outside the visible terrain area.boolean
isViewClippingEnabled()
Indicates whether view volume clipping is performed.void
removeAllIcons()
Clears the contents of this layer's internal Icon collection.void
removeIcon(WWIcon icon)
Removes the specifiedicon
from this layer's internal collection, if it exists.void
setAllowBatchPicking(boolean allowBatchPicking)
Specifies whether batch picking is allowed.void
setAlwaysUseAbsoluteElevation(boolean alwaysUseAbsoluteElevation)
Normally, an icon's elevation is treated as an offset from the terrain when it is less than the globe's maximum elevation.void
setHorizonClippingEnabled(boolean horizonClippingEnabled)
Indicates whether to render icons beyond the horizon.void
setIcons(java.lang.Iterable<WWIcon> iconIterable)
Overrides the collection of currently active Icons with the specifiediconIterable
.void
setOpacity(double opacity)
Opacity is not applied to layers of this type.void
setPedestal(Pedestal pedestal)
Sets thePedestal
used by this layers internalIconRenderer
.void
setPickFrustumClippingEnabled(boolean pickFrustumClippingEnabled)
Indicates whether to render icons outside the picking volume when in pick mode.void
setRegionCulling(boolean regionCulling)
Indicates whether the layer culls icons whose latitude-longitude location is outside the visible terrain area.void
setViewClippingEnabled(boolean viewClippingEnabled)
Indicates whether to render icons outside the view volume.java.lang.String
toString()
-
Methods inherited from class gov.nasa.worldwind.layers.AbstractLayer
createLayerConfigElements, dispose, doPreRender, getDataFileStore, getExpiryTime, getLayerConfigParams, getMaxActiveAltitude, getMaxEffectiveAltitude, getMinActiveAltitude, getMinEffectiveAltitude, getName, getRestorableState, getScale, getScreenCredit, isAtMaxResolution, isEnabled, isLayerActive, isLayerConfigDocument, isLayerInView, isMultiResolution, isNetworkRetrievalEnabled, isPickEnabled, pick, preRender, render, restoreState, setDataFileStore, setEnabled, setExpiryTime, setMaxActiveAltitude, setMinActiveAltitude, setName, setNetworkRetrievalEnabled, setPickEnabled, setScreenCredit
-
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
-
-
-
-
Field Detail
-
icons
protected final BasicQuadTree<WWIcon> icons
-
iconsOverride
protected java.lang.Iterable<WWIcon> iconsOverride
-
iconRenderer
protected IconRenderer iconRenderer
-
lastActiveIconsLists
protected java.util.HashMap<GlobeStateKey,java.util.Set<WWIcon>> lastActiveIconsLists
-
frameId
protected long frameId
-
-
Method Detail
-
addIcon
public void addIcon(WWIcon icon)
Adds the specifiedicon
to this layer's internal collection. If this layer's internal collection has been overridden with a call tosetIcons(java.lang.Iterable<gov.nasa.worldwind.render.WWIcon>)
, this will throw an exception.- Parameters:
icon
- Icon to add.- Throws:
java.lang.IllegalArgumentException
- Ificon
is null.java.lang.IllegalStateException
- If a custom Iterable has been specified by a call tosetIcons
.
-
addIcons
public void addIcons(java.lang.Iterable<WWIcon> icons)
Adds the contents of the specifiedicons
to this layer's internal collection. If this layer's internal collection has been overriden with a call tosetIcons(java.lang.Iterable<gov.nasa.worldwind.render.WWIcon>)
, this will throw an exception.- Parameters:
icons
- Icons to add.- Throws:
java.lang.IllegalArgumentException
- Ificons
is null.java.lang.IllegalStateException
- If a custom Iterable has been specified by a call tosetIcons
.
-
removeIcon
public void removeIcon(WWIcon icon)
Removes the specifiedicon
from this layer's internal collection, if it exists. If this layer's internal collection has been overriden with a call tosetIcons(java.lang.Iterable<gov.nasa.worldwind.render.WWIcon>)
, this will throw an exception.- Parameters:
icon
- Icon to remove.- Throws:
java.lang.IllegalArgumentException
- Ificon
is null.java.lang.IllegalStateException
- If a custom Iterable has been specified by a call tosetIcons
.
-
removeAllIcons
public void removeAllIcons()
Clears the contents of this layer's internal Icon collection. If this layer's internal collection has been overridden with a call tosetIcons(java.lang.Iterable<gov.nasa.worldwind.render.WWIcon>)
, this will throw an exception.- Throws:
java.lang.IllegalStateException
- If a custom Iterable has been specified by a call tosetIcons
.
-
clearIcons
protected void clearIcons()
-
getIcons
public java.lang.Iterable<WWIcon> getIcons()
Returns the Iterable of Icons currently in use by this layer. If the caller has specified a custom Iterable viasetIcons(java.lang.Iterable<gov.nasa.worldwind.render.WWIcon>)
, this will returns a reference to that Iterable. If the caller passedsetIcons
a null parameter, or ifsetIcons
has not been called, this returns a view of this layer's internal collection of Icons. The view has no definitive order and may contain duplicate entries.- Returns:
- Iterable of currently active Icons.
-
isRegionCulling
public boolean isRegionCulling()
Indicates whether the layer culls icons whose latitude-longitude location is outside the visible terrain area. SeesetRegionCulling(boolean)
for a fuller description of region culling.- Returns:
- regionCulling true if region culling is performed, otherwise false.
-
setRegionCulling
public void setRegionCulling(boolean regionCulling)
Indicates whether the layer culls icons whose latitude-longitude location is outside the visible terrain area. This typically provides better performance when some icons are not in view. However, it might remove icons at high altitude over the horizon.- Parameters:
regionCulling
- true if region culling is performed, otherwise false.
-
getActiveIcons
protected java.lang.Iterable<WWIcon> getActiveIcons(DrawContext dc)
Returns the Iterable of currently active Icons. If the caller has specified a custom Iterable viasetIcons(java.lang.Iterable<gov.nasa.worldwind.render.WWIcon>)
, this will returns a reference to that Iterable. If the caller passedsetIcons
a null parameter, or ifsetIcons
has not been called, this returns a view of this layer's internal collection of Icons, culled to eliminate those outside the current sector geometry.- Parameters:
dc
- a current DrawContext.- Returns:
- Iterable of currently active Icons.
-
setIcons
public void setIcons(java.lang.Iterable<WWIcon> iconIterable)
Overrides the collection of currently active Icons with the specifiediconIterable
. This layer will maintain a reference toiconIterable
strictly for picking and rendering. This layer will not modify the Iterable reference. However, this will clear the internal collection of Icons, and will prevent any modification to its contents viaaddIcon, addIcons, or removeIcons
.If the specified
iconIterable
is null, this layer will revert to maintaining its internal collection.- Parameters:
iconIterable
- Iterable to use instead of this layer's internal collection, or null to use this layer's internal collection.
-
getPedestal
public Pedestal getPedestal()
Returns thePedestal
used by this layers internalIconRenderer
.- Returns:
Pedestal
used by this layers internalIconRenderer
.
-
setPedestal
public void setPedestal(Pedestal pedestal)
Sets thePedestal
used by this layers internalIconRenderer
.- Parameters:
pedestal
-Pedestal
to be used by this layers internalIconRenderer
.
-
isHorizonClippingEnabled
public boolean isHorizonClippingEnabled()
Indicates whether horizon clipping is performed.- Returns:
true
if horizon clipping is performed, otherwisefalse
.- See Also:
setHorizonClippingEnabled(boolean)
-
setHorizonClippingEnabled
public void setHorizonClippingEnabled(boolean horizonClippingEnabled)
Indicates whether to render icons beyond the horizon. If view culling is enabled, the icon is also tested for view volume inclusion. The default isfalse
, horizon clipping is not performed.- Parameters:
horizonClippingEnabled
-true
if horizon clipping should be performed, otherwisefalse
.- See Also:
setViewClippingEnabled(boolean)
-
isViewClippingEnabled
public boolean isViewClippingEnabled()
Indicates whether view volume clipping is performed.- Returns:
true
if view volume clipping is performed, otherwisefalse
.- See Also:
setViewClippingEnabled(boolean)
-
setViewClippingEnabled
public void setViewClippingEnabled(boolean viewClippingEnabled)
Indicates whether to render icons outside the view volume. This is primarily to control icon visibility beyond the far view clipping plane. Some important use cases demand that clipping not be performed. If horizon clipping is enabled, the icon is also tested for horizon clipping. The default isfalse
, view volume clipping is not performed.- Parameters:
viewClippingEnabled
-true
if view clipping should be performed, otherwisefalse
.- See Also:
setHorizonClippingEnabled(boolean)
-
isPickFrustumClippingEnabled
public boolean isPickFrustumClippingEnabled()
Indicates whether picking volume clipping is performed.- Returns:
true
if picking volume clipping is performed, otherwisefalse
.- See Also:
setViewClippingEnabled(boolean)
-
setPickFrustumClippingEnabled
public void setPickFrustumClippingEnabled(boolean pickFrustumClippingEnabled)
Indicates whether to render icons outside the picking volume when in pick mode. This increases performance by only drawing the icons within the picking volume when picking is enabled. Some important use cases demand that clipping not be performed. The default isfalse
, picking volume clipping is not performed.- Parameters:
pickFrustumClippingEnabled
-true
if picking clipping should be performed, otherwisefalse
.
-
isAlwaysUseAbsoluteElevation
public boolean isAlwaysUseAbsoluteElevation()
Indicates whether an icon's elevation is treated as an offset from the terrain or an absolute elevation above sea level.- Returns:
true
if icon elevations are treated as absolute,false
if they're treated as offsets from the terrain.
-
setAlwaysUseAbsoluteElevation
public void setAlwaysUseAbsoluteElevation(boolean alwaysUseAbsoluteElevation)
Normally, an icon's elevation is treated as an offset from the terrain when it is less than the globe's maximum elevation. Setting #setAlwaysUseAbsoluteElevation totrue
causes the elevation to be treated as an absolute elevation above sea level.- Parameters:
alwaysUseAbsoluteElevation
-true
to treat icon elevations as absolute,false
to treat them as offsets from the terrain.
-
setOpacity
public void setOpacity(double opacity)
Opacity is not applied to layers of this type. The icon image is assumed to indicates its opacity.- Specified by:
setOpacity
in interfaceLayer
- Overrides:
setOpacity
in classAbstractLayer
- Parameters:
opacity
- the current opacity value, which is ignored by this layer.
-
getOpacity
public double getOpacity()
Returns the layer's opacity value, which is ignored by this layer the icon's image is assumed to indicate its opacity.- Specified by:
getOpacity
in interfaceLayer
- Overrides:
getOpacity
in classAbstractLayer
- Returns:
- The layer opacity, a value between 0 and 1.
-
isAllowBatchPicking
public boolean isAllowBatchPicking()
Indicates whether icons are picked as a batch and therefore aSelectEvent
will contain only one icon from the layer. Batch picking is much faster than individual picking, so this attribute should be used judiciously.- Returns:
- true if batch picking is allowed, otherwise false.
- See Also:
setAllowBatchPicking(boolean)
-
setAllowBatchPicking
public void setAllowBatchPicking(boolean allowBatchPicking)
Specifies whether batch picking is allowed. If so, aSelectEvent
from the layer will contain only one icon even if several overlapping icons are at the pick point. Batch picking is much faster than individual picking so the default value is true.- Parameters:
allowBatchPicking
- true if batch picking is allowed, otherwise false.
-
doPick
protected void doPick(DrawContext dc, java.awt.Point pickPoint)
- Overrides:
doPick
in classAbstractLayer
-
doRender
protected void doRender(DrawContext dc)
- Specified by:
doRender
in classAbstractLayer
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractLayer
-
-