NASA World Wind

gov.nasa.worldwind
Class AbstractSceneController

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.AbstractSceneController
All Implemented Interfaces:
AVList, Disposable, MessageListener, SceneController, WWObject, PropertyChangeListener, EventListener
Direct Known Subclasses:
BasicSceneController

public abstract class AbstractSceneController
extends WWObjectImpl
implements SceneController


Field Summary
protected  ClutterFilter clutterFilter
           
protected  DrawContext dc
           
protected  boolean deepPick
           
protected  long frame
           
protected  double framesPerSecond
           
protected  double frameTime
           
protected  GLRuntimeCapabilities glRuntimeCaps
           
protected  GpuResourceCache gpuResourceCache
           
protected  PickedObjectList lastObjectsInPickRect
          The list of picked objects that intersect the current pick rectangle.
protected  PickedObjectList lastPickedObjects
          The list of picked objects at the current pick point.
protected  Model model
           
protected  Collection<PerformanceStatistic> perFrameStatistics
           
protected  Set<String> perFrameStatisticsKeys
           
protected  Map<Integer,PickedObject> pickableObjects
          Map of integer color codes to picked objects used to quickly resolve the top picked objects in doResolveTopPick(gov.nasa.worldwind.render.DrawContext, java.awt.Rectangle).
protected  Point pickPoint
          The pick point in AWT screen coordinates, or null if the pick point is disabled.
protected  ArrayList<Point> pickPoints
           
protected  Rectangle pickRect
          The pick rectangle in AWT screen coordinates, or null if the pick rectangle is disabled.
protected  double pickTime
           
protected  Collection<Throwable> renderingExceptions
           
protected  ScreenCreditController screenCreditController
           
protected static String SURFACE_OBJECT_TILE_COUNT_NAME
          The display name for the surface object tile count performance statistic.
protected  SurfaceObjectTileBuilder surfaceObjectTileBuilder
          Support class used to build the composite representation of surface objects as a list of SurfaceTiles.
protected  Collection<SurfaceTile> surfaceObjectTiles
          The composite surface object representation.
protected  TextRendererCache textRendererCache
           
protected  long timebase
           
protected  double verticalExaggeration
           
protected  View view
           
 
Constructor Summary
AbstractSceneController()
           
 
Method Summary
protected  void applyView(DrawContext dc)
           
protected  void buildCompositeSurfaceObjects(DrawContext dc)
          Builds a composite representation for all SurfaceObject instances in the draw context's ordered surface renderable queue.
protected  void checkGLErrors(DrawContext dc)
          Called to check for openGL errors.
protected  void clearFrame(DrawContext dc)
           
protected  void createPickFrustum(DrawContext dc)
           
protected  SurfaceObjectTileBuilder createSurfaceObjectTileBuilder()
          Returns a new SurfaceObjectTileBuilder configured to build a composite representation of SurfaceObject instances.
protected  void createTerrain(DrawContext dc)
           
 void dispose()
          Releases resources associated with this scene controller.
protected  void doDeepPick(DrawContext dc)
           
protected  void doNonTerrainPick(DrawContext dc)
           
protected abstract  void doRepaint(DrawContext dc)
           
protected  void doResolveTopPick(DrawContext dc, Point pickPoint)
           
protected  void doResolveTopPick(DrawContext dc, Rectangle pickRect)
           
protected  void draw(DrawContext dc)
           
protected  void drawCompositeSurfaceObjects(DrawContext dc)
          Causes the scene controller to draw the composite representation of all SurfaceObject instances in the draw context's ordered surface renderable queue.
protected  void drawOrderedSurfaceRenderables(DrawContext dc)
           
protected  void finalizeFrame(DrawContext dc)
           
 ClutterFilter getClutterFilter()
          Returns the current clutter filter.
 DrawContext getDrawContext()
          Returns the current draw context.
 double getFramesPerSecond()
          Returns the current average frames drawn per second.
 double getFrameTime()
          Returns the per-frame timestamp.
 GLRuntimeCapabilities getGLRuntimeCapabilities()
          Returns the GLRuntimeCapabilities associated with this SceneController.
 GpuResourceCache getGpuResourceCache()
          Returns this scene controller's GPU Resource cache.
 Model getModel()
          Indicates the scene controller's model.
 PickedObjectList getObjectsInPickRectangle()
          Returns the list of picked objects that intersect the current pick rectangle.
 Collection<PerformanceStatistic> getPerFrameStatistics()
          Returns the current per-frame statistics.
 PickedObjectList getPickedObjectList()
          Returns the list of picked objects at the current pick point.
 Point getPickPoint()
          Returns the current pick point in AWT screen coordinates.
 Rectangle getPickRectangle()
          Returns the current pick rectangle in AWT screen coordinates.
 Collection<Throwable> getRenderingExceptions()
          Returns the rendering exceptions accumulated by this SceneController during the last frame as a Collection of Throwable objects.
 ScreenCreditController getScreenCreditController()
          Returns the current screen credit controller.
 SectorGeometryList getTerrain()
          Returns the terrain geometry used to draw the most recent frame.
 TextRendererCache getTextRendererCache()
           
 double getVerticalExaggeration()
          Indicates the current vertical exaggeration.
 View getView()
          Returns the current view.
