NASA World Wind

gov.nasa.worldwind.layers
Class CachedRenderableLayer

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.CachedRenderableLayer
All Implemented Interfaces:
AVList, Disposable, MessageListener, Layer, Restorable, WWObject, PropertyChangeListener, EventListener

public class CachedRenderableLayer
extends AbstractLayer

Holds a collection of Renderables and manages local caching of them. Provides searching for Renderables by sector, location or name.

NOTE: This class is experimental and not fully implemented. You should not use it now.


Field Summary
protected static int DEFAULT_DEPTH
           
protected  BasicQuadTree<Renderable> extentTree
           
protected  PickSupport pickSupport
           
 
Constructor Summary
CachedRenderableLayer(Sector coverage)
          Constructs a layer instance.
CachedRenderableLayer(Sector coverage, int numLevels)
          Constructs a layer instance.
 
Method Summary
 void add(Renderable item)
          Add a Renderable to the layer.
 void add(Renderable item, String name)
          Adds a named Renderable to the layer.
 void dispose()
          Disposes any Renderables implementing @{link Dispose} and removes all Renderables from the layer.
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)
           
 Iterable<? extends Renderable> getAllRenderables()
          Returns all Renderables in the layer.
 Renderable getByName(String name)
          Searches the layer for a named Renderable.
 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.
 Collection<? extends Renderable> getRenderables(LatLon location)
          Returns all Renderables at a specfied location.
 Collection<? extends Renderable> getRenderables(Sector extent)
          Returns all Renderables within or intersecting a specified sector.
 boolean hasItems()
          Indictes whether the layer contains Renderables.
 void remove(Renderable item)
          Remove a Renderable from the layer if the Renderable is in the layer.
 void removeByName(String name)
          Remove a named Renderable from the layer if it is in the layer.
 void setOpacity(double opacity)
          Opacity is not applied to layers of this type because each renderable typically has its own opacity control.
 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
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, 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
 
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
 

Field Detail

DEFAULT_DEPTH

protected static final int DEFAULT_DEPTH
See Also:
Constant Field Values

extentTree

protected BasicQuadTree<Renderable> extentTree

pickSupport

protected PickSupport pickSupport
Constructor Detail

CachedRenderableLayer

public CachedRenderableLayer(Sector coverage)
Constructs a layer instance.

Parameters:
coverage - the geographic area covered by the layer's Renderables.
Throws:
IllegalArgumentException - if the coverage sector is null.

CachedRenderableLayer

public CachedRenderableLayer(Sector coverage,
                             int numLevels)
Constructs a layer instance.

Parameters:
coverage - the geographic area covered by the layer's Renderables.
numLevels - the depth of the tree used to sort the Renderables.
Throws:
IllegalArgumentException - if the coverage sector is null or the number of levels is less than 1;
Method Detail

add

public void add(Renderable item)
Add a Renderable to the layer.

Parameters:
item - the Renderable to add.
Throws:
IllegalArgumentException - if the item is null or does not implement GeographicExtent.
See Also:
add(gov.nasa.worldwind.render.Renderable, String)

add

public void add(Renderable item,
                String name)
Adds a named Renderable to the layer. The Renderable can subsequently participate in a name search of the layer.

Parameters:
item - the Renderable to add.
name - a name for the Renderable. May be null, in which case the item has no name.
Throws:
IllegalArgumentException - if the item is null or does not implement GeographicExtent.
See Also:
add(gov.nasa.worldwind.render.Renderable)

dispose

public void dispose()
Disposes any Renderables implementing @{link Dispose} and removes all Renderables from the layer.

Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractLayer

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)

getAllRenderables

public Iterable<? extends Renderable> getAllRenderables()
Returns all Renderables in the layer.

Returns:
an Iterable over all the Renderables in the layer.

getByName

public Renderable getByName(String name)
Searches the layer for a named Renderable.

Parameters:
name - the name to search for. If null, no search is performed and null is returned.
Returns:
the Renderable of the given name, or null if no Renderable with the name is in the layer.

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 Collection<? extends Renderable> getRenderables(LatLon location)
Returns all Renderables at a specfied location.

Parameters:
location - the location of interest.
Returns:
the Collection of Renderables at the specified location.
See Also:
getRenderables(gov.nasa.worldwind.geom.Sector), getAllRenderables()

getRenderables

public Collection<? extends Renderable> getRenderables(Sector extent)
Returns all Renderables within or intersecting a specified sector.

Parameters:
extent - the location of interest.
Returns:
the Collection of Renderables within or intersecting the boundary of the sector.
See Also:
getRenderables(gov.nasa.worldwind.geom.LatLon), getAllRenderables()

hasItems

public boolean hasItems()
Indictes whether the layer contains Renderables.

Returns:
true if the layer contains Renderables, otherwise false.

remove

public void remove(Renderable item)
Remove a Renderable from the layer if the Renderable is in the layer.

Parameters:
item - the Renderable to remove
See Also:
removeByName(String)

removeByName

public void removeByName(String name)
Remove a named Renderable from the layer if it is in the layer.

Parameters:
name - the name of the Renderable to remove. If null, no Renderable is removed.
See Also:
remove(gov.nasa.worldwind.render.Renderable)

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.

toString

public String toString()
Overrides:
toString in class AbstractLayer

NASA World Wind