Changeset 2341 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2009-10-28T19:33:49+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r2333 r2341 3 3 4 4 import static org.openstreetmap.josm.gui.conflict.tags.TagConflictResolutionUtil.combineTigerTags; 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;6 5 import static org.openstreetmap.josm.gui.conflict.tags.TagConflictResolutionUtil.completeTagCollectionForEditing; 7 6 import static org.openstreetmap.josm.gui.conflict.tags.TagConflictResolutionUtil.normalizeTagCollectionBeforeEditing; … … 14 13 import java.util.Collection; 15 14 import java.util.HashSet; 15 import java.util.LinkedHashSet; 16 16 import java.util.LinkedList; 17 17 import java.util.List; … … 54 54 return; 55 55 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 56 Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class); 56 LinkedHashSet<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class); 57 57 if (selectedNodes.size() < 2) { 58 58 JOptionPane.showMessageDialog( … … 74 74 75 75 /** 76 * Selects a node out of a collection of candidate nodes. The selected 77 * node will become the target node the remaining nodes are merged to. 78 * 76 * Find which node to merge into (i.e. which one will be left) 77 * The last selected node will become the target node the remaining 78 * nodes are merged to. 79 * 79 80 * @param candidates the collection of candidate nodes 80 81 * @return the selected target node 81 82 */ 82 public static Node selectTargetNode(Collection<Node> candidates) { 83 // Find which node to merge into (i.e. which one will be left) 84 // - this should be combined from two things: 85 // 1. It will be the first node in the list that has a 86 // positive ID number, OR the first node. 87 // 2. It will be at the position of the first node in the 88 // list. 89 // 90 // *However* - there is the problem that the selection list is 91 // _not_ in the order that the nodes were clicked on, meaning 92 // that the user doesn't know which node will be chosen (so 93 // (2) is not implemented yet.) :-( 83 public static Node selectTargetNode(LinkedHashSet<Node> candidates) { 94 84 Node targetNode = null; 95 for (Node n: candidates) { 96 if (!n.isNew()) { 97 targetNode = n; 98 break; 99 } 100 } 101 if (targetNode == null) { 102 // an arbitrary node 103 targetNode = candidates.iterator().next(); 85 for (Node n : candidates) { // pick last one 86 targetNode = n; 104 87 } 105 88 return targetNode;
Note:
See TracChangeset
for help on using the changeset viewer.
