source: josm/trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java@ 12542

Last change on this file since 12542 was 12542, checked in by Don-vip, 7 years ago

partial revert of r12537

  • Property svn:eol-style set to native
File size: 26.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.ActionEvent;
8import java.awt.event.KeyEvent;
9import java.util.ArrayList;
10import java.util.Arrays;
11import java.util.Collection;
12import java.util.Collections;
13import java.util.HashMap;
14import java.util.HashSet;
15import java.util.Iterator;
16import java.util.LinkedList;
17import java.util.List;
18import java.util.Map;
19import java.util.Set;
20
21import javax.swing.JOptionPane;
22
23import org.openstreetmap.josm.Main;
24import org.openstreetmap.josm.command.Command;
25import org.openstreetmap.josm.command.MoveCommand;
26import org.openstreetmap.josm.command.SequenceCommand;
27import org.openstreetmap.josm.data.coor.EastNorth;
28import org.openstreetmap.josm.data.osm.Node;
29import org.openstreetmap.josm.data.osm.OsmPrimitive;
30import org.openstreetmap.josm.data.osm.Way;
31import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
32import org.openstreetmap.josm.gui.Notification;
33import org.openstreetmap.josm.tools.JosmRuntimeException;
34import org.openstreetmap.josm.tools.Shortcut;
35import org.openstreetmap.josm.tools.Utils;
36
37/**
38 * Tools / Orthogonalize
39 *
40 * Align edges of a way so all angles are angles of 90 or 180 degrees.
41 * See USAGE String below.
42 */
43public final class OrthogonalizeAction extends JosmAction {
44 private static final String USAGE = tr(
45 "<h3>When one or more ways are selected, the shape is adjusted such, that all angles are 90 or 180 degrees.</h3>"+
46 "You can add two nodes to the selection. Then, the direction is fixed by these two reference nodes. "+
47 "(Afterwards, you can undo the movement for certain nodes:<br>"+
48 "Select them and press the shortcut for Orthogonalize / Undo. The default is Shift-Q.)");
49
50 private static final double EPSILON = 1E-6;
51
52 /**
53 * Constructs a new {@code OrthogonalizeAction}.
54 */
55 public OrthogonalizeAction() {
56 super(tr("Orthogonalize Shape"),
57 "ortho",
58 tr("Move nodes so all angles are 90 or 180 degrees"),
59 Shortcut.registerShortcut("tools:orthogonalize", tr("Tool: {0}", tr("Orthogonalize Shape")),
60 KeyEvent.VK_Q,
61 Shortcut.DIRECT), true);
62 putValue("help", ht("/Action/OrthogonalizeShape"));
63 }
64
65 /**
66 * excepted deviation from an angle of 0, 90, 180, 360 degrees
67 * maximum value: 45 degrees
68 *
69 * Current policy is to except just everything, no matter how strange the result would be.
70 */
71 private static final double TOLERANCE1 = Utils.toRadians(45.); // within a way
72 private static final double TOLERANCE2 = Utils.toRadians(45.); // ways relative to each other
73
74 /**
75 * Remember movements, so the user can later undo it for certain nodes
76 */
77 private static final Map<Node, EastNorth> rememberMovements = new HashMap<>();
78
79 /**
80 * Undo the previous orthogonalization for certain nodes.
81 *
82 * This is useful, if the way shares nodes that you don't like to change, e.g. imports or
83 * work of another user.
84 *
85 * This action can be triggered by shortcut only.
86 */
87 public static class Undo extends JosmAction {
88 /**
89 * Constructor
90 */
91 public Undo() {
92 super(tr("Orthogonalize Shape / Undo"), "ortho",
93 tr("Undo orthogonalization for certain nodes"),
94 Shortcut.registerShortcut("tools:orthogonalizeUndo", tr("Tool: {0}", tr("Orthogonalize Shape / Undo")),
95 KeyEvent.VK_Q,
96 Shortcut.SHIFT),
97 true, "action/orthogonalize/undo", true);
98 }
99
100 @Override
101 public void actionPerformed(ActionEvent e) {
102 if (!isEnabled())
103 return;
104 final Collection<Command> commands = new LinkedList<>();
105 final Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected();
106 try {
107 for (OsmPrimitive p : sel) {
108 if (!(p instanceof Node)) throw new InvalidUserInputException("selected object is not a node");
109 Node n = (Node) p;
110 if (rememberMovements.containsKey(n)) {
111 EastNorth tmp = rememberMovements.get(n);
112 commands.add(new MoveCommand(n, -tmp.east(), -tmp.north()));
113 rememberMovements.remove(n);
114 }
115 }
116 if (!commands.isEmpty()) {
117 Main.main.undoRedo.add(new SequenceCommand(tr("Orthogonalize / Undo"), commands));
118 } else {
119 throw new InvalidUserInputException("Commands are empty");
120 }
121 } catch (InvalidUserInputException ex) {
122 Main.debug(ex);
123 new Notification(
124 tr("Orthogonalize Shape / Undo<br>"+
125 "Please select nodes that were moved by the previous Orthogonalize Shape action!"))
126 .setIcon(JOptionPane.INFORMATION_MESSAGE)
127 .show();
128 }
129 }
130
131 @Override
132 protected void updateEnabledState() {
133 updateEnabledStateOnCurrentSelection();
134 }
135
136 @Override
137 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
138 setEnabled(selection != null && !selection.isEmpty());
139 }
140 }
141
142 @Override
143 public void actionPerformed(ActionEvent e) {
144 if (!isEnabled())
145 return;
146 if ("EPSG:4326".equals(Main.getProjection().toString())) {
147 String msg = tr("<html>You are using the EPSG:4326 projection which might lead<br>" +
148 "to undesirable results when doing rectangular alignments.<br>" +
149 "Change your projection to get rid of this warning.<br>" +
150 "Do you want to continue?</html>");
151 if (!ConditionalOptionPaneUtil.showConfirmationDialog(
152 "align_rectangular_4326",
153 Main.parent,
154 msg,
155 tr("Warning"),
156 JOptionPane.YES_NO_OPTION,
157 JOptionPane.QUESTION_MESSAGE,
158 JOptionPane.YES_OPTION))
159 return;
160 }
161
162 final Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected();
163
164 try {
165 final SequenceCommand command = orthogonalize(sel);
166 Main.main.undoRedo.add(new SequenceCommand(tr("Orthogonalize"), command));
167 } catch (InvalidUserInputException ex) {
168 Main.debug(ex);
169 String msg;
170 if ("usage".equals(ex.getMessage())) {
171 msg = "<h2>" + tr("Usage") + "</h2>" + USAGE;
172 } else {
173 msg = ex.getMessage() + "<br><hr><h2>" + tr("Usage") + "</h2>" + USAGE;
174 }
175 new Notification(msg)
176 .setIcon(JOptionPane.INFORMATION_MESSAGE)
177 .setDuration(Notification.TIME_DEFAULT)
178 .show();
179 }
180 }
181
182 /**
183 * Rectifies the selection
184 * @param selection the selection which should be rectified
185 * @return a rectifying command
186 * @throws InvalidUserInputException if the selection is invalid
187 */
188 static SequenceCommand orthogonalize(Iterable<OsmPrimitive> selection) throws InvalidUserInputException {
189 final List<Node> nodeList = new ArrayList<>();
190 final List<WayData> wayDataList = new ArrayList<>();
191 // collect nodes and ways from the selection
192 for (OsmPrimitive p : selection) {
193 if (p instanceof Node) {
194 nodeList.add((Node) p);
195 } else if (p instanceof Way) {
196 if (!p.isIncomplete()) {
197 wayDataList.add(new WayData(((Way) p).getNodes()));
198 }
199 } else {
200 throw new InvalidUserInputException(tr("Selection must consist only of ways and nodes."));
201 }
202 }
203 if (wayDataList.isEmpty() && nodeList.size() > 2) {
204 final WayData data = new WayData(nodeList);
205 final Collection<Command> commands = orthogonalize(Collections.singletonList(data), Collections.<Node>emptyList());
206 return new SequenceCommand(tr("Orthogonalize"), commands);
207 } else if (wayDataList.isEmpty()) {
208 throw new InvalidUserInputException("usage");
209 } else {
210 if (nodeList.size() == 2 || nodeList.isEmpty()) {
211 OrthogonalizeAction.rememberMovements.clear();
212 final Collection<Command> commands = new LinkedList<>();
213
214 if (nodeList.size() == 2) { // fixed direction
215 commands.addAll(orthogonalize(wayDataList, nodeList));
216 } else if (nodeList.isEmpty()) {
217 List<List<WayData>> groups = buildGroups(wayDataList);
218 for (List<WayData> g: groups) {
219 commands.addAll(orthogonalize(g, nodeList));
220 }
221 } else {
222 throw new IllegalStateException();
223 }
224
225 return new SequenceCommand(tr("Orthogonalize"), commands);
226
227 } else {
228 throw new InvalidUserInputException("usage");
229 }
230 }
231 }
232
233 /**
234 * Collect groups of ways with common nodes in order to orthogonalize each group separately.
235 * @param wayDataList list of ways
236 * @return groups of ways with common nodes
237 */
238 private static List<List<WayData>> buildGroups(List<WayData> wayDataList) {
239 List<List<WayData>> groups = new ArrayList<>();
240 Set<WayData> remaining = new HashSet<>(wayDataList);
241 while (!remaining.isEmpty()) {
242 List<WayData> group = new ArrayList<>();
243 groups.add(group);
244 Iterator<WayData> it = remaining.iterator();
245 WayData next = it.next();
246 it.remove();
247 extendGroupRec(group, next, new ArrayList<>(remaining));
248 remaining.removeAll(group);
249 }
250 return groups;
251 }
252
253 private static void extendGroupRec(List<WayData> group, WayData newGroupMember, List<WayData> remaining) {
254 group.add(newGroupMember);
255 for (int i = 0; i < remaining.size(); ++i) {
256 WayData candidate = remaining.get(i);
257 if (candidate == null) continue;
258 if (!Collections.disjoint(candidate.wayNodes, newGroupMember.wayNodes)) {
259 remaining.set(i, null);
260 extendGroupRec(group, candidate, remaining);
261 }
262 }
263 }
264
265 /**
266 *
267 * Outline:
268 * 1. Find direction of all segments
269 * - direction = 0..3 (right,up,left,down)
270 * - right is not really right, you may have to turn your screen
271 * 2. Find average heading of all segments
272 * - heading = angle of a vector in polar coordinates
273 * - sum up horizontal segments (those with direction 0 or 2)
274 * - sum up vertical segments
275 * - turn the vertical sum by 90 degrees and add it to the horizontal sum
276 * - get the average heading from this total sum
277 * 3. Rotate all nodes by the average heading so that right is really right
278 * and all segments are approximately NS or EW.
279 * 4. If nodes are connected by a horizontal segment: Replace their y-Coordinate by
280 * the mean value of their y-Coordinates.
281 * - The same for vertical segments.
282 * 5. Rotate back.
283 * @param wayDataList list of ways
284 * @param headingNodes list of heading nodes
285 * @return list of commands to perform
286 * @throws InvalidUserInputException if selected ways have an angle different from 90 or 180 degrees
287 **/
288 private static Collection<Command> orthogonalize(List<WayData> wayDataList, List<Node> headingNodes) throws InvalidUserInputException {
289 // find average heading
290 double headingAll;
291 try {
292 if (headingNodes.isEmpty()) {
293 // find directions of the segments and make them consistent between different ways
294 wayDataList.get(0).calcDirections(Direction.RIGHT);
295 double refHeading = wayDataList.get(0).heading;
296 EastNorth totSum = new EastNorth(0., 0.);
297 for (WayData w : wayDataList) {
298 w.calcDirections(Direction.RIGHT);
299 int directionOffset = angleToDirectionChange(w.heading - refHeading, TOLERANCE2);
300 w.calcDirections(Direction.RIGHT.changeBy(directionOffset));
301 if (angleToDirectionChange(refHeading - w.heading, TOLERANCE2) != 0)
302 throw new JosmRuntimeException("orthogonalize error");
303 totSum = EN.sum(totSum, w.segSum);
304 }
305 headingAll = EN.polar(new EastNorth(0., 0.), totSum);
306 } else {
307 headingAll = EN.polar(headingNodes.get(0).getEastNorth(), headingNodes.get(1).getEastNorth());
308 for (WayData w : wayDataList) {
309 w.calcDirections(Direction.RIGHT);
310 int directionOffset = angleToDirectionChange(w.heading - headingAll, TOLERANCE2);
311 w.calcDirections(Direction.RIGHT.changeBy(directionOffset));
312 }
313 }
314 } catch (RejectedAngleException ex) {
315 throw new InvalidUserInputException(
316 tr("<html>Please make sure all selected ways head in a similar direction<br>"+
317 "or orthogonalize them one by one.</html>"), ex);
318 }
319
320 // put the nodes of all ways in a set
321 final Set<Node> allNodes = new HashSet<>();
322 for (WayData w : wayDataList) {
323 allNodes.addAll(w.wayNodes);
324 }
325
326 // the new x and y value for each node
327 final Map<Node, Double> nX = new HashMap<>();
328 final Map<Node, Double> nY = new HashMap<>();
329
330 // calculate the centroid of all nodes
331 // it is used as rotation center
332 EastNorth pivot = new EastNorth(0., 0.);
333 for (Node n : allNodes) {
334 pivot = EN.sum(pivot, n.getEastNorth());
335 }
336 pivot = new EastNorth(pivot.east() / allNodes.size(), pivot.north() / allNodes.size());
337
338 // rotate
339 for (Node n: allNodes) {
340 EastNorth tmp = EN.rotateCC(pivot, n.getEastNorth(), -headingAll);
341 nX.put(n, tmp.east());
342 nY.put(n, tmp.north());
343 }
344
345 // orthogonalize
346 final Direction[] horizontal = {Direction.RIGHT, Direction.LEFT};
347 final Direction[] vertical = {Direction.UP, Direction.DOWN};
348 final Direction[][] orientations = {horizontal, vertical};
349 for (Direction[] orientation : orientations) {
350 final Set<Node> s = new HashSet<>(allNodes);
351 int size = s.size();
352 for (int dummy = 0; dummy < size; ++dummy) {
353 if (s.isEmpty()) {
354 break;
355 }
356 final Node dummyN = s.iterator().next(); // pick arbitrary element of s
357
358 final Set<Node> cs = new HashSet<>(); // will contain each node that can be reached from dummyN
359 cs.add(dummyN); // walking only on horizontal / vertical segments
360
361 boolean somethingHappened = true;
362 while (somethingHappened) {
363 somethingHappened = false;
364 for (WayData w : wayDataList) {
365 for (int i = 0; i < w.nSeg; ++i) {
366 Node n1 = w.wayNodes.get(i);
367 Node n2 = w.wayNodes.get(i+1);
368 if (Arrays.asList(orientation).contains(w.segDirections[i])) {
369 if (cs.contains(n1) && !cs.contains(n2)) {
370 cs.add(n2);
371 somethingHappened = true;
372 }
373 if (cs.contains(n2) && !cs.contains(n1)) {
374 cs.add(n1);
375 somethingHappened = true;
376 }
377 }
378 }
379 }
380 }
381
382 final Map<Node, Double> nC = (orientation == horizontal) ? nY : nX;
383
384 double average = 0;
385 for (Node n : cs) {
386 s.remove(n);
387 average += nC.get(n).doubleValue();
388 }
389 average = average / cs.size();
390
391 // if one of the nodes is a heading node, forget about the average and use its value
392 for (Node fn : headingNodes) {
393 if (cs.contains(fn)) {
394 average = nC.get(fn);
395 }
396 }
397
398 // At this point, the two heading nodes (if any) are horizontally aligned, i.e. they
399 // have the same y coordinate. So in general we shouldn't find them in a vertical string
400 // of segments. This can still happen in some pathological cases (see #7889). To avoid
401 // both heading nodes collapsing to one point, we simply skip this segment string and
402 // don't touch the node coordinates.
403 if (orientation == vertical && headingNodes.size() == 2 && cs.containsAll(headingNodes)) {
404 continue;
405 }
406
407 for (Node n : cs) {
408 nC.put(n, average);
409 }
410 }
411 if (!s.isEmpty()) throw new JosmRuntimeException("orthogonalize error");
412 }
413
414 // rotate back and log the change
415 final Collection<Command> commands = new LinkedList<>();
416 for (Node n: allNodes) {
417 EastNorth tmp = new EastNorth(nX.get(n), nY.get(n));
418 tmp = EN.rotateCC(pivot, tmp, headingAll);
419 final double dx = tmp.east() - n.getEastNorth().east();
420 final double dy = tmp.north() - n.getEastNorth().north();
421 if (headingNodes.contains(n)) { // The heading nodes should not have changed
422 if (Math.abs(dx) > Math.abs(EPSILON * tmp.east()) ||
423 Math.abs(dy) > Math.abs(EPSILON * tmp.east()))
424 throw new AssertionError("heading node has changed");
425 } else {
426 OrthogonalizeAction.rememberMovements.put(n, new EastNorth(dx, dy));
427 commands.add(new MoveCommand(n, dx, dy));
428 }
429 }
430 return commands;
431 }
432
433 /**
434 * Class contains everything we need to know about a single way.
435 */
436 private static class WayData {
437 public final List<Node> wayNodes; // The assigned way
438 public final int nSeg; // Number of Segments of the Way
439 public final int nNode; // Number of Nodes of the Way
440 public final Direction[] segDirections; // Direction of the segments
441 // segment i goes from node i to node (i+1)
442 public EastNorth segSum; // (Vector-)sum of all horizontal segments plus the sum of all vertical
443 // segments turned by 90 degrees
444 public double heading; // heading of segSum == approximate heading of the way
445
446 WayData(List<Node> wayNodes) {
447 this.wayNodes = wayNodes;
448 this.nNode = wayNodes.size();
449 this.nSeg = nNode - 1;
450 this.segDirections = new Direction[nSeg];
451 }
452
453 /**
454 * Estimate the direction of the segments, given the first segment points in the
455 * direction <code>pInitialDirection</code>.
456 * Then sum up all horizontal / vertical segments to have a good guess for the
457 * heading of the entire way.
458 * @param pInitialDirection initial direction
459 * @throws InvalidUserInputException if selected ways have an angle different from 90 or 180 degrees
460 */
461 public void calcDirections(Direction pInitialDirection) throws InvalidUserInputException {
462 final EastNorth[] en = new EastNorth[nNode]; // alias: wayNodes.get(i).getEastNorth() ---> en[i]
463 for (int i = 0; i < nNode; i++) {
464 en[i] = wayNodes.get(i).getEastNorth();
465 }
466 Direction direction = pInitialDirection;
467 segDirections[0] = direction;
468 for (int i = 0; i < nSeg - 1; i++) {
469 double h1 = EN.polar(en[i], en[i+1]);
470 double h2 = EN.polar(en[i+1], en[i+2]);
471 try {
472 direction = direction.changeBy(angleToDirectionChange(h2 - h1, TOLERANCE1));
473 } catch (RejectedAngleException ex) {
474 throw new InvalidUserInputException(tr("Please select ways with angles of approximately 90 or 180 degrees."), ex);
475 }
476 segDirections[i+1] = direction;
477 }
478
479 // sum up segments
480 EastNorth h = new EastNorth(0., 0.);
481 EastNorth v = new EastNorth(0., 0.);
482 for (int i = 0; i < nSeg; ++i) {
483 EastNorth segment = EN.diff(en[i+1], en[i]);
484 if (segDirections[i] == Direction.RIGHT) {
485 h = EN.sum(h, segment);
486 } else if (segDirections[i] == Direction.UP) {
487 v = EN.sum(v, segment);
488 } else if (segDirections[i] == Direction.LEFT) {
489 h = EN.diff(h, segment);
490 } else if (segDirections[i] == Direction.DOWN) {
491 v = EN.diff(v, segment);
492 } else throw new IllegalStateException();
493 }
494 // rotate the vertical vector by 90 degrees (clockwise) and add it to the horizontal vector
495 segSum = EN.sum(h, new EastNorth(v.north(), -v.east()));
496 this.heading = EN.polar(new EastNorth(0., 0.), segSum);
497 }
498 }
499
500 enum Direction {
501 RIGHT, UP, LEFT, DOWN;
502 public Direction changeBy(int directionChange) {
503 int tmp = (this.ordinal() + directionChange) % 4;
504 if (tmp < 0) {
505 tmp += 4; // the % operator can return negative value
506 }
507 return Direction.values()[tmp];
508 }
509 }
510
511 /**
512 * Make sure angle (up to 2*Pi) is in interval [ 0, 2*Pi ).
513 * @param a angle
514 * @return correct angle
515 */
516 private static double standardAngle0to2PI(double a) {
517 while (a >= 2 * Math.PI) {
518 a -= 2 * Math.PI;
519 }
520 while (a < 0) {
521 a += 2 * Math.PI;
522 }
523 return a;
524 }
525
526 /**
527 * Make sure angle (up to 2*Pi) is in interval ( -Pi, Pi ].
528 * @param a angle
529 * @return correct angle
530 */
531 private static double standardAngleMPItoPI(double a) {
532 while (a > Math.PI) {
533 a -= 2 * Math.PI;
534 }
535 while (a <= -Math.PI) {
536 a += 2 * Math.PI;
537 }
538 return a;
539 }
540
541 /**
542 * Class contains some auxiliary functions
543 */
544 static final class EN {
545 private EN() {
546 // Hide implicit public constructor for utility class
547 }
548
549 /**
550 * Rotate counter-clock-wise.
551 * @param pivot pivot
552 * @param en original east/north
553 * @param angle angle, in radians
554 * @return new east/north
555 */
556 public static EastNorth rotateCC(EastNorth pivot, EastNorth en, double angle) {
557 double cosPhi = Math.cos(angle);
558 double sinPhi = Math.sin(angle);
559 double x = en.east() - pivot.east();
560 double y = en.north() - pivot.north();
561 double nx = cosPhi * x - sinPhi * y + pivot.east();
562 double ny = sinPhi * x + cosPhi * y + pivot.north();
563 return new EastNorth(nx, ny);
564 }
565
566 public static EastNorth sum(EastNorth en1, EastNorth en2) {
567 return new EastNorth(en1.east() + en2.east(), en1.north() + en2.north());
568 }
569
570 public static EastNorth diff(EastNorth en1, EastNorth en2) {
571 return new EastNorth(en1.east() - en2.east(), en1.north() - en2.north());
572 }
573
574 public static double polar(EastNorth en1, EastNorth en2) {
575 return Math.atan2(en2.north() - en1.north(), en2.east() - en1.east());
576 }
577 }
578
579 /**
580 * Recognize angle to be approximately 0, 90, 180 or 270 degrees.
581 * returns an integral value, corresponding to a counter clockwise turn.
582 * @param a angle, in radians
583 * @param deltaMax maximum tolerance, in radians
584 * @return an integral value, corresponding to a counter clockwise turn
585 * @throws RejectedAngleException in case of invalid angle
586 */
587 private static int angleToDirectionChange(double a, double deltaMax) throws RejectedAngleException {
588 a = standardAngleMPItoPI(a);
589 double d0 = Math.abs(a);
590 double d90 = Math.abs(a - Math.PI / 2);
591 double dm90 = Math.abs(a + Math.PI / 2);
592 int dirChange;
593 if (d0 < deltaMax) {
594 dirChange = 0;
595 } else if (d90 < deltaMax) {
596 dirChange = 1;
597 } else if (dm90 < deltaMax) {
598 dirChange = -1;
599 } else {
600 a = standardAngle0to2PI(a);
601 double d180 = Math.abs(a - Math.PI);
602 if (d180 < deltaMax) {
603 dirChange = 2;
604 } else
605 throw new RejectedAngleException();
606 }
607 return dirChange;
608 }
609
610 /**
611 * Exception: unsuited user input
612 */
613 protected static class InvalidUserInputException extends Exception {
614 InvalidUserInputException(String message) {
615 super(message);
616 }
617
618 InvalidUserInputException(String message, Throwable cause) {
619 super(message, cause);
620 }
621 }
622
623 /**
624 * Exception: angle cannot be recognized as 0, 90, 180 or 270 degrees
625 */
626 protected static class RejectedAngleException extends Exception {
627 RejectedAngleException() {
628 super();
629 }
630 }
631
632 @Override
633 protected void updateEnabledState() {
634 updateEnabledStateOnCurrentSelection();
635 }
636
637 @Override
638 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
639 setEnabled(selection != null && !selection.isEmpty());
640 }
641}
Note: See TracBrowser for help on using the repository browser.