public class ScreenSelector extends WWObjectImpl implements java.awt.event.MouseListener, java.awt.event.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 java.util.List<MessageListener> |
messageListeners |
protected java.util.List<java.lang.Object> |
selectedObjects |
static java.lang.String |
SELECTION_CHANGED
Message type indicating that the list of selected objects has changed.
|
static java.lang.String |
SELECTION_ENDED
Message type indicating that the user has completed their selection.
|
static java.lang.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) |
Modifier and Type | Method and Description |
---|---|
void |
addMessageListener(MessageListener listener) |
protected Layer |
createLayer() |
protected ScreenSelector.SelectionRectangle |
createSelectionRectangle() |
void |
disable() |
void |
enable() |
java.awt.Color |
getBorderColor() |
java.awt.Color |
getInteriorColor() |
Layer |
getLayer() |
java.util.List<?> |
getSelectedObjects() |
WorldWindow |
getWwd() |
protected java.awt.Point |
limitPointToWorldWindow(java.awt.Point point)
Limits the specified point's x and y coordinates to the WorldWindow's viewport, and returns a new point with the
limited coordinates.
|
void |
mouseClicked(java.awt.event.MouseEvent mouseEvent) |
void |
mouseDragged(java.awt.event.MouseEvent mouseEvent) |
void |
mouseEntered(java.awt.event.MouseEvent mouseEvent) |
void |
mouseExited(java.awt.event.MouseEvent mouseEvent) |
void |
mouseMoved(java.awt.event.MouseEvent mouseEvent) |
void |
mousePressed(java.awt.event.MouseEvent mouseEvent) |
void |
mouseReleased(java.awt.event.MouseEvent mouseEvent) |
void |
removeMessageListener(MessageListener listener) |
void |
selected(SelectEvent event) |
protected void |
selectionChanged(java.awt.event.MouseEvent mouseEvent) |
protected void |
selectionEnded(java.awt.event.MouseEvent mouseEvent) |
protected void |
selectionStarted(java.awt.event.MouseEvent mouseEvent) |
protected void |
selectObjects(java.util.List<?> list) |
protected void |
sendMessage(Message message) |
void |
setBorderColor(java.awt.Color color) |
void |
setInteriorColor(java.awt.Color color) |
onMessage, propertyChange
addPropertyChangeListener, 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, setValues
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
protected boolean armed
protected Layer layer
protected java.util.List<MessageListener> messageListeners
protected java.util.List<java.lang.Object> selectedObjects
public static final java.lang.String SELECTION_CHANGED
public static final java.lang.String SELECTION_ENDED
public static final java.lang.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 java.awt.Color getBorderColor()
public java.awt.Color getInteriorColor()
public Layer getLayer()
public java.util.List<?> getSelectedObjects()
public WorldWindow getWwd()
protected java.awt.Point limitPointToWorldWindow(java.awt.Point point)
point
- the point to limit.public void mouseClicked(java.awt.event.MouseEvent mouseEvent)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent mouseEvent)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseEntered(java.awt.event.MouseEvent mouseEvent)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent mouseEvent)
mouseExited
in interface java.awt.event.MouseListener
public void mouseMoved(java.awt.event.MouseEvent mouseEvent)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mousePressed(java.awt.event.MouseEvent mouseEvent)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent mouseEvent)
mouseReleased
in interface java.awt.event.MouseListener
public void removeMessageListener(MessageListener listener)
public void selected(SelectEvent event)
selected
in interface SelectListener
protected void selectionChanged(java.awt.event.MouseEvent mouseEvent)
protected void selectionEnded(java.awt.event.MouseEvent mouseEvent)
protected void selectionStarted(java.awt.event.MouseEvent mouseEvent)
protected void selectObjects(java.util.List<?> list)
protected void sendMessage(Message message)
public void setBorderColor(java.awt.Color color)
public void setInteriorColor(java.awt.Color color)