NASA World Wind

gov.nasa.worldwind
Class WorldWindowGLAutoDrawable

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.WorldWindowImpl
              extended by gov.nasa.worldwind.WorldWindowGLAutoDrawable
All Implemented Interfaces:
AVList, MessageListener, WorldWindow, WorldWindowGLDrawable, WWObject, PropertyChangeListener, EventListener, GLEventListener
Direct Known Subclasses:
ConfiguringGLRuntimeCapabilities.MyGLAutoDrawable

public class WorldWindowGLAutoDrawable
extends WorldWindowImpl
implements WorldWindowGLDrawable, GLEventListener

A non-platform specific WorldWindow class. This class can be aggregated into platform-specific classes to provide the core functionality of World Wind.


Field Summary
static long DEFAULT_VIEW_STOP_TIME
          Default time in milliseconds that the view must remain unchanged before the View.VIEW_STOPPED message is sent.
protected  long lastViewID
          The most recent View modelView ID.
protected  ScheduledFuture viewRefreshTask
          Schedule task to send the View.VIEW_STOPPED message after the view stop time elapses.
protected  long viewStopTime
          Time in milliseconds that the view must remain unchanged before the View.VIEW_STOPPED message is sent.
 
Fields inherited from class gov.nasa.worldwind.WorldWindowImpl
gpuResourceCache
 
Constructor Summary
WorldWindowGLAutoDrawable()
          Construct a new WorldWindowGLCanvas for a specified GLDrawable.
 
Method Summary
protected  void checkForViewChange()
          Determine if the view has changed since the previous frame.
 void display(GLAutoDrawable glAutoDrawable)
          See GLEventListener.display(GLAutoDrawable).
 void dispose(GLAutoDrawable glAutoDrawable)
          See GLEventListener.init(GLAutoDrawable).
protected  int doDisplay()
          Performs the actual repaint.
protected  void doShutdown()
           
protected  void doSwapBuffers(GLAutoDrawable drawable)
          Performs the actual buffer swap.
 void endInitialization()
           
 GLContext getContext()
          Returns the GLContext associated with this WorldWindow.
protected  String[] getRequiredOglExtensions()
           
protected  String[] getRequiredOglFunctions()
           
 long getViewStopTime()
          Indicates the amount of time, in milliseconds, that the View must remain unchanged before a View.VIEW_STOPPED event is triggered.
 void init(GLAutoDrawable glAutoDrawable)
          See GLEventListener.init(GLAutoDrawable).
 void initDrawable(GLAutoDrawable glAutoDrawable)
           
 void initGpuResourceCache(GpuResourceCache cache)
           
protected  void initializeCreditsController()
           
protected  boolean isGLContextCompatible(GLContext context)
           
 void onMessage(Message msg)
          Empty implementation of MessageListener.
 void propertyChange(PropertyChangeEvent propertyChangeEvent)
          The property change listener for this instance.
 void redraw()
          Causes a repaint event to be enqueued with the window system for this world window.
 void redrawNow()
          Immediately repaints the world window without waiting for a window system repaint event.
protected  void reinitialize(GLAutoDrawable glAutoDrawable)
           
 void reshape(GLAutoDrawable glAutoDrawable, int x, int y, int w, int h)
          See GLEventListener.reshape(GLAutoDrawable, int, int, int, int).
protected  void scheduleViewStopTask(long delay)
          Schedule a task that will send a View.VIEW_STOPPED message to the Model when the task executes.
 void setViewStopTime(long time)
          Specifies the amount of time, in milliseconds, that the View must remain unchanged before a View.VIEW_STOPPED event is triggered.
 void shutdown()
          Causes resources used by the World Window to be freed.
 
Methods inherited from class gov.nasa.worldwind.WorldWindowImpl
addPositionListener, addRenderingExceptionListener, addRenderingListener, addSelectListener, callPositionListeners, callRenderingExceptionListeners, callRenderingListeners, callSelectListeners, createGpuResourceCache, getCurrentBoxSelection, getCurrentPosition, getCurrentSelection, getGpuResourceCache, getInputHandler, getModel, getObjectsAtCurrentPosition, getObjectsInSelectionBox, getPerFrameStatistics, getSceneController, getView, removePositionListener, removeRenderingExceptionListener, removeRenderingListener, removeSelectListener, setGpuResourceCache, setInputHandler, setModel, setModelAndView, setPerFrameStatisticsKeys, setSceneController, setView
 
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.WorldWindow
addPositionListener, addRenderingExceptionListener, addRenderingListener, addSelectListener, getCurrentPosition, getGpuResourceCache, getInputHandler, getModel, getObjectsAtCurrentPosition, getObjectsInSelectionBox, getPerFrameStatistics, getSceneController, getView, removePositionListener, removeRenderingExceptionListener, removeRenderingListener, removeSelectListener, setInputHandler, setModel, setModelAndView, setPerFrameStatisticsKeys, setSceneController, setView
 
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
 

Field Detail

DEFAULT_VIEW_STOP_TIME

public static final long DEFAULT_VIEW_STOP_TIME
Default time in milliseconds that the view must remain unchanged before the View.VIEW_STOPPED message is sent.

See Also:
Constant Field Values

lastViewID

protected long lastViewID
The most recent View modelView ID.

See Also:
View.getViewStateID()

viewRefreshTask

protected ScheduledFuture viewRefreshTask
Schedule task to send the View.VIEW_STOPPED message after the view stop time elapses.


viewStopTime

protected long viewStopTime
Time in milliseconds that the view must remain unchanged before the View.VIEW_STOPPED message is sent.

Constructor Detail

WorldWindowGLAutoDrawable

public WorldWindowGLAutoDrawable()
Construct a new WorldWindowGLCanvas for a specified GLDrawable.

Method Detail

