NASA World Wind

gov.nasa.worldwind.render
Class DrawContextImpl

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.render.DrawContextImpl
All Implemented Interfaces:
AVList, Disposable, DrawContext, WWObject, java.beans.PropertyChangeListener, java.util.EventListener

public class DrawContextImpl
extends WWObjectImpl
implements DrawContext


Field Summary
 
Fields inherited from class gov.nasa.worldwind.avlist.AVListImpl
changeSupport
 
Constructor Summary
DrawContextImpl()
           
 
Method Summary
 void addOrderedRenderable(OrderedRenderable orderedRenderable)
           
 void addPickedObject(PickedObject pickedObject)
          Adds a single insatnce of the picked object to the current picked-object list
 void addPickedObjects(PickedObjectList pickedObjects)
          Add picked objects to the current list of picked objects.
 void addPickPointFrustum()
          Creates a frustum around the current pickpoint and adds it to the list of Pick Frustums.
 void addScreenCredit(ScreenCredit credit)
           
 void disablePickingMode()
          Disables color picking mode
 void dispose()
          Free internal resources held by this draw context.
 void drawUnitQuad()
           
 void drawUnitQuad(com.sun.opengl.util.texture.TextureCoords texCoords)
           
 void enablePickingMode()
          Enables color picking mode
 AnnotationRenderer getAnnotationRenderer()
          Returns the draw context's annotation renderer, typically used by annotations that are not contained in an AnnotationLayer.
 java.awt.Color getClearColor()
           
 Layer getCurrentLayer()
          Returns the current-layer.
 int getDrawableHeight()
          Retrieves the drawable height of this DrawContext.
 int getDrawableWidth()
          Retrieves the drawable width of this DrawContext.
 long getFrameTimeStamp()
           
 SurfaceTileRenderer getGeographicSurfaceTileRenderer()
           
 javax.media.opengl.GL getGL()
          Retrieves the current javax.media.opengl.GL.
 javax.media.opengl.GLContext getGLContext()
          Retrieves this DrawContexts javax.media.opengl.GLContext.
 javax.media.opengl.GLDrawable getGLDrawable()
          Retrieves the currentjavax.media.opengl.GLDrawable.
 Globe getGlobe()
          Retrieves the current Globe, which may be null.
 GLRuntimeCapabilities getGLRuntimeCapabilities()
          Returns the GLRuntimeCapabilities associated with this DrawContext.
 javax.media.opengl.glu.GLU getGLU()
          Retrieves the current javax.media.opengl.glu.GLU.
 LayerList getLayers()
          Retrieves a list containing all the current layers.
 Model getModel()
          Retrieves the current Model, which may be null.
 java.util.Queue<OrderedRenderable> getOrderedRenderables()
           
 java.util.Collection<PerformanceStatistic> getPerFrameStatistics()
           
 java.util.Set<java.lang.String> getPerFrameStatisticsKeys()
           
 PickedObjectList getPickedObjects()
          Returns the list of objects picked during the most recent pick traversal.
 PickPointFrustumList getPickFrustums()
          Gets the FrustumList containing all the current Pick Frustums
 java.awt.Point getPickPoint()
           
 java.awt.Dimension getPickPointFrustumDimension()
          Gets the dimension of the current Pick Point Frustum
 Vec4 getPointOnGlobe(Angle latitude, Angle longitude)
           
 int getRedrawRequested()
           
 java.util.Map<ScreenCredit,java.lang.Long> getScreenCredits()
           
 Vec4 getScreenPoint(Angle latitude, Angle longitude, double metersElevation)
           
 Vec4 getScreenPoint(Position position)
           
 Vec4 getScreenPoint(Vec4 modelPoint)
           
 SectorGeometryList getSurfaceGeometry()
          Retrieves a list of all the sectors rendered so far this frame.
 TextRendererCache getTextRendererCache()
           
 TextureCache getTextureCache()
           
 java.awt.Color getUniquePickColor()
          Returns a unique color to serve as a pick identifier during picking.
 double getVerticalExaggeration()
          Retrieves the current vertical exaggeration.
 View getView()
          Retrieves the current View, which may be null.
 Position getViewportCenterPosition()
           
 java.awt.Point getViewportCenterScreenPoint()
           
 Sector getVisibleSector()
          Retrieves a Sector which is at least as large as the current visible sector.
 java.util.List<Sector> getVisibleSectors(double[] resolutions, long timeLimit, Sector sector)
          Returns the visible sectors at one of several specified resolutions within a specfied search sector.
 void initialize(javax.media.opengl.GLContext glContext)
          Initializes this DrawContext.
 boolean isPickingMode()
          Returns true if the Picking mode is active, otherwise return false
 void setAnnotationRenderer(AnnotationRenderer ar)
          Since Annotations are Renderables, they can be exist outside an AnnotationLayer, in which case they are responsible for rendering themselves.
 void setCurrentLayer(Layer layer)
          Sets the current-layer field to the specified layer or null.
 void setFrameTimeStamp(long frameTimeStamp)
           
 void setGLContext(javax.media.opengl.GLContext glContext)
          Assigns this DrawContext a new javax.media.opengl.GLContext.
 void setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities)
          Sets the GLRuntimeCapabilities associated with this DrawContext to the specified parameter.
 void setModel(Model model)
          Assign a new Model.
 void setPerFrameStatistic(java.lang.String key, java.lang.String displayName, java.lang.Object value)
           
 void setPerFrameStatistics(java.util.Collection<PerformanceStatistic> stats)
           
 void setPerFrameStatisticsKeys(java.util.Set<java.lang.String> statKeys, java.util.Collection<PerformanceStatistic> stats)
           
 void setPickPoint(java.awt.Point pickPoint)
           
 void setPickPointFrustumDimension(java.awt.Dimension dim)
          Set the size (in pixels) of the pick point frustum at the near plane.
 void setRedrawRequested(int redrawRequested)
           
 void setSurfaceGeometry(SectorGeometryList surfaceGeometry)
           
 void setTextRendererCache(TextRendererCache textRendererCache)
           
 void setTextureCache(TextureCache textureCache)
           
 void setVerticalExaggeration(double verticalExaggeration)
          Sets the vertical exaggeration.
 void setView(View view)
          Assigns a new View.
 void setViewportCenterPosition(Position viewportCenterPosition)
           
 void setViewportCenterScreenPoint(java.awt.Point viewportCenterScreenPoint)
           
 void setVisibleSector(Sector s)
          Sets the visible Sector.
 
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, 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
 

