Ticket #19061: 19061.patch
| File 19061.patch, 51.5 KB (added by , 6 years ago) |
|---|
-
.classpath
27 27 <attribute name="test" value="true"/> 28 28 </attributes> 29 29 </classpathentry> 30 <classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=JOSM&ivyXmlPath=ivy.xml&confs=*&ivySettingsPath=ivysettings.xml&loadSettingsOnDemand=false&ivyUserDir=&propertyFiles="/>30 <classpathentry exported="true" kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=JOSM&ivyXmlPath=ivy.xml&confs=*&ivySettingsPath=ivysettings.xml&loadSettingsOnDemand=false&ivyUserDir=&propertyFiles="/> 31 31 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> 32 32 <attributes> 33 33 <attribute name="module" value="true"/> -
josm-latest.jnlp
3 3 <jnlp spec="6.0+" codebase="https://josm.openstreetmap.de/download/" href="josm-latest.jnlp"> 4 4 <information> 5 5 <title>JOSM (development version)</title> 6 <vendor>OpenStreetMap</vendor> 7 <homepage href="https://josm.openstreetmap.de"/> 6 <vendor>OpenStreetMap</vendor> 7 <homepage href="https://josm.openstreetmap.de"/> 8 8 <description>Java OpenStreetMap editor</description> 9 9 <description kind="one-line">JOSM</description> 10 10 <description kind="tooltip">JOSM</description> … … 20 20 <all-permissions/> 21 21 </security> 22 22 <resources> 23 <java version="1.8+" max-heap-size="2048m" java-vm-args="--add-modules=java.scripting,java.sql --add-exports=java.desktop/com.apple.eawt=ALL-UNNAMED --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED --add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED --add-exports=jdk.deploy/com.sun.deploy.config=ALL-UNNAMED --add-opens=j ava.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.desktop/javax.imageio.spi=ALL-UNNAMED --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED"/>23 <java version="1.8+" max-heap-size="2048m" java-vm-args="--add-modules=java.scripting,java.sql --add-exports=java.desktop/com.apple.eawt=ALL-UNNAMED --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED --add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED --add-exports=jdk.deploy/com.sun.deploy.config=ALL-UNNAMED --add-opens=jdk.swing.interop=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.desktop/javax.imageio.spi=ALL-UNNAMED --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED"/> 24 24 <jar href="josm-latest.jar"/> 25 25 <property name="java.util.Arrays.useLegacyMergeSort" value="true"/> 26 26 </resources> -
src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
11 11 import java.awt.event.KeyEvent; 12 12 import java.awt.event.MouseEvent; 13 13 import java.awt.geom.Point2D; 14 import java.util.ArrayList; 14 15 import java.util.Collection; 15 16 import java.util.Collections; 16 17 import java.util.HashSet; … … 32 33 import org.openstreetmap.josm.data.UndoRedoHandler; 33 34 import org.openstreetmap.josm.data.coor.EastNorth; 34 35 import org.openstreetmap.josm.data.osm.DataSet; 35 import org.openstreetmap.josm.data.osm.Node; 36 import org.openstreetmap.josm.data.osm.INode; 37 import org.openstreetmap.josm.data.osm.IPrimitive; 38 import org.openstreetmap.josm.data.osm.IWay; 36 39 import org.openstreetmap.josm.data.osm.OsmData; 37 40 import org.openstreetmap.josm.data.osm.OsmPrimitive; 38 41 import org.openstreetmap.josm.data.osm.Way; … … 183 186 * to remove the highlight from them again as otherwise the whole data 184 187 * set would have to be checked. 185 188 */ 186 private transient Optional< OsmPrimitive> currentHighlight = Optional.empty();189 private transient Optional<IPrimitive> currentHighlight = Optional.empty(); 187 190 188 191 /** 189 192 * Create a new SelectAction … … 257 260 * @return {@code true} if repaint is required 258 261 */ 259 262 private boolean giveUserFeedback(MouseEvent e, int modifiers) { 260 Optional< OsmPrimitive> c = Optional.ofNullable(263 Optional<IPrimitive> c = Optional.ofNullable( 261 264 mv.getNearestNodeOrWay(e.getPoint(), mv.isSelectablePredicate, true)); 262 265 263 266 updateKeyModifiersEx(modifiers); 264 267 determineMapMode(c.isPresent()); 265 268 266 Optional< OsmPrimitive> newHighlight = Optional.empty();269 Optional<IPrimitive> newHighlight = Optional.empty(); 267 270 268 271 virtualManager.clear(); 269 272 if (mode == Mode.MOVE && !dragInProgress() && virtualManager.activateVirtualNodeNearPoint(e.getPoint())) { … … 300 303 * @param nearbyStuff primitives near the cursor 301 304 * @return the cursor that should be displayed 302 305 */ 303 private Cursor getCursor( OsmPrimitive nearbyStuff) {306 private Cursor getCursor(IPrimitive nearbyStuff) { 304 307 String c = "rect"; 305 308 switch(mode) { 306 309 case MOVE: … … 308 311 c = "virtual_node"; 309 312 break; 310 313 } 311 final OsmPrimitive osm = nearbyStuff;314 final IPrimitive osm = nearbyStuff; 312 315 313 316 if (dragInProgress()) { 314 317 // only consider merge if ctrl is pressed and there are nodes in … … 319 322 } 320 323 // only show merge to node cursor if nearby node and that node is currently 321 324 // not being dragged 322 final boolean hasTarget = osm instanceof Node && !osm.isSelected();325 final boolean hasTarget = osm instanceof INode && !osm.isSelected(); 323 326 c = hasTarget ? "merge_to_node" : "merge"; 324 327 break; 325 328 } 326 329 327 c = (osm instanceof Node) ? "node" : c;328 c = (osm instanceof Way) ? "way" : c;330 c = (osm instanceof INode) ? "node" : c; 331 c = (osm instanceof IWay) ? "way" : c; 329 332 if (shift) { 330 333 c += "_add"; 331 334 } else if (ctrl) { … … 369 372 return true; 370 373 } 371 374 372 private boolean repaintIfRequired(Optional< OsmPrimitive> newHighlight) {375 private boolean repaintIfRequired(Optional<IPrimitive> newHighlight) { 373 376 if (!drawTargetHighlight || currentHighlight.equals(newHighlight)) 374 377 return false; 375 378 currentHighlight.ifPresent(osm -> osm.setHighlighted(false)); … … 413 416 414 417 // primitives under cursor are stored in c collection 415 418 416 OsmPrimitive nearestPrimitive = mv.getNearestNodeOrWay(e.getPoint(), mv.isSelectablePredicate, true);419 IPrimitive nearestPrimitive = mv.getNearestNodeOrWay(e.getPoint(), mv.isSelectablePredicate, true); 417 420 418 421 determineMapMode(nearestPrimitive != null); 419 422 … … 437 440 if (!cancelDrawMode && nearestPrimitive instanceof Way) { 438 441 virtualManager.activateVirtualNodeNearPoint(e.getPoint()); 439 442 } 440 OsmPrimitive toSelect = cycleManager.cycleSetup(nearestPrimitive, e.getPoint());443 IPrimitive toSelect = cycleManager.cycleSetup(nearestPrimitive, e.getPoint()); 441 444 selectPrims(asColl(toSelect), false, false); 442 445 useLastMoveCommandIfPossible(); 443 446 // Schedule a timer to update status line "initialMoveDelay+1" ms in the future … … 510 513 // If ctrl is pressed we are in merge mode. Look for a nearby node, 511 514 // highlight it and adjust the cursor accordingly. 512 515 final boolean canMerge = ctrl && !getLayerManager().getEditDataSet().getSelectedNodes().isEmpty(); 513 final OsmPrimitive p = canMerge ? findNodeToMergeTo(e.getPoint()) : null;516 final IPrimitive p = canMerge ? findNodeToMergeTo(e.getPoint()) : null; 514 517 boolean needsRepaint = removeHighlighting(); 515 518 if (p != null) { 516 519 p.setHighlighted(true); … … 603 606 selectPrims(cycleManager.cyclePrims(), true, false); 604 607 605 608 // If the user double-clicked a node, change to draw mode 606 Collection< OsmPrimitive> c = ds.getSelected();607 if (e.getClickCount() >= 2 && c.size() == 1 && c.iterator().next() instanceof Node) {609 Collection<IPrimitive> c = new ArrayList<>(ds.getSelected()); 610 if (e.getClickCount() >= 2 && c.size() == 1 && c.iterator().next() instanceof INode) { 608 611 // We need to do it like this as otherwise drawAction will see a double 609 612 // click and switch back to SelectMode 610 613 MainApplication.worker.execute(() -> map.selectDrawTool(true)); … … 698 701 // Currently we support only transformations which do not affect relations. 699 702 // So don't add them in the first place to make handling easier 700 703 DataSet ds = getLayerManager().getEditDataSet(); 701 Collection< OsmPrimitive> selection = ds.getSelectedNodesAndWays();704 Collection<IPrimitive> selection = new ArrayList<>(ds.getSelectedNodesAndWays()); 702 705 if (selection.isEmpty()) { // if nothing was selected to drag, just select nearest node/way to the cursor 703 706 ds.setSelected(mv.getNearestNodeOrWay(mv.getPoint(startEN), mv.isSelectablePredicate, true)); 704 707 } 705 708 706 Collection< Node> affectedNodes = AllNodesVisitor.getAllNodes(selection);709 Collection<INode> affectedNodes = new ArrayList<>(AllNodesVisitor.getAllNodes(selection)); 707 710 // for these transformations, having only one node makes no sense - quit silently 708 711 if (affectedNodes.size() < 2 && (mode == Mode.ROTATE || mode == Mode.SCALE)) { 709 712 return false; … … 721 724 moveCmd = new MoveCommand(selection, startEN, currentEN); 722 725 UndoRedoHandler.getInstance().add(moveCmd); 723 726 } 724 for ( Node n : affectedNodes) {727 for (INode n : affectedNodes) { 725 728 if (n.isOutSideWorld()) { 726 729 // Revert move 727 730 if (moveCmd != null) { … … 770 773 } 771 774 } 772 775 773 private static boolean doesImpactStatusLine(Collection< Node> affectedNodes, Collection<Way> selectedWays) {774 for ( Wayw : selectedWays) {775 for ( Node n : w.getNodes()) {776 private static boolean doesImpactStatusLine(Collection<INode> affectedNodes, Collection<IWay<?>> selectedWays) { 777 for (IWay<?> w : selectedWays) { 778 for (INode n : w.getNodes()) { 776 779 if (affectedNodes.contains(n)) { 777 780 return true; 778 781 } … … 791 794 return; 792 795 } 793 796 Command c = getLastCommandInDataset(dataSet); 794 Collection< Node> affectedNodes = AllNodesVisitor.getAllNodes(dataSet.getSelected());797 Collection<? extends INode> affectedNodes = AllNodesVisitor.getAllNodes(dataSet.getSelected()); 795 798 if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) { 796 799 // old command was created with different base point of movement, we need to recalculate it 797 800 ((MoveCommand) c).changeStartPoint(startEN); … … 830 833 ed.toggleEnable("movedHiddenElements"); 831 834 showConfirmMoveDialog(ed); 832 835 } 833 Set< Node> nodes = new HashSet<>();836 Set<INode> nodes = new HashSet<>(); 834 837 int max = Config.getPref().getInt("warn.move.maxelements", 20); 835 for ( OsmPrimitive osm : getLayerManager().getEditDataSet().getSelected()) {836 if (osm instanceof Way) {837 nodes.addAll((( Way) osm).getNodes());838 } else if (osm instanceof Node) {839 nodes.add(( Node) osm);838 for (IPrimitive osm : getLayerManager().getEditDataSet().getSelected()) { 839 if (osm instanceof IWay) { 840 nodes.addAll(((IWay<?>) osm).getNodes()); 841 } else if (osm instanceof INode) { 842 nodes.add((INode) osm); 840 843 } 841 844 if (nodes.size() > max) { 842 845 break; … … 929 932 * @param nodes the collection of nodes. Ignored if null 930 933 * @param targetLocationNode this node's location will be used for the target node 931 934 */ 932 public void mergeNodes(OsmDataLayer layer, Collection< Node> nodes,933 Node targetLocationNode) {935 public void mergeNodes(OsmDataLayer layer, Collection<INode> nodes, 936 INode targetLocationNode) { 934 937 MergeNodesAction.doMergeNodes(layer, nodes, targetLocationNode); 935 938 } 936 939 … … 940 943 * @param p mouse position 941 944 * @return node to merge to, or null 942 945 */ 943 private Node findNodeToMergeTo(Point p) {944 Collection< Node> target = mv.getNearestNodes(p,945 getLayerManager().getEditDataSet().getSelectedNodes(),946 private INode findNodeToMergeTo(Point p) { 947 Collection<INode> target = mv.getNearestNodes(p, 948 new ArrayList<>(getLayerManager().getEditDataSet().getSelectedNodes()), 946 949 mv.isSelectablePredicate); 947 950 return target.isEmpty() ? null : target.iterator().next(); 948 951 } 949 952 950 private void selectPrims(Collection< OsmPrimitive> prims, boolean released, boolean area) {951 DataSet ds = getLayerManager().getActiveDataSet();953 private void selectPrims(Collection<IPrimitive> prims, boolean released, boolean area) { 954 OsmData<?, ?, ?, ?> ds = getLayerManager().getActiveData(); 952 955 953 956 // not allowed together: do not change dataset selection, return early 954 957 // Virtual Ways: if non-empty the cursor is above a virtual node. So don't highlight … … 1029 1032 1030 1033 private class CycleManager { 1031 1034 1032 private Collection< OsmPrimitive> cycleList = Collections.emptyList();1035 private Collection<IPrimitive> cycleList = Collections.emptyList(); 1033 1036 private boolean cyclePrims; 1034 private OsmPrimitive cycleStart;1037 private IPrimitive cycleStart; 1035 1038 private boolean waitForMouseUpParameter; 1036 1039 private boolean multipleMatchesParameter; 1037 1040 /** … … 1105 1108 * <code>cycleList</code> field 1106 1109 * @return the next element of cycle list 1107 1110 */ 1108 private Collection< OsmPrimitive> cyclePrims() {1111 private Collection<IPrimitive> cyclePrims() { 1109 1112 if (cycleList.size() <= 1) { 1110 1113 // no real cycling, just return one-element collection with nearest primitive in it 1111 1114 return cycleList; -
src/org/openstreetmap/josm/command/DeleteCommand.java
478 478 cmds.add(new DeleteCommand(primitivesToDelete.iterator().next().getDataSet(), primitivesToDelete)); 479 479 } 480 480 481 return newSequenceCommand(tr("Delete"), cmds);481 return SequenceCommand.createSimplifiedSequenceCommand(tr("Delete"), cmds); 482 482 } 483 483 484 484 /** -
src/org/openstreetmap/josm/command/SequenceCommand.java
74 74 this(name, Arrays.asList(sequenz)); 75 75 } 76 76 77 /** 78 * Convenient constructor, if the commands are known at compile time. 79 * @param name The description text to be used for the sequence command, if one is created. 80 * @param sequenz The sequence that should be executed. 81 * @return Either a SequenceCommand, or the only command in the potential sequence 82 * @since xxx 83 */ 84 public static Command createSimplifiedSequenceCommand(String name, Command... sequenz) { 85 if (sequenz.length == 1) { 86 return sequenz[0]; 87 } 88 return new SequenceCommand(name, sequenz); 89 } 90 91 /** 92 * Convenient constructor, if the commands are known at compile time. 93 * @param name The description text to be used for the sequence command, if one is created. 94 * @param sequenz The sequence that should be executed. 95 * @return Either a SequenceCommand, or the only command in the potential sequence 96 * @since xxx 97 */ 98 public static Command createSimplifiedSequenceCommand(String name, Collection<Command> sequenz) { 99 if (sequenz.size() == 1) { 100 return sequenz.iterator().next(); 101 } 102 return new SequenceCommand(name, sequenz); 103 } 104 77 105 @Override public boolean executeCommand() { 78 106 for (int i = 0; i < sequence.length; i++) { 79 107 boolean result = sequence[i].executeCommand(); -
src/org/openstreetmap/josm/data/osm/INode.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import org.openstreetmap.josm.data.Bounds; 4 5 import org.openstreetmap.josm.data.coor.EastNorth; 5 6 import org.openstreetmap.josm.data.coor.ILatLon; 6 7 import org.openstreetmap.josm.data.coor.LatLon; … … 70 71 default String getDisplayName(NameFormatter formatter) { 71 72 return formatter.format(this); 72 73 } 74 75 76 /** 77 * Determines if this node is outside of the world. See also #13538. 78 * @return <code>true</code>, if the coordinate is outside the world, compared by using lat/lon and east/north 79 * @since 14960 (extracted to INode in xxx) 80 */ 81 default public boolean isOutSideWorld() { 82 LatLon ll = getCoor(); 83 if (ll != null) { 84 Bounds b = ProjectionRegistry.getProjection().getWorldBoundsLatLon(); 85 if (lat() < b.getMinLat() || lat() > b.getMaxLat() || lon() < b.getMinLon() || lon() > b.getMaxLon()) { 86 return true; 87 } 88 if (!ProjectionRegistry.getProjection().latlon2eastNorth(ll).equalsEpsilon(getEastNorth(), 1.0)) { 89 // we get here if a node was moved or created left from -180 or right from +180 90 return true; 91 } 92 } 93 return false; 94 } 73 95 } -
src/org/openstreetmap/josm/data/osm/IWay.java
132 132 * @since 13922 133 133 */ 134 134 boolean isInnerNode(INode n); 135 136 /** 137 * Adds a node to the end of the list of nodes. Ignored, if n is null. 138 * 139 * @param n the node. Ignored, if null 140 * @throws IllegalStateException if this way is marked as incomplete. We can't add a node 141 * to an incomplete way 142 * @since 1313 Way, xxx IWay 143 */ 144 void addNode(N node); 135 145 } -
src/org/openstreetmap/josm/data/osm/Node.java
10 10 import java.util.function.Predicate; 11 11 import java.util.stream.Collectors; 12 12 13 import org.openstreetmap.josm.data.Bounds;14 13 import org.openstreetmap.josm.data.coor.EastNorth; 15 14 import org.openstreetmap.josm.data.coor.LatLon; 16 15 import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor; … … 405 404 return referrers(Way.class).collect(Collectors.toList()); 406 405 } 407 406 408 /**409 * Determines if this node is outside of the world. See also #13538.410 * @return <code>true</code>, if the coordinate is outside the world, compared by using lat/lon and east/north411 * @since 14960412 */413 public boolean isOutSideWorld() {414 LatLon ll = getCoor();415 if (ll != null) {416 Bounds b = ProjectionRegistry.getProjection().getWorldBoundsLatLon();417 if (lat() < b.getMinLat() || lat() > b.getMaxLat() || lon() < b.getMinLon() || lon() > b.getMaxLon()) {418 return true;419 }420 if (!ProjectionRegistry.getProjection().latlon2eastNorth(ll).equalsEpsilon(getEastNorth(), 1.0)) {421 // we get here if a node was moved or created left from -180 or right from +180422 return true;423 }424 }425 return false;426 }427 428 407 @Override 429 408 public UniqueIdGenerator getIdGenerator() { 430 409 return idGenerator; -
src/org/openstreetmap/josm/data/osm/Way.java
395 395 } 396 396 } 397 397 398 /** 399 * Adds a node to the end of the list of nodes. Ignored, if n is null. 400 * 401 * @param n the node. Ignored, if null 402 * @throws IllegalStateException if this way is marked as incomplete. We can't add a node 403 * to an incomplete way 404 * @since 1313 405 */ 398 @Override 406 399 public void addNode(Node n) { 407 400 checkDatasetNotReadOnly(); 408 401 if (n == null) return; -
src/org/openstreetmap/josm/data/osm/WaySegment.java
2 2 package org.openstreetmap.josm.data.osm; 3 3 4 4 import java.awt.geom.Line2D; 5 import java.lang.reflect.InvocationTargetException; 5 6 import java.util.Objects; 6 7 8 import org.openstreetmap.josm.tools.Logging; 9 7 10 /** 8 11 * A segment consisting of 2 consecutive nodes out of a way. 9 12 */ 10 public final class WaySegment implements Comparable<WaySegment> {13 public final class WaySegment<N extends INode, W extends IWay<N>> implements Comparable<WaySegment<N, W>> { 11 14 12 15 /** 13 16 * The way. 14 17 */ 15 public final W ayway;18 public final W way; 16 19 17 20 /** 18 21 * The index of one of the 2 nodes in the way. The other node has the … … 26 29 * @param i The node lower index 27 30 * @throws IllegalArgumentException in case of invalid index 28 31 */ 29 public WaySegment(W ayw, int i) {32 public WaySegment(W w, int i) { 30 33 way = w; 31 34 lowerIndex = i; 32 35 if (i < 0 || i >= w.getNodesCount() - 1) { … … 38 41 * Returns the first node of the way segment. 39 42 * @return the first node 40 43 */ 41 public N odegetFirstNode() {44 public N getFirstNode() { 42 45 return way.getNode(lowerIndex); 43 46 } 44 47 … … 46 49 * Returns the second (last) node of the way segment. 47 50 * @return the second node 48 51 */ 49 public N odegetSecondNode() {52 public N getSecondNode() { 50 53 return way.getNode(lowerIndex + 1); 51 54 } 52 55 … … 58 61 * @return way segment 59 62 * @throws IllegalArgumentException if the node pair is not part of way 60 63 */ 61 public static WaySegment forNodePair(Way way, Node first, Nodesecond) {64 public static <N extends INode, W extends IWay<N>> WaySegment<N, W> forNodePair(W way, N first, N second) { 62 65 int endIndex = way.getNodesCount() - 1; 63 66 while (endIndex > 0) { 64 67 final int indexOfFirst = way.getNodes().subList(0, endIndex).lastIndexOf(first); 65 68 if (second.equals(way.getNode(indexOfFirst + 1))) { 66 return new WaySegment (way, indexOfFirst);69 return new WaySegment<>(way, indexOfFirst); 67 70 } 68 71 endIndex--; 69 72 } … … 72 75 73 76 /** 74 77 * Returns this way segment as complete way. 75 * @return the way segment as {@code W ay}78 * @return the way segment as {@code W} 76 79 */ 77 public Way toWay() { 78 Way w = new Way(); 79 w.addNode(getFirstNode()); 80 w.addNode(getSecondNode()); 81 return w; 80 public W toWay() { 81 try { 82 /** way is of type W, so it should always create a new W */ 83 @SuppressWarnings("unchecked") 84 W w = (W) way.getClass().getConstructor().newInstance(); 85 w.addNode(getFirstNode()); 86 w.addNode(getSecondNode()); 87 return w; 88 } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException 89 | NoSuchMethodException | SecurityException e) { 90 Logging.trace(e); 91 return null; 92 } 82 93 } 83 94 84 95 @Override … … 85 96 public boolean equals(Object o) { 86 97 if (this == o) return true; 87 98 if (o == null || getClass() != o.getClass()) return false; 88 WaySegment that = (WaySegment) o;99 WaySegment<?, ?> that = (WaySegment<?, ?>) o; 89 100 return lowerIndex == that.lowerIndex && 90 101 Objects.equals(way, that.way); 91 102 } … … 96 107 } 97 108 98 109 @Override 99 public int compareTo(WaySegment o) {110 public int compareTo(WaySegment<N, W> o) { 100 111 return o == null ? -1 : (equals(o) ? 0 : toWay().compareTo(o.toWay())); 101 112 } 102 113 -
src/org/openstreetmap/josm/gui/NavigatableComponent.java
40 40 import org.openstreetmap.josm.data.coor.LatLon; 41 41 import org.openstreetmap.josm.data.osm.BBox; 42 42 import org.openstreetmap.josm.data.osm.DataSet; 43 import org.openstreetmap.josm.data.osm.Node; 44 import org.openstreetmap.josm.data.osm.OsmPrimitive; 45 import org.openstreetmap.josm.data.osm.Relation; 46 import org.openstreetmap.josm.data.osm.Way; 43 import org.openstreetmap.josm.data.osm.INode; 44 import org.openstreetmap.josm.data.osm.IPrimitive; 45 import org.openstreetmap.josm.data.osm.IRelation; 46 import org.openstreetmap.josm.data.osm.IWay; 47 import org.openstreetmap.josm.data.osm.OsmData; 47 48 import org.openstreetmap.josm.data.osm.WaySegment; 48 49 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 49 50 import org.openstreetmap.josm.data.preferences.BooleanProperty; … … 90 91 /** 91 92 * To determine if a primitive is currently selectable. 92 93 */ 93 public transient Predicate< OsmPrimitive> isSelectablePredicate = prim -> {94 public transient Predicate<IPrimitive> isSelectablePredicate = prim -> { 94 95 if (!prim.isSelectable()) return false; 95 96 // if it isn't displayed on screen, you cannot click on it 96 97 MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock(); … … 549 550 * @param n The node, where this geopoint would be drawn. 550 551 * @return The point on screen where "node" would be drawn, relative to the own top/left. 551 552 */ 552 public Point2D getPoint2D( Node n) {553 public Point2D getPoint2D(INode n) { 553 554 return getPoint2D(n.getEastNorth()); 554 555 } 555 556 … … 590 591 * looses precision, may overflow (depends on p and current scale) 591 592 * @param n node 592 593 * @return point 593 * @see #getPoint2D( Node)594 * @see #getPoint2D(INode) 594 595 */ 595 public Point getPoint( Node n) {596 public Point getPoint(INode n) { 596 597 Point2D d = getPoint2D(n); 597 598 return new Point((int) d.getX(), (int) d.getY()); 598 599 } … … 982 983 * 983 984 * @return a sorted map with the keys representing the distance of their associated nodes to point p. 984 985 */ 985 private Map<Double, List< Node>> getNearestNodesImpl(Point p, Predicate<OsmPrimitive> predicate) {986 Map<Double, List< Node>> nearestMap = new TreeMap<>();987 DataSet ds = MainApplication.getLayerManager().getActiveDataSet();986 private Map<Double, List<INode>> getNearestNodesImpl(Point p, Predicate<IPrimitive> predicate) { 987 Map<Double, List<INode>> nearestMap = new TreeMap<>(); 988 OsmData<?, ?, ?, ?> ds = MainApplication.getLayerManager().getActiveData(); 988 989 989 990 if (ds != null) { 990 991 double dist, snapDistanceSq = PROP_SNAP_DISTANCE.get(); 991 992 snapDistanceSq *= snapDistanceSq; 992 993 993 for ( Node n : ds.searchNodes(getBBox(p, PROP_SNAP_DISTANCE.get()))) {994 for (INode n : ds.searchNodes(getBBox(p, PROP_SNAP_DISTANCE.get()))) { 994 995 if (predicate.test(n) 995 996 && (dist = getPoint2D(n).distanceSq(p)) < snapDistanceSq) { 996 997 nearestMap.computeIfAbsent(dist, k -> new LinkedList<>()).add(n); … … 1014 1015 * dist(nearest) to dist(nearest)+4px around p and 1015 1016 * that are not in ignore. 1016 1017 */ 1017 public final List< Node> getNearestNodes(Point p,1018 Collection< Node> ignore, Predicate<OsmPrimitive> predicate) {1019 List< Node> nearestList = Collections.emptyList();1018 public final List<INode> getNearestNodes(Point p, 1019 Collection<INode> ignore, Predicate<IPrimitive> predicate) { 1020 List<INode> nearestList = Collections.emptyList(); 1020 1021 1021 1022 if (ignore == null) { 1022 1023 ignore = Collections.emptySet(); 1023 1024 } 1024 1025 1025 Map<Double, List< Node>> nlists = getNearestNodesImpl(p, predicate);1026 Map<Double, List<INode>> nlists = getNearestNodesImpl(p, predicate); 1026 1027 if (!nlists.isEmpty()) { 1027 1028 Double minDistSq = null; 1028 for (Entry<Double, List< Node>> entry : nlists.entrySet()) {1029 for (Entry<Double, List<INode>> entry : nlists.entrySet()) { 1029 1030 Double distSq = entry.getKey(); 1030 List< Node> nlist = entry.getValue();1031 List<INode> nlist = entry.getValue(); 1031 1032 1032 1033 // filter nodes to be ignored before determining minDistSq.. 1033 1034 nlist.removeAll(ignore); … … 1060 1061 * dist(nearest) to dist(nearest)+4px around p. 1061 1062 * @see #getNearestNodes(Point, Collection, Predicate) 1062 1063 */ 1063 public final List< Node> getNearestNodes(Point p, Predicate<OsmPrimitive> predicate) {1064 public final List<INode> getNearestNodes(Point p, Predicate<IPrimitive> predicate) { 1064 1065 return getNearestNodes(p, null, predicate); 1065 1066 } 1066 1067 … … 1084 1085 * 1085 1086 * @return A node within snap-distance to point p, that is chosen by the algorithm described. 1086 1087 */ 1087 public final Node getNearestNode(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected) {1088 public final INode getNearestNode(Point p, Predicate<IPrimitive> predicate, boolean useSelected) { 1088 1089 return getNearestNode(p, predicate, useSelected, null); 1089 1090 } 1090 1091 … … 1112 1113 * @return A node within snap-distance to point p, that is chosen by the algorithm described. 1113 1114 * @since 6065 1114 1115 */ 1115 public final Node getNearestNode(Point p, Predicate<OsmPrimitive> predicate,1116 boolean useSelected, Collection< OsmPrimitive> preferredRefs) {1116 public final INode getNearestNode(Point p, Predicate<IPrimitive> predicate, 1117 boolean useSelected, Collection<IPrimitive> preferredRefs) { 1117 1118 1118 Map<Double, List< Node>> nlists = getNearestNodesImpl(p, predicate);1119 Map<Double, List<INode>> nlists = getNearestNodesImpl(p, predicate); 1119 1120 if (nlists.isEmpty()) return null; 1120 1121 1121 1122 if (preferredRefs != null && preferredRefs.isEmpty()) preferredRefs = null; 1122 Node ntsel = null, ntnew = null, ntref = null;1123 INode ntsel = null, ntnew = null, ntref = null; 1123 1124 boolean useNtsel = useSelected; 1124 1125 double minDistSq = nlists.keySet().iterator().next(); 1125 1126 1126 for (Entry<Double, List< Node>> entry : nlists.entrySet()) {1127 for (Entry<Double, List<INode>> entry : nlists.entrySet()) { 1127 1128 Double distSq = entry.getKey(); 1128 for ( Node nd : entry.getValue()) {1129 for (INode nd : entry.getValue()) { 1129 1130 // find the nearest selected node 1130 1131 if (ntsel == null && nd.isSelected()) { 1131 1132 ntsel = nd; … … 1136 1137 useNtsel |= Utils.equalsEpsilon(distSq, minDistSq); 1137 1138 } 1138 1139 if (ntref == null && preferredRefs != null && Utils.equalsEpsilon(distSq, minDistSq)) { 1139 List< OsmPrimitive> ndRefs = nd.getReferrers();1140 for ( OsmPrimitive ref: preferredRefs) {1140 List<? extends IPrimitive> ndRefs = nd.getReferrers(); 1141 for (IPrimitive ref: preferredRefs) { 1141 1142 if (ndRefs.contains(ref)) { 1142 1143 ntref = nd; 1143 1144 break; … … 1170 1171 * 1171 1172 * @return The nearest node to point p. 1172 1173 */ 1173 public final Node getNearestNode(Point p, Predicate<OsmPrimitive> predicate) {1174 public final INode getNearestNode(Point p, Predicate<IPrimitive> predicate) { 1174 1175 return getNearestNode(p, predicate, true); 1175 1176 } 1176 1177 … … 1184 1185 * @return a sorted map with the keys representing the perpendicular 1185 1186 * distance of their associated way segments to point p. 1186 1187 */ 1187 private Map<Double, List<WaySegment >> getNearestWaySegmentsImpl(Point p, Predicate<OsmPrimitive> predicate) {1188 Map<Double, List<WaySegment >> nearestMap = new TreeMap<>();1188 private Map<Double, List<WaySegment<?, ?>>> getNearestWaySegmentsImpl(Point p, Predicate<IPrimitive> predicate) { 1189 Map<Double, List<WaySegment<?, ?>>> nearestMap = new TreeMap<>(); 1189 1190 DataSet ds = MainApplication.getLayerManager().getActiveDataSet(); 1190 1191 1191 1192 if (ds != null) { … … 1192 1193 double snapDistanceSq = Config.getPref().getInt("mappaint.segment.snap-distance", 10); 1193 1194 snapDistanceSq *= snapDistanceSq; 1194 1195 1195 for ( Wayw : ds.searchWays(getBBox(p, Config.getPref().getInt("mappaint.segment.snap-distance", 10)))) {1196 for (IWay<?> w : ds.searchWays(getBBox(p, Config.getPref().getInt("mappaint.segment.snap-distance", 10)))) { 1196 1197 if (!predicate.test(w)) { 1197 1198 continue; 1198 1199 } 1199 Node lastN = null;1200 INode lastN = null; 1200 1201 int i = -2; 1201 for ( Node n : w.getNodes()) {1202 for (INode n : w.getNodes()) { 1202 1203 i++; 1203 1204 if (n.isDeleted() || n.isIncomplete()) { //FIXME: This shouldn't happen, raise exception? 1204 1205 continue; … … 1224 1225 >> 32 << 32); // resolution in numbers with large exponent not needed here.. 1225 1226 1226 1227 if (perDistSq < snapDistanceSq && a < c + snapDistanceSq && b < c + snapDistanceSq) { 1227 nearestMap.computeIfAbsent(perDistSq, k -> new LinkedList<>()).add(new WaySegment (w, i));1228 nearestMap.computeIfAbsent(perDistSq, k -> new LinkedList<>()).add(new WaySegment<>(w, i)); 1228 1229 } 1229 1230 1230 1231 lastN = n; … … 1247 1248 * @return all segments within 10px of p that are not in ignore, 1248 1249 * sorted by their perpendicular distance. 1249 1250 */ 1250 public final List<WaySegment > getNearestWaySegments(Point p,1251 Collection<WaySegment > ignore, Predicate<OsmPrimitive> predicate) {1252 List<WaySegment > nearestList = new ArrayList<>();1253 List<WaySegment > unselected = new LinkedList<>();1251 public final List<WaySegment<?, ?>> getNearestWaySegments(Point p, 1252 Collection<WaySegment<?, ?>> ignore, Predicate<IPrimitive> predicate) { 1253 List<WaySegment<?, ?>> nearestList = new ArrayList<>(); 1254 List<WaySegment<?, ?>> unselected = new LinkedList<>(); 1254 1255 1255 for (List<WaySegment > wss : getNearestWaySegmentsImpl(p, predicate).values()) {1256 for (List<WaySegment<?, ?>> wss : getNearestWaySegmentsImpl(p, predicate).values()) { 1256 1257 // put selected waysegs within each distance group first 1257 1258 // makes the order of nearestList dependent on current selection state 1258 for (WaySegment ws : wss) {1259 for (WaySegment<?, ?> ws : wss) { 1259 1260 (ws.way.isSelected() ? nearestList : unselected).add(ws); 1260 1261 } 1261 1262 nearestList.addAll(unselected); … … 1277 1278 * @return all segments within 10px of p, sorted by their perpendicular distance. 1278 1279 * @see #getNearestWaySegments(Point, Collection, Predicate) 1279 1280 */ 1280 public final List<WaySegment > getNearestWaySegments(Point p, Predicate<OsmPrimitive> predicate) {1281 public final List<WaySegment<?, ?>> getNearestWaySegments(Point p, Predicate<IPrimitive> predicate) { 1281 1282 return getNearestWaySegments(p, null, predicate); 1282 1283 } 1283 1284 … … 1292 1293 * and, depending on use_selected, prefers a selected way segment, if found. 1293 1294 * @see #getNearestWaySegments(Point, Collection, Predicate) 1294 1295 */ 1295 public final WaySegment getNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected) {1296 WaySegment wayseg = null;1297 WaySegment ntsel = null;1296 public final WaySegment<?, ?> getNearestWaySegment(Point p, Predicate<IPrimitive> predicate, boolean useSelected) { 1297 WaySegment<?, ?> wayseg = null; 1298 WaySegment<?, ?> ntsel = null; 1298 1299 1299 for (List<WaySegment > wslist : getNearestWaySegmentsImpl(p, predicate).values()) {1300 for (List<WaySegment<?, ?>> wslist : getNearestWaySegmentsImpl(p, predicate).values()) { 1300 1301 if (wayseg != null && ntsel != null) { 1301 1302 break; 1302 1303 } 1303 for (WaySegment ws : wslist) {1304 for (WaySegment<?, ?> ws : wslist) { 1304 1305 if (wayseg == null) { 1305 1306 wayseg = ws; 1306 1307 } … … 1328 1329 * @see #getNearestWaySegments(Point, Collection, Predicate) 1329 1330 * @since 6065 1330 1331 */ 1331 public final WaySegment getNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate,1332 boolean useSelected, Collection< OsmPrimitive> preferredRefs) {1333 WaySegment wayseg = null;1332 public final WaySegment<? extends INode, ? extends IWay<?>> getNearestWaySegment(Point p, Predicate<IPrimitive> predicate, 1333 boolean useSelected, Collection<IPrimitive> preferredRefs) { 1334 WaySegment<?, ?> wayseg = null; 1334 1335 if (preferredRefs != null && preferredRefs.isEmpty()) 1335 1336 preferredRefs = null; 1336 1337 1337 for (List<WaySegment > wslist : getNearestWaySegmentsImpl(p, predicate).values()) {1338 for (WaySegment ws : wslist) {1338 for (List<WaySegment<?, ?>> wslist : getNearestWaySegmentsImpl(p, predicate).values()) { 1339 for (WaySegment<?, ?> ws : wslist) { 1339 1340 if (wayseg == null) { 1340 1341 wayseg = ws; 1341 1342 } … … 1347 1348 if (preferredRefs.contains(ws.getFirstNode()) || preferredRefs.contains(ws.getSecondNode())) { 1348 1349 return ws; 1349 1350 } 1350 Collection< OsmPrimitive> wayRefs = ws.way.getReferrers();1351 Collection<? extends IPrimitive> wayRefs = ws.way.getReferrers(); 1351 1352 // prefer member of the given relations 1352 for ( OsmPrimitive ref: preferredRefs) {1353 if (ref instanceof Relation && wayRefs.contains(ref)) {1353 for (IPrimitive ref: preferredRefs) { 1354 if (ref instanceof IRelation && wayRefs.contains(ref)) { 1354 1355 return ws; 1355 1356 } 1356 1357 } … … 1367 1368 * 1368 1369 * @return The nearest way segment to point p. 1369 1370 */ 1370 public final WaySegment getNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate) {1371 public final WaySegment<?, ?> getNearestWaySegment(Point p, Predicate<IPrimitive> predicate) { 1371 1372 return getNearestWaySegment(p, predicate, true); 1372 1373 } 1373 1374 … … 1383 1384 * @return all nearest ways to the screen point given that are not in ignore. 1384 1385 * @see #getNearestWaySegments(Point, Collection, Predicate) 1385 1386 */ 1386 public final List< Way> getNearestWays(Point p,1387 Collection< Way> ignore, Predicate<OsmPrimitive> predicate) {1388 List< Way> nearestList = new ArrayList<>();1389 Set< Way> wset = new HashSet<>();1387 public final List<IWay<?>> getNearestWays(Point p, 1388 Collection<IWay<?>> ignore, Predicate<IPrimitive> predicate) { 1389 List<IWay<?>> nearestList = new ArrayList<>(); 1390 Set<IWay<?>> wset = new HashSet<>(); 1390 1391 1391 for (List<WaySegment > wss : getNearestWaySegmentsImpl(p, predicate).values()) {1392 for (WaySegment ws : wss) {1392 for (List<WaySegment<?, ?>> wss : getNearestWaySegmentsImpl(p, predicate).values()) { 1393 for (WaySegment<?, ?> ws : wss) { 1393 1394 if (wset.add(ws.way)) { 1394 1395 nearestList.add(ws.way); 1395 1396 } … … 1413 1414 * @return all nearest ways to the screen point given. 1414 1415 * @see #getNearestWays(Point, Collection, Predicate) 1415 1416 */ 1416 public final List< Way> getNearestWays(Point p, Predicate<OsmPrimitive> predicate) {1417 public final List<IWay<?>> getNearestWays(Point p, Predicate<IPrimitive> predicate) { 1417 1418 return getNearestWays(p, null, predicate); 1418 1419 } 1419 1420 … … 1426 1427 * @return The nearest way to point p, prefer a selected way if there are multiple nearest. 1427 1428 * @see #getNearestWaySegment(Point, Predicate) 1428 1429 */ 1429 public final Way getNearestWay(Point p, Predicate<OsmPrimitive> predicate) {1430 WaySegment nearestWaySeg = getNearestWaySegment(p, predicate);1430 public final IWay<?> getNearestWay(Point p, Predicate<IPrimitive> predicate) { 1431 WaySegment<?, ?> nearestWaySeg = getNearestWaySegment(p, predicate); 1431 1432 return (nearestWaySeg == null) ? null : nearestWaySeg.way; 1432 1433 } 1433 1434 … … 1452 1453 * @see #getNearestNodes(Point, Collection, Predicate) 1453 1454 * @see #getNearestWays(Point, Collection, Predicate) 1454 1455 */ 1455 public final List< OsmPrimitive> getNearestNodesOrWays(Point p,1456 Collection< OsmPrimitive> ignore, Predicate<OsmPrimitive> predicate) {1457 List< OsmPrimitive> nearestList = Collections.emptyList();1458 OsmPrimitive osm = getNearestNodeOrWay(p, predicate, false);1456 public final List<IPrimitive> getNearestNodesOrWays(Point p, 1457 Collection<IPrimitive> ignore, Predicate<IPrimitive> predicate) { 1458 List<IPrimitive> nearestList = Collections.emptyList(); 1459 IPrimitive osm = getNearestNodeOrWay(p, predicate, false); 1459 1460 1460 1461 if (osm != null) { 1461 if (osm instanceof Node) {1462 if (osm instanceof INode) { 1462 1463 nearestList = new ArrayList<>(getNearestNodes(p, predicate)); 1463 } else if (osm instanceof Way) {1464 } else if (osm instanceof IWay) { 1464 1465 nearestList = new ArrayList<>(getNearestWays(p, predicate)); 1465 1466 } 1466 1467 if (ignore != null) { … … 1481 1482 * @return Primitives nearest to the given screen point. 1482 1483 * @see #getNearestNodesOrWays(Point, Collection, Predicate) 1483 1484 */ 1484 public final List< OsmPrimitive> getNearestNodesOrWays(Point p, Predicate<OsmPrimitive> predicate) {1485 public final List<IPrimitive> getNearestNodesOrWays(Point p, Predicate<IPrimitive> predicate) { 1485 1486 return getNearestNodesOrWays(p, null, predicate); 1486 1487 } 1487 1488 … … 1494 1495 * @param useSelected whether to prefer selected nodes 1495 1496 * @return true, if the node fulfills the properties of the function body 1496 1497 */ 1497 private boolean isPrecedenceNode( Node osm, Point p, boolean useSelected) {1498 private boolean isPrecedenceNode(INode osm, Point p, boolean useSelected) { 1498 1499 if (osm != null) { 1499 1500 if (p.distanceSq(getPoint2D(osm)) <= (4*4)) return true; 1500 1501 if (osm.isTagged()) return true; … … 1527 1528 * @see #getNearestNode(Point, Predicate) 1528 1529 * @see #getNearestWay(Point, Predicate) 1529 1530 */ 1530 public final OsmPrimitive getNearestNodeOrWay(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected) {1531 Collection< OsmPrimitive> sel;1532 DataSet ds = MainApplication.getLayerManager().getActiveDataSet();1531 public final IPrimitive getNearestNodeOrWay(Point p, Predicate<IPrimitive> predicate, boolean useSelected) { 1532 Collection<IPrimitive> sel; 1533 OsmData<?, ?, ?, ?> ds = MainApplication.getLayerManager().getActiveData(); 1533 1534 if (useSelected && ds != null) { 1534 sel = ds.getSelected();1535 sel = new ArrayList<>(ds.getSelected()); 1535 1536 } else { 1536 1537 sel = null; 1537 1538 } 1538 OsmPrimitive osm = getNearestNode(p, predicate, useSelected, sel);1539 IPrimitive osm = getNearestNode(p, predicate, useSelected, sel); 1539 1540 1540 if (isPrecedenceNode(( Node) osm, p, useSelected)) return osm;1541 WaySegment ws;1541 if (isPrecedenceNode((INode) osm, p, useSelected)) return osm; 1542 WaySegment<?, ?> ws; 1542 1543 if (useSelected) { 1543 1544 ws = getNearestWaySegment(p, predicate, useSelected, sel); 1544 1545 } else { … … 1559 1560 // is wayseg shorter than maxWaySegLenSq and 1560 1561 // is p closer to the middle of wayseg than to the nearest node? 1561 1562 if (wp1.distanceSq(wp2) < maxWaySegLenSq && 1562 p.distanceSq(project(0.5, wp1, wp2)) < p.distanceSq(getPoint2D(( Node) osm))) {1563 p.distanceSq(project(0.5, wp1, wp2)) < p.distanceSq(getPoint2D((INode) osm))) { 1563 1564 osm = ws.way; 1564 1565 } 1565 1566 } … … 1596 1597 * @return a list of all objects that are nearest to point p and 1597 1598 * not in ignore or an empty list if nothing was found. 1598 1599 */ 1599 public final List< OsmPrimitive> getAllNearest(Point p,1600 Collection< OsmPrimitive> ignore, Predicate<OsmPrimitive> predicate) {1601 List< OsmPrimitive> nearestList = new ArrayList<>();1602 Set< Way> wset = new HashSet<>();1600 public final List<IPrimitive> getAllNearest(Point p, 1601 Collection<IPrimitive> ignore, Predicate<IPrimitive> predicate) { 1602 List<IPrimitive> nearestList = new ArrayList<>(); 1603 Set<IWay<?>> wset = new HashSet<>(); 1603 1604 1604 1605 // add nearby ways 1605 for (List<WaySegment > wss : getNearestWaySegmentsImpl(p, predicate).values()) {1606 for (WaySegment ws : wss) {1606 for (List<WaySegment<?, ?>> wss : getNearestWaySegmentsImpl(p, predicate).values()) { 1607 for (WaySegment<?, ?> ws : wss) { 1607 1608 if (wset.add(ws.way)) { 1608 1609 nearestList.add(ws.way); 1609 1610 } … … 1611 1612 } 1612 1613 1613 1614 // add nearby nodes 1614 for (List< Node> nlist : getNearestNodesImpl(p, predicate).values()) {1615 for (List<INode> nlist : getNearestNodesImpl(p, predicate).values()) { 1615 1616 nearestList.addAll(nlist); 1616 1617 } 1617 1618 1618 1619 // add parent relations of nearby nodes and ways 1619 Set< OsmPrimitive> parentRelations = new HashSet<>();1620 for ( OsmPrimitive o : nearestList) {1621 for ( OsmPrimitive r : o.getReferrers()) {1622 if (r instanceof Relation && predicate.test(r)) {1620 Set<IPrimitive> parentRelations = new HashSet<>(); 1621 for (IPrimitive o : nearestList) { 1622 for (IPrimitive r : o.getReferrers()) { 1623 if (r instanceof IRelation && predicate.test(r)) { 1623 1624 parentRelations.add(r); 1624 1625 } 1625 1626 } … … 1644 1645 * or an empty list if nothing was found. 1645 1646 * @see #getAllNearest(Point, Collection, Predicate) 1646 1647 */ 1647 public final List< OsmPrimitive> getAllNearest(Point p, Predicate<OsmPrimitive> predicate) {1648 public final List<IPrimitive> getAllNearest(Point p, Predicate<IPrimitive> predicate) { 1648 1649 return getAllNearest(p, null, predicate); 1649 1650 } 1650 1651 -
src/org/openstreetmap/josm/gui/SelectionManager.java
19 19 20 20 import org.openstreetmap.josm.actions.SelectByInternalPointAction; 21 21 import org.openstreetmap.josm.data.Bounds; 22 import org.openstreetmap.josm.data.osm. DataSet;23 import org.openstreetmap.josm.data.osm. Node;24 import org.openstreetmap.josm.data.osm. OsmPrimitive;25 import org.openstreetmap.josm.data.osm. Way;22 import org.openstreetmap.josm.data.osm.INode; 23 import org.openstreetmap.josm.data.osm.IPrimitive; 24 import org.openstreetmap.josm.data.osm.IWay; 25 import org.openstreetmap.josm.data.osm.OsmData; 26 26 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors; 27 27 import org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable; 28 28 import org.openstreetmap.josm.tools.Utils; … … 363 363 * objects that are touched, instead those which are completely covered. 364 364 * @return The collection of selected objects. 365 365 */ 366 public Collection< OsmPrimitive> getSelectedObjects(boolean alt) {367 Collection< OsmPrimitive> selection = new LinkedList<>();366 public Collection<IPrimitive> getSelectedObjects(boolean alt) { 367 Collection<IPrimitive> selection = new LinkedList<>(); 368 368 369 369 // whether user only clicked, not dragged. 370 370 boolean clicked = false; … … 373 373 clicked = true; 374 374 } 375 375 376 DataSet ds = MainApplication.getLayerManager().getActiveDataSet();376 OsmData<?, ?, ?, ?> ds = MainApplication.getLayerManager().getActiveData(); 377 377 if (clicked) { 378 378 Point center = new Point(selectionResult.xpoints[0], selectionResult.ypoints[0]); 379 OsmPrimitive osm = nc.getNearestNodeOrWay(center, OsmPrimitive::isSelectable, false);379 IPrimitive osm = nc.getNearestNodeOrWay(center, IPrimitive::isSelectable, false); 380 380 if (osm != null) { 381 381 selection.add(osm); 382 382 } 383 383 } else if (ds != null) { 384 384 // nodes 385 for ( Node n : ds.getNodes()) {385 for (INode n : ds.getNodes()) { 386 386 if (n.isSelectable() && selectionResult.contains(nc.getPoint2D(n))) { 387 387 selection.add(n); 388 388 } … … 389 389 } 390 390 391 391 // ways 392 for ( Wayw : ds.getWays()) {392 for (IWay<?> w : ds.getWays()) { 393 393 if (!w.isSelectable() || w.isEmpty()) { 394 394 continue; 395 395 } 396 396 if (alt) { 397 for ( Node n : w.getNodes()) {397 for (INode n : w.getNodes()) { 398 398 if (!n.isIncomplete() && selectionResult.contains(nc.getPoint2D(n))) { 399 399 selection.add(w); 400 400 break; … … 402 402 } 403 403 } else { 404 404 boolean allIn = true; 405 for ( Node n : w.getNodes()) {405 for (INode n : w.getNodes()) { 406 406 if (!n.isIncomplete() && !selectionResult.contains(nc.getPoint(n))) { 407 407 allIn = false; 408 408 break;
