public class ScreenSelector extends WWObjectImpl implements MouseListener, MouseMotionListener, SelectListener
getSelectedObjects().
enable() and the
ScreenSelector then translates mouse events to changes in the selection rectangle. The selection rectangle is
displayed as a filled rectangle with a 1-pixel wide border drawn in the interiorColor and borderColor. The
ScreenSelector consumes mouse events it responds in order to suppress navigation events while the user is performing
a selection. When the user selection is complete, call disable() and the ScreenSelector stops responding to
mouse events.
While the ScreenSelector is enabled it keeps track of the objects intersecting the selection rectangle, which can be
accessed by calling getSelectedObjects. When the list of selected objects changes, SceneSelector sends
SELECTION_STARTED, SELECTION_CHANGED, and SELECTION_ENDED messages to its message listeners. These three messages
correspond to the user starting a selection, changing what's in the selection, and completing the selection. To
receive a notification when the list of selected objects changes, register a MessageListener with the SceneSelector
by calling addMessageListener(gov.nasa.worldwind.event.MessageListener).
Note that enabling or disabling the ScreenSelector does not change its list of selected objects. The list of selected
objects only changes in response to user input when the ScreenSelector is enabled.
setInteriorColor(java.awt.Color) and setBorderColor(java.awt.Color) to specify the rectangle's interior
and border colors, respectively. Setting either value to null causes ScreenRectangle to use the default
values: 25% opaque white interior, 100% opaque white border.
To further customize the displayed rectangle, create a subclass of ScreenSelector, override the method
createSelectionRectangle, and return a subclass of the internal class ScreenSelector.SelectionRectangle.| Modifier and Type | Class and Description |
|---|---|
protected static class |
ScreenSelector.SelectionRectangle |
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
armed |
protected Layer |
layer |
protected List<MessageListener> |
messageListeners |
protected List<Object> |
selectedObjects |
static String |
SELECTION_CHANGED
Message type indicating that the list of selected objects has changed.
|
static String |
SELECTION_ENDED
Message type indicating that the user has completed their selection.
|
static String |
SELECTION_STARTED
Message type indicating that the user has started their selection.
|
protected ScreenSelector.SelectionRectangle |
selectionRect |
protected WorldWindow |
wwd |
| Constructor and Description |
|---|
ScreenSelector(WorldWindow worldWindow) |
onMessage, propertyChangeaddPropertyChangeListener, 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, setValuesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValuesprotected boolean armed
protected Layer layer
protected List<MessageListener> messageListeners
public static final String SELECTION_CHANGED
public static final String SELECTION_ENDED
public static final String SELECTION_STARTED
protected ScreenSelector.SelectionRectangle selectionRect
protected WorldWindow wwd
public ScreenSelector(WorldWindow worldWindow)
public void addMessageListener(MessageListener listener)
protected Layer createLayer()
protected ScreenSelector.SelectionRectangle createSelectionRectangle()
public void disable()
public void enable()
public Color getBorderColor()
public Color getInteriorColor()
public Layer getLayer()
public List<?> getSelectedObjects()
public WorldWindow getWwd()
protected Point limitPointToWorldWindow(Point point)
point - the point to limit.public void mouseClicked(MouseEvent mouseEvent)
mouseClicked in interface MouseListenerpublic void mouseDragged(MouseEvent mouseEvent)
mouseDragged in interface MouseMotionListenerpublic void mouseEntered(MouseEvent mouseEvent)
mouseEntered in interface MouseListenerpublic void mouseExited(MouseEvent mouseEvent)
mouseExited in interface MouseListenerpublic void mouseMoved(MouseEvent mouseEvent)
mouseMoved in interface MouseMotionListenerpublic void mousePressed(MouseEvent mouseEvent)
mousePressed in interface MouseListenerpublic void mouseReleased(MouseEvent mouseEvent)
mouseReleased in interface MouseListenerpublic void removeMessageListener(MessageListener listener)
public void selected(SelectEvent event)
selected in interface SelectListenerprotected void selectionChanged(MouseEvent mouseEvent)
protected void selectionEnded(MouseEvent mouseEvent)
protected void selectionStarted(MouseEvent mouseEvent)
protected void selectObjects(List<?> list)
protected void sendMessage(Message message)
public void setBorderColor(Color color)
public void setInteriorColor(Color color)