1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.actions.mapmode;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 | import static org.openstreetmap.josm.tools.I18n.trn;
|
---|
6 |
|
---|
7 | import java.awt.Cursor;
|
---|
8 | import java.awt.Point;
|
---|
9 | import java.awt.Rectangle;
|
---|
10 | import java.awt.event.ActionEvent;
|
---|
11 | import java.awt.event.InputEvent;
|
---|
12 | import java.awt.event.KeyEvent;
|
---|
13 | import java.awt.event.MouseEvent;
|
---|
14 | import java.util.ArrayList;
|
---|
15 | import java.util.Collection;
|
---|
16 | import java.util.Collections;
|
---|
17 | import java.util.LinkedList;
|
---|
18 | import java.util.List;
|
---|
19 |
|
---|
20 | import javax.swing.JOptionPane;
|
---|
21 |
|
---|
22 | import org.openstreetmap.josm.Main;
|
---|
23 | import org.openstreetmap.josm.actions.MergeNodesAction;
|
---|
24 | import org.openstreetmap.josm.command.AddCommand;
|
---|
25 | import org.openstreetmap.josm.command.ChangeCommand;
|
---|
26 | import org.openstreetmap.josm.command.Command;
|
---|
27 | import org.openstreetmap.josm.command.MoveCommand;
|
---|
28 | import org.openstreetmap.josm.command.RotateCommand;
|
---|
29 | import org.openstreetmap.josm.command.SequenceCommand;
|
---|
30 | import org.openstreetmap.josm.data.coor.EastNorth;
|
---|
31 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
32 | import org.openstreetmap.josm.data.osm.Node;
|
---|
33 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
34 | import org.openstreetmap.josm.data.osm.Way;
|
---|
35 | import org.openstreetmap.josm.data.osm.WaySegment;
|
---|
36 | import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor;
|
---|
37 | import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;
|
---|
38 | import org.openstreetmap.josm.gui.MapFrame;
|
---|
39 | import org.openstreetmap.josm.gui.MapView;
|
---|
40 | import org.openstreetmap.josm.gui.SelectionManager;
|
---|
41 | import org.openstreetmap.josm.gui.SelectionManager.SelectionEnded;
|
---|
42 | import org.openstreetmap.josm.gui.layer.Layer;
|
---|
43 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
44 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
45 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Move is an action that can move all kind of OsmPrimitives (except keys for now).
|
---|
49 | *
|
---|
50 | * If an selected object is under the mouse when dragging, move all selected objects.
|
---|
51 | * If an unselected object is under the mouse when dragging, it becomes selected
|
---|
52 | * and will be moved.
|
---|
53 | * If no object is under the mouse, move all selected objects (if any)
|
---|
54 | *
|
---|
55 | * @author imi
|
---|
56 | */
|
---|
57 | public class SelectAction extends MapMode implements SelectionEnded {
|
---|
58 |
|
---|
59 | enum Mode { move, rotate, select }
|
---|
60 | private Mode mode = null;
|
---|
61 | private long mouseDownTime = 0;
|
---|
62 | private boolean didMove = false;
|
---|
63 | private boolean cancelDrawMode = false;
|
---|
64 | Node virtualNode = null;
|
---|
65 | Collection<WaySegment> virtualWays = new ArrayList<WaySegment>();
|
---|
66 | SequenceCommand virtualCmds = null;
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * The old cursor before the user pressed the mouse button.
|
---|
70 | */
|
---|
71 | private Cursor oldCursor;
|
---|
72 | /**
|
---|
73 | * The position of the mouse before the user moves a node.
|
---|
74 | */
|
---|
75 | private Point mousePos;
|
---|
76 | private SelectionManager selectionManager;
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * The time which needs to pass between click and release before something
|
---|
80 | * counts as a move, in milliseconds
|
---|
81 | */
|
---|
82 | private int initialMoveDelay;
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * The screen distance which needs to be travelled before something
|
---|
86 | * counts as a move, in pixels
|
---|
87 | */
|
---|
88 | private int initialMoveThreshold;
|
---|
89 | private boolean initialMoveThresholdExceeded = false;
|
---|
90 | /**
|
---|
91 | * Create a new SelectAction
|
---|
92 | * @param mapFrame The MapFrame this action belongs to.
|
---|
93 | */
|
---|
94 | public SelectAction(MapFrame mapFrame) {
|
---|
95 | super(tr("Select"), "move/move", tr("Select, move and rotate objects"),
|
---|
96 | Shortcut.registerShortcut("mapmode:select", tr("Mode: {0}", tr("Select")), KeyEvent.VK_S, Shortcut.GROUP_EDIT),
|
---|
97 | mapFrame,
|
---|
98 | getCursor("normal", "selection", Cursor.DEFAULT_CURSOR));
|
---|
99 | putValue("help", "Action/Move/Move");
|
---|
100 | selectionManager = new SelectionManager(this, false, mapFrame.mapView);
|
---|
101 | initialMoveDelay = Main.pref.getInteger("edit.initial-move-delay",200);
|
---|
102 | initialMoveThreshold = Main.pref.getInteger("edit.initial-move-threshold",5);
|
---|
103 | }
|
---|
104 |
|
---|
105 | private static Cursor getCursor(String name, String mod, int def) {
|
---|
106 | try {
|
---|
107 | return ImageProvider.getCursor(name, mod);
|
---|
108 | } catch (Exception e) {
|
---|
109 | }
|
---|
110 | return Cursor.getPredefinedCursor(def);
|
---|
111 | }
|
---|
112 |
|
---|
113 | private void setCursor(Cursor c) {
|
---|
114 | if (oldCursor == null) {
|
---|
115 | oldCursor = Main.map.mapView.getCursor();
|
---|
116 | Main.map.mapView.setCursor(c);
|
---|
117 | }
|
---|
118 | }
|
---|
119 |
|
---|
120 | private void restoreCursor() {
|
---|
121 | if (oldCursor != null) {
|
---|
122 | Main.map.mapView.setCursor(oldCursor);
|
---|
123 | oldCursor = null;
|
---|
124 | }
|
---|
125 | }
|
---|
126 |
|
---|
127 | @Override public void enterMode() {
|
---|
128 | super.enterMode();
|
---|
129 | Main.map.mapView.addMouseListener(this);
|
---|
130 | Main.map.mapView.addMouseMotionListener(this);
|
---|
131 | Main.map.mapView.enableVirtualNodes(
|
---|
132 | Main.pref.getInteger("mappaint.node.virtual-size", 8) != 0);
|
---|
133 | }
|
---|
134 |
|
---|
135 | @Override public void exitMode() {
|
---|
136 | super.exitMode();
|
---|
137 | selectionManager.unregister(Main.map.mapView);
|
---|
138 | Main.map.mapView.removeMouseListener(this);
|
---|
139 | Main.map.mapView.removeMouseMotionListener(this);
|
---|
140 | Main.map.mapView.enableVirtualNodes(false);
|
---|
141 | }
|
---|
142 |
|
---|
143 | /**
|
---|
144 | * If the left mouse button is pressed, move all currently selected
|
---|
145 | * objects (if one of them is under the mouse) or the current one under the
|
---|
146 | * mouse (which will become selected).
|
---|
147 | */
|
---|
148 | @Override public void mouseDragged(MouseEvent e) {
|
---|
149 | if(!Main.map.mapView.isVisibleDrawableLayer())
|
---|
150 | return;
|
---|
151 |
|
---|
152 | cancelDrawMode = true;
|
---|
153 | if (mode == Mode.select) return;
|
---|
154 |
|
---|
155 | // do not count anything as a move if it lasts less than 100 milliseconds.
|
---|
156 | if ((mode == Mode.move) && (System.currentTimeMillis() - mouseDownTime < initialMoveDelay)) return;
|
---|
157 |
|
---|
158 | if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == 0)
|
---|
159 | return;
|
---|
160 |
|
---|
161 | if (mode == Mode.move) {
|
---|
162 | setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
|
---|
163 | }
|
---|
164 |
|
---|
165 | if (mousePos == null) {
|
---|
166 | mousePos = e.getPoint();
|
---|
167 | return;
|
---|
168 | }
|
---|
169 |
|
---|
170 | if (!initialMoveThresholdExceeded) {
|
---|
171 | int dxp = mousePos.x - e.getX();
|
---|
172 | int dyp = mousePos.y - e.getY();
|
---|
173 | int dp = (int) Math.sqrt(dxp*dxp+dyp*dyp);
|
---|
174 | if (dp < initialMoveThreshold) return;
|
---|
175 | initialMoveThresholdExceeded = true;
|
---|
176 | }
|
---|
177 |
|
---|
178 | EastNorth mouseEN = Main.map.mapView.getEastNorth(e.getX(), e.getY());
|
---|
179 | EastNorth mouseStartEN = Main.map.mapView.getEastNorth(mousePos.x, mousePos.y);
|
---|
180 | double dx = mouseEN.east() - mouseStartEN.east();
|
---|
181 | double dy = mouseEN.north() - mouseStartEN.north();
|
---|
182 | if (dx == 0 && dy == 0)
|
---|
183 | return;
|
---|
184 |
|
---|
185 | if (virtualWays.size() > 0) {
|
---|
186 | Collection<Command> virtualCmds = new LinkedList<Command>();
|
---|
187 | virtualCmds.add(new AddCommand(virtualNode));
|
---|
188 | for(WaySegment virtualWay : virtualWays) {
|
---|
189 | Way w = virtualWay.way;
|
---|
190 | Way wnew = new Way(w);
|
---|
191 | wnew.addNode(virtualWay.lowerIndex+1, virtualNode);
|
---|
192 | virtualCmds.add(new ChangeCommand(w, wnew));
|
---|
193 | }
|
---|
194 | virtualCmds.add(new MoveCommand(virtualNode, dx, dy));
|
---|
195 | String text = trn("Add and move a virtual new node to way",
|
---|
196 | "Add and move a virtual new node to {0} ways", virtualWays.size(),
|
---|
197 | virtualWays.size());
|
---|
198 |
|
---|
199 | Main.main.undoRedo.add(new SequenceCommand(text, virtualCmds));
|
---|
200 | selectPrims(Collections.singleton((OsmPrimitive)virtualNode), false, false, false);
|
---|
201 | virtualWays.clear();
|
---|
202 | virtualNode = null;
|
---|
203 | } else {
|
---|
204 | // Currently we support moving and rotating, which do not affect relations.
|
---|
205 | // So don't add them in the first place to make handling easier
|
---|
206 | Collection<OsmPrimitive> selection = Main.ds.getSelectedPhysical();
|
---|
207 | Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection);
|
---|
208 |
|
---|
209 | // when rotating, having only one node makes no sense - quit silently
|
---|
210 | if (mode == Mode.rotate && affectedNodes.size() < 2)
|
---|
211 | return;
|
---|
212 |
|
---|
213 | Command c = !Main.main.undoRedo.commands.isEmpty()
|
---|
214 | ? Main.main.undoRedo.commands.getLast() : null;
|
---|
215 | if (c instanceof SequenceCommand)
|
---|
216 | c = ((SequenceCommand)c).getLastCommand();
|
---|
217 |
|
---|
218 | if (mode == Mode.move) {
|
---|
219 | if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand)c).objects))
|
---|
220 | ((MoveCommand)c).moveAgain(dx,dy);
|
---|
221 | else
|
---|
222 | Main.main.undoRedo.add(
|
---|
223 | c = new MoveCommand(selection, dx, dy));
|
---|
224 |
|
---|
225 | for (Node n : affectedNodes) {
|
---|
226 | if (n.coor.isOutSideWorld()) {
|
---|
227 | // Revert move
|
---|
228 | ((MoveCommand) c).moveAgain(-dx, -dy);
|
---|
229 |
|
---|
230 | JOptionPane.showMessageDialog(Main.parent,
|
---|
231 | tr("Cannot move objects outside of the world."));
|
---|
232 | restoreCursor();
|
---|
233 | return;
|
---|
234 | }
|
---|
235 | }
|
---|
236 | } else if (mode == Mode.rotate) {
|
---|
237 | if (c instanceof RotateCommand && affectedNodes.equals(((RotateCommand)c).objects))
|
---|
238 | ((RotateCommand)c).rotateAgain(mouseStartEN, mouseEN);
|
---|
239 | else
|
---|
240 | Main.main.undoRedo.add(new RotateCommand(selection, mouseStartEN, mouseEN));
|
---|
241 | }
|
---|
242 | }
|
---|
243 |
|
---|
244 | Main.map.mapView.repaint();
|
---|
245 | mousePos = e.getPoint();
|
---|
246 |
|
---|
247 | didMove = true;
|
---|
248 | }
|
---|
249 |
|
---|
250 | private Collection<OsmPrimitive> getNearestCollectionVirtual(Point p, boolean allSegements) {
|
---|
251 | MapView c = Main.map.mapView;
|
---|
252 | int snapDistance = Main.pref.getInteger("mappaint.node.virtual-snap-distance", 8);
|
---|
253 | snapDistance *= snapDistance;
|
---|
254 | OsmPrimitive osm = c.getNearestNode(p);
|
---|
255 | virtualWays.clear();
|
---|
256 | virtualNode = null;
|
---|
257 | Node virtualWayNode = null;
|
---|
258 |
|
---|
259 | if (osm == null)
|
---|
260 | {
|
---|
261 | Collection<WaySegment> nearestWaySegs = allSegements
|
---|
262 | ? c.getNearestWaySegments(p)
|
---|
263 | : Collections.singleton(c.getNearestWaySegment(p));
|
---|
264 |
|
---|
265 | for(WaySegment nearestWS : nearestWaySegs) {
|
---|
266 | if (nearestWS == null)
|
---|
267 | continue;
|
---|
268 |
|
---|
269 | osm = nearestWS.way;
|
---|
270 | if(Main.pref.getInteger("mappaint.node.virtual-size", 8) > 0)
|
---|
271 | {
|
---|
272 | Way w = (Way)osm;
|
---|
273 | Point p1 = c.getPoint(w.nodes.get(nearestWS.lowerIndex).eastNorth);
|
---|
274 | Point p2 = c.getPoint(w.nodes.get(nearestWS.lowerIndex+1).eastNorth);
|
---|
275 | if(SimplePaintVisitor.isLargeSegment(p1, p2, Main.pref.getInteger("mappaint.node.virtual-space", 70)))
|
---|
276 | {
|
---|
277 | Point pc = new Point((p1.x+p2.x)/2, (p1.y+p2.y)/2);
|
---|
278 | if (p.distanceSq(pc) < snapDistance)
|
---|
279 | {
|
---|
280 | // Check that only segments on top of each other get added to the
|
---|
281 | // virtual ways list. Otherwise ways that coincidentally have their
|
---|
282 | // virtual node at the same spot will be joined which is likely unwanted
|
---|
283 | if(virtualWayNode != null) {
|
---|
284 | if( !w.nodes.get(nearestWS.lowerIndex+1).equals(virtualWayNode)
|
---|
285 | && !w.nodes.get(nearestWS.lowerIndex ).equals(virtualWayNode))
|
---|
286 | continue;
|
---|
287 | } else
|
---|
288 | virtualWayNode = w.nodes.get(nearestWS.lowerIndex+1);
|
---|
289 |
|
---|
290 | virtualWays.add(nearestWS);
|
---|
291 | if(virtualNode == null)
|
---|
292 | virtualNode = new Node(Main.map.mapView.getLatLon(pc.x, pc.y));
|
---|
293 | }
|
---|
294 | }
|
---|
295 | }
|
---|
296 | }
|
---|
297 | }
|
---|
298 | if (osm == null)
|
---|
299 | return Collections.emptySet();
|
---|
300 | return Collections.singleton(osm);
|
---|
301 | }
|
---|
302 |
|
---|
303 | /**
|
---|
304 | * Look, whether any object is selected. If not, select the nearest node.
|
---|
305 | * If there are no nodes in the dataset, do nothing.
|
---|
306 | *
|
---|
307 | * If the user did not press the left mouse button, do nothing.
|
---|
308 | *
|
---|
309 | * Also remember the starting position of the movement and change the mouse
|
---|
310 | * cursor to movement.
|
---|
311 | */
|
---|
312 | @Override public void mousePressed(MouseEvent e) {
|
---|
313 | if(!Main.map.mapView.isVisibleDrawableLayer())
|
---|
314 | return;
|
---|
315 |
|
---|
316 | cancelDrawMode = false;
|
---|
317 | if (! (Boolean)this.getValue("active")) return;
|
---|
318 | if (e.getButton() != MouseEvent.BUTTON1)
|
---|
319 | return;
|
---|
320 | boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0;
|
---|
321 | boolean alt = (e.getModifiers() & (ActionEvent.ALT_MASK|InputEvent.ALT_GRAPH_MASK)) != 0;
|
---|
322 | boolean shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0;
|
---|
323 |
|
---|
324 | // We don't want to change to draw tool if the user tries to (de)select
|
---|
325 | // stuff but accidentally clicks in an empty area when selection is empty
|
---|
326 | if(shift || ctrl)
|
---|
327 | cancelDrawMode = true;
|
---|
328 |
|
---|
329 | mouseDownTime = System.currentTimeMillis();
|
---|
330 | didMove = false;
|
---|
331 | initialMoveThresholdExceeded = false;
|
---|
332 |
|
---|
333 | Collection<OsmPrimitive> osmColl = getNearestCollectionVirtual(e.getPoint(), alt);
|
---|
334 |
|
---|
335 | if (ctrl && shift) {
|
---|
336 | if (Main.ds.getSelected().isEmpty()) selectPrims(osmColl, true, false, false);
|
---|
337 | mode = Mode.rotate;
|
---|
338 | setCursor(ImageProvider.getCursor("rotate", null));
|
---|
339 | } else if (!osmColl.isEmpty()) {
|
---|
340 | // Don't replace the selection now if the user clicked on a
|
---|
341 | // selected object (this would break moving of selected groups).
|
---|
342 | // We'll do that later in mouseReleased if the user didn't try to
|
---|
343 | // move.
|
---|
344 | selectPrims(osmColl,
|
---|
345 | shift || Main.ds.getSelected().containsAll(osmColl),
|
---|
346 | ctrl, false);
|
---|
347 | mode = Mode.move;
|
---|
348 | } else {
|
---|
349 | mode = Mode.select;
|
---|
350 | oldCursor = Main.map.mapView.getCursor();
|
---|
351 | selectionManager.register(Main.map.mapView);
|
---|
352 | selectionManager.mousePressed(e);
|
---|
353 | }
|
---|
354 | if(mode != Mode.move || shift || ctrl)
|
---|
355 | {
|
---|
356 | virtualNode = null;
|
---|
357 | virtualWays.clear();
|
---|
358 | }
|
---|
359 |
|
---|
360 | updateStatusLine();
|
---|
361 | // Mode.select redraws when selectPrims is called
|
---|
362 | // Mode.move redraws when mouseDragged is called
|
---|
363 | // Mode.rotate redraws here
|
---|
364 | if(mode == Mode.rotate)
|
---|
365 | Main.map.mapView.repaint();
|
---|
366 |
|
---|
367 | mousePos = e.getPoint();
|
---|
368 | }
|
---|
369 |
|
---|
370 | /**
|
---|
371 | * Restore the old mouse cursor.
|
---|
372 | */
|
---|
373 | @Override public void mouseReleased(MouseEvent e) {
|
---|
374 | if(!Main.map.mapView.isVisibleDrawableLayer())
|
---|
375 | return;
|
---|
376 |
|
---|
377 | if (mode == Mode.select) {
|
---|
378 | selectionManager.unregister(Main.map.mapView);
|
---|
379 |
|
---|
380 | // Select Draw Tool if no selection has been made
|
---|
381 | if(Main.ds.getSelected().size() == 0 && !cancelDrawMode) {
|
---|
382 | Main.map.selectDrawTool(true);
|
---|
383 | return;
|
---|
384 | }
|
---|
385 | }
|
---|
386 | restoreCursor();
|
---|
387 |
|
---|
388 | if (mode == Mode.move) {
|
---|
389 | boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0;
|
---|
390 | boolean shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0;
|
---|
391 | if (!didMove) {
|
---|
392 | selectPrims(
|
---|
393 | Main.map.mapView.getNearestCollection(e.getPoint()),
|
---|
394 | shift, ctrl, true);
|
---|
395 |
|
---|
396 | // If the user double-clicked a node, change to draw mode
|
---|
397 | List<OsmPrimitive> sel = new ArrayList<OsmPrimitive>(Main.ds.getSelected());
|
---|
398 | if(e.getClickCount() >=2 && sel.size() == 1 && sel.get(0) instanceof Node) {
|
---|
399 | // We need to do it like this as otherwise drawAction will see a double
|
---|
400 | // click and switch back to SelectMode
|
---|
401 | Main.worker.execute(new Runnable(){
|
---|
402 | public void run() {
|
---|
403 | Main.map.selectDrawTool(true);
|
---|
404 | }
|
---|
405 | });
|
---|
406 | return;
|
---|
407 | }
|
---|
408 | } else {
|
---|
409 | Collection<OsmPrimitive> selection = Main.ds.getSelected();
|
---|
410 | if (ctrl) {
|
---|
411 | Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection);
|
---|
412 | Collection<Node> nn = Main.map.mapView.getNearestNodes(e.getPoint(), affectedNodes);
|
---|
413 | if (nn != null) {
|
---|
414 | Node n = nn.iterator().next();
|
---|
415 | LinkedList<Node> selNodes = new LinkedList<Node>();
|
---|
416 | for (OsmPrimitive osm : selection)
|
---|
417 | if (osm instanceof Node)
|
---|
418 | selNodes.add((Node)osm);
|
---|
419 | if (selNodes.size() > 0) {
|
---|
420 | selNodes.add(n);
|
---|
421 | MergeNodesAction.mergeNodes(selNodes, n);
|
---|
422 | }
|
---|
423 | }
|
---|
424 | }
|
---|
425 | DataSet.fireSelectionChanged(selection);
|
---|
426 | }
|
---|
427 | }
|
---|
428 |
|
---|
429 | // I don't see why we need this.
|
---|
430 | //updateStatusLine();
|
---|
431 | mode = null;
|
---|
432 | updateStatusLine();
|
---|
433 | }
|
---|
434 |
|
---|
435 | public void selectionEnded(Rectangle r, boolean alt, boolean shift, boolean ctrl) {
|
---|
436 | selectPrims(selectionManager.getObjectsInRectangle(r, alt), shift, ctrl, false);
|
---|
437 | }
|
---|
438 |
|
---|
439 | public void selectPrims(Collection<OsmPrimitive> selectionList, boolean shift, boolean ctrl, boolean released) {
|
---|
440 | if ((shift && ctrl) || (ctrl && !released))
|
---|
441 | return; // not allowed together
|
---|
442 |
|
---|
443 | Collection<OsmPrimitive> curSel;
|
---|
444 | if (!ctrl && !shift)
|
---|
445 | curSel = new LinkedList<OsmPrimitive>(); // new selection will replace the old.
|
---|
446 | else
|
---|
447 | curSel = Main.ds.getSelected();
|
---|
448 |
|
---|
449 | for (OsmPrimitive osm : selectionList)
|
---|
450 | {
|
---|
451 | if (ctrl)
|
---|
452 | {
|
---|
453 | if(curSel.contains(osm))
|
---|
454 | curSel.remove(osm);
|
---|
455 | else
|
---|
456 | curSel.add(osm);
|
---|
457 | }
|
---|
458 | else
|
---|
459 | curSel.add(osm);
|
---|
460 | }
|
---|
461 | Main.ds.setSelected(curSel);
|
---|
462 | Main.map.mapView.repaint();
|
---|
463 | }
|
---|
464 |
|
---|
465 | @Override public String getModeHelpText() {
|
---|
466 | if (mode == Mode.select) {
|
---|
467 | return tr("Release the mouse button to select the objects in the rectangle.");
|
---|
468 | } else if (mode == Mode.move) {
|
---|
469 | return tr("Release the mouse button to stop moving. Ctrl to merge with nearest node.");
|
---|
470 | } else if (mode == Mode.rotate) {
|
---|
471 | return tr("Release the mouse button to stop rotating.");
|
---|
472 | } else {
|
---|
473 | return tr("Move objects by dragging; Shift to add to selection (Ctrl to toggle); Shift-Ctrl to rotate selected; or change selection");
|
---|
474 | }
|
---|
475 | }
|
---|
476 |
|
---|
477 | @Override public boolean layerIsSupported(Layer l) {
|
---|
478 | return l instanceof OsmDataLayer;
|
---|
479 | }
|
---|
480 | }
|
---|