protected  Point getViewportCenter(DrawContext dc)
           
protected  void initializeDrawContext(DrawContext dc)
           
protected  void initializeFrame(DrawContext dc)
           
 boolean isDeepPickEnabled()
          Indicates whether all items under the cursor are identified during picking and within SelectEvents.
protected  PickedObjectList mergePickedObjectLists(PickedObjectList listA, PickedObjectList listB)
           
protected  void pick(DrawContext dc)
           
protected  void pickLayers(DrawContext dc)
           
protected  void pickOrderedSurfaceRenderables(DrawContext dc)
           
protected  void pickTerrain(DrawContext dc)
           
protected  void preRender(DrawContext dc)
           
protected  void preRenderOrderedSurfaceRenderables(DrawContext dc)
           
 void reinitialize()
          Reinitializes the scene controller.
 int repaint()
          Cause the window to regenerate the frame, including pick resolution.
protected  void resolveTopPick(DrawContext dc)
           
 void setClutterFilter(ClutterFilter clutterFilter)
          Specifies the clutter filter to use.
 void setDeepPickEnabled(boolean tf)
          Specifies whether all items under the cursor are identified during picking and within SelectEvents.
 void setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities)
          Sets the GLRuntimeCapabilities associated with this SceneController to the specified parameter.
 void setGpuResourceCache(GpuResourceCache gpuResourceCache)
          Specifies the GPU Resource cache to use.
 void setModel(Model model)
          Specifies the scene controller's model.
 void setPerFrameStatisticsKeys(Set<String> keys)
          Specifies the performance values to monitor.
protected  void setPickedObjectList(PickedObjectList pol)
           
 void setPickPoint(Point pickPoint)
          Specifies the current pick point in AWT screen coordinates, or null to indicate that there is no pick point.
 void setPickRectangle(Rectangle pickRect)
          Specifies the current pick rectangle in AWT screen coordinates, or null to indicate that there is no pick rectangle.
 void setScreenCreditController(ScreenCreditController screenCreditController)
          Specifies the ScreenCreditController to use for displaying screen credits for the model of this screen controller.
 void setVerticalExaggeration(double verticalExaggeration)
          Specifies the exaggeration to apply to elevation values of terrain and other displayed items.
 void setView(View view)
          Sets the current view.
 
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, toString, 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

clutterFilter

protected ClutterFilter clutterFilter

dc

protected DrawContext dc

deepPick

protected boolean deepPick

frame

protected long frame

framesPerSecond

protected double framesPerSecond

frameTime

protected double frameTime

glRuntimeCaps

protected GLRuntimeCapabilities glRuntimeCaps

gpuResourceCache

protected GpuResourceCache gpuResourceCache

lastObjectsInPickRect

protected PickedObjectList lastObjectsInPickRect
The list of picked objects that intersect the current pick rectangle. This list is computed during each call to repaint. Initially null.


lastPickedObjects

protected PickedObjectList lastPickedObjects
The list of picked objects at the current pick point. This list is computed during each call to repaint. Initially null.


model

protected Model model

perFrameStatistics

protected Collection<PerformanceStatistic> perFrameStatistics

perFrameStatisticsKeys

protected Set<String> perFrameStatisticsKeys

pickableObjects

protected Map<Integer,PickedObject> pickableObjects
Map of integer color codes to picked objects used to quickly resolve the top picked objects in doResolveTopPick(gov.nasa.worldwind.render.DrawContext, java.awt.Rectangle). This map is used only when a pick rectangle is specified. Initialized to a new HashMap.


pickPoint

protected Point pickPoint
The pick point in AWT screen coordinates, or null if the pick point is disabled. Initially null.


pickPoints

protected ArrayList<Point> pickPoints

pickRect

protected Rectangle pickRect
The pick rectangle in AWT screen coordinates, or null if the pick rectangle is disabled. Initially null.


pickTime

protected double pickTime

renderingExceptions

