Changeset 422 in josm for trunk/src/org
- Timestamp:
- 2007-10-25T22:54:01+02:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r402 r422 29 29 import org.openstreetmap.josm.gui.SelectionManager.SelectionEnded; 30 30 import org.openstreetmap.josm.tools.ImageProvider; 31 import org.openstreetmap.josm.actions.MergeNodesAction; 31 32 /** 32 33 * Move is an action that can move all kind of OsmPrimitives (except Keys for now). … … 232 233 } 233 234 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 } 234 254 updateStatusLine(); 235 255 mode = null; … … 264 284 return "Release the mouse button to select the objects in the rectangle."; 265 285 } 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."; 267 287 } else if (mode == Mode.rotate) { 268 288 return "Release the mouse button to stop rotating."; -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r420 r422 23 23 import org.openstreetmap.josm.actions.GpxExportAction; 24 24 import org.openstreetmap.josm.actions.HelpAction; 25 import org.openstreetmap.josm.actions.MergeNodesAction; 25 26 import org.openstreetmap.josm.actions.NewAction; 26 27 import org.openstreetmap.josm.actions.OpenAction; … … 65 66 public final Action alignInCircle = new AlignInCircleAction(); 66 67 public final Action alignInLine = new AlignInLineAction(); 68 public final Action mergeNodes = new MergeNodesAction(); 67 69 public final Action upload = new UploadAction(); 68 70 public final Action save = new SaveAction(null); … … 129 131 toolsMenu.add(splitWay); 130 132 toolsMenu.add(combineWay); 133 toolsMenu.addSeparator(); 134 toolsMenu.add(mergeNodes); 131 135 add(toolsMenu); 132 136 -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r407 r422 291 291 292 292 /** 293 * @return A list of all nodes that are nearest to 294 * the mouse. Does a simple sequential scan on all the data. 295 * 296 * @return A collection of all nodes or <code>null</code> 297 * if no node under or near the point. The returned 298 * list is never empty. 299 */ 300 public Collection<Node> getNearestNodes(Point p) { 301 Collection<Node> nearest = new HashSet<Node>(); 302 for (Node n : Main.ds.nodes) { 303 if (!n.deleted && !n.incomplete 304 && getPoint(n.eastNorth).distanceSq(p) < 100) { 305 nearest.add(n); 306 } 307 } 308 return nearest.isEmpty() ? null : nearest; 309 } 310 311 /** 312 * @return the nearest nodes to the screen point given that is not 313 * in ignore. 314 * 315 * @param p the point for which to search the nearest segment. 316 * @param ignore a collection of nodes which are not to be returned. 317 * May be null. 318 */ 319 public final Collection<Node> getNearestNodes(Point p, Collection<Node> ignore) { 320 Collection<Node> nearest = getNearestNodes(p); 321 if (nearest == null) return null; 322 if (ignore != null) nearest.removeAll(ignore); 323 return nearest.isEmpty() ? null : nearest; 324 } 325 326 /** 293 327 * @return The projection to be used in calculating stuff. 294 328 */
Note:
See TracChangeset
for help on using the changeset viewer.