Changeset 429 in josm for trunk/src/org
- Timestamp:
- 2007-10-26T10:44:20+02:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r426 r429 38 38 import org.openstreetmap.josm.data.osm.Way; 39 39 import org.openstreetmap.josm.data.osm.Node; 40 import org.openstreetmap.josm. data.osm.NodePair;40 import org.openstreetmap.josm.tools.Pair; 41 41 import org.openstreetmap.josm.tools.GBC; 42 42 … … 53 53 } 54 54 55 private static class RelationRolePair {56 public Relation rel;57 public String role;58 59 public RelationRolePair(Relation rel, String role) {60 this.rel = rel;61 this.role = role;62 }63 64 @Override public boolean equals(Object o) {65 return o instanceof RelationRolePair66 && rel == ((RelationRolePair) o).rel67 && role.equals(((RelationRolePair) o).role);68 }69 70 @Override public int hashCode() {71 return rel.hashCode() ^ role.hashCode();72 }73 }74 75 55 public void actionPerformed(ActionEvent event) { 76 56 Collection<OsmPrimitive> selection = Main.ds.getSelected(); … … 96 76 // Step 1, iterate over all relations and figure out which of our 97 77 // selected ways are members of a relation. 98 HashMap< RelationRolePair, HashSet<Way>> backlinks =99 new HashMap< RelationRolePair, HashSet<Way>>();78 HashMap<Pair<Relation,String>, HashSet<Way>> backlinks = 79 new HashMap<Pair<Relation,String>, HashSet<Way>>(); 100 80 HashSet<Relation> relationsUsingWays = new HashSet<Relation>(); 101 81 for (Relation r : Main.ds.relations) { … … 105 85 for(Way w : selectedWays) { 106 86 if (rm.member == w) { 107 RelationRolePair pair = new RelationRolePair(r, rm.role);87 Pair<Relation,String> pair = new Pair<Relation,String>(r, rm.role); 108 88 HashSet<Way> waylinks = new HashSet<Way>(); 109 89 if (backlinks.containsKey(pair)) { … … 238 218 // 4. Profit! 239 219 240 HashSet< NodePair> chunkSet = new HashSet<NodePair>();220 HashSet<Pair<Node,Node>> chunkSet = new HashSet<Pair<Node,Node>>(); 241 221 for (Way w : ways) { 242 222 if (w.nodes.size() == 0) continue; … … 248 228 } 249 229 250 NodePair np = new NodePair(lastN, n);230 Pair<Node,Node> np = new Pair<Node,Node>(lastN, n); 251 231 if (ignoreDirection) { 252 np.sort();232 Pair.sort(np); 253 233 } 254 234 chunkSet.add(np); … … 257 237 } 258 238 } 259 LinkedList< NodePair> chunks = new LinkedList<NodePair>(chunkSet);239 LinkedList<Pair<Node,Node>> chunks = new LinkedList<Pair<Node,Node>>(chunkSet); 260 240 261 241 if (chunks.isEmpty()) { … … 263 243 } 264 244 265 List<Node> nodeList = chunks.poll().toArrayList();245 List<Node> nodeList = Pair.toArrayList(chunks.poll()); 266 246 while (!chunks.isEmpty()) { 267 ListIterator< NodePair> it = chunks.listIterator();247 ListIterator<Pair<Node,Node>> it = chunks.listIterator(); 268 248 boolean foundChunk = false; 269 249 while (it.hasNext()) { 270 NodePaircurChunk = it.next();250 Pair<Node,Node> curChunk = it.next(); 271 251 if (curChunk.a == nodeList.get(nodeList.size() - 1)) { // append 272 252 nodeList.add(curChunk.b); -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r428 r429 38 38 import org.openstreetmap.josm.data.osm.Way; 39 39 import org.openstreetmap.josm.data.osm.Node; 40 import org.openstreetmap.josm. data.osm.NodePair;40 import org.openstreetmap.josm.tools.Pair; 41 41 import org.openstreetmap.josm.data.osm.visitor.CollectBackReferencesVisitor; 42 42 import org.openstreetmap.josm.tools.GBC; … … 97 97 } 98 98 99 private static class RelationRolePair {100 public Relation rel;101 public String role;102 103 public RelationRolePair(Relation rel, String role) {104 this.rel = rel;105 this.role = role;106 }107 108 @Override public boolean equals(Object o) {109 return o instanceof RelationRolePair110 && rel == ((RelationRolePair) o).rel111 && role.equals(((RelationRolePair) o).role);112 }113 114 @Override public int hashCode() {115 return rel.hashCode() ^ role.hashCode();116 }117 }118 119 99 /** 120 100 * really do the merging - returns the node that is left … … 133 113 // Step 1, iterate over all relations and figure out which of our 134 114 // selected ways are members of a relation. 135 HashMap< RelationRolePair, HashSet<Node>> backlinks =136 new HashMap< RelationRolePair, HashSet<Node>>();115 HashMap<Pair<Relation,String>, HashSet<Node>> backlinks = 116 new HashMap<Pair<Relation,String>, HashSet<Node>>(); 137 117 HashSet<Relation> relationsUsingNodes = new HashSet<Relation>(); 138 118 for (Relation r : Main.ds.relations) { … … 142 122 for (Node n : allNodes) { 143 123 if (rm.member == n) { 144 RelationRolePair pair = new RelationRolePair(r, rm.role);124 Pair<Relation,String> pair = new Pair<Relation,String>(r, rm.role); 145 125 HashSet<Node> nodelinks = new HashSet<Node>(); 146 126 if (backlinks.containsKey(pair)) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r409 r429 30 30 import org.openstreetmap.josm.data.coor.EastNorth; 31 31 import org.openstreetmap.josm.data.osm.Node; 32 import org.openstreetmap.josm. data.osm.NodePair;32 import org.openstreetmap.josm.tools.Pair; 33 33 import org.openstreetmap.josm.data.osm.OsmPrimitive; 34 34 import org.openstreetmap.josm.data.osm.Way; … … 140 140 } 141 141 142 Set< NodePair> segSet = new HashSet<NodePair>();142 Set<Pair<Node,Node>> segSet = new HashSet<Pair<Node,Node>>(); 143 143 144 144 for (Map.Entry<Way, List<Integer>> insertPoint : insertPoints.entrySet()) { … … 150 150 pruneSuccsAndReverse(is); 151 151 for (int i : is) segSet.add( 152 new NodePair(w.nodes.get(i), w.nodes.get(i+1)).sort());152 Pair.sort(new Pair<Node,Node>(w.nodes.get(i), w.nodes.get(i+1)))); 153 153 for (int i : is) wnew.nodes.add(i + 1, n); 154 154 … … 311 311 * @param n the node to adjust 312 312 */ 313 private static void adjustNode(Collection< NodePair> segs, Node n) {313 private static void adjustNode(Collection<Pair<Node,Node>> segs, Node n) { 314 314 315 315 switch (segs.size()) { … … 320 320 // it by something else. All it does it compute the intersection between 321 321 // the two segments and adjust the node position. The code doesnt 322 Iterator< NodePair> i = segs.iterator();323 NodePairseg = i.next();322 Iterator<Pair<Node,Node>> i = segs.iterator(); 323 Pair<Node,Node> seg = i.next(); 324 324 EastNorth A = seg.a.eastNorth; 325 325 EastNorth B = seg.b.eastNorth;
Note:
See TracChangeset
for help on using the changeset viewer.