NASA World Wind

gov.nasa.worldwind.layers
Class RenderableLayer

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.RenderableLayer
All Implemented Interfaces:
AVList, Disposable, MessageListener, Layer, Restorable, WWObject, PropertyChangeListener, EventListener
Direct Known Subclasses:
BMNGOneImage, LayerManagerLayer, MeasureTool.CustomRenderableLayer, OpenStreetMapShapefileLoader.TextAndShapesLayer, PickFrustum.PickFrustumLayer, SkyColorLayer, StarsLayer, SurfaceImageLayer, ViewControlsLayer, ViewVolumeViewer.SectorGeometryLayer, ViewVolumeViewer.ViewVolumeLayer

public class RenderableLayer
extends AbstractLayer

The RenderableLayer class manages a collection of Renderable objects for rendering, picking, and disposal.

See Also:
Renderable

Field Summary
protected  PickSupport pickSupport
           
protected  Collection<Renderable> renderables
           
protected  Iterable<Renderable> renderablesOverride
           
 
Constructor Summary
RenderableLayer()
          Creates a new RenderableLayer with a null delegateOwner
 
Method Summary
 void addRenderable(Renderable renderable)
          Adds the specified renderable to this layer's internal collection.
 void addRenderables(Iterable<? extends Renderable> renderables)
          Adds the contents of the specified renderables to this layer's internal collection.
protected  void clearRenderables()
           
 void dispose()
          Disposes the contents of this layer's internal Renderable collection, but does not remove any elements from that collection.
protected  void disposeRenderables()
           
protected  void doPick(DrawContext dc, Iterable<? extends Renderable> renderables, Point pickPoint)
           
protected  void doPick(DrawContext dc, Point pickPoint)
           
protected  void doPreRender(DrawContext dc)
           
protected  void doPreRender(DrawContext dc, Iterable<? extends Renderable> renderables)
           
protected  void doRender(DrawContext dc)
           
protected  void doRender(DrawContext dc, Iterable<? extends Renderable> renderables)
           
protected  Iterable<Renderable> getActiveRenderables()
          Returns the Iterable of currently active Renderables.
 int getNumRenderables()
           
 double getOpacity()
          Returns the layer's opacity value, which is ignored by this layer because each of its renderables typiically has its own opacity control.
 Iterable<Renderable> getRenderables()
          Returns the Iterable of Renderables currently in use by this layer.
 void onMessage(Message message)
          Empty implementation of MessageListener.
 void removeAllRenderables()
          Clears the contents of this layer's internal Renderable collection.
 void removeRenderable(Renderable renderable)
          Removes the specified renderable from this layer's internal collection, if it exists.
 void setOpacity(double opacity)
          Opacity is not applied to layers of this type because each renderable typically has its own opacity control.
 void setRenderables(Iterable<Renderable> renderableIterable)
          Overrides the collection of currently active Renderables with the specified renderableIterable.
 String toString()
           
 
Methods inherited from class gov.nasa.worldwind.layers.AbstractLayer
createLayerConfigElements, 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
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, 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
 

Field Detail

pickSupport

protected PickSupport pickSupport

renderables

protected Collection<Renderable> renderables

renderablesOverride

protected Iterable<Renderable> renderablesOverride
Constructor Detail

RenderableLayer

public RenderableLayer()
Creates a new RenderableLayer with a null delegateOwner

Method Detail

addRenderable

public void addRenderable(Renderable renderable)
Adds the specified renderable to this layer's internal collection. If this layer's internal collection has been overridden with a call to setRenderables(Iterable), this will throw an exception.

If the renderable implements AVList, the layer forwards its property change events to the layer's property change listeners. Any property change listeners the layer attaches to the renderable are removed in removeRenderable(gov.nasa.worldwind.render.Renderable), removeAllRenderables(), or dispose().

Parameters:
renderable - Renderable to add.
Throws:
IllegalArgumentException - If renderable is null.
IllegalStateException - If a custom Iterable has been specified by a call to setRenderables.

addRenderables

public void addRenderables(Iterable<? extends Renderable> renderables)
Adds the contents of the specified renderables to this layer's internal collection. If this layer's internal collection has been overriden with a call to setRenderables(Iterable), this will throw an exception.

If any of the renderables implement AVList, the layer forwards their property change events to the layer's property change listeners. Any property change listeners the layer attaches to the renderable are removed in removeRenderable(gov.nasa.worldwind.render.Renderable), removeAllRenderables(), or dispose().

Parameters:
renderables - Renderables to add.
Throws:
IllegalArgumentException - If renderables is null.
IllegalStateException - If a custom Iterable has been specified by a call to setRenderables.