Constructor Detail

DrawContextImpl

public DrawContextImpl()
Method Detail

addOrderedRenderable

public void addOrderedRenderable(OrderedRenderable orderedRenderable)
Specified by:
addOrderedRenderable in interface DrawContext

addPickedObject

public void addPickedObject(PickedObject pickedObject)
Adds a single insatnce of the picked object to the current picked-object list

Specified by:
addPickedObject in interface DrawContext
Parameters:
pickedObject - the object to add
Throws:
java.lang.IllegalArgumentException - if picked Object is null

addPickedObjects

public void addPickedObjects(PickedObjectList pickedObjects)
Add picked objects to the current list of picked objects.

Specified by:
addPickedObjects in interface DrawContext
Parameters:
pickedObjects - the list of picked objects to add
Throws:
java.lang.IllegalArgumentException - if pickedObjects is null

addPickPointFrustum

public void addPickPointFrustum()
Creates a frustum around the current pickpoint and adds it to the list of Pick Frustums. The frustum size is set with setPickPointFrustumSize().

Specified by:
addPickPointFrustum in interface DrawContext

addScreenCredit

public void addScreenCredit(ScreenCredit credit)
Specified by:
addScreenCredit in interface DrawContext

disablePickingMode

public void disablePickingMode()
Disables color picking mode

Specified by:
disablePickingMode in interface DrawContext

dispose

public void dispose()
Free internal resources held by this draw context. A GL context must be current when this method is called.

Specified by:
dispose in interface Disposable
Throws:
javax.media.opengl.GLException - - If an OpenGL context is not current when this method is called.

drawUnitQuad

public void drawUnitQuad()
Specified by:
drawUnitQuad in interface DrawContext

drawUnitQuad

public void drawUnitQuad(com.sun.opengl.util.texture.TextureCoords texCoords)
Specified by:
drawUnitQuad in interface DrawContext

enablePickingMode

public void enablePickingMode()
Enables color picking mode

Specified by:
enablePickingMode in interface DrawContext

getAnnotationRenderer

public AnnotationRenderer getAnnotationRenderer()
Description copied from interface: DrawContext
Returns the draw context's annotation renderer, typically used by annotations that are not contained in an AnnotationLayer.

Specified by:
getAnnotationRenderer in interface DrawContext
Returns:
the annotation renderer.

getClearColor

public java.awt.Color getClearColor()
Specified by:
getClearColor in interface DrawContext

getCurrentLayer

public Layer getCurrentLayer()
Description copied from interface: DrawContext
Returns the current-layer. The field is informative only and enables layer contents to determine their containing layer.