protected Collection<Throwable> renderingExceptions

screenCreditController

protected ScreenCreditController screenCreditController

SURFACE_OBJECT_TILE_COUNT_NAME

protected static final String SURFACE_OBJECT_TILE_COUNT_NAME
The display name for the surface object tile count performance statistic.

See Also:
Constant Field Values

surfaceObjectTileBuilder

protected SurfaceObjectTileBuilder surfaceObjectTileBuilder
Support class used to build the composite representation of surface objects as a list of SurfaceTiles.


surfaceObjectTiles

protected Collection<SurfaceTile> surfaceObjectTiles
The composite surface object representation. Populated each frame by the surfaceObjectTileBuilder.


textRendererCache

protected TextRendererCache textRendererCache

timebase

protected long timebase

verticalExaggeration

protected double verticalExaggeration

view

protected View view
Constructor Detail

AbstractSceneController

public AbstractSceneController()
Method Detail

applyView

protected void applyView(DrawContext dc)

buildCompositeSurfaceObjects

protected void buildCompositeSurfaceObjects(DrawContext dc)
Builds a composite representation for all SurfaceObject instances in the draw context's ordered surface renderable queue. While building the composite representation this invokes SurfaceObject.render(gov.nasa.worldwind.render.DrawContext) in ordered rendering mode. This does nothing if the ordered surface renderable queue is empty, or if it does not contain any SurfaceObjects.

This method is called during the preRender phase, and is therefore free to modify the framebuffer contents to create the composite representation.

Parameters:
dc - The drawing context containing the surface objects to build a composite representation for.
See Also:
DrawContext.getOrderedSurfaceRenderables()

checkGLErrors

protected void checkGLErrors(DrawContext dc)
Called to check for openGL errors. This method includes a "round-trip" between the application and renderer, which is slow. Therefore, this method is excluded from the "normal" render pass. It is here as a matter of convenience to developers, and is not part of the API.

Parameters:
dc - the relevant DrawContext

clearFrame

protected void clearFrame(DrawContext dc)

createPickFrustum

protected void createPickFrustum(DrawContext dc)

createSurfaceObjectTileBuilder

protected SurfaceObjectTileBuilder createSurfaceObjectTileBuilder()
Returns a new SurfaceObjectTileBuilder configured to build a composite representation of SurfaceObject instances.

Returns:
A new SurfaceObjectTileBuilder.

createTerrain

protected void createTerrain(DrawContext dc)

dispose

public void dispose()
Releases resources associated with this scene controller.

Specified by:
dispose in interface Disposable

doDeepPick

protected void doDeepPick(DrawContext dc)

doNonTerrainPick

protected void doNonTerrainPick(DrawContext dc)

doRepaint

protected abstract void doRepaint(DrawContext dc)

doResolveTopPick

protected void doResolveTopPick(DrawContext dc,
                                Point pickPoint)

doResolveTopPick

protected void doResolveTopPick(DrawContext dc,
                                Rectangle pickRect)

draw

protected void draw(DrawContext dc)

drawCompositeSurfaceObjects

protected void drawCompositeSurfaceObjects(DrawContext dc)
Causes the scene controller to draw the composite representation of all SurfaceObject instances in the draw context's ordered surface renderable queue. This representation was built during the preRender phase. This does nothing if the ordered surface renderable queue is empty, or if it does not contain any SurfaceObjects.

Parameters:
dc - The drawing context containing the surface objects who's composite representation is drawn.

drawOrderedSurfaceRenderables

protected void drawOrderedSurfaceRenderables(DrawContext dc)

finalizeFrame

protected void finalizeFrame(DrawContext dc)

getClutterFilter

public ClutterFilter getClutterFilter()
Description copied from interface: SceneController
Returns the current clutter filter.

Specified by:
getClutterFilter in interface SceneController
Returns:
the current clutter filter. May be null, in which case decluttering is not performed.

getDrawContext

public DrawContext getDrawContext()
Description copied from interface: SceneController
Returns the current draw context.

Specified by:
getDrawContext in interface SceneController
Returns:
the current draw context.

getFramesPerSecond

public double getFramesPerSecond()
Description copied from interface: SceneController
Returns the current average frames drawn per second. A frame is one repaint of the window and includes a pick pass and a render pass.

Specified by:
getFramesPerSecond in interface SceneController
Returns:
the current average number of frames drawn per second.

getFrameTime

public double getFrameTime()
Description copied from interface: SceneController
Returns the per-frame timestamp.

Specified by:
getFrameTime in interface SceneController
Returns:
the per-frame timestamp, in milliseconds.

getGLRuntimeCapabilities

