Package gov.nasa.worldwind
Class AbstractSceneController
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.AbstractSceneController
-
- All Implemented Interfaces:
AVList,Disposable,MessageListener,SceneController,WWObject,java.beans.PropertyChangeListener,java.util.EventListener
- Direct Known Subclasses:
BasicSceneController
public abstract class AbstractSceneController extends WWObjectImpl implements SceneController
-
-
Field Summary
Fields Modifier and Type Field Description protected ClutterFilterclutterFilterprotected DrawContextdcprotected booleandeepPickprotected booleandeferOrderedRenderingprotected longframeprotected doubleframesPerSecondprotected doubleframeTimeprotected GLRuntimeCapabilitiesglRuntimeCapsprotected GpuResourceCachegpuResourceCacheprotected PickedObjectListlastObjectsInPickRectThe list of picked objects that intersect the current pick rectangle.protected PickedObjectListlastPickedObjectsThe list of picked objects at the current pick point.protected Modelmodelprotected java.util.Collection<PerformanceStatistic>perFrameStatisticsprotected java.util.Set<java.lang.String>perFrameStatisticsKeysprotected java.util.Map<java.lang.Integer,PickedObject>pickableObjectsMap of integer color codes to picked objects used to quickly resolve the top picked objects indoResolveTopPick(gov.nasa.worldwind.render.DrawContext, java.awt.Rectangle).protected java.awt.PointpickPointThe pick point in AWT screen coordinates, ornullif the pick point is disabled.protected java.util.ArrayList<java.awt.Point>pickPointsprotected java.awt.RectanglepickRectThe pick rectangle in AWT screen coordinates, ornullif the pick rectangle is disabled.protected doublepickTimeprotected java.util.Collection<java.lang.Throwable>renderingExceptionsprotected ScreenCreditControllerscreenCreditControllerprotected static java.lang.StringSURFACE_OBJECT_TILE_COUNT_NAMEThe display name for the surface object tile count performance statistic.protected SurfaceObjectTileBuildersurfaceObjectTileBuilderSupport class used to build the composite representation of surface objects as a list of SurfaceTiles.protected TextRendererCachetextRendererCacheprotected longtimebaseprotected doubleverticalExaggerationprotected Viewview
-
Constructor Summary
Constructors Constructor Description AbstractSceneController()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidapplyView(DrawContext dc)protected voidbuildCompositeSurfaceObjects(DrawContext dc)Builds a composite representation for allSurfaceObjectinstances in the draw context's ordered surface renderable queue.protected voidcheckGLErrors(DrawContext dc)Called to check for openGL errors.protected voidclearFrame(DrawContext dc)protected voidcreatePickFrustum(DrawContext dc)protected voidcreateTerrain(DrawContext dc)voiddispose()Releases resources associated with this scene controller.protected voiddoDeepPick(DrawContext dc)protected voiddoNonTerrainPick(DrawContext dc)protected abstract voiddoRepaint(DrawContext dc)protected voiddoResolveTopPick(DrawContext dc, java.awt.Point pickPoint)protected voiddoResolveTopPick(DrawContext dc, java.awt.Rectangle pickRect)protected voiddraw(DrawContext dc)protected voiddrawCompositeSurfaceObjects(DrawContext dc)Causes the scene controller to draw the composite representation of allSurfaceObjectinstances in the draw context's ordered surface renderable queue.protected voiddrawOrderedSurfaceRenderables(DrawContext dc)protected voidfinalizeFrame(DrawContext dc)ClutterFiltergetClutterFilter()Returns the current clutter filter.DrawContextgetDrawContext()Returns the current draw context.doublegetFramesPerSecond()Returns the current average frames drawn per second.doublegetFrameTime()Returns the per-frame timestamp.GLRuntimeCapabilitiesgetGLRuntimeCapabilities()Returns theGLRuntimeCapabilitiesassociated with this SceneController.GpuResourceCachegetGpuResourceCache()Returns this scene controller's GPU Resource cache.ModelgetModel()Indicates the scene controller's model.PickedObjectListgetObjectsInPickRectangle()Returns the list of picked objects that intersect the current pick rectangle.java.util.Collection<PerformanceStatistic>getPerFrameStatistics()Returns the current per-frame statistics.PickedObjectListgetPickedObjectList()Returns the list of picked objects at the current pick point.java.awt.PointgetPickPoint()Returns the current pick point in AWT screen coordinates.java.awt.RectanglegetPickRectangle()Returns the current pick rectangle in AWT screen coordinates.java.util.Collection<java.lang.Throwable>getRenderingExceptions()Returns the rendering exceptions accumulated by this SceneController during the last frame as aCollectionofThrowableobjects.ScreenCreditControllergetScreenCreditController()Returns the current screen credit controller.SectorGeometryListgetTerrain()Returns the terrain geometry used to draw the most recent frame.TextRendererCachegetTextRendererCache()doublegetVerticalExaggeration()Indicates the current vertical exaggeration.ViewgetView()Returns the current view.protected java.awt.PointgetViewportCenter(DrawContext dc)protected voidinitializeDrawContext(DrawContext dc)protected voidinitializeFrame(DrawContext dc)booleanisDeepPickEnabled()Indicates whether all items under the cursor are identified during picking and withinSelectEvents.booleanisDeferOrderedRendering()protected PickedObjectListmergePickedObjectLists(PickedObjectList listA, PickedObjectList listB)protected voidpick(DrawContext dc)protected voidpickLayers(DrawContext dc)protected voidpickOrderedSurfaceRenderables(DrawContext dc)protected voidpickTerrain(DrawContext dc)protected voidpreRender(DrawContext dc)protected voidpreRenderOrderedSurfaceRenderables(DrawContext dc)voidreinitialize()Reinitializes the scene controller.intrepaint()Cause the window to regenerate the frame, including pick resolution.protected voidresolveTopPick(DrawContext dc)voidsetClutterFilter(ClutterFilter clutterFilter)Specifies the clutter filter to use.voidsetDeepPickEnabled(boolean tf)Specifies whether all items under the cursor are identified during picking and withinSelectEvents.voidsetDeferOrderedRendering(boolean deferOrderedRendering)voidsetGLRuntimeCapabilities(GLRuntimeCapabilities capabilities)Sets theGLRuntimeCapabilitiesassociated with this SceneController to the specified parameter.voidsetGpuResourceCache(GpuResourceCache gpuResourceCache)Specifies the GPU Resource cache to use.voidsetModel(Model model)Specifies the scene controller's model.voidsetPerFrameStatisticsKeys(java.util.Set<java.lang.String> keys)Specifies the performance values to monitor.protected voidsetPickedObjectList(PickedObjectList pol)voidsetPickPoint(java.awt.Point pickPoint)Specifies the current pick point in AWT screen coordinates, ornullto indicate that there is no pick point.voidsetPickRectangle(java.awt.Rectangle pickRect)Specifies the current pick rectangle in AWT screen coordinates, ornullto indicate that there is no pick rectangle.voidsetScreenCreditController(ScreenCreditController screenCreditController)Specifies theScreenCreditControllerto use for displaying screen credits for the model of this screen controller.voidsetVerticalExaggeration(double verticalExaggeration)Specifies the exaggeration to apply to elevation values of terrain and other displayed items.voidsetView(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, 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 gov.nasa.worldwind.event.MessageListener
onMessage
-
-
-
-
Field Detail
-
model
protected Model model
-
view
protected View view
-
verticalExaggeration
protected double verticalExaggeration
-
dc
protected DrawContext dc
-
lastPickedObjects
protected PickedObjectList lastPickedObjects
The list of picked objects at the current pick point. This list is computed during each call to repaint. Initiallynull.
-
lastObjectsInPickRect
protected PickedObjectList lastObjectsInPickRect
The list of picked objects that intersect the current pick rectangle. This list is computed during each call to repaint. Initiallynull.
-
pickableObjects
protected java.util.Map<java.lang.Integer,PickedObject> pickableObjects
Map of integer color codes to picked objects used to quickly resolve the top picked objects indoResolveTopPick(gov.nasa.worldwind.render.DrawContext, java.awt.Rectangle). This map is used only when a pick rectangle is specified. Initialized to a new HashMap.
-
frame
protected long frame
-
timebase
protected long timebase
-
framesPerSecond
protected double framesPerSecond
-
frameTime
protected double frameTime
-
pickTime
protected double pickTime
-
pickPoint
protected java.awt.Point pickPoint
The pick point in AWT screen coordinates, ornullif the pick point is disabled. Initiallynull.
-
pickRect
protected java.awt.Rectangle pickRect
The pick rectangle in AWT screen coordinates, ornullif the pick rectangle is disabled. Initiallynull.
-
deepPick
protected boolean deepPick
-
gpuResourceCache
protected GpuResourceCache gpuResourceCache
-
textRendererCache
protected TextRendererCache textRendererCache
-
perFrameStatisticsKeys
protected java.util.Set<java.lang.String> perFrameStatisticsKeys
-
perFrameStatistics
protected java.util.Collection<PerformanceStatistic> perFrameStatistics
-
renderingExceptions
protected java.util.Collection<java.lang.Throwable> renderingExceptions
-
screenCreditController
protected ScreenCreditController screenCreditController
-
glRuntimeCaps
protected GLRuntimeCapabilities glRuntimeCaps
-
pickPoints
protected java.util.ArrayList<java.awt.Point> pickPoints
-
surfaceObjectTileBuilder
protected SurfaceObjectTileBuilder surfaceObjectTileBuilder
Support class used to build the composite representation of surface objects as a list of SurfaceTiles. We keep a reference to the tile builder instance used to build tiles because it acts as a cache key to the tiles and determines when the tiles must be updated. The tile builder does not retain any references the SurfaceObjects, so keeping a reference to it does not leak memory.
-
SURFACE_OBJECT_TILE_COUNT_NAME
protected static final java.lang.String SURFACE_OBJECT_TILE_COUNT_NAME
The display name for the surface object tile count performance statistic.- See Also:
- Constant Field Values
-
clutterFilter
protected ClutterFilter clutterFilter
-
deferOrderedRendering
protected boolean deferOrderedRendering
-
-
Method Detail
-
reinitialize
public void reinitialize()
Description copied from interface:SceneControllerReinitializes the scene controller.- Specified by:
reinitializein interfaceSceneController
-
dispose
public void dispose()
Releases resources associated with this scene controller.- Specified by:
disposein interfaceDisposable
-
getGpuResourceCache
public GpuResourceCache getGpuResourceCache()
Description copied from interface:SceneControllerReturns this scene controller's GPU Resource cache.- Specified by:
getGpuResourceCachein interfaceSceneController- Returns:
- this scene controller's GPU Resource cache.
-
setGpuResourceCache
public void setGpuResourceCache(GpuResourceCache gpuResourceCache)
Description copied from interface:SceneControllerSpecifies the GPU Resource cache to use.- Specified by:
setGpuResourceCachein interfaceSceneController- Parameters:
gpuResourceCache- the texture cache.
-
getTextRendererCache
public TextRendererCache getTextRendererCache()
-
getModel
public Model getModel()
Description copied from interface:SceneControllerIndicates the scene controller's model. This returnsnullif the scene controller has no model.- Specified by:
getModelin interfaceSceneController- Returns:
- the scene controller's model, or
nullif the scene controller has no model.
-
getView
public View getView()
Description copied from interface:SceneControllerReturns the current view. This method fires anAVKey.VIEWproperty change event.- Specified by:
getViewin interfaceSceneController- Returns:
- the current view.
-
setModel
public void setModel(Model model)
Description copied from interface:SceneControllerSpecifies the scene controller's model. This method fires anAVKey.MODELproperty change event.- Specified by:
setModelin interfaceSceneController- Parameters:
model- the scene controller's model.
-
setView
public void setView(View view)
Description copied from interface:SceneControllerSets the current view.- Specified by:
setViewin interfaceSceneController- Parameters:
view- the view.
-
setVerticalExaggeration
public void setVerticalExaggeration(double verticalExaggeration)
Description copied from interface:SceneControllerSpecifies the exaggeration to apply to elevation values of terrain and other displayed items.- Specified by:
setVerticalExaggerationin interfaceSceneController- Parameters:
verticalExaggeration- the vertical exaggeration to apply.
-
getVerticalExaggeration
public double getVerticalExaggeration()
Description copied from interface:SceneControllerIndicates the current vertical exaggeration.- Specified by:
getVerticalExaggerationin interfaceSceneController- Returns:
- the current vertical exaggeration.
-
setPickPoint
public void setPickPoint(java.awt.Point pickPoint)
Specifies the current pick point in AWT screen coordinates, ornullto 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 callingSceneController.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:
setPickPointin interfaceSceneController- Parameters:
pickPoint- the current pick point, ornull.
-
getPickPoint
public java.awt.Point getPickPoint()
Returns the current pick point in AWT screen coordinates.- Specified by:
getPickPointin interfaceSceneController- Returns:
- the current pick point, or
nullif no pick point is current. - See Also:
SceneController.setPickPoint(java.awt.Point)
-
setPickRectangle
public void setPickRectangle(java.awt.Rectangle pickRect)
Specifies the current pick rectangle in AWT screen coordinates, ornullto 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 callingSceneController.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:
setPickRectanglein interfaceSceneController- Parameters:
pickRect- the current pick rectangle, ornull.
-
getPickRectangle
public java.awt.Rectangle getPickRectangle()
Returns the current pick rectangle in AWT screen coordinates.- Specified by:
getPickRectanglein interfaceSceneController- Returns:
- the current pick rectangle, or
nullif no pick rectangle is current. - See Also:
SceneController.setPickRectangle(java.awt.Rectangle)
-
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:
getPickedObjectListin interfaceSceneController- Returns:
- the list of picked objects at the pick point, or null if no objects are currently picked.
-
setPickedObjectList
protected void setPickedObjectList(PickedObjectList pol)
-
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:
getObjectsInPickRectanglein interfaceSceneController- Returns:
- the list of picked objects intersecting the pick rectangle, or null if no objects are currently intersecting the rectangle.
-
setDeepPickEnabled
public void setDeepPickEnabled(boolean tf)
Description copied from interface:SceneControllerSpecifies whether all items under the cursor are identified during picking and withinSelectEvents.- Specified by:
setDeepPickEnabledin interfaceSceneController- Parameters:
tf- true to identify all items under the cursor during picking, otherwise false.
-
isDeepPickEnabled
public boolean isDeepPickEnabled()
Description copied from interface:SceneControllerIndicates whether all items under the cursor are identified during picking and withinSelectEvents.- Specified by:
isDeepPickEnabledin interfaceSceneController- Returns:
- true if all items under the cursor are identified during picking, otherwise false.
-
getTerrain
public SectorGeometryList getTerrain()
Description copied from interface:SceneControllerReturns the terrain geometry used to draw the most recent frame. The geometry spans only the area most recently visible.- Specified by:
getTerrainin interfaceSceneController- Returns:
- the terrain geometry used to draw the most recent frame. May be null.
-
getDrawContext
public DrawContext getDrawContext()
Description copied from interface:SceneControllerReturns the current draw context.- Specified by:
getDrawContextin interfaceSceneController- Returns:
- the current draw context.
-
getFramesPerSecond
public double getFramesPerSecond()
Description copied from interface:SceneControllerReturns 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:
getFramesPerSecondin interfaceSceneController- Returns:
- the current average number of frames drawn per second.
-
getFrameTime
public double getFrameTime()
Description copied from interface:SceneControllerReturns the per-frame timestamp.- Specified by:
getFrameTimein interfaceSceneController- Returns:
- the per-frame timestamp, in milliseconds.
-
setPerFrameStatisticsKeys
public void setPerFrameStatisticsKeys(java.util.Set<java.lang.String> keys)
Description copied from interface:SceneControllerSpecifies the performance values to monitor. SeePerformanceStatisticfor the available keys.- Specified by:
setPerFrameStatisticsKeysin interfaceSceneController- Parameters:
keys- the performance statistic keys to monitor.
-
getPerFrameStatistics
public java.util.Collection<PerformanceStatistic> getPerFrameStatistics()
Description copied from interface:SceneControllerReturns the current per-frame statistics.- Specified by:
getPerFrameStatisticsin interfaceSceneController- Returns:
- the current per-frame statistics.
-
getRenderingExceptions
public java.util.Collection<java.lang.Throwable> getRenderingExceptions()
Description copied from interface:SceneControllerReturns the rendering exceptions accumulated by this SceneController during the last frame as aCollectionofThrowableobjects.- Specified by:
getRenderingExceptionsin interfaceSceneController- Returns:
- the Collection of accumulated rendering exceptions.
-
getScreenCreditController
public ScreenCreditController getScreenCreditController()
Description copied from interface:SceneControllerReturns the current screen credit controller.- Specified by:
getScreenCreditControllerin interfaceSceneController- Returns:
- the current screen credit controller. May be null.
- See Also:
SceneController.setScreenCreditController(gov.nasa.worldwind.render.ScreenCreditController)
-
setScreenCreditController
public void setScreenCreditController(ScreenCreditController screenCreditController)
Description copied from interface:SceneControllerSpecifies theScreenCreditControllerto use for displaying screen credits for the model of this screen controller.- Specified by:
setScreenCreditControllerin interfaceSceneController- Parameters:
screenCreditController- the screen credit controller. May be null, in which case screen credits are not displayed.
-
getGLRuntimeCapabilities
public GLRuntimeCapabilities getGLRuntimeCapabilities()
Returns theGLRuntimeCapabilitiesassociated with this SceneController.- Specified by:
getGLRuntimeCapabilitiesin interfaceSceneController- Returns:
- this SceneController's associated GLRuntimeCapabilities.
-
setGLRuntimeCapabilities
public void setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities)
Sets theGLRuntimeCapabilitiesassociated with this SceneController to the specified parameter.- Specified by:
setGLRuntimeCapabilitiesin interfaceSceneController- Parameters:
capabilities- the GLRuntimeCapabilities to be associated with this SceneController.
-
getClutterFilter
public ClutterFilter getClutterFilter()
Description copied from interface:SceneControllerReturns the current clutter filter.- Specified by:
getClutterFilterin interfaceSceneController- Returns:
- the current clutter filter. May be null, in which case decluttering is not performed.
-
setClutterFilter
public void setClutterFilter(ClutterFilter clutterFilter)
Description copied from interface:SceneControllerSpecifies the clutter filter to use.- Specified by:
setClutterFilterin interfaceSceneController- Parameters:
clutterFilter- the clutter filter to use. May be null to indicate no decluttering.
-
isDeferOrderedRendering
public boolean isDeferOrderedRendering()
-
setDeferOrderedRendering
public void setDeferOrderedRendering(boolean deferOrderedRendering)
-
repaint
public int repaint()
Description copied from interface:SceneControllerCause the window to regenerate the frame, including pick resolution.- Specified by:
repaintin interfaceSceneController- Returns:
- if greater than zero, the window should be automatically repainted again at the indicated number of milliseconds from this method's return.
-
doRepaint
protected abstract void doRepaint(DrawContext dc)
-
initializeDrawContext
protected void initializeDrawContext(DrawContext dc)
-
getViewportCenter
protected java.awt.Point getViewportCenter(DrawContext dc)
-
initializeFrame
protected void initializeFrame(DrawContext dc)
-
clearFrame
protected void clearFrame(DrawContext dc)
-
finalizeFrame
protected void finalizeFrame(DrawContext dc)
-
applyView
protected void applyView(DrawContext dc)
-
createPickFrustum
protected void createPickFrustum(DrawContext dc)
-
createTerrain
protected void createTerrain(DrawContext dc)
-
preRender
protected void preRender(DrawContext dc)
-
pickTerrain
protected void pickTerrain(DrawContext dc)
-
pickLayers
protected void pickLayers(DrawContext dc)
-
resolveTopPick
protected void resolveTopPick(DrawContext dc)
-
doResolveTopPick
protected void doResolveTopPick(DrawContext dc, java.awt.Point pickPoint)
-
doResolveTopPick
protected void doResolveTopPick(DrawContext dc, java.awt.Rectangle pickRect)
-
pick
protected void pick(DrawContext dc)
-
doNonTerrainPick
protected void doNonTerrainPick(DrawContext dc)
-
doDeepPick
protected void doDeepPick(DrawContext dc)
-
mergePickedObjectLists
protected PickedObjectList mergePickedObjectLists(PickedObjectList listA, PickedObjectList listB)
-
draw
protected void draw(DrawContext dc)
-
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 relevantDrawContext
-
preRenderOrderedSurfaceRenderables
protected void preRenderOrderedSurfaceRenderables(DrawContext dc)
-
pickOrderedSurfaceRenderables
protected void pickOrderedSurfaceRenderables(DrawContext dc)
-
drawOrderedSurfaceRenderables
protected void drawOrderedSurfaceRenderables(DrawContext dc)
-
buildCompositeSurfaceObjects
protected void buildCompositeSurfaceObjects(DrawContext dc)
Builds a composite representation for allSurfaceObjectinstances in the draw context's ordered surface renderable queue. While building the composite representation this invokesRenderable.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()
-
drawCompositeSurfaceObjects
protected void drawCompositeSurfaceObjects(DrawContext dc)
Causes the scene controller to draw the composite representation of allSurfaceObjectinstances 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.
-
-