Specified by:
getCurrentLayer in interface DrawContext
Returns:
the current layer, or null if no layer is current.

getDrawableHeight

public final int getDrawableHeight()
Description copied from interface: DrawContext
Retrieves the drawable height of this DrawContext.

Specified by:
getDrawableHeight in interface DrawContext
Returns:
the drawable height of this DrawCOntext

getDrawableWidth

public final int getDrawableWidth()
Description copied from interface: DrawContext
Retrieves the drawable width of this DrawContext.

Specified by:
getDrawableWidth in interface DrawContext
Returns:
the drawable width of this DrawCOntext

getFrameTimeStamp

public long getFrameTimeStamp()
Specified by:
getFrameTimeStamp in interface DrawContext

getGeographicSurfaceTileRenderer

public SurfaceTileRenderer getGeographicSurfaceTileRenderer()
Specified by:
getGeographicSurfaceTileRenderer in interface DrawContext

getGL

public final javax.media.opengl.GL getGL()
Description copied from interface: DrawContext
Retrieves the current javax.media.opengl.GL. A GL or GLU is required for all graphical rendering in World Wind.

Specified by:
getGL in interface DrawContext
Returns:
the current GL if available, null otherwise

getGLContext

public final javax.media.opengl.GLContext getGLContext()
Description copied from interface: DrawContext
Retrieves this DrawContexts javax.media.opengl.GLContext. If this method returns null, then there are potentially no active GLContexts and rendering should be aborted.

Specified by:
getGLContext in interface DrawContext
Returns:
this DrawContexts javax.media.opengl.GLContext.

getGLDrawable

public final javax.media.opengl.GLDrawable getGLDrawable()
Description copied from interface: DrawContext
Retrieves the currentjavax.media.opengl.GLDrawable. A GLDrawable can be used to create a GLContext, which can then be used for rendering.

Specified by:
getGLDrawable in interface DrawContext
Returns:
the current GLDrawable, null if none available

getGlobe

public final Globe getGlobe()
Description copied from interface: DrawContext
Retrieves the current Globe, which may be null.

Specified by:
getGlobe in interface DrawContext
Returns:
the current Globe, which may be null

getGLRuntimeCapabilities

public GLRuntimeCapabilities getGLRuntimeCapabilities()
Description copied from interface: DrawContext
Returns the GLRuntimeCapabilities associated with this DrawContext.

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

getGLU

public final javax.media.opengl.glu.GLU getGLU()
Description copied from interface: DrawContext
Retrieves the current javax.media.opengl.glu.GLU. A GLU or GL is required for all graphical rendering in World Wind.

Specified by:
getGLU in interface DrawContext
Returns:
the current GLU if available, null otherwise

getLayers

public final LayerList getLayers()
Description copied from interface: DrawContext
Retrieves a list containing all the current layers. No guarantee is made about the order of the layers.

Specified by:
getLayers in interface DrawContext
Returns:
a LayerList containing all the current layers

getModel

public final Model getModel()
Description copied from interface: DrawContext
Retrieves the current Model, which may be null.

Specified by:
getModel in interface DrawContext
Returns:
the current Model, which may be null

getOrderedRenderables

public java.util.Queue<OrderedRenderable> getOrderedRenderables()
Specified by:
getOrderedRenderables in interface DrawContext

getPerFrameStatistics

public java.util.Collection<PerformanceStatistic> getPerFrameStatistics()
Specified by:
getPerFrameStatistics in interface DrawContext

getPerFrameStatisticsKeys

public java.util.Set<java.lang.String> getPerFrameStatisticsKeys()
Specified by:
getPerFrameStatisticsKeys in interface DrawContext

getPickedObjects

public PickedObjectList getPickedObjects()
Description copied from interface: DrawContext
Returns the list of objects picked during the most recent pick traversal.

Specified by:
getPickedObjects in interface DrawContext
Returns:
the list of picked objects

getPickFrustums

public PickPointFrustumList getPickFrustums()
Gets the FrustumList containing all the current Pick Frustums

Specified by:
getPickFrustums in interface DrawContext
Returns:
FrustumList of Pick Frustums

getPickPoint

public java.awt.Point getPickPoint()
Specified by:
getPickPoint in interface DrawContext

getPickPointFrustumDimension

public java.awt.Dimension getPickPointFrustumDimension()
Gets the dimension of the current Pick Point Frustum

Specified by:
getPickPointFrustumDimension in interface DrawContext
Returns:
the dimension of the current Pick Point Frustum

getPointOnGlobe

public Vec4 getPointOnGlobe(Angle latitude,
                            Angle longitude)
