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

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

sonar - squid:S00112 - Generic exceptions should never be thrown: define JosmRuntimeException

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