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

Last change on this file since 13252 was 13123, checked in by Don-vip, 6 years ago

javadoc

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