Specified by:
getPointOnGlobe in interface DrawContext

getRedrawRequested

public int getRedrawRequested()
Specified by:
getRedrawRequested in interface DrawContext

getScreenCredits

public java.util.Map<ScreenCredit,java.lang.Long> getScreenCredits()
Specified by:
getScreenCredits in interface DrawContext

getScreenPoint

public Vec4 getScreenPoint(Angle latitude,
                           Angle longitude,
                           double metersElevation)
Specified by:
getScreenPoint in interface DrawContext

getScreenPoint

public Vec4 getScreenPoint(Position position)
Specified by:
getScreenPoint in interface DrawContext

getScreenPoint

public Vec4 getScreenPoint(Vec4 modelPoint)
Specified by:
getScreenPoint in interface DrawContext

getSurfaceGeometry

public SectorGeometryList getSurfaceGeometry()
Description copied from interface: DrawContext
Retrieves a list of all the sectors rendered so far this frame.

Specified by:
getSurfaceGeometry in interface DrawContext
Returns:
a SectorGeometryList containing every SectorGeometry rendered so far this render pass.

getTextRendererCache

public TextRendererCache getTextRendererCache()
Specified by:
getTextRendererCache in interface DrawContext

getTextureCache

public TextureCache getTextureCache()
Specified by:
getTextureCache in interface DrawContext

getUniquePickColor

public java.awt.Color getUniquePickColor()
Description copied from interface: DrawContext
Returns a unique color to serve as a pick identifier during picking.

Specified by:
getUniquePickColor in interface DrawContext
Returns:
a unique pick color

getVerticalExaggeration

public final double getVerticalExaggeration()
Description copied from interface: DrawContext
Retrieves the current vertical exaggeration. Vertical exaggeration affects the appearance of areas with varied elevation. A vertical exaggeration of zero creates a surface which exactly fits the shape of the underlying Globe. A vertical exaggeration of 3 will create mountains and valleys which are three times as high/deep as they really are.

Specified by:
getVerticalExaggeration in interface DrawContext
Returns:
the current vertical exaggeration

getView

public final View getView()
Description copied from interface: DrawContext
Retrieves the current View, which may be null.

Specified by:
getView in interface DrawContext
Returns:
the current View, which may be null

getViewportCenterPosition

public Position getViewportCenterPosition()
Specified by:
getViewportCenterPosition in interface DrawContext

getViewportCenterScreenPoint

public java.awt.Point getViewportCenterScreenPoint()
Specified by:
getViewportCenterScreenPoint in interface DrawContext

getVisibleSector

public final Sector getVisibleSector()
Description copied from interface: DrawContext
Retrieves a Sector which is at least as large as the current visible sector. The value returned is the value passed to SetVisibleSector. This method may return null.

Specified by:
getVisibleSector in interface DrawContext
Returns:
a Sector at least the size of the curernt visible sector, null if unavailable

getVisibleSectors

public java.util.List<Sector> getVisibleSectors(double[] resolutions,
                                                long timeLimit,
                                                Sector sector)
Description copied from interface: DrawContext
Returns the visible sectors at one of several specified resolutions within a specfied search sector. Several sectors resolutions may be specified along with a time limit. The best resolution that can be determined within the time limit is returned.

Adherence to the time limit is not precise. The limit is checked only between full searches at each resolution. The search may take more than the specified time, but will terminate if no time is left before starting a higher-resolution search.

Specified by:
getVisibleSectors in interface DrawContext
Parameters:
resolutions - the resolutions of the sectors to return, in latitude.
timeLimit - the amount of time, in milliseconds, to allow for searching.
sector - the sector to decompose into visible sectors.
Returns:
the visible sectors at the best resolution achievable given the time limit. The actual resolution can be determined by examining the delta-latitude value of any of the returnced sectors.

initialize

public final void initialize(javax.media.opengl.GLContext glContext)
Description copied from interface: DrawContext
Initializes this DrawContext. This method should be called at the beginning of each frame to prepare the DrawContext for the coming render pass.

Specified by:
initialize in interface DrawContext
Parameters:
glContext - the javax.media.opengl.GLContext to use for this render pass

isPickingMode

public boolean isPickingMode()
Returns true if the Picking mode is active, otherwise return false

Specified by:
isPickingMode in interface DrawContext
Returns:
true for Picking mode, otherwise false

setAnnotationRenderer

public void setAnnotationRenderer(AnnotationRenderer ar)
Description copied from interface: DrawContext
Since Annotations are Renderables, they can be exist outside an AnnotationLayer, in which case they are responsible for rendering themselves. The draw context's annotation renderer provides an active renderer for that purpose.

