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

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

see #15182 - deprecate Main.main.undoRedo. Replacement: gui.MainApplication.undoRedo

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