001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.actions; 003 004import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 005import static org.openstreetmap.josm.tools.I18n.tr; 006 007import java.awt.event.ActionEvent; 008import java.awt.event.KeyEvent; 009import java.util.ArrayList; 010import java.util.Arrays; 011import java.util.Collection; 012import java.util.Collections; 013import java.util.HashMap; 014import java.util.HashSet; 015import java.util.Iterator; 016import java.util.LinkedList; 017import java.util.List; 018import java.util.Map; 019import java.util.Set; 020 021import javax.swing.JOptionPane; 022 023import org.openstreetmap.josm.Main; 024import org.openstreetmap.josm.command.Command; 025import org.openstreetmap.josm.command.MoveCommand; 026import org.openstreetmap.josm.command.SequenceCommand; 027import org.openstreetmap.josm.data.coor.EastNorth; 028import org.openstreetmap.josm.data.coor.PolarCoor; 029import org.openstreetmap.josm.data.osm.Node; 030import org.openstreetmap.josm.data.osm.OsmPrimitive; 031import org.openstreetmap.josm.data.osm.Way; 032import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 033import org.openstreetmap.josm.gui.MainApplication; 034import org.openstreetmap.josm.gui.Notification; 035import org.openstreetmap.josm.tools.JosmRuntimeException; 036import org.openstreetmap.josm.tools.Logging; 037import org.openstreetmap.josm.tools.Shortcut; 038import org.openstreetmap.josm.tools.Utils; 039 040/** 041 * Tools / Orthogonalize 042 * 043 * Align edges of a way so all angles are angles of 90 or 180 degrees. 044 * See USAGE String below. 045 */ 046public final class OrthogonalizeAction extends JosmAction { 047 private static final String USAGE = tr( 048 "<h3>When one or more ways are selected, the shape is adjusted such, that all angles are 90 or 180 degrees.</h3>"+ 049 "You can add two nodes to the selection. Then, the direction is fixed by these two reference nodes. "+ 050 "(Afterwards, you can undo the movement for certain nodes:<br>"+ 051 "Select them and press the shortcut for Orthogonalize / Undo. The default is Shift-Q.)"); 052 053 private static final double EPSILON = 1E-6; 054 055 /** 056 * Constructs a new {@code OrthogonalizeAction}. 057 */ 058 public OrthogonalizeAction() { 059 super(tr("Orthogonalize Shape"), 060 "ortho", 061 tr("Move nodes so all angles are 90 or 180 degrees"), 062 Shortcut.registerShortcut("tools:orthogonalize", tr("Tool: {0}", tr("Orthogonalize Shape")), 063 KeyEvent.VK_Q, 064 Shortcut.DIRECT), true); 065 putValue("help", ht("/Action/OrthogonalizeShape")); 066 } 067 068 /** 069 * excepted deviation from an angle of 0, 90, 180, 360 degrees 070 * maximum value: 45 degrees 071 * 072 * Current policy is to except just everything, no matter how strange the result would be. 073 */ 074 private static final double TOLERANCE1 = Utils.toRadians(45.); // within a way 075 private static final double TOLERANCE2 = Utils.toRadians(45.); // ways relative to each other 076 077 /** 078 * Remember movements, so the user can later undo it for certain nodes 079 */ 080 private static final Map<Node, EastNorth> rememberMovements = new HashMap<>(); 081 082 /** 083 * Undo the previous orthogonalization for certain nodes. 084 * 085 * This is useful, if the way shares nodes that you don't like to change, e.g. imports or 086 * work of another user. 087 * 088 * This action can be triggered by shortcut only. 089 */ 090 public static class Undo extends JosmAction { 091 /** 092 * Constructor 093 */ 094 public Undo() { 095 super(tr("Orthogonalize Shape / Undo"), "ortho", 096 tr("Undo orthogonalization for certain nodes"), 097 Shortcut.registerShortcut("tools:orthogonalizeUndo", tr("Tool: {0}", tr("Orthogonalize Shape / Undo")), 098 KeyEvent.VK_Q, 099 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 updateEnabledStateOnModifiableSelection(selection); 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 * @since 13670 191 */ 192 public static SequenceCommand orthogonalize(Iterable<OsmPrimitive> selection) throws InvalidUserInputException { 193 final List<Node> nodeList = new ArrayList<>(); 194 final List<WayData> wayDataList = new ArrayList<>(); 195 // collect nodes and ways from the selection 196 for (OsmPrimitive p : selection) { 197 if (p instanceof Node) { 198 nodeList.add((Node) p); 199 } else if (p instanceof Way) { 200 if (!p.isIncomplete()) { 201 wayDataList.add(new WayData(((Way) p).getNodes())); 202 } 203 } else { 204 throw new InvalidUserInputException(tr("Selection must consist only of ways and nodes.")); 205 } 206 } 207 if (wayDataList.isEmpty() && nodeList.size() > 2) { 208 final WayData data = new WayData(nodeList); 209 final Collection<Command> commands = orthogonalize(Collections.singletonList(data), Collections.<Node>emptyList()); 210 return new SequenceCommand(tr("Orthogonalize"), commands); 211 } else if (wayDataList.isEmpty()) { 212 throw new InvalidUserInputException("usage"); 213 } else { 214 if (nodeList.size() == 2 || nodeList.isEmpty()) { 215 OrthogonalizeAction.rememberMovements.clear(); 216 final Collection<Command> commands = new LinkedList<>(); 217 218 if (nodeList.size() == 2) { // fixed direction 219 commands.addAll(orthogonalize(wayDataList, nodeList)); 220 } else if (nodeList.isEmpty()) { 221 List<List<WayData>> groups = buildGroups(wayDataList); 222 for (List<WayData> g: groups) { 223 commands.addAll(orthogonalize(g, nodeList)); 224 } 225 } else { 226 throw new IllegalStateException(); 227 } 228 229 return new SequenceCommand(tr("Orthogonalize"), commands); 230 231 } else { 232 throw new InvalidUserInputException("usage"); 233 } 234 } 235 } 236 237 /** 238 * Collect groups of ways with common nodes in order to orthogonalize each group separately. 239 * @param wayDataList list of ways 240 * @return groups of ways with common nodes 241 */ 242 private static List<List<WayData>> buildGroups(List<WayData> wayDataList) { 243 List<List<WayData>> groups = new ArrayList<>(); 244 Set<WayData> remaining = new HashSet<>(wayDataList); 245 while (!remaining.isEmpty()) { 246 List<WayData> group = new ArrayList<>(); 247 groups.add(group); 248 Iterator<WayData> it = remaining.iterator(); 249 WayData next = it.next(); 250 it.remove(); 251 extendGroupRec(group, next, new ArrayList<>(remaining)); 252 remaining.removeAll(group); 253 } 254 return groups; 255 } 256 257 private static void extendGroupRec(List<WayData> group, WayData newGroupMember, List<WayData> remaining) { 258 group.add(newGroupMember); 259 for (int i = 0; i < remaining.size(); ++i) { 260 WayData candidate = remaining.get(i); 261 if (candidate == null) continue; 262 if (!Collections.disjoint(candidate.wayNodes, newGroupMember.wayNodes)) { 263 remaining.set(i, null); 264 extendGroupRec(group, candidate, remaining); 265 } 266 } 267 } 268 269 /** 270 * 271 * Outline: 272 * 1. Find direction of all segments 273 * - direction = 0..3 (right,up,left,down) 274 * - right is not really right, you may have to turn your screen 275 * 2. Find average heading of all segments 276 * - heading = angle of a vector in polar coordinates 277 * - sum up horizontal segments (those with direction 0 or 2) 278 * - sum up vertical segments 279 * - turn the vertical sum by 90 degrees and add it to the horizontal sum 280 * - get the average heading from this total sum 281 * 3. Rotate all nodes by the average heading so that right is really right 282 * and all segments are approximately NS or EW. 283 * 4. If nodes are connected by a horizontal segment: Replace their y-Coordinate by 284 * the mean value of their y-Coordinates. 285 * - The same for vertical segments. 286 * 5. Rotate back. 287 * @param wayDataList list of ways 288 * @param headingNodes list of heading nodes 289 * @return list of commands to perform 290 * @throws InvalidUserInputException if selected ways have an angle different from 90 or 180 degrees 291 **/ 292 private static Collection<Command> orthogonalize(List<WayData> wayDataList, List<Node> headingNodes) throws InvalidUserInputException { 293 // find average heading 294 double headingAll; 295 try { 296 if (headingNodes.isEmpty()) { 297 // find directions of the segments and make them consistent between different ways 298 wayDataList.get(0).calcDirections(Direction.RIGHT); 299 double refHeading = wayDataList.get(0).heading; 300 EastNorth totSum = new EastNorth(0., 0.); 301 for (WayData w : wayDataList) { 302 w.calcDirections(Direction.RIGHT); 303 int directionOffset = angleToDirectionChange(w.heading - refHeading, TOLERANCE2); 304 w.calcDirections(Direction.RIGHT.changeBy(directionOffset)); 305 if (angleToDirectionChange(refHeading - w.heading, TOLERANCE2) != 0) 306 throw new JosmRuntimeException("orthogonalize error"); 307 totSum = EN.sum(totSum, w.segSum); 308 } 309 headingAll = EN.polar(new EastNorth(0., 0.), totSum); 310 } else { 311 headingAll = EN.polar(headingNodes.get(0).getEastNorth(), headingNodes.get(1).getEastNorth()); 312 for (WayData w : wayDataList) { 313 w.calcDirections(Direction.RIGHT); 314 int directionOffset = angleToDirectionChange(w.heading - headingAll, TOLERANCE2); 315 w.calcDirections(Direction.RIGHT.changeBy(directionOffset)); 316 } 317 } 318 } catch (RejectedAngleException ex) { 319 throw new InvalidUserInputException( 320 tr("<html>Please make sure all selected ways head in a similar direction<br>"+ 321 "or orthogonalize them one by one.</html>"), ex); 322 } 323 324 // put the nodes of all ways in a set 325 final Set<Node> allNodes = new HashSet<>(); 326 for (WayData w : wayDataList) { 327 allNodes.addAll(w.wayNodes); 328 } 329 330 // the new x and y value for each node 331 final Map<Node, Double> nX = new HashMap<>(); 332 final Map<Node, Double> nY = new HashMap<>(); 333 334 // calculate the centroid of all nodes 335 // it is used as rotation center 336 EastNorth pivot = new EastNorth(0., 0.); 337 for (Node n : allNodes) { 338 pivot = EN.sum(pivot, n.getEastNorth()); 339 } 340 pivot = new EastNorth(pivot.east() / allNodes.size(), pivot.north() / allNodes.size()); 341 342 // rotate 343 for (Node n: allNodes) { 344 EastNorth tmp = EN.rotateCC(pivot, n.getEastNorth(), -headingAll); 345 nX.put(n, tmp.east()); 346 nY.put(n, tmp.north()); 347 } 348 349 // orthogonalize 350 final Direction[] horizontal = {Direction.RIGHT, Direction.LEFT}; 351 final Direction[] vertical = {Direction.UP, Direction.DOWN}; 352 final Direction[][] orientations = {horizontal, vertical}; 353 for (Direction[] orientation : orientations) { 354 final Set<Node> s = new HashSet<>(allNodes); 355 int size = s.size(); 356 for (int dummy = 0; dummy < size; ++dummy) { 357 if (s.isEmpty()) { 358 break; 359 } 360 final Node dummyN = s.iterator().next(); // pick arbitrary element of s 361 362 final Set<Node> cs = new HashSet<>(); // will contain each node that can be reached from dummyN 363 cs.add(dummyN); // walking only on horizontal / vertical segments 364 365 boolean somethingHappened = true; 366 while (somethingHappened) { 367 somethingHappened = false; 368 for (WayData w : wayDataList) { 369 for (int i = 0; i < w.nSeg; ++i) { 370 Node n1 = w.wayNodes.get(i); 371 Node n2 = w.wayNodes.get(i+1); 372 if (Arrays.asList(orientation).contains(w.segDirections[i])) { 373 if (cs.contains(n1) && !cs.contains(n2)) { 374 cs.add(n2); 375 somethingHappened = true; 376 } 377 if (cs.contains(n2) && !cs.contains(n1)) { 378 cs.add(n1); 379 somethingHappened = true; 380 } 381 } 382 } 383 } 384 } 385 386 final Map<Node, Double> nC = (orientation == horizontal) ? nY : nX; 387 388 double average = 0; 389 for (Node n : cs) { 390 s.remove(n); 391 average += nC.get(n).doubleValue(); 392 } 393 average = average / cs.size(); 394 395 // if one of the nodes is a heading node, forget about the average and use its value 396 for (Node fn : headingNodes) { 397 if (cs.contains(fn)) { 398 average = nC.get(fn); 399 } 400 } 401 402 // At this point, the two heading nodes (if any) are horizontally aligned, i.e. they 403 // have the same y coordinate. So in general we shouldn't find them in a vertical string 404 // of segments. This can still happen in some pathological cases (see #7889). To avoid 405 // both heading nodes collapsing to one point, we simply skip this segment string and 406 // don't touch the node coordinates. 407 if (orientation == vertical && headingNodes.size() == 2 && cs.containsAll(headingNodes)) { 408 continue; 409 } 410 411 for (Node n : cs) { 412 nC.put(n, average); 413 } 414 } 415 if (!s.isEmpty()) throw new JosmRuntimeException("orthogonalize error"); 416 } 417 418 // rotate back and log the change 419 final Collection<Command> commands = new LinkedList<>(); 420 for (Node n: allNodes) { 421 EastNorth tmp = new EastNorth(nX.get(n), nY.get(n)); 422 tmp = EN.rotateCC(pivot, tmp, headingAll); 423 final double dx = tmp.east() - n.getEastNorth().east(); 424 final double dy = tmp.north() - n.getEastNorth().north(); 425 if (headingNodes.contains(n)) { // The heading nodes should not have changed 426 if (Math.abs(dx) > Math.abs(EPSILON * tmp.east()) || 427 Math.abs(dy) > Math.abs(EPSILON * tmp.east())) 428 throw new AssertionError("heading node has changed"); 429 } else { 430 OrthogonalizeAction.rememberMovements.put(n, new EastNorth(dx, dy)); 431 commands.add(new MoveCommand(n, dx, dy)); 432 } 433 } 434 return commands; 435 } 436 437 /** 438 * Class contains everything we need to know about a single way. 439 */ 440 private static class WayData { 441 /** The assigned way */ 442 public final List<Node> wayNodes; 443 /** Number of Segments of the Way */ 444 public final int nSeg; 445 /** Number of Nodes of the Way */ 446 public final int nNode; 447 /** Direction of the segments */ 448 public final Direction[] segDirections; 449 // segment i goes from node i to node (i+1) 450 /** (Vector-)sum of all horizontal segments plus the sum of all vertical */ 451 public EastNorth segSum; 452 // segments turned by 90 degrees 453 /** heading of segSum == approximate heading of the way */ 454 public double heading; 455 456 WayData(List<Node> wayNodes) { 457 this.wayNodes = wayNodes; 458 this.nNode = wayNodes.size(); 459 this.nSeg = nNode - 1; 460 this.segDirections = new Direction[nSeg]; 461 } 462 463 /** 464 * Estimate the direction of the segments, given the first segment points in the 465 * direction <code>pInitialDirection</code>. 466 * Then sum up all horizontal / vertical segments to have a good guess for the 467 * heading of the entire way. 468 * @param pInitialDirection initial direction 469 * @throws InvalidUserInputException if selected ways have an angle different from 90 or 180 degrees 470 */ 471 public void calcDirections(Direction pInitialDirection) throws InvalidUserInputException { 472 final EastNorth[] en = new EastNorth[nNode]; // alias: wayNodes.get(i).getEastNorth() ---> en[i] 473 for (int i = 0; i < nNode; i++) { 474 en[i] = wayNodes.get(i).getEastNorth(); 475 } 476 Direction direction = pInitialDirection; 477 segDirections[0] = direction; 478 for (int i = 0; i < nSeg - 1; i++) { 479 double h1 = EN.polar(en[i], en[i+1]); 480 double h2 = EN.polar(en[i+1], en[i+2]); 481 try { 482 direction = direction.changeBy(angleToDirectionChange(h2 - h1, TOLERANCE1)); 483 } catch (RejectedAngleException ex) { 484 throw new InvalidUserInputException(tr("Please select ways with angles of approximately 90 or 180 degrees."), ex); 485 } 486 segDirections[i+1] = direction; 487 } 488 489 // sum up segments 490 EastNorth h = new EastNorth(0., 0.); 491 EastNorth v = new EastNorth(0., 0.); 492 for (int i = 0; i < nSeg; ++i) { 493 EastNorth segment = EN.diff(en[i+1], en[i]); 494 if (segDirections[i] == Direction.RIGHT) { 495 h = EN.sum(h, segment); 496 } else if (segDirections[i] == Direction.UP) { 497 v = EN.sum(v, segment); 498 } else if (segDirections[i] == Direction.LEFT) { 499 h = EN.diff(h, segment); 500 } else if (segDirections[i] == Direction.DOWN) { 501 v = EN.diff(v, segment); 502 } else throw new IllegalStateException(); 503 } 504 // rotate the vertical vector by 90 degrees (clockwise) and add it to the horizontal vector 505 segSum = EN.sum(h, new EastNorth(v.north(), -v.east())); 506 this.heading = EN.polar(new EastNorth(0., 0.), segSum); 507 } 508 } 509 510 enum Direction { 511 RIGHT, UP, LEFT, DOWN; 512 public Direction changeBy(int directionChange) { 513 int tmp = (this.ordinal() + directionChange) % 4; 514 if (tmp < 0) { 515 tmp += 4; // the % operator can return negative value 516 } 517 return Direction.values()[tmp]; 518 } 519 } 520 521 /** 522 * Make sure angle (up to 2*Pi) is in interval [ 0, 2*Pi ). 523 * @param a angle 524 * @return correct angle 525 */ 526 private static double standardAngle0to2PI(double a) { 527 while (a >= 2 * Math.PI) { 528 a -= 2 * Math.PI; 529 } 530 while (a < 0) { 531 a += 2 * Math.PI; 532 } 533 return a; 534 } 535 536 /** 537 * Make sure angle (up to 2*Pi) is in interval ( -Pi, Pi ]. 538 * @param a angle 539 * @return correct angle 540 */ 541 private static double standardAngleMPItoPI(double a) { 542 while (a > Math.PI) { 543 a -= 2 * Math.PI; 544 } 545 while (a <= -Math.PI) { 546 a += 2 * Math.PI; 547 } 548 return a; 549 } 550 551 /** 552 * Class contains some auxiliary functions 553 */ 554 static final class EN { 555 private EN() { 556 // Hide implicit public constructor for utility class 557 } 558 559 /** 560 * Rotate counter-clock-wise. 561 * @param pivot pivot 562 * @param en original east/north 563 * @param angle angle, in radians 564 * @return new east/north 565 */ 566 public static EastNorth rotateCC(EastNorth pivot, EastNorth en, double angle) { 567 double cosPhi = Math.cos(angle); 568 double sinPhi = Math.sin(angle); 569 double x = en.east() - pivot.east(); 570 double y = en.north() - pivot.north(); 571 double nx = cosPhi * x - sinPhi * y + pivot.east(); 572 double ny = sinPhi * x + cosPhi * y + pivot.north(); 573 return new EastNorth(nx, ny); 574 } 575 576 public static EastNorth sum(EastNorth en1, EastNorth en2) { 577 return new EastNorth(en1.east() + en2.east(), en1.north() + en2.north()); 578 } 579 580 public static EastNorth diff(EastNorth en1, EastNorth en2) { 581 return new EastNorth(en1.east() - en2.east(), en1.north() - en2.north()); 582 } 583 584 public static double polar(EastNorth en1, EastNorth en2) { 585 return PolarCoor.computeAngle(en2, en1); 586 } 587 } 588 589 /** 590 * Recognize angle to be approximately 0, 90, 180 or 270 degrees. 591 * returns an integral value, corresponding to a counter clockwise turn. 592 * @param a angle, in radians 593 * @param deltaMax maximum tolerance, in radians 594 * @return an integral value, corresponding to a counter clockwise turn 595 * @throws RejectedAngleException in case of invalid angle 596 */ 597 private static int angleToDirectionChange(double a, double deltaMax) throws RejectedAngleException { 598 a = standardAngleMPItoPI(a); 599 double d0 = Math.abs(a); 600 double d90 = Math.abs(a - Math.PI / 2); 601 double dm90 = Math.abs(a + Math.PI / 2); 602 int dirChange; 603 if (d0 < deltaMax) { 604 dirChange = 0; 605 } else if (d90 < deltaMax) { 606 dirChange = 1; 607 } else if (dm90 < deltaMax) { 608 dirChange = -1; 609 } else { 610 a = standardAngle0to2PI(a); 611 double d180 = Math.abs(a - Math.PI); 612 if (d180 < deltaMax) { 613 dirChange = 2; 614 } else 615 throw new RejectedAngleException(); 616 } 617 return dirChange; 618 } 619 620 /** 621 * Exception: unsuited user input 622 * @since 13670 623 */ 624 public static final class InvalidUserInputException extends Exception { 625 InvalidUserInputException(String message) { 626 super(message); 627 } 628 629 InvalidUserInputException(String message, Throwable cause) { 630 super(message, cause); 631 } 632 } 633 634 /** 635 * Exception: angle cannot be recognized as 0, 90, 180 or 270 degrees 636 */ 637 protected static class RejectedAngleException extends Exception { 638 RejectedAngleException() { 639 super(); 640 } 641 } 642 643 @Override 644 protected void updateEnabledState() { 645 updateEnabledStateOnCurrentSelection(); 646 } 647 648 @Override 649 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 650 updateEnabledStateOnModifiableSelection(selection); 651 } 652}