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
TheAnnotationLayerclass manages a collection ofAnnotationobjects for rendering and picking.AnnotationLayerdelegates to its internalAnnotationRendererfor rendering and picking operations. TheAnnotationRendereris 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>annotationsprotected java.lang.Iterable<Annotation>annotationsOverride
-
Constructor Summary
Constructors Constructor Description AnnotationLayer()Creates a newAnnotationLayerwith an empty collection of Annotations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnnotation(Annotation annotation)Adds the specifiedannotationto this layer's internal collection.voidaddAnnotations(java.lang.Iterable<Annotation> annotations)Adds the contents of the specifiedannotationsto this layer's internal collection.protected voidclearAnnotations()protected voiddoPick(DrawContext dc, java.awt.Point pickPoint)protected voiddoRender(DrawContext dc)protected java.lang.Iterable<Annotation>getActiveAnnotations()Returns the Iterable of currently active Annotations.AnnotationRenderergetAnnotationRenderer()Returns theAnnotationRendererthis layer delegates to during picking and rendering.java.lang.Iterable<Annotation>getAnnotations()Returns the Iterable of Annotations currently in use by this layer.doublegetOpacity()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.voidremoveAllAnnotations()Clears the contents of this layer's internal Annotation collection.voidremoveAnnotation(Annotation annotation)Removes the specifiedannotationfrom this layer's internal collection, if it exists.voidsetAnnotationRenderer(AnnotationRenderer annotationRenderer)Sets theAnnotationRendererthis layer delegates to during picking and rendering.voidsetAnnotations(java.lang.Iterable<Annotation> annotationIterable)Overrides the collection of currently active Annotations with the specifiedannotationIterable.voidsetOpacity(double opacity)Opacity is not applied to layers of this type because each annotation has an attribute set with opacity control.java.lang.StringtoString()-
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 specifiedannotationto 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- Ifannotationis 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 specifiedannotationsto 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- Ifannotationsis null.java.lang.IllegalStateException- If a custom Iterable has been specified by a call tosetAnnotations.
-
removeAnnotation
public void removeAnnotation(Annotation annotation)
Removes the specifiedannotationfrom 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- Ifannotationis 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 passedsetAnnotationsa null parameter, or ifsetAnnotationshas 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 passedsetAnnotationsa null parameter, or ifsetAnnotationshas 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 toannotationIterablestrictly 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
annotationIterableis 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:
setOpacityin interfaceLayer- Overrides:
setOpacityin 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:
getOpacityin interfaceLayer- Overrides:
getOpacityin classAbstractLayer- Returns:
- The layer opacity, a value between 0 and 1.
-
getAnnotationRenderer
public AnnotationRenderer getAnnotationRenderer()
Returns theAnnotationRendererthis layer delegates to during picking and rendering.- Returns:
AnnotationRendererused to pick and renderAnnotations.
-
setAnnotationRenderer
public void setAnnotationRenderer(AnnotationRenderer annotationRenderer)
Sets theAnnotationRendererthis layer delegates to during picking and rendering.- Parameters:
annotationRenderer-AnnotationRendererused to pick and renderAnnotations.- Throws:
java.lang.IllegalArgumentException- IfannotationRendereris null.
-
doPick
protected void doPick(DrawContext dc, java.awt.Point pickPoint)
- Overrides:
doPickin classAbstractLayer
-
doRender
protected void doRender(DrawContext dc)
- Specified by:
doRenderin classAbstractLayer
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractLayer
-
-