NASA World Wind

gov.nasa.worldwindx.examples.util
Class HotSpotController

java.lang.Object
  extended by gov.nasa.worldwindx.examples.util.HotSpotController
All Implemented Interfaces:
SelectListener, MouseMotionListener, EventListener

public class HotSpotController
extends Object
implements SelectListener, MouseMotionListener

Controller to forward selection, keyboard, and mouse events on the World Window to the active HotSpot. The active HotSpot is updated on SelectEvent.ROLLOVER select events, but not during a drag operation. This ensures that the active HotSpot remains active while it's being dragged, regardless of what's under the cursor.

The active HotSpot is updated during non-drag rollover select events as follows:


Field Summary
protected  HotSpot activeHotSpot
           
protected  boolean customCursor
          Indicates that the active HotSpot has set a custom cursor that must be reset when the HotSpot is deactivated.
protected  boolean dragging
           
protected  WorldWindow wwd
           
 
Constructor Summary
HotSpotController(WorldWindow wwd)
          Creates a new HotSpotController for a specified World Window, and assigns the controller as a SelectListener on the World Window.
 
Method Summary
protected  void doSelected(SelectEvent event)
          Updates the active HotSpot depending on the specified select event action: SelectEvent.DRAG_END - Forwards the event to the active HotSpot, then updates the active HotSpot. SelectEvent.ROLLOVER while not dragging - Updates the active HotSpot, then forwards the event to the active HotSpot. Other event types - forwards the event to the active HotSpot
protected  HotSpot getActiveHotSpot()
          Returns the currently active HotSpot, or null if there is no active HotSpot.
protected  boolean isDragging()
          Returns whether the user is dragging the object under the cursor.
 void mouseDragged(MouseEvent e)
          
 void mouseMoved(MouseEvent e)
          Update the cursor when the mouse moves.
 void selected(SelectEvent event)
          Updates the active HotSpot if necessary, and forwards the select event to the active HotSpot.
protected  void setActiveHotSpot(HotSpot hotSpot)
          Sets the active HotSpot to the specified HotSpot.
protected  void setDragging(boolean dragging)
          Specifies whether the user is dragging the object under the cursor.
protected  void updateActiveHotSpot(PickedObject po)
          Updates the active HotSpot and the currently displayed cursor according to the picked objects in the specified event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activeHotSpot

protected HotSpot activeHotSpot

customCursor

protected boolean customCursor
Indicates that the active HotSpot has set a custom cursor that must be reset when the HotSpot is deactivated.


dragging

protected boolean dragging

wwd

protected WorldWindow wwd
Constructor Detail

HotSpotController

public HotSpotController(WorldWindow wwd)
Creates a new HotSpotController for a specified World Window, and assigns the controller as a SelectListener on the World Window.

Parameters:
wwd - The World Window to monitor selection events for.
Method Detail

doSelected

protected void doSelected(SelectEvent event)
Updates the active HotSpot depending on the specified select event action:

Parameters:
event - A select event on the World Window we're monitoring.

getActiveHotSpot

protected HotSpot getActiveHotSpot()
Returns the currently active HotSpot, or null if there is no active HotSpot.

Returns:
The currently active HotSpot, or null.

isDragging

protected boolean isDragging()
Returns whether the user is dragging the object under the cursor.

Returns:
true if the user is dragging the object under the cursor, otherwise false.

mouseDragged

public void mouseDragged(MouseEvent e)

Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent e)
Update the cursor when the mouse moves.

Specified by:
mouseMoved in interface MouseMotionListener
Parameters:
e - Mouse event.

selected

public void selected(SelectEvent event)
Updates the active HotSpot if necessary, and forwards the select event to the active HotSpot. This does nothing if the select event is null.

This forwards the select event to doSelected(gov.nasa.worldwind.event.SelectEvent), and catches and logs any exceptions thrown by doSelected.

Specified by:
selected in interface SelectListener
Parameters:
event - A select event on the World Window we're monitoring.

setActiveHotSpot

protected void setActiveHotSpot(HotSpot hotSpot)
Sets the active HotSpot to the specified HotSpot. The HotSpot may be null, indicating that there is no active HotSpot. This registers the new HotSpot as key listener, mouse listener, mouse motion listener, and mouse wheel listener on the World Window's InputHandler. This removes the previously active HotSpot as a listener on the World Window's InputHandler. This does nothing if the active HotSpot and the specified HotSpot are the same object.

Additionally, this updates the World Window's Cursor to the value returned by hotSpot.getCursor(), or null if the specified hotSpot is null.

Parameters:
hotSpot - The HotSpot that becomes the active HotSpot. null to indicate that there is no active HotSpot.

setDragging

protected void setDragging(boolean dragging)
Specifies whether the user is dragging the object under the cursor.

Parameters:
dragging - true if the user is dragging the object under the cursor, otherwise false.

updateActiveHotSpot

protected void updateActiveHotSpot(PickedObject po)
Updates the active HotSpot and the currently displayed cursor according to the picked objects in the specified event. The active HotSpot is assigned as follows:

Parameters:
po - Top picked object, which will provide the active HotSpot.

NASA World Wind