public class SelectAction extends MapMode implements ModifierListener, KeyPressReleaseListener, SelectionManager.SelectionEnded
Modifier and Type | Class and Description |
---|---|
(package private) static class |
SelectAction.ConfirmMoveDialog |
private class |
SelectAction.CycleManager |
static class |
SelectAction.Mode
Select action mode.
|
private static class |
SelectAction.SelectActionCursor |
private class |
SelectAction.VirtualManager |
JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
Modifier and Type | Field and Description |
---|---|
private boolean |
cancelDrawMode |
private SelectAction.CycleManager |
cycleManager |
private boolean |
didMouseDrag |
private boolean |
drawTargetHighlight |
private int |
initialMoveDelay
The time which needs to pass between click and release before something
counts as a move, in milliseconds
|
private int |
initialMoveThreshold
The screen distance which needs to be travelled before something
counts as a move, in pixels
|
private boolean |
initialMoveThresholdExceeded |
private boolean |
lassoMode |
private java.awt.Point |
lastMousePos
The last known position of the mouse.
|
private SelectAction.Mode |
mode |
private int |
mouseDownButton
The pressed button of the user mouse down event.
|
private long |
mouseDownTime
The time of the user mouse down event.
|
private long |
mouseReleaseTime
The time of the user mouse down event.
|
private MapView |
mv
The component this SelectAction is associated with.
|
private java.awt.event.MouseEvent |
oldEvent |
private java.util.Set<OsmPrimitive> |
oldHighlights
elements that have been highlighted in the previous iteration.
|
boolean |
repeatedKeySwitchLassoOption |
private SelectionManager |
selectionManager |
private EastNorth |
startEN
point where user pressed the mouse to start movement
|
private java.awt.Point |
startingDraggingPos
The old cursor before the user pressed the mouse button.
|
private SelectAction.VirtualManager |
virtualManager |
sc
Constructor and Description |
---|
SelectAction(MapFrame mapFrame)
Create a new SelectAction
|
Modifier and Type | Method and Description |
---|---|
protected static <T> java.util.Collection<T> |
asColl(T o)
Returns
o as collection of o 's type. |
private void |
confirmOrUndoMovement(java.awt.event.MouseEvent e)
Present warning in the following cases and undo unwanted movements:
large and possibly unwanted movements
movement of node with attached ways that are hidden by filters
|
private void |
determineMapMode(boolean hasSelectionNearby)
sets the mapmode according to key modifiers and if there are any
selectables nearby.
|
private static boolean |
doesImpactStatusLine(java.util.Collection<Node> affectedNodes,
java.util.Collection<Way> selectedWays) |
void |
doKeyPressed(java.awt.event.KeyEvent e)
This is called when key press event is actually pressed
(no fake events while holding key)
|
void |
doKeyReleased(java.awt.event.KeyEvent e)
This is called when key press event is actually released
(no fake events while holding key)
|
private boolean |
dragInProgress()
Determines whenever elements have been grabbed and moved (i.e.
|
void |
enterMode()
Makes this map mode active.
|
void |
exitMode()
Makes this map mode inactive.
|
private Node |
findNodeToMergeTo(java.awt.Point p)
Tries to find a node to merge to when in move-merge mode for the current mouse
position.
|
private java.awt.Cursor |
getCursor(java.util.Collection<OsmPrimitive> nearbyStuff)
works out which cursor should be displayed for most of SelectAction's
features.
|
private static Command |
getLastCommand()
Obtain command in undoRedo stack to "continue" when dragging
|
SelectAction.Mode |
getMode()
Returns the current select mode.
|
java.lang.String |
getModeHelpText() |
private boolean |
giveUserFeedback(java.awt.event.MouseEvent e)
handles adding highlights and updating the cursor for the given mouse event.
|
private boolean |
giveUserFeedback(java.awt.event.MouseEvent e,
int modifiers)
handles adding highlights and updating the cursor for the given mouse event.
|
boolean |
layerIsSupported(Layer l)
Determines if layer
l is supported by this map mode. |
void |
mergeNodes(OsmDataLayer layer,
java.util.Collection<Node> nodes,
Node targetLocationNode)
Merge nodes using
MergeNodesAction . |
private void |
mergePrims(java.awt.Point p)
Merges the selected nodes to the one closest to the given mouse position if the control
key is pressed.
|
void |
modifiersChanged(int modifiers) |
void |
mouseDragged(java.awt.event.MouseEvent e)
If the left mouse button is pressed, move all currently selected
objects (if one of them is under the mouse) or the current one under the
mouse (which will become selected).
|
void |
mouseExited(java.awt.event.MouseEvent e) |
void |
mouseMoved(java.awt.event.MouseEvent e) |
void |
mousePressed(java.awt.event.MouseEvent e)
Look, whether any object is selected.
|
void |
mouseReleased(java.awt.event.MouseEvent e) |
private boolean |
movesHiddenWay() |
private boolean |
removeHighlighting()
Removes all existing highlights.
|
private boolean |
repaintIfRequired(java.util.Set<OsmPrimitive> newHighlights) |
void |
selectionEnded(java.awt.Rectangle r,
java.awt.event.MouseEvent e)
Called, when the left mouse button was released.
|
private void |
selectPrims(java.util.Collection<OsmPrimitive> prims,
boolean released,
boolean area) |
void |
setLassoMode(boolean lassoMode)
Enable or diable the lasso mode
|
private boolean |
updateCommandWhileDragging(EastNorth currentEN)
Create or update data modification command while dragging mouse - implementation of
continuous moving, scaling and rotation
|
private void |
useLastMoveCommandIfPossible()
Adapt last move command (if it is suitable) to work with next drag, started at point startEN
|
actionPerformed, mouseClicked, mouseEntered, requestFocusInMapView, updateKeyModifiers, updateKeyModifiers, updateKeyModifiers, updateStatusLine
destroy, getCurrentDataSet, getEditLayer, getShortcut, initEnabledState, installAdapters, setTooltip, updateEnabledState, updateEnabledState
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addPropertyChangeListener, removePropertyChangeListener
private boolean lassoMode
public boolean repeatedKeySwitchLassoOption
private java.awt.event.MouseEvent oldEvent
private SelectAction.Mode mode
private final transient SelectionManager selectionManager
private boolean cancelDrawMode
private boolean drawTargetHighlight
private boolean didMouseDrag
private java.awt.Point startingDraggingPos
private java.awt.Point lastMousePos
private long mouseDownTime
private int mouseDownButton
private long mouseReleaseTime
private int initialMoveDelay
private int initialMoveThreshold
private boolean initialMoveThresholdExceeded
private transient java.util.Set<OsmPrimitive> oldHighlights
private final transient SelectAction.CycleManager cycleManager
private final transient SelectAction.VirtualManager virtualManager
public SelectAction(MapFrame mapFrame)
mapFrame
- The MapFrame this action belongs to.public void enterMode()
MapMode
public void exitMode()
MapMode
public void modifiersChanged(int modifiers)
modifiersChanged
in interface ModifierListener
private boolean giveUserFeedback(java.awt.event.MouseEvent e)
e
- MouseEvent
which should be used as base for the feedbacktrue
if repaint is requiredprivate boolean giveUserFeedback(java.awt.event.MouseEvent e, int modifiers)
e
- MouseEvent
which should be used as base for the feedbackmodifiers
- define custom keyboard modifiers if the ones from MouseEvent are outdated or similartrue
if repaint is requiredprivate java.awt.Cursor getCursor(java.util.Collection<OsmPrimitive> nearbyStuff)
nearbyStuff
- primitives near the cursorprivate boolean removeHighlighting()
private boolean repaintIfRequired(java.util.Set<OsmPrimitive> newHighlights)
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
mousePressed
in class MapMode
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
mouseMoved
in class MapMode
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
mouseDragged
in class MapMode
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
mouseExited
in class MapMode
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
mouseReleased
in class MapMode
public void selectionEnded(java.awt.Rectangle r, java.awt.event.MouseEvent e)
SelectionManager.SelectionEnded
selectionEnded
in interface SelectionManager.SelectionEnded
r
- The rectangle that encloses the current selection.e
- The mouse event.InputEvent.getModifiersEx()
,
SelectionManager.getSelectedObjects(boolean)
public void doKeyPressed(java.awt.event.KeyEvent e)
KeyPressReleaseListener
doKeyPressed
in interface KeyPressReleaseListener
e
- key eventpublic void doKeyReleased(java.awt.event.KeyEvent e)
KeyPressReleaseListener
doKeyReleased
in interface KeyPressReleaseListener
e
- key eventprivate void determineMapMode(boolean hasSelectionNearby)
hasSelectionNearby
- true
if some primitves are selectable nearbyprivate boolean dragInProgress()
private boolean updateCommandWhileDragging(EastNorth currentEN)
currentEN
- - mouse positiontrue
when action was performed)private static boolean doesImpactStatusLine(java.util.Collection<Node> affectedNodes, java.util.Collection<Way> selectedWays)
private void useLastMoveCommandIfPossible()
private static Command getLastCommand()
private void confirmOrUndoMovement(java.awt.event.MouseEvent e)
e
- the mouse event causing the action (mouse released)private boolean movesHiddenWay()
private void mergePrims(java.awt.Point p)
p
- mouse positionpublic void mergeNodes(OsmDataLayer layer, java.util.Collection<Node> nodes, Node targetLocationNode)
MergeNodesAction
.
Can be overridden for testing purpose.layer
- layer the reference data layer. Must not be nullnodes
- the collection of nodes. Ignored if nulltargetLocationNode
- this node's location will be used for the target nodeprivate Node findNodeToMergeTo(java.awt.Point p)
p
- mouse positionprivate void selectPrims(java.util.Collection<OsmPrimitive> prims, boolean released, boolean area)
public final SelectAction.Mode getMode()
public java.lang.String getModeHelpText()
getModeHelpText
in class MapMode
public boolean layerIsSupported(Layer l)
MapMode
l
is supported by this map mode.
By default, all tools will work with all layers.
Can be overwritten to require a special type of layerlayerIsSupported
in class MapMode
l
- layertrue
if the layer is supported by this map modepublic void setLassoMode(boolean lassoMode)
lassoMode
- true to enable the lasso mode, false otherwiseprotected static <T> java.util.Collection<T> asColl(T o)
o
as collection of o
's type.T
- object typeo
- any objecto
as collection of o
's type.