Ignore:
Timestamp:
2007-10-25T22:54:01+02:00 (19 years ago)
Author:
framm
Message:
  • added patch by Matthew Newton <matthew-osm@…> to merge nodes. I know there's already a merge nodes in the utils plugin but I guess we need the node merge in the core, as we already have merging and splitting ways there...
Location:
trunk/src/org/openstreetmap/josm/actions
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r402 r422  
    2929import org.openstreetmap.josm.gui.SelectionManager.SelectionEnded;
    3030import org.openstreetmap.josm.tools.ImageProvider;
     31import org.openstreetmap.josm.actions.MergeNodesAction;
    3132/**
    3233 * Move is an action that can move all kind of OsmPrimitives (except Keys for now).
     
    232233                }
    233234                restoreCursor();
     235    if (mode == Mode.move) {
     236                  boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0;
     237      if (ctrl) {
     238                    Collection<OsmPrimitive> selection = Main.ds.getSelected();
     239                    Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection);
     240                    Collection<Node> nn = Main.map.mapView.getNearestNodes(e.getPoint(), affectedNodes);
     241        if (nn != null) {
     242          Node n = nn.iterator().next();
     243          LinkedList<Node> selNodes = new LinkedList<Node>();
     244          for (OsmPrimitive osm : selection)
     245            if (osm instanceof Node)
     246              selNodes.add((Node)osm);
     247          if (selNodes.size() > 0) {
     248            selNodes.add(n);
     249            MergeNodesAction.mergeNodes(selNodes, n);
     250          }
     251        }
     252      }
     253    }
    234254                updateStatusLine();
    235255                mode = null;
     
    264284                        return "Release the mouse button to select the objects in the rectangle.";
    265285                } else if (mode == Mode.move) {
    266                         return "Release the mouse button to stop moving.";
     286                        return "Release the mouse button to stop moving. Ctrl to merge with nearest node.";
    267287                } else if (mode == Mode.rotate) {
    268288                        return "Release the mouse button to stop rotating.";
Note: See TracChangeset for help on using the changeset viewer.