public GLRuntimeCapabilities getGLRuntimeCapabilities()
Returns the GLRuntimeCapabilities associated with this SceneController.

Specified by:
getGLRuntimeCapabilities in interface SceneController
Returns:
this SceneController's associated GLRuntimeCapabilities.

getGpuResourceCache

public GpuResourceCache getGpuResourceCache()
Description copied from interface: SceneController
Returns this scene controller's GPU Resource cache.

Specified by:
getGpuResourceCache in interface SceneController
Returns:
this scene controller's GPU Resource cache.

getModel

public Model getModel()
Description copied from interface: SceneController
Indicates the scene controller's model. This returns null if the scene controller has no model.

Specified by:
getModel in interface SceneController
Returns:
the scene controller's model, or null if the scene controller has no model.

getObjectsInPickRectangle

public PickedObjectList getObjectsInPickRectangle()
Returns the list of picked objects that intersect the current pick rectangle. The returned list is computed during the most recent call to repaint.

Specified by:
getObjectsInPickRectangle in interface SceneController
Returns:
the list of picked objects intersecting the pick rectangle, or null if no objects are currently intersecting the rectangle.

getPerFrameStatistics

public Collection<PerformanceStatistic> getPerFrameStatistics()
Description copied from interface: SceneController
Returns the current per-frame statistics.

Specified by:
getPerFrameStatistics in interface SceneController
Returns:
the current per-frame statistics.

getPickedObjectList

public PickedObjectList getPickedObjectList()
Returns the list of picked objects at the current pick point. The returned list is computed during the most recent call to repaint.

Specified by:
getPickedObjectList in interface SceneController
Returns:
the list of picked objects at the pick point, or null if no objects are currently picked.

getPickPoint

public Point getPickPoint()
Returns the current pick point in AWT screen coordinates.

Specified by:
getPickPoint in interface SceneController
Returns:
the current pick point, or null if no pick point is current.
See Also:
SceneController.setPickPoint(java.awt.Point)

getPickRectangle

public Rectangle getPickRectangle()
Returns the current pick rectangle in AWT screen coordinates.

Specified by:
getPickRectangle in interface SceneController
Returns:
the current pick rectangle, or null if no pick rectangle is current.
See Also:
SceneController.setPickRectangle(java.awt.Rectangle)

getRenderingExceptions

public Collection<Throwable> getRenderingExceptions()
Description copied from interface: SceneController
Returns the rendering exceptions accumulated by this SceneController during the last frame as a Collection of Throwable objects.

Specified by:
getRenderingExceptions in interface SceneController
Returns:
the Collection of accumulated rendering exceptions.

getScreenCreditController

public ScreenCreditController getScreenCreditController()
Description copied from interface: SceneController
Returns the current screen credit controller.

Specified by:
getScreenCreditController in interface SceneController
Returns:
the current screen credit controller. May be null.
See Also:
SceneController.setScreenCreditController(gov.nasa.worldwind.render.ScreenCreditController)

getTerrain

public SectorGeometryList getTerrain()
Description copied from interface: SceneController
Returns the terrain geometry used to draw the most recent frame. The geometry spans only the area most recently visible.

Specified by:
getTerrain in interface SceneController
Returns:
the terrain geometry used to draw the most recent frame. May be null.

getTextRendererCache

public TextRendererCache getTextRendererCache()

getVerticalExaggeration

public double getVerticalExaggeration()
Description copied from interface: SceneController
Indicates the current vertical exaggeration.

Specified by:
getVerticalExaggeration in interface SceneController
Returns:
the current vertical exaggeration.

getView

public View getView()
Description copied from interface: SceneController
Returns the current view. This method fires an AVKey.VIEW property change event.

Specified by:
getView in interface SceneController
Returns:
the current view.

getViewportCenter

protected Point getViewportCenter(DrawContext dc)

initializeDrawContext

protected void initializeDrawContext(DrawContext dc)

initializeFrame

protected void initializeFrame(DrawContext dc)

isDeepPickEnabled

public boolean isDeepPickEnabled()
Description copied from interface: SceneController
Indicates whether all items under the cursor are identified during picking and within SelectEvents.

Specified by:
isDeepPickEnabled in interface SceneController
Returns:
true if all items under the cursor are identified during picking, otherwise false.

mergePickedObjectLists

protected PickedObjectList mergePickedObjectLists(PickedObjectList listA,
                                                  PickedObjectList listB)

pick

protected void pick(DrawContext dc)

pickLayers

protected void pickLayers(DrawContext dc)

pickOrderedSurfaceRenderables

