public class WorldWindowGLCanvas extends GLCanvas implements WorldWindow, PropertyChangeListener
WorldWindowGLCanvas
is a heavyweight AWT component for displaying World Wind Model
s (globe and
layers). It's a self-contained component intended to serve as an application's WorldWindow
. Construction
options exist to specify a specific graphics device and to share graphics resources with another graphics device.
Heavyweight AWT components such as instances of this class can be used in conjunction with lightweight Swing
components. A discussion of doing so is in the Heavyweight and Lightweight Issues section of the "JOGL User's Guide". All that's typically necessary is
to invoke the following methods of the indicated Swing classes: ToolTipManager.setLightWeightPopupEnabled(boolean)
,
JPopupMenu.setLightWeightPopupEnabled(boolean)
and JPopupMenu.setLightWeightPopupEnabled(boolean)
.
These methods should be invoked within a static
block within an application's main class.
This class is capable of supporting stereo devices. To cause a stereo device to be selected and used, specify the
Java VM property "gov.nasa.worldwind.stereo.mode=device" prior to creating an instance of this class. A stereo
capable SceneController
such as StereoSceneController
must also be specified in
the World Wind Configuration
. The default configuration specifies a stereo-capable controller. To prevent
stereo from being used by subsequently opened WorldWindowGLCanvas
es, set the property to a an empty string,
"". If a stereo device cannot be selected and used, this falls back to a non-stereo device that supports World Wind's
minimum requirements.
Under certain conditions, JOGL replaces the GLContext
associated with instances of this class. This then
necessitates that all resources such as textures that have been stored on the graphic devices must be regenerated for
the new context. World Wind does this automatically by clearing the associated GpuResourceCache
. Objects
subsequently rendered automatically re-create those resources. If an application creates its own graphics resources,
including textures, vertex buffer objects and display lists, it must store them in the GpuResourceCache
associated with the current DrawContext
so that they are automatically cleared, and
be prepared to re-create them if they do not exist in the DrawContext
's current
GpuResourceCache
when needed. Examples of doing this can be found by searching for usages of the method
GpuResourceCache.get(Object)
and GpuResourceCache.getTexture(Object)
.Canvas.AccessibleAWTCanvas
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
WindowClosingProtocol.WindowClosingMode
AWTPrintLifecycle.Context
Modifier and Type | Field and Description |
---|---|
protected WorldWindowGLDrawable |
wwd
The drawable to which
WorldWindow methods are delegated. |
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
DEFAULT_PRINT_TILE_SIZE
SCREEN_CHANGE_ACTION_ENABLED
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
WorldWindowGLCanvas()
Constructs a new
WorldWindowGLCanvas on the default graphics device. |
WorldWindowGLCanvas(WorldWindow shareWith)
Constructs a new
WorldWindowGLCanvas on the default graphics device and shares graphics resources
with another WorldWindow . |
WorldWindowGLCanvas(WorldWindow shareWith,
GraphicsDevice device)
Constructs a new
WorldWindowGLCanvas on a specified graphics device and shares graphics resources
with another WorldWindow . |
WorldWindowGLCanvas(WorldWindow shareWith,
GraphicsDevice device,
GLCapabilities capabilities,
GLCapabilitiesChooser chooser)
Constructs a new
WorldWindowGLCanvas on a specified device with the specified capabilities and
shares graphics resources with another WorldWindow . |
Modifier and Type | Method and Description |
---|---|
void |
addPositionListener(PositionListener listener)
Adds a position listener to this world window.
|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds the specified all-property property change listener that will be called for all list changes.
|
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Adds a property change listener for the specified key.
|
void |
addRenderingExceptionListener(RenderingExceptionListener listener)
Adds an exception listener to this world window.
|
void |
addRenderingListener(RenderingListener listener)
Adds a rendering listener to this world window.
|
void |
addSelectListener(SelectListener listener)
Adds a select listener to this world window.
|
AVList |
clearList() |
AVList |
copy()
Returns a shallow copy of this
AVList instance: the keys and values themselves are not cloned. |
protected void |
createDefaultInputHandler()
Constructs and attaches the
InputHandler for this WorldWindow . |
protected void |
createView()
Constructs and attaches the
View for this WorldWindow . |
void |
firePropertyChange(PropertyChangeEvent propertyChangeEvent)
Calls all registered property change listeners with the specified property change event.
|
void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Calls all property change listeners associated with the specified key.
|
Position |
getCurrentPosition()
Returns the current latitude, longitude and altitude of the current cursor position, or
null if the
cursor is not on the globe. |
Set<Map.Entry<String,Object>> |
getEntries() |
GpuResourceCache |
getGpuResourceCache()
Returns the GPU Resource used by this World Window.
|
InputHandler |
getInputHandler()
Returns the input handler associated with this instance.
|
Model |
getModel()
Returns the window's current model.
|
PickedObjectList |
getObjectsAtCurrentPosition()
Returns the World Wind objects at the current cursor position.
|
PickedObjectList |
getObjectsInSelectionBox()
Returns the World Wind objects intersecting the current selection box.
|
Collection<PerformanceStatistic> |
getPerFrameStatistics()
Returns the active per-frame performance statistics such as number of tiles drawn in the most recent frame.
|
SceneController |
getSceneController()
Returns the scene controller associated with this instance.
|
String |
getStringValue(String key)
Returns the value for a specified key.
|
Object |
getValue(String key)
Returns the value for a specified key.
|
Collection<Object> |
getValues() |
View |
getView()
Returns this window's current view.
|
boolean |
hasKey(String key)
Indicates whether a key is in the collection.
|
boolean |
isEnableGpuCacheReinitialization()
Indicates whether the GPU resource cache is reinitialized when this window is reinitialized.
|
void |
propertyChange(PropertyChangeEvent evt) |
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.
|
Object |
removeKey(String key)
Removes a specified key from the collection if the key exists, otherwise returns without affecting the
collection.
|
void |
removePositionListener(PositionListener listener)
Removes the specified position listener associated with this world window.
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes the specified all-property property change listener.
|
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Removes a property change listener associated with the specified key.
|
void |
removeRenderingExceptionListener(RenderingExceptionListener listener)
Removes the specified rendering exception listener associated with this world window.
|
void |
removeRenderingListener(RenderingListener listener)
Removes a specified rendering listener associated with this world window.
|
void |
removeSelectListener(SelectListener listener)
Removes the specified select listener associated with this world window.
|
void |
setEnableGpuCacheReinitialization(boolean enableGpuCacheReinitialization)
Specifies whether to reinitialize the GPU resource cache when this window is reinitialized.
|
void |
setInputHandler(InputHandler inputHandler)
Sets the input handler to use for this instance.
|
void |
setModel(Model model)
Sets the model to display in this window.
|
void |
setModelAndView(Model model,
View view)
Sets the model to display in this window and the view used to display it.
|
void |
setPerFrameStatisticsKeys(Set<String> keys)
Activates the per-frame performance statistic specified.
|
void |
setSceneController(SceneController sceneController)
Specifies a new scene controller for the window.
|
Object |
setValue(String key,
Object value)
Adds a key/value pair to the list.
|
AVList |
setValues(AVList avList)
Adds the contents of another attribute-value list to the list.
|
void |
setView(View view)
Sets the view to use when displaying this window's model.
|
void |
shutdown()
Causes resources used by the World Window to be freed.
|
addGLEventListener, addGLEventListener, addNotify, areAllGLEventListenerInitialized, createContext, destroy, destroyImpl, display, disposeGLEventListener, getAnimator, getAutoSwapBufferMode, getChosenGLCapabilities, getContext, getContextCreationFlags, getDefaultCloseOperation, getDelegatedDrawable, getExclusiveContextThread, getFactory, getGL, getGLEventListener, getGLEventListenerCount, getGLEventListenerInitState, getGLProfile, getGraphicsConfiguration, getHandle, getNativeSurface, getRequestedGLCapabilities, getShallUseOffscreenLayer, getThreadName, getUpstreamWidget, invoke, invoke, isGLOriented, isOffscreenLayerSurfaceEnabled, isRealized, main, paint, print, releasePrint, removeGLEventListener, removeNotify, reshape, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setDefaultCloseOperation, setExclusiveContextThread, setGL, setGLEventListenerInitState, setRealized, setShallUseOffscreenLayer, setSharedAutoDrawable, setSharedContext, setupPrint, swapBuffers, toString, update
createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getContext
repaint, setSize
addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener
getHeight, getWidth
protected final WorldWindowGLDrawable wwd
WorldWindow
methods are delegated.public WorldWindowGLCanvas()
WorldWindowGLCanvas
on the default graphics device.public WorldWindowGLCanvas(WorldWindow shareWith)
WorldWindowGLCanvas
on the default graphics device and shares graphics resources
with another WorldWindow
.shareWith
- a WorldWindow
with which to share graphics resources.GLCanvas.GLCanvas(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser,
javax.media.opengl.GLContext, java.awt.GraphicsDevice)
public WorldWindowGLCanvas(WorldWindow shareWith, GraphicsDevice device)
WorldWindowGLCanvas
on a specified graphics device and shares graphics resources
with another WorldWindow
.shareWith
- a WorldWindow
with which to share graphics resources.device
- the GraphicsDevice
on which to create the window. May be null, in which case the
default screen device of the local GraphicsEnvironment
is used.GLCanvas.GLCanvas(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser,
javax.media.opengl.GLContext, java.awt.GraphicsDevice)
public WorldWindowGLCanvas(WorldWindow shareWith, GraphicsDevice device, GLCapabilities capabilities, GLCapabilitiesChooser chooser)
WorldWindowGLCanvas
on a specified device with the specified capabilities and
shares graphics resources with another WorldWindow
.shareWith
- a WorldWindow
with which to share graphics resources.device
- the GraphicsDevice
on which to create the window. May be null, in which case the
default screen device of the local GraphicsEnvironment
is used.capabilities
- a capabilities object indicating the OpenGL rendering context's capabilities. May be null, in
which case a default set of capabilities is used.chooser
- a chooser object that customizes the specified capabilities. May be null, in which case a
default chooser is used.GLCanvas.GLCanvas(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser,
javax.media.opengl.GLContext, java.awt.GraphicsDevice)
public void addPositionListener(PositionListener listener)
WorldWindow
addPositionListener
in interface WorldWindow
listener
- The position listener to add.public void addPropertyChangeListener(PropertyChangeListener listener)
AVList
addPropertyChangeListener
in interface AVList
addPropertyChangeListener
in interface ComponentEvents
addPropertyChangeListener
in class Component
listener
- the listener to call.PropertyChangeSupport
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
AVList
addPropertyChangeListener
in interface AVList
addPropertyChangeListener
in interface ComponentEvents
addPropertyChangeListener
in class Component
propertyName
- the key to associate the listener with.listener
- the listener to associate with the key.PropertyChangeSupport
public void addRenderingExceptionListener(RenderingExceptionListener listener)
WorldWindow
addRenderingExceptionListener
in interface WorldWindow
listener
- the The exception listener to add.public void addRenderingListener(RenderingListener listener)
WorldWindow
addRenderingListener
in interface WorldWindow
listener
- The rendering listener to add to those notified of rendering events by this world window.public void addSelectListener(SelectListener listener)
WorldWindow
addSelectListener
in interface WorldWindow
listener
- The select listener to add.public AVList copy()
AVList
AVList
instance: the keys and values themselves are not cloned.protected void createDefaultInputHandler()
InputHandler
for this WorldWindow
.protected void createView()
View
for this WorldWindow
.public void firePropertyChange(PropertyChangeEvent propertyChangeEvent)
AVList
firePropertyChange
in interface AVList
propertyChangeEvent
- the eventPropertyChangeSupport
public void firePropertyChange(String propertyName, Object oldValue, Object newValue)
AVList
odValue
and newValue
are equal and non-null.firePropertyChange
in interface AVList
firePropertyChange
in class Component
propertyName
- the keyoldValue
- the value associated with the key before the even causing the firing.newValue
- the new value associated with the key.PropertyChangeSupport
public Position getCurrentPosition()
WorldWindow
null
if the
cursor is not on the globe.getCurrentPosition
in interface WorldWindow
null
if the cursor is not positioned on the globe.public Set<Map.Entry<String,Object>> getEntries()
getEntries
in interface AVList
public GpuResourceCache getGpuResourceCache()
WorldWindow
getGpuResourceCache
in interface WorldWindow
public InputHandler getInputHandler()
WorldWindow
getInputHandler
in interface WorldWindow
null
if no input handler is associated.public Model getModel()
WorldWindow
getModel
in interface WorldWindow
public PickedObjectList getObjectsAtCurrentPosition()
WorldWindow
getObjectsAtCurrentPosition
in interface WorldWindow
null
if no objects are under the cursor.public PickedObjectList getObjectsInSelectionBox()
WorldWindow
getObjectsInSelectionBox
in interface WorldWindow
null
if no objects are in the box.public Collection<PerformanceStatistic> getPerFrameStatistics()
WorldWindow
getPerFrameStatistics
in interface WorldWindow
public SceneController getSceneController()
WorldWindow
getSceneController
in interface WorldWindow
null
if no scene controller is
associated.public String getStringValue(String key)
AVList
String
.getStringValue
in interface AVList
key
- the attribute name. May not be null
.null
.public Object getValue(String key)
AVList
public Collection<Object> getValues()
public View getView()
WorldWindow
getView
in interface WorldWindow
public boolean hasKey(String key)
AVList
public boolean isEnableGpuCacheReinitialization()
WorldWindow
isEnableGpuCacheReinitialization
in interface WorldWindow
true
if reinitialization is enabled, otherwise false
.public void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
public void redraw()
WorldWindow
redraw
in interface WorldWindow
public void redrawNow()
WorldWindow
redrawNow
in interface WorldWindow
public Object removeKey(String key)
AVList
public void removePositionListener(PositionListener listener)
WorldWindow
removePositionListener
in interface WorldWindow
listener
- The listener to remove.public void removePropertyChangeListener(PropertyChangeListener listener)
AVList
removePropertyChangeListener
in interface AVList
removePropertyChangeListener
in interface ComponentEvents
removePropertyChangeListener
in class Component
listener
- the listener to remove.PropertyChangeSupport
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
AVList
removePropertyChangeListener
in interface AVList
removePropertyChangeListener
in interface ComponentEvents
removePropertyChangeListener
in class Component
propertyName
- the key associated with the change listener.listener
- the listener to remove.PropertyChangeSupport
public void removeRenderingExceptionListener(RenderingExceptionListener listener)
WorldWindow
removeRenderingExceptionListener
in interface WorldWindow
listener
- The listener to remove.public void removeRenderingListener(RenderingListener listener)
WorldWindow
removeRenderingListener
in interface WorldWindow
listener
- The rendering listener to remove.public void removeSelectListener(SelectListener listener)
WorldWindow
removeSelectListener
in interface WorldWindow
listener
- The select listener to remove.public void setEnableGpuCacheReinitialization(boolean enableGpuCacheReinitialization)
WorldWindow
true
indicates that the GPU resource cache this window is using should be cleared when its init()
method is called, typically when re-parented. Set this to false
when this window is sharing context
with other windows and is likely to be re-parented. It prevents the flashing caused by clearing and
re-populating the GPU resource cache during re-parenting. The default value is true
.setEnableGpuCacheReinitialization
in interface WorldWindow
enableGpuCacheReinitialization
- true
to enable reinitialization, otherwise false
.public void setInputHandler(InputHandler inputHandler)
WorldWindow
setInputHandler
in interface WorldWindow
inputHandler
- The input handler to use for this world window. May by null
if null
is specified, the current input handler, if any, is disassociated with the world window.public void setModel(Model model)
WorldWindow
null
is specified for the model, the current model, if
any, is disassociated with the window.setModel
in interface WorldWindow
model
- the model to display. May be null
.public void setModelAndView(Model model, View view)
WorldWindow
null
is specified for
the model, the current model, if any, is disassociated with the window. If null
is specified for the
view, the current view, if any, is disassociated with the window.setModelAndView
in interface WorldWindow
model
- the model to display. May benull
.view
- the view to use to display this window's model. May benull
.public void setPerFrameStatisticsKeys(Set<String> keys)
WorldWindow
setPerFrameStatisticsKeys
in interface WorldWindow
keys
- The statistics to activate.public void setSceneController(SceneController sceneController)
WorldWindow
View
, Model
and any desired per-frame statistics keys.setSceneController
in interface WorldWindow
sceneController
- the new scene controller.SceneController.setView(View)
,
SceneController.setModel(Model)
,
SceneController.setPerFrameStatisticsKeys(java.util.Set)
public Object setValue(String key, Object value)
AVList
setValue
in interface AVList
key
- the attribute name. May not be null
.value
- the attribute value. May be null
, in which case any existing value for the key is
removed from the collection.public AVList setValues(AVList avList)
AVList
public void setView(View view)
WorldWindow
null
is specified for the view, the
current view, if any, is disassociated with the window.setView
in interface WorldWindow
view
- the view to use to display this window's model. May be null.public void shutdown()
WorldWindow
shutdown
in interface WorldWindow