public class WorldWindowGLJPanel extends GLJPanel implements WorldWindow, PropertyChangeListener
WorldWindowGLCanvas
is a lightweight Swing 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.
Note: The Java SDK for OpenGL (JOGL) support for the underlying GLJPanel
that this class uses has
historically been problematic. It works well on some devices but not on others, and its performance varies much more
among devices than that of its heavyweight counterpart, WorldWindowGLCanvas
. It's therefore best to use the
heavyweight component if possible. You can find detailed information on this issue in the Heavyweight and
Lightweight Issues section of the "JOGL User's
Guide"
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)
.JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
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. |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
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 |
---|
WorldWindowGLJPanel()
Constructs a new
WorldWindowGLCanvas window on the default graphics device. |
WorldWindowGLJPanel(WorldWindow shareWith)
Constructs a new
WorldWindowGLJPanel on the default graphics device and shares graphics resources
with another WorldWindow . |
WorldWindowGLJPanel(WorldWindow shareWith,
GLCapabilities capabilities,
GLCapabilitiesChooser chooser)
Constructs a new
WorldWindowGLJPanel that shares graphics resources with another
WorldWindow and whose capabilities are chosen via a specified GLCapabilities object and a
GLCapabilitiesChooser . |
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, display, dispose, disposeGLEventListener, getAnimator, getAutoSwapBufferMode, getChosenGLCapabilities, getContext, getContextCreationFlags, getCustomPixelBufferProvider, getDefaultCloseOperation, getDelegatedDrawable, getExclusiveContextThread, getFactory, getGL, getGLEventListener, getGLEventListenerCount, getGLEventListenerInitState, getGLProfile, getHandle, getNativeSurface, getSkipGLOrientationVerticalFlip, getTextureUnit, getThreadName, getUpstreamWidget, initializeBackend, invoke, invoke, isGLOriented, isRealized, paintComponent, print, printComponent, releasePrint, removeGLEventListener, removeNotify, reshape, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setDefaultCloseOperation, setExclusiveContextThread, setGL, setGLEventListenerInitState, setOpaque, setPixelBufferProvider, setRealized, setSharedAutoDrawable, setSharedContext, setSkipGLOrientationVerticalFlip, setTextureUnit, setupPrint, shouldPreserveColorBufferIfTranslucent, swapBuffers, toString
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, printAll, printBorder, printChildren, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
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 WorldWindowGLJPanel()
WorldWindowGLCanvas
window on the default graphics device.public WorldWindowGLJPanel(WorldWindow shareWith)
WorldWindowGLJPanel
on the default graphics device and shares graphics resources
with another WorldWindow
.shareWith
- a WorldWindow
with which to share graphics resources.GLJPanel.GLJPanel(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser,
javax.media.opengl.GLContext)
public WorldWindowGLJPanel(WorldWindow shareWith, GLCapabilities capabilities, GLCapabilitiesChooser chooser)
WorldWindowGLJPanel
that shares graphics resources with another
WorldWindow
and whose capabilities are chosen via a specified GLCapabilities
object and a
GLCapabilitiesChooser
.shareWith
- a WorldWindow
with which to share graphics resources.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.GLJPanel.GLJPanel(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser,
javax.media.opengl.GLContext)
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 Container
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 Container
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