protected void pickOrderedSurfaceRenderables(DrawContext dc)

pickTerrain

protected void pickTerrain(DrawContext dc)

preRender

protected void preRender(DrawContext dc)

preRenderOrderedSurfaceRenderables

protected void preRenderOrderedSurfaceRenderables(DrawContext dc)

reinitialize

public void reinitialize()
Description copied from interface: SceneController
Reinitializes the scene controller.

Specified by:
reinitialize in interface SceneController

repaint

public int repaint()
Description copied from interface: SceneController
Cause the window to regenerate the frame, including pick resolution.

Specified by:
repaint in interface SceneController
Returns:
if greater than zero, the window should be automatically repainted again at the indicated number of milliseconds from this method's return.

resolveTopPick

protected void resolveTopPick(DrawContext dc)

setClutterFilter

public void setClutterFilter(ClutterFilter clutterFilter)
Description copied from interface: SceneController
Specifies the clutter filter to use.

Specified by:
setClutterFilter in interface SceneController
Parameters:
clutterFilter - the clutter filter to use. May be null to indicate no decluttering.

setDeepPickEnabled

public void setDeepPickEnabled(boolean tf)
Description copied from interface: SceneController
Specifies whether all items under the cursor are identified during picking and within SelectEvents.

Specified by:
setDeepPickEnabled in interface SceneController
Parameters:
tf - true to identify all items under the cursor during picking, otherwise false.

setGLRuntimeCapabilities

public void setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities)
Sets the GLRuntimeCapabilities associated with this SceneController to the specified parameter.

Specified by:
setGLRuntimeCapabilities in interface SceneController
Parameters:
capabilities - the GLRuntimeCapabilities to be associated with this SceneController.

setGpuResourceCache

public void setGpuResourceCache(GpuResourceCache gpuResourceCache)
Description copied from interface: SceneController
Specifies the GPU Resource cache to use.

Specified by:
setGpuResourceCache in interface SceneController
Parameters:
gpuResourceCache - the texture cache.

setModel

public void setModel(Model model)
Description copied from interface: SceneController
Specifies the scene controller's model. This method fires an AVKey.MODEL property change event.

Specified by:
setModel in interface SceneController
Parameters:
model - the scene controller's model.

setPerFrameStatisticsKeys

public void setPerFrameStatisticsKeys(Set<String> keys)
Description copied from interface: SceneController
Specifies the performance values to monitor. See PerformanceStatistic for the available keys.

Specified by:
setPerFrameStatisticsKeys in interface SceneController
Parameters:
keys - the performance statistic keys to monitor.

setPickedObjectList

protected void setPickedObjectList(PickedObjectList pol)

setPickPoint

public void setPickPoint(Point pickPoint)
Specifies the current pick point in AWT screen coordinates, or null to indicate that there is no pick point. Each frame, this scene controller determines which objects are drawn at the pick point and places them in a PickedObjectList. This list can be accessed by calling SceneController.getPickedObjectList().

If the pick point is null, this scene controller ignores the pick point and the list of objects returned by getPickedObjectList is empty.

Specified by:
setPickPoint in interface SceneController
Parameters:
pickPoint - the current pick point, or null.

setPickRectangle

public void setPickRectangle(Rectangle pickRect)
Specifies the current pick rectangle in AWT screen coordinates, or null to indicate that there is no pick rectangle. Each frame, this scene controller determines which objects intersect the pick rectangle and places them in a PickedObjectList. This list can be accessed by calling SceneController.getObjectsInPickRectangle().

If the pick rectangle is null, this scene controller ignores the pick rectangle and the list of objects returned by getObjectsInPickRectangle is empty.

Specified by:
setPickRectangle in interface SceneController
Parameters:
pickRect - the current pick rectangle, or null.

setScreenCreditController

public void setScreenCreditController(ScreenCreditController screenCreditController)
Description copied from interface: SceneController
Specifies the ScreenCreditController to use for displaying screen credits for the model of this screen controller.

Specified by:
setScreenCreditController in interface SceneController
Parameters:
screenCreditController - the screen credit controller. May be null, in which case screen credits are not displayed.

setVerticalExaggeration

public void setVerticalExaggeration(double verticalExaggeration)
Description copied from interface: SceneController
Specifies the exaggeration to apply to elevation values of terrain and other displayed items.

Specified by:
setVerticalExaggeration in interface SceneController
Parameters:
verticalExaggeration - the vertical exaggeration to apply.

setView

public void setView(View view)
Description copied from interface: SceneController
Sets the current view.

Specified by:
setView in interface SceneController
Parameters:
view - the view.

NASA World Wind