Specified by:
setAnnotationRenderer in interface DrawContext
Parameters:
ar - the new annotation renderer for the draw context.

setCurrentLayer

public void setCurrentLayer(Layer layer)
Description copied from interface: DrawContext
Sets the current-layer field to the specified layer or null. The field is informative only and enables layer contents to determine their containing layer.

Specified by:
setCurrentLayer in interface DrawContext
Parameters:
layer - the current layer or null.

setFrameTimeStamp

public void setFrameTimeStamp(long frameTimeStamp)
Specified by:
setFrameTimeStamp in interface DrawContext

setGLContext

public final void setGLContext(javax.media.opengl.GLContext glContext)
Description copied from interface: DrawContext
Assigns this DrawContext a new javax.media.opengl.GLContext. May throw a NullPointerException if glContext is null.

Specified by:
setGLContext in interface DrawContext
Parameters:
glContext - the new javax.media.opengl.GLContext

setGLRuntimeCapabilities

public void setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities)
Description copied from interface: DrawContext
Sets the GLRuntimeCapabilities associated with this DrawContext to the specified parameter.

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

setModel

public final void setModel(Model model)
Description copied from interface: DrawContext
Assign a new Model. Some layers cannot function properly with a null Model. It is recommended that the Model is never set to null during a normal render pass.

Specified by:
setModel in interface DrawContext
Parameters:
model - the new Model

setPerFrameStatistic

public void setPerFrameStatistic(java.lang.String key,
                                 java.lang.String displayName,
                                 java.lang.Object value)
Specified by:
setPerFrameStatistic in interface DrawContext

setPerFrameStatistics

public void setPerFrameStatistics(java.util.Collection<PerformanceStatistic> stats)
Specified by:
setPerFrameStatistics in interface DrawContext

setPerFrameStatisticsKeys

public void setPerFrameStatisticsKeys(java.util.Set<java.lang.String> statKeys,
                                      java.util.Collection<PerformanceStatistic> stats)
Specified by:
setPerFrameStatisticsKeys in interface DrawContext

setPickPoint

public void setPickPoint(java.awt.Point pickPoint)
Specified by:
setPickPoint in interface DrawContext

setPickPointFrustumDimension

public void setPickPointFrustumDimension(java.awt.Dimension dim)
Set the size (in pixels) of the pick point frustum at the near plane.

Specified by:
setPickPointFrustumDimension in interface DrawContext
Parameters:
dim - dimension of pick point frustum

setRedrawRequested

public void setRedrawRequested(int redrawRequested)
Specified by:
setRedrawRequested in interface DrawContext

setSurfaceGeometry

public void setSurfaceGeometry(SectorGeometryList surfaceGeometry)
Specified by:
setSurfaceGeometry in interface DrawContext

setTextRendererCache

public void setTextRendererCache(TextRendererCache textRendererCache)
Specified by:
setTextRendererCache in interface DrawContext

setTextureCache

public void setTextureCache(TextureCache textureCache)
Specified by:
setTextureCache in interface DrawContext

setVerticalExaggeration

public final void setVerticalExaggeration(double verticalExaggeration)
Description copied from interface: DrawContext
Sets the vertical exaggeration. Vertical exaggeration affects the appearance of areas with varied elevation. A vertical exaggeration of zero creates a surface which exactly fits the shape of the underlying Globe. A vertical exaggeration of 3 will create mountains and valleys which are three times as high/deep as they really are.

Specified by:
setVerticalExaggeration in interface DrawContext
Parameters:
verticalExaggeration - the new vertical exaggeration.

setView

public final void setView(View view)
Description copied from interface: DrawContext
Assigns a new View. Some layers cannot function properly with a null View. It is recommended that the View is never set to null during a normal render pass.

Specified by:
setView in interface DrawContext
Parameters:
view - the enw View

setViewportCenterPosition

public void setViewportCenterPosition(Position viewportCenterPosition)
Specified by:
setViewportCenterPosition in interface DrawContext

setViewportCenterScreenPoint

public void setViewportCenterScreenPoint(java.awt.Point viewportCenterScreenPoint)
Specified by:
setViewportCenterScreenPoint in interface DrawContext

setVisibleSector

public final void setVisibleSector(Sector s)
Description copied from interface: DrawContext
Sets the visible Sector. The new visible sector must completely encompass the Sector which is visible on the display.

Specified by:
setVisibleSector in interface DrawContext
Parameters:
s - the new visible Sector

NASA World Wind