clearRenderables

protected void clearRenderables()

dispose

public void dispose()
Disposes the contents of this layer's internal Renderable collection, but does not remove any elements from that collection.

If any of layer's internal Renderables implement AVList, this stops forwarding their property change events to the layer's property change listeners. Any property change listeners the layer attached to the renderables in addRenderable(gov.nasa.worldwind.render.Renderable) or addRenderables(Iterable) are removed.

Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractLayer
Throws:
IllegalStateException - If a custom Iterable has been specified by a call to setRenderables.

disposeRenderables

protected void disposeRenderables()

doPick

protected void doPick(DrawContext dc,
                      Iterable<? extends Renderable> renderables,
                      Point pickPoint)

doPick

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

doPreRender

protected void doPreRender(DrawContext dc)
Overrides:
doPreRender in class AbstractLayer

doPreRender

protected void doPreRender(DrawContext dc,
                           Iterable<? extends Renderable> renderables)

doRender

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

doRender

protected void doRender(DrawContext dc,
                        Iterable<? extends Renderable> renderables)

getActiveRenderables

protected Iterable<Renderable> getActiveRenderables()
Returns the Iterable of currently active Renderables. If the caller has specified a custom Iterable via setRenderables(Iterable), this will returns a reference to that Iterable. If the caller passed setRenderables a null parameter, or if setRenderables has not been called, this returns a view of this layer's internal collection of Renderables.

Returns:
Iterable of currently active Renderables.

getNumRenderables

public int getNumRenderables()

getOpacity

public double getOpacity()
Returns the layer's opacity value, which is ignored by this layer because each of its renderables typiically has its own opacity control.

Specified by:
getOpacity in interface Layer
Overrides:
getOpacity in class AbstractLayer
Returns:
The layer opacity, a value between 0 and 1.

getRenderables

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

Returns:
Iterable of currently active Renderables.

onMessage

public void onMessage(Message message)
Empty implementation of MessageListener.

This implementation forwards the message to each Renderable that implements MessageListener.

Specified by:
onMessage in interface MessageListener
Overrides:
onMessage in class WWObjectImpl
Parameters:
message - The message that was received.

removeAllRenderables

public void removeAllRenderables()
Clears the contents of this layer's internal Renderable collection. If this layer's internal collection has been overriden with a call to setRenderables(Iterable), this will throw an exception.

If any of the renderables implement AVList, this stops forwarding their property change events to the layer's property change listeners. Any property change listeners the layer attached to the renderables in addRenderable(gov.nasa.worldwind.render.Renderable) or addRenderables(Iterable) are removed.

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

removeRenderable

public void removeRenderable(Renderable renderable)
Removes the specified renderable from this layer's internal collection, if it exists. If this layer's internal collection has been overridden with a call to setRenderables(Iterable), this will throw an exception.

If the renderable implements AVList, this stops forwarding the its property change events to the layer's property change listeners. Any property change listeners the layer attached to the renderable in addRenderable(gov.nasa.worldwind.render.Renderable) or addRenderables(Iterable) are removed.

Parameters:
renderable - Renderable to remove.
Throws:
IllegalArgumentException - If renderable is null.
IllegalStateException - If a custom Iterable has been specified by a call to setRenderables.

setOpacity

public void setOpacity(double opacity)
Opacity is not applied to layers of this type because each renderable typically has its own opacity control.

Specified by:
setOpacity in interface Layer
Overrides:
setOpacity in class AbstractLayer
Parameters:
opacity - the current opacity value, which is ignored by this layer.

setRenderables

public void setRenderables(Iterable<Renderable> renderableIterable)
Overrides the collection of currently active Renderables with the specified renderableIterable. This layer will maintain a reference to renderableIterable strictly for picking and rendering. This layer will not modify the reference, or dispose of its contents. This will also clear and dispose of the internal collection of Renderables, and will prevent any modification to its contents via addRenderable, addRenderables, removeRenderables, or dispose.

Unlike addRenderable(gov.nasa.worldwind.render.Renderable) or addRenderables(Iterable), this does not forward any of the renderable's property change events to the layer's property change listeners. Since the layer is not in control of the iIterable's contents, attaching property change listeners to the renderables could cause the them to hold dangling references to the layer. If any of the renderables in the Iterable rely on forwarding property change events for proper operation - such as AbstractBrowserBalloon - use addRenderables(Iterable) instead.

If the specified renderableIterable is null, this layer reverts to maintaining its internal collection.

Parameters:
renderableIterable - 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