Package gov.nasa.worldwind.layers
Class AnnotationLayer
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.layers.AbstractLayer
-
- gov.nasa.worldwind.layers.AnnotationLayer
-
- All Implemented Interfaces:
AVList
,Disposable
,MessageListener
,Layer
,Restorable
,WWObject
,java.beans.PropertyChangeListener
,java.util.EventListener
public class AnnotationLayer extends AbstractLayer
TheAnnotationLayer
class manages a collection ofAnnotation
objects for rendering and picking.AnnotationLayer
delegates to its internalAnnotationRenderer
for rendering and picking operations. TheAnnotationRenderer
is specified by callingsetAnnotationRenderer(gov.nasa.worldwind.render.AnnotationRenderer)
.- See Also:
Annotation
,AnnotationRenderer
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Collection<Annotation>
annotations
protected java.lang.Iterable<Annotation>
annotationsOverride
-
Constructor Summary
Constructors Constructor Description AnnotationLayer()
Creates a newAnnotationLayer
with an empty collection of Annotations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAnnotation(Annotation annotation)
Adds the specifiedannotation
to this layer's internal collection.void
addAnnotations(java.lang.Iterable<Annotation> annotations)
Adds the contents of the specifiedannotations
to this layer's internal collection.protected void
clearAnnotations()
protected void
doPick(DrawContext dc, java.awt.Point pickPoint)
protected void
doRender(DrawContext dc)
protected java.lang.Iterable<Annotation>
getActiveAnnotations()
Returns the Iterable of currently active Annotations.AnnotationRenderer
getAnnotationRenderer()
Returns theAnnotationRenderer
this layer delegates to during picking and rendering.java.lang.Iterable<Annotation>
getAnnotations()
Returns the Iterable of Annotations currently in use by this layer.double
getOpacity()
Returns the layer's opacity value, which is ignored by this layer because each of its annotations has an attribute with its own opacity control.void
removeAllAnnotations()
Clears the contents of this layer's internal Annotation collection.void
removeAnnotation(Annotation annotation)
Removes the specifiedannotation
from this layer's internal collection, if it exists.void
setAnnotationRenderer(AnnotationRenderer annotationRenderer)
Sets theAnnotationRenderer
this layer delegates to during picking and rendering.void
setAnnotations(java.lang.Iterable<Annotation> annotationIterable)
Overrides the collection of currently active Annotations with the specifiedannotationIterable
.void
setOpacity(double opacity)
Opacity is not applied to layers of this type because each annotation has an attribute set with opacity control.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
-
annotations
protected final java.util.Collection<Annotation> annotations
-
annotationsOverride
protected java.lang.Iterable<Annotation> annotationsOverride
-
-
Method Detail
-
addAnnotation
public void addAnnotation(Annotation annotation)
Adds the specifiedannotation
to this layer's internal collection. If this layer's internal collection has been overriden with a call tosetAnnotations(java.lang.Iterable<gov.nasa.worldwind.render.Annotation>)
, this will throw an exception.- Parameters:
annotation
- Annotation to add.- Throws:
java.lang.IllegalArgumentException
- Ifannotation
is null.java.lang.IllegalStateException
- If a custom Iterable has been specified by a call tosetAnnotations
.
-
addAnnotations
public void addAnnotations(java.lang.Iterable<Annotation> annotations)
Adds the contents of the specifiedannotations
to this layer's internal collection. If this layer's internal collection has been overriden with a call tosetAnnotations(java.lang.Iterable<gov.nasa.worldwind.render.Annotation>)
, this will throw an exception.- Parameters:
annotations
- Annotations to add.- Throws:
java.lang.IllegalArgumentException
- Ifannotations
is null.java.lang.IllegalStateException
- If a custom Iterable has been specified by a call tosetAnnotations
.
-
removeAnnotation
public void removeAnnotation(Annotation annotation)
Removes the specifiedannotation
from this layer's internal collection, if it exists. If this layer's internal collection has been overriden with a call tosetAnnotations(java.lang.Iterable<gov.nasa.worldwind.render.Annotation>)
, this will throw an exception.- Parameters:
annotation
- Annotation to remove.- Throws:
java.lang.IllegalArgumentException
- Ifannotation
is null.java.lang.IllegalStateException
- If a custom Iterable has been specified by a call tosetAnnotations
.
-
removeAllAnnotations
public void removeAllAnnotations()
Clears the contents of this layer's internal Annotation collection. If this layer's internal collection has been overriden with a call tosetAnnotations(java.lang.Iterable<gov.nasa.worldwind.render.Annotation>)
, this will throw an exception.- Throws:
java.lang.IllegalStateException
- If a custom Iterable has been specified by a call tosetAnnotations
.
-
clearAnnotations
protected void clearAnnotations()
-
getAnnotations
public java.lang.Iterable<Annotation> getAnnotations()
Returns the Iterable of Annotations currently in use by this layer. If the caller has specified a custom Iterable viasetAnnotations(java.lang.Iterable<gov.nasa.worldwind.render.Annotation>)
, this will returns a reference to that Iterable. If the caller passedsetAnnotations
a null parameter, or ifsetAnnotations
has not been called, this returns a view of this layer's internal collection of Annotations.- Returns:
- Iterable of currently active Annotations.
-
getActiveAnnotations
protected java.lang.Iterable<Annotation> getActiveAnnotations()
Returns the Iterable of currently active Annotations. If the caller has specified a custom Iterable viasetAnnotations(java.lang.Iterable<gov.nasa.worldwind.render.Annotation>)
, this will returns a reference to that Iterable. If the caller passedsetAnnotations
a null parameter, or ifsetAnnotations
has not been called, this returns a view of this layer's internal collection of Annotations.- Returns:
- Iterable of currently active Annotations.
-
setAnnotations
public void setAnnotations(java.lang.Iterable<Annotation> annotationIterable)
Overrides the collection of currently active Annotations with the specifiedannotationIterable
. This layer will maintain a reference toannotationIterable
strictly for picking and rendering. This layer will not modify the Iterable reference. However, this will clear the internal collection of Annotations, and will prevent any modification to its contents viaaddAnnotation, addAnnotations, or removeAnnotations
.If the specified
annotationIterable
is null, this layer will revert to maintaining its internal collection.- Parameters:
annotationIterable
- Iterable to use instead of this layer's internal collection, or null to use this layer's internal collection.
-
setOpacity
public void setOpacity(double opacity)
Opacity is not applied to layers of this type because each annotation has an attribute set with opacity control.- 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 because each of its annotations has an attribute with its own opacity control.- Specified by:
getOpacity
in interfaceLayer
- Overrides:
getOpacity
in classAbstractLayer
- Returns:
- The layer opacity, a value between 0 and 1.
-
getAnnotationRenderer
public AnnotationRenderer getAnnotationRenderer()
Returns theAnnotationRenderer
this layer delegates to during picking and rendering.- Returns:
AnnotationRenderer
used to pick and renderAnnotations
.
-
setAnnotationRenderer
public void setAnnotationRenderer(AnnotationRenderer annotationRenderer)
Sets theAnnotationRenderer
this layer delegates to during picking and rendering.- Parameters:
annotationRenderer
-AnnotationRenderer
used to pick and renderAnnotations
.- Throws:
java.lang.IllegalArgumentException
- IfannotationRenderer
is null.
-
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
-
-