checkForViewChange

protected void checkForViewChange()
Determine if the view has changed since the previous frame. If the view has changed, schedule a task that will send a View.VIEW_STOPPED to the Model if the view does not change for viewStopTime milliseconds.

See Also:
getViewStopTime()

display

public void display(GLAutoDrawable glAutoDrawable)
See GLEventListener.display(GLAutoDrawable).

Specified by:
display in interface GLEventListener
Parameters:
glAutoDrawable - the drawable
Throws:
IllegalStateException - if no SceneController exists for this canvas

dispose

public void dispose(GLAutoDrawable glAutoDrawable)
See GLEventListener.init(GLAutoDrawable).

GLEventListener's dispose method indicates that the GL context has been released, and provides the listener an opportunity to clean up any resources. Dispose does not imply that the component's lifecycle has ended or that the application is closing. There are three cases in which dispose may be called:

This implementation is left empty. In the case when a WorldWindow or a World Wind application has reached its end of life, its resources should be released by calling WorldWindow.shutdown() or WorldWind.shutDown(), respectively. In the case when a WorldWindow is removed from its parent frame or that frame is closed without a call to shutdown, it is assumed that the application intends to reuse the WorldWindow. Resources associated with the previous GL context are released in the subsequent call to init.

Specified by:
dispose in interface GLEventListener
Parameters:
glAutoDrawable - the drawable

doDisplay

protected int doDisplay()
Performs the actual repaint. Provided so that subclasses may override the repaint steps.

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

doShutdown

protected void doShutdown()

doSwapBuffers

protected void doSwapBuffers(GLAutoDrawable drawable)
Performs the actual buffer swap. Provided so that subclasses may override the swap steps.

Parameters:
drawable - the window's associated drawable.

endInitialization

public void endInitialization()
Specified by:
endInitialization in interface WorldWindowGLDrawable

getContext

public GLContext getContext()
Description copied from interface: WorldWindow
Returns the GLContext associated with this WorldWindow.

Specified by:
getContext in interface WorldWindow
Returns:
the GLContext associated with this window. May be null.

getRequiredOglExtensions

protected String[] getRequiredOglExtensions()

getRequiredOglFunctions

protected String[] getRequiredOglFunctions()

getViewStopTime

public long getViewStopTime()
Indicates the amount of time, in milliseconds, that the View must remain unchanged before a View.VIEW_STOPPED event is triggered.

Returns:
Time in milliseconds that the View must must remain unchanged before the view stopped event is triggered.

init

public void init(GLAutoDrawable glAutoDrawable)
See GLEventListener.init(GLAutoDrawable).

Specified by:
init in interface GLEventListener
Parameters:
glAutoDrawable - the drawable

initDrawable

public void initDrawable(GLAutoDrawable glAutoDrawable)
Specified by:
initDrawable in interface WorldWindowGLDrawable

initGpuResourceCache

public void initGpuResourceCache(GpuResourceCache cache)
Specified by:
initGpuResourceCache in interface WorldWindowGLDrawable

initializeCreditsController

protected void initializeCreditsController()

isGLContextCompatible

protected boolean isGLContextCompatible(GLContext context)

onMessage

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

Forward the message event to the Model for distribution to the layers.

Specified by:
onMessage in interface MessageListener
Overrides:
onMessage in class WWObjectImpl
Parameters:
msg - Message event.

propertyChange

public void propertyChange(PropertyChangeEvent propertyChangeEvent)
Description copied from class: WWObjectImpl
The property change listener for this instance. Receives property change notifications that this instance has registered with other property change notifiers.

Specified by:
propertyChange in interface PropertyChangeListener
Overrides:
propertyChange in class WWObjectImpl
Parameters:
propertyChangeEvent - the event

redraw

public void redraw()
Description copied from interface: WorldWindow
Causes a repaint event to be enqueued with the window system for this world window. The repaint will occur at the window system's discretion, within the window system toolkit's event loop, and on the thread of that loop. This is the preferred method for requesting a repaint of the world window.

Specified by:
redraw in interface WorldWindow
Overrides:
redraw in class WorldWindowImpl

redrawNow

public void redrawNow()
Description copied from interface: WorldWindow
Immediately repaints the world window without waiting for a window system repaint event. This is not the preferred way to cause a repaint, but is provided for the rare cases that require it.

Specified by:
redrawNow in interface WorldWindow
Overrides:
redrawNow in class WorldWindowImpl

reinitialize

protected void reinitialize(GLAutoDrawable glAutoDrawable)

reshape

public void reshape(GLAutoDrawable glAutoDrawable,
                    int x,
                    int y,
                    int w,
                    int h)
See GLEventListener.reshape(GLAutoDrawable, int, int, int, int).

Specified by:
reshape in interface GLEventListener
Parameters:
glAutoDrawable - the drawable

scheduleViewStopTask

protected void scheduleViewStopTask(long delay)
Schedule a task that will send a View.VIEW_STOPPED message to the Model when the task executes. If the task runs (is not cancelled), then the view is considered stopped. Only one view stop task is scheduled at a time. If this method is called again before the task executes, the task will be cancelled and a new task scheduled.

Parameters:
delay - Delay in milliseconds until the task runs.

setViewStopTime

public void setViewStopTime(long time)
Specifies the amount of time, in milliseconds, that the View must remain unchanged before a View.VIEW_STOPPED event is triggered.

Parameters:
time - Time in milliseconds that the View must must remain unchanged before the view stopped event is triggered.

shutdown

public void shutdown()
Description copied from class: WorldWindowImpl
Causes resources used by the World Window to be freed. The World Window cannot be used once this method is called. An OpenGL context for the window must be current.

Specified by:
shutdown in interface WorldWindow
Overrides:
shutdown in class WorldWindowImpl

NASA World Wind