WorldWind Java provides a multi-layered event system built on top of AWT’s event model. The most important event type for 3D interaction is theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nasaworldwind/worldwindjava/llms.txt
Use this file to discover all available pages before exploring further.
SelectEvent, which is fired whenever the user clicks on, hovers over, drags, or selects objects rendered on the globe. Additional listener interfaces handle cursor position changes and rendering frame lifecycle events.
WorldWind’s event model is AWT-based and all
SelectEvent callbacks are invoked on the AWT Event Dispatch Thread (EDT). Do not perform long-running operations inside event listeners. When updating non-AWT components from a listener, use SwingUtilities.invokeLater(). Calling wwd.redraw() from within a listener is safe.SelectListener
SelectListener is the primary interface for interacting with objects on the globe. Register a listener with wwd.addSelectListener(SelectListener). The single method selected(SelectEvent event) is called for every relevant user gesture.
SelectEvent Types
SelectEvent carries an eventAction string constant identifying the gesture type:
| Constant | Trigger |
|---|---|
SelectEvent.LEFT_CLICK | User clicked the left mouse button over a renderable |
SelectEvent.LEFT_DOUBLE_CLICK | User double-clicked the left mouse button over a renderable |
SelectEvent.RIGHT_CLICK | User clicked the right mouse button over a renderable |
SelectEvent.LEFT_PRESS | User pressed (but not released) the left mouse button |
SelectEvent.RIGHT_PRESS | User pressed the right mouse button |
SelectEvent.ROLLOVER | Cursor moved over or off a renderable (fired every frame) |
SelectEvent.HOVER | Cursor paused stationary over a renderable |
SelectEvent.DRAG | User is dragging a renderable with the left button held |
SelectEvent.DRAG_END | User released the mouse after a drag |
SelectEvent.BOX_ROLLOVER | A selection rectangle intersects one or more renderables |
SelectEvent methods:
| Method | Returns | Description |
|---|---|---|
getEventAction() | String | The event type constant (use equals(), not ==) |
getTopObject() | Object | The top-most picked renderable, or null |
getTopPickedObject() | PickedObject | The PickedObject wrapper for the top-most renderable |
getObjects() | PickedObjectList | All picked objects at the cursor position |
hasObjects() | boolean | Whether any objects were picked |
getPickPoint() | Point | Cursor position in GL surface coordinates |
getMouseEvent() | MouseEvent | Underlying AWT mouse event, may be null |
consume() | void | Prevents subsequent listeners from processing this event |
SelectListener — registering a basic click handler
Picking Objects
WorldWind performs a color-coded picking pass each frame. Each rendered object is assigned a unique pick color; the framebuffer pixel under the cursor is sampled to identify which object is there. This makes picking resolution-independent and works correctly through transparency. To retrieve the object under the cursor and distinguish it from terrain:PickedObject — inspecting what was picked
Deep Picking
By default WorldWind returns only the top-most object at the cursor position. Deep picking reports all objects at the cursor, including those occluded by others. This is useful for stacked or overlapping renderables such as airspaces, paths, or tactical symbols. Enable deep picking on theSceneController:
DeepPicking.java — enabling deep picking for overlapping objects
Position Listener
PositionListener receives updates whenever the geographic position under the cursor changes. This is used to display coordinates in a status bar.
PositionEvent — tracking cursor lat/lon/alt
PositionEvent fields:
getPosition()— current geographic position under the cursor;nullif off the globegetPreviousPosition()— previous position; allows computing delta movementgetScreenPoint()— AWT screen coordinates of the cursor
StatusBar component in ApplicationTemplate uses a PositionListener to display lat/lon/alt in real time.
Rendering Listener
RenderingListener fires at specific points in the rendering pipeline each frame. Use it for tasks that must be synchronized with rendering, such as reading the framebuffer or updating overlays.
RenderingEvent — hooking into the render pipeline
RenderingEvent stages:
| Constant | When |
|---|---|
RenderingEvent.BEFORE_RENDERING | Start of the frame, before any scene rendering |
RenderingEvent.BEFORE_BUFFER_SWAP | After rendering, before the back-buffer swap |
RenderingEvent.AFTER_BUFFER_SWAP | After the frame is fully displayed |
Dragging Shapes
WorldWind providesBasicDragger (in gov.nasa.worldwind.util) as a ready-made SelectListener that handles dragging any Draggable renderable to a new geographic position. Simply register it with wwd.addSelectListener(new BasicDragger(wwd)).
DraggingShapes.java — enabling drag for all shapes in a layer
SelectEvent.DRAG and SelectEvent.DRAG_END:
SelectListener — custom drag logic
Highlighting
TheHighlightController utility class (in gov.nasa.worldwindx.examples.util) monitors the WorldWindow for ROLLOVER events and automatically calls setHighlighted(true) on any Highlightable renderable under the cursor. ApplicationTemplate creates one by default.
HighlightController — automatic rollover highlighting
Highlightable interface and respond to setHighlighted(boolean) by switching between normal and highlight attribute bundles.
Tool Tips
ToolTipController (in gov.nasa.worldwindx.examples.util) displays a text annotation when the cursor rolls over or hovers over an object that has AVKey.DISPLAY_NAME set. ApplicationTemplate installs one automatically:
ToolTipController — showing display-name tooltips
ToolTipController — configuring rollover and hover keys