Changeset 27474 in osm for applications/editors/josm/plugins/ImproveWayAccuracy
- Timestamp:
- 2012-01-16T05:49:42+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ImproveWayAccuracy/src/org/openstreetmap/josm/plugins/iwa/IWAMode.java
r26610 r27474 26 26 import java.util.ArrayList; 27 27 import java.util.Collection; 28 import java.util.Iterator; 28 29 import java.util.LinkedList; 29 30 import java.util.List; 31 import java.util.Map; 30 32 31 33 import javax.swing.JOptionPane; … … 36 38 import org.openstreetmap.josm.command.ChangeCommand; 37 39 import org.openstreetmap.josm.command.Command; 40 import org.openstreetmap.josm.command.DeleteCommand; 38 41 import org.openstreetmap.josm.command.MoveCommand; 39 42 import org.openstreetmap.josm.command.SequenceCommand; … … 80 83 final private Cursor cursorImprove; 81 84 final private Cursor cursorImproveAdd; 85 final private Cursor cursorImproveDelete; 82 86 final private Cursor cursorImproveAddLock; 83 87 final private Cursor cursorImproveLock; … … 85 89 private boolean shift = false; 86 90 private boolean ctrl = false; 87 private boolean oldShift = false; 88 private boolean oldCtrl = false; 91 private boolean alt = false; 89 92 90 93 private final Color guideColor; … … 108 111 cursorSelectHover = ImageProvider.getCursor("hand", "mode"); 109 112 cursorImprove = ImageProvider.getCursor("crosshair", null); 110 cursorImproveAdd = ImageProvider.getCursor("crosshair", "add_node"); 113 cursorImproveAdd = ImageProvider.getCursor("crosshair", "addnode"); 114 cursorImproveDelete = ImageProvider.getCursor("crosshair", "delete_node"); 111 115 cursorImproveAddLock = ImageProvider.getCursor("crosshair", 112 116 "add_node_lock"); … … 355 359 } 356 360 357 if (ctrl && candidateSegment != null) {361 if (ctrl && !alt && candidateSegment != null) { 358 362 // Adding a new node to the highlighted segment 359 363 // Important: If there are other ways containing the same … … 413 417 Main.main.undoRedo.add(new SequenceCommand(text, virtualCmds)); 414 418 419 } else if(alt && ctrl && candidateNode != null) { 420 421 //check to see if node has interesting keys 422 Iterator<String> keyIterator = candidateNode.getKeys().keySet().iterator(); 423 boolean hasTags = false; 424 while(keyIterator.hasNext()) { 425 String key = keyIterator.next(); 426 if(!OsmPrimitive.isUninterestingKey(key)) { 427 hasTags = true; 428 break; 429 } 430 } 431 432 //check to see if node is in use by more than one object 433 List<OsmPrimitive> referrers = candidateNode.getReferrers(); 434 List<Way> ways = OsmPrimitive.getFilteredList(referrers, Way.class); 435 if(referrers.size() != 1 || ways.size() != 1) { 436 JOptionPane.showMessageDialog(Main.parent, 437 tr("Cannot delete node that is referenced by multiple objects"), 438 tr("Error"), JOptionPane.ERROR_MESSAGE); 439 } 440 else if(hasTags) { 441 JOptionPane.showMessageDialog(Main.parent, 442 tr("Cannot delete node that has tags"), 443 tr("Error"), JOptionPane.ERROR_MESSAGE); 444 } 445 else { 446 List<Node> nodeList = new ArrayList<Node>(); 447 nodeList.add(candidateNode); 448 Command deleteCmd = DeleteCommand.delete(getEditLayer(), nodeList, true); 449 Main.main.undoRedo.add(deleteCmd); 450 } 451 452 415 453 } else if (candidateNode != null) { 416 454 // Moving the highlighted node … … 450 488 @Override 451 489 protected void updateKeyModifiers(InputEvent e) { 452 oldCtrl = ctrl;453 oldShift = shift;454 490 ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 455 491 shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; 492 alt = (e.getModifiers() & ActionEvent.ALT_MASK) != 0; 456 493 } 457 494 … … 469 506 : cursorSelectHover, this); 470 507 } else if (state == State.improving) { 471 mv.setNewCursor(ctrl ? (shift || dragging ? cursorImproveAddLock 472 : cursorImproveAdd) 473 : (shift || dragging ? cursorImproveLock : cursorImprove), 474 this); 508 if(alt && ctrl) { 509 mv.setNewCursor(cursorImproveDelete, this); 510 } else if(shift || dragging) { 511 if(ctrl) { 512 mv.setNewCursor(cursorImproveAddLock, this); 513 } else { 514 mv.setNewCursor(cursorImproveLock, this); 515 } 516 } 517 else if(ctrl && !alt){ 518 mv.setNewCursor(cursorImproveAdd, this); 519 } 520 else { 521 mv.setNewCursor(cursorImprove, this); 522 } 475 523 } 476 524 } … … 482 530 public void updateCursorDependentObjectsIfNeeded() { 483 531 if (state == State.improving && (shift || dragging) 484 && (ctrl == oldCtrl)485 532 && !(candidateNode == null && candidateSegment == null)) 486 533 return; … … 495 542 targetWay = IWATargetWayHelper.findWay(mv, mousePos); 496 543 } else if (state == State.improving) { 497 if (ctrl ) {544 if (ctrl && !alt) { 498 545 candidateSegment = IWATargetWayHelper.findCandidateSegment(mv, 499 546 targetWay, mousePos);
Note:
See TracChangeset
for help on using the changeset viewer.