NASA World Wind

gov.nasa.worldwind.layers
Class AnnotationLayer

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.layers.AbstractLayer
              extended by gov.nasa.worldwind.layers.AnnotationLayer
All Implemented Interfaces:
AVList, Disposable, Layer, Restorable, WWObject, PropertyChangeListener, EventListener

public class AnnotationLayer
extends AbstractLayer

The AnnotationLayer class manages a collection of Annotation objects for rendering and picking. AnnotationLayer delegates to its internal AnnotationRenderer for rendering and picking operations. The AnnotationRenderer is specified by calling setAnnotationRenderer(gov.nasa.worldwind.render.AnnotationRenderer).

See Also:
Annotation, AnnotationRenderer

Field Summary
 
Fields inherited from class gov.nasa.worldwind.avlist.AVListImpl
changeSupport
 
Constructor Summary
AnnotationLayer()
          Creates a new AnnotationLayer with an empty collection of Annotations.
 
Method Summary
 void addAnnotation(Annotation annotation)
          Adds the specified annotation to this layer's internal collection.
 void addAnnotations(Iterable<Annotation> annotations)
          Adds the contents of the specified annotations to this layer's internal collection.
protected  void doPick(DrawContext dc, Point pickPoint)
           
protected  void doRender(DrawContext dc)
           
 AnnotationRenderer getAnnotationRenderer()
          Returns the AnnotationRenderer this layer delegates to during picking and rendering.
 Iterable<Annotation> getAnnotations()
          Returns the Iterable of Annotations currently in use by this layer.
 void removeAllAnnotations()
          Clears the contents of this layer's internal Annotation collection.
 void removeAnnotation(Annotation annotation)
          Removes the specified annotation from this layer's internal collection, if it exists.
 void setAnnotationRenderer(AnnotationRenderer annotationRenderer)
          Sets the AnnotationRenderer this layer delegates to during picking and rendering.
 void setAnnotations(Iterable<Annotation> annotationIterable)
          Overrides the collection of currently active Annotations with the specified annotationIterable.
 String toString()
           
 
Methods inherited from class gov.nasa.worldwind.layers.AbstractLayer
dispose, getMaxActiveAltitude, getMinActiveAltitude, getName, getOpacity, getRestorableState, getScale, isAtMaxResolution, isEnabled, isLayerActive, isLayerInView, isMultiResolution, isPickEnabled, pick, render, restoreState, setEnabled, setMaxActiveAltitude, setMinActiveAltitude, setName, setOpacity, setPickEnabled
 
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
propertyChange
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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 java.beans.PropertyChangeListener
propertyChange
 

Constructor Detail

AnnotationLayer

public AnnotationLayer()
Creates a new AnnotationLayer with an empty collection of Annotations.

Method Detail

addAnnotation

public void addAnnotation(Annotation annotation)
Adds the specified annotation to this layer's internal collection. If this layer's internal collection has been overriden with a call to setAnnotations(java.lang.Iterable), this will throw an exception.

Parameters:
annotation - Annotation to add.
Throws:
IllegalArgumentException - If annotation is null.
IllegalStateException - If a custom Iterable has been specified by a call to setAnnotations.

addAnnotations

public void addAnnotations(Iterable<Annotation> annotations)
Adds the contents of the specified annotations to this layer's internal collection. If this layer's internal collection has been overriden with a call to setAnnotations(java.lang.Iterable), this will throw an exception.

Parameters:
annotations - Annotations to add.
Throws:
IllegalArgumentException - If annotations is null.
IllegalStateException - If a custom Iterable has been specified by a call to setAnnotations.

doPick

protected void doPick(DrawContext dc,
                      Point pickPoint)
Overrides:
doPick in class AbstractLayer

doRender

protected void doRender(DrawContext dc)
Specified by:
doRender in class AbstractLayer

getAnnotationRenderer

public AnnotationRenderer getAnnotationRenderer()
Returns the AnnotationRenderer this layer delegates to during picking and rendering.

Returns:
AnnotationRenderer used to pick and render Annotations.

getAnnotations

public Iterable<Annotation> getAnnotations()
Returns the Iterable of Annotations currently in use by this layer. If the caller has specified a custom Iterable via setAnnotations(java.lang.Iterable), this will returns a reference to that Iterable. If the caller passed setAnnotations a null parameter, or if setAnnotations has not been called, this returns a view of this layer's internal collection of Annotations.

Returns:
Iterable of currently active Annotations.

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 to setAnnotations(java.lang.Iterable), this will throw an exception.

Throws:
IllegalStateException - If a custom Iterable has been specified by a call to setAnnotations.

removeAnnotation

public void removeAnnotation(Annotation annotation)
Removes the specified annotation from this layer's internal collection, if it exists. If this layer's internal collection has been overriden with a call to setAnnotations(java.lang.Iterable), this will throw an exception.

Parameters:
annotation - Annotation to remove.
Throws:
IllegalArgumentException - If annotation is null.
IllegalStateException - If a custom Iterable has been specified by a call to setAnnotations.

setAnnotationRenderer

public void setAnnotationRenderer(AnnotationRenderer annotationRenderer)
Sets the AnnotationRenderer this layer delegates to during picking and rendering.

Parameters:
annotationRenderer - AnnotationRenderer used to pick and render Annotations.
Throws:
IllegalArgumentException - If annotationRenderer is null.

setAnnotations

public void setAnnotations(Iterable<Annotation> annotationIterable)
Overrides the collection of currently active Annotations with the specified annotationIterable. This layer will maintain a reference to annotationIterable 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 via addAnnotation, 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.

toString

public String toString()
Overrides:
toString in class AbstractLayer

NASA World Wind