Changeset 1862 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2009-07-27T21:09:44+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r1762 r1862 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 7 import java.util.HashSet;8 6 9 7 import java.util.ArrayList; 10 8 import java.util.Arrays; 11 9 import java.util.Collection; 10 import java.util.HashSet; 12 11 import java.util.List; 13 12 14 13 import org.openstreetmap.josm.data.osm.visitor.Visitor; 14 import org.openstreetmap.josm.tools.CopyList; 15 15 import org.openstreetmap.josm.tools.Pair; 16 16 … … 26 26 */ 27 27 public final List<Node> nodes = new ArrayList<Node>(); 28 29 /** 30 * 31 * You can modify returned list but changes will not be propagated back 32 * to the Way. Use {@link #setNodes(List)} to update this way 33 * @return Nodes composing the way 34 * @since 1862 35 */ 36 public List<Node> getNodes() { 37 return new CopyList<Node>(nodes.toArray(new Node[nodes.size()])); 38 } 39 40 /** 41 * @param nodes 42 * @since 1862 43 */ 44 public void setNodes(List<Node> nodes) { 45 this.nodes.clear(); 46 this.nodes.addAll(nodes); 47 } 48 49 /** 50 * 51 * @return 52 * @since 1862 53 */ 54 public int getNodesCount() { 55 return nodes.size(); 56 } 57 58 /** 59 * 60 * @param index 61 * @return 62 * @since 1862 63 */ 64 public Node getNode(int index) { 65 return nodes.get(index); 66 } 28 67 29 68 /* mappaint data */ -
trunk/src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java
r1523 r1862 6 6 7 7 import org.openstreetmap.josm.data.osm.DataSet; 8 import org.openstreetmap.josm.data.osm.Node; 9 import org.openstreetmap.josm.data.osm.OsmPrimitive; 8 10 import org.openstreetmap.josm.data.osm.Relation; 9 11 import org.openstreetmap.josm.data.osm.RelationMember; 10 import org.openstreetmap.josm.data.osm.Node;11 import org.openstreetmap.josm.data.osm.OsmPrimitive;12 12 import org.openstreetmap.josm.data.osm.Way; 13 13 … … 47 47 for (Way w : ds.ways) { 48 48 if (w.deleted || w.incomplete) continue; 49 for (Node n2 : w. nodes) {49 for (Node n2 : w.getNodes()) { 50 50 if (n == n2) { 51 51 data.add(w); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r1843 r1862 21 21 import java.util.Iterator; 22 22 import java.util.LinkedList; 23 import java.util.List; 23 24 24 25 import javax.swing.ImageIcon; … … 162 163 */ 163 164 public void visit(Way w) { 164 if(w. nodes.size() < 2)165 if(w.getNodesCount() < 2) 165 166 { 166 167 w.mappaintVisibleCode = viewid; … … 174 175 double maxy = -10000; 175 176 176 for (Node n : w. nodes)177 for (Node n : w.getNodes()) 177 178 { 178 179 if(n.getEastNorth().east() > maxx) maxx = n.getEastNorth().east(); … … 293 294 { 294 295 lastN = null; 295 for(Node n : w. nodes)296 for(Node n : w.getNodes()) 296 297 { 297 298 if(lastN != null) … … 308 309 /* draw the way */ 309 310 lastN = null; 310 Iterator<Node> it = w. nodes.iterator();311 Iterator<Node> it = w.getNodes().iterator(); 311 312 while (it.hasNext()) 312 313 { … … 326 327 { 327 328 lastN = null; 328 for(Node n : w. nodes)329 for(Node n : w.getNodes()) 329 330 { 330 331 if(lastN != null) … … 365 366 Way w = null; 366 367 Boolean selected = false; 367 ArrayList<Node> n = null;368 List<Node> n = null; 368 369 Boolean joined = true; 369 370 while(joined && left != 0) … … 380 381 { 381 382 int mode = 0; 382 int cl = c. nodes.size()-1;383 int cl = c.getNodesCount()-1; 383 384 int nl; 384 385 if(n == null) 385 386 { 386 nl = w. nodes.size()-1;387 if(w. nodes.get(nl) == c.nodes.get(0)) mode = 21;388 else if(w. nodes.get(nl) == c.nodes.get(cl)) mode = 22;389 else if(w. nodes.get(0) == c.nodes.get(0)) mode = 11;390 else if(w. nodes.get(0) == c.nodes.get(cl)) mode = 12;387 nl = w.getNodesCount()-1; 388 if(w.getNode(nl) == c.getNode(0)) mode = 21; 389 else if(w.getNode(nl) == c.getNode(cl)) mode = 22; 390 else if(w.getNode(0) == c.getNode(0)) mode = 11; 391 else if(w.getNode(0) == c.getNode(cl)) mode = 12; 391 392 } 392 393 else 393 394 { 394 395 nl = n.size()-1; 395 if(n.get(nl) == c. nodes.get(0)) mode = 21;396 else if(n.get(0) == c. nodes.get(cl)) mode = 12;397 else if(n.get(0) == c. nodes.get(0)) mode = 11;398 else if(n.get(nl) == c. nodes.get(cl)) mode = 22;396 if(n.get(nl) == c.getNode(0)) mode = 21; 397 else if(n.get(0) == c.getNode(cl)) mode = 12; 398 else if(n.get(0) == c.getNode(0)) mode = 11; 399 else if(n.get(nl) == c.getNode(cl)) mode = 22; 399 400 } 400 401 if(mode != 0) … … 404 405 if(c.selected) selected = true; 405 406 --left; 406 if(n == null) n = new ArrayList<Node>(w.nodes);407 if(n == null) n = w.getNodes(); 407 408 n.remove((mode == 21 || mode == 22) ? nl : 0); 408 409 if(mode == 21) 409 n.addAll(c. nodes);410 n.addAll(c.getNodes()); 410 411 else if(mode == 12) 411 n.addAll(0, c. nodes);412 n.addAll(0, c.getNodes()); 412 413 else if(mode == 22) 413 414 { 414 for(Node node : c. nodes)415 for(Node node : c.getNodes()) 415 416 n.add(nl, node); 416 417 } 417 418 else /* mode == 11 */ 418 419 { 419 for(Node node : c. nodes)420 for(Node node : c.getNodes()) 420 421 n.add(0, node); 421 422 } … … 551 552 { 552 553 Way w = (Way) m.member; 553 if(w. nodes.size() < 2)554 if(w.getNodesCount() < 2) 554 555 { 555 556 r.putError(tr("Way ''{0}'' with less than two points.", … … 640 641 if(fromWay.firstNode() == via) { 641 642 //System.out.println("From way heading away from via"); 642 fromNode = fromWay. nodes.get(1);643 fromNode = fromWay.getNode(1); 643 644 } else { 644 645 //System.out.println("From way heading towards via"); 645 fromNode = fromWay. nodes.get(fromWay.nodes.size()-2);646 fromNode = fromWay.getNode(fromWay.nodes.size()-2); 646 647 } 647 648 … … 796 797 { 797 798 Way w = (Way) m.member; 798 if(w. nodes.size() < 2)799 if(w.getNodesCount() < 2) 799 800 { 800 801 r.putError(tr("Way ''{0}'' with less than two points.", … … 881 882 { 882 883 way = w; 883 for (Node n : w. nodes)884 for (Node n : w.getNodes()) 884 885 { 885 886 p = nc.getPoint(n); … … 1059 1060 Polygon polygon = new Polygon(); 1060 1061 1061 for (Node n : w. nodes)1062 for (Node n : w.getNodes()) 1062 1063 { 1063 1064 Point p = nc.getPoint(n); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r1753 r1862 7 7 import java.util.HashMap; 8 8 import java.util.LinkedList; 9 import java.util.List; 9 10 import java.util.Map; 10 11 import java.util.logging.Logger; … … 51 52 /** 52 53 * constructor 53 * 54 * 54 55 * The visitor will merge <code>theirDataSet</code> onto <code>myDataSet</code> 55 * 56 * 56 57 * @param myDataSet dataset with my primitives 57 58 * @param theirDataSet dataset with their primitives. … … 76 77 /** 77 78 * Merges a primitive <code>other</code> of type <P> onto my primitives. 78 * 79 * 79 80 * If other.id != 0 it tries to merge it with an corresponding primitive from 80 81 * my dataset with the same id. If this is not possible a conflict is remembered 81 82 * in {@see #conflicts}. 82 * 83 * 83 84 * If other.id == 0 it tries to find a primitive in my dataset with id == 0 which 84 85 * is semantically equal. If it finds one it merges its technical attributes onto 85 86 * my primitive. 86 * 87 * 87 88 * @param <P> the type of the other primitive 88 89 * @param other the other primitive … … 171 172 private void fixWay(Way w) { 172 173 boolean replacedSomething = false; 173 Li nkedList<Node> newNodes = new LinkedList<Node>();174 for (Node myNode : w. nodes) {174 List<Node> newNodes = new LinkedList<Node>(); 175 for (Node myNode : w.getNodes()) { 175 176 Node mergedNode = (Node) merged.get(myNode); 176 177 if (mergedNode != null) { … … 184 185 } 185 186 if (replacedSomething) { 186 w.nodes.clear(); 187 w.nodes.addAll(newNodes); 187 w.setNodes(newNodes); 188 188 } 189 189 } … … 310 310 * Runs the merge operation. Successfully merged {@see OsmPrimitive}s are in 311 311 * {@see #getMyDataSet()}. 312 * 312 * 313 313 * See {@see #getConflicts()} for a map of conflicts after the merge operation. 314 314 */ … … 322 322 /** 323 323 * replies my dataset 324 * 324 * 325 325 * @return 326 326 */ … … 332 332 /** 333 333 * replies the map of conflicts 334 * 334 * 335 335 * @return the map of conflicts 336 336 */ -
trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r1725 r1862 20 20 import org.openstreetmap.josm.Main; 21 21 import org.openstreetmap.josm.data.osm.DataSet; 22 import org.openstreetmap.josm.data.osm.RelationMember;23 22 import org.openstreetmap.josm.data.osm.Node; 24 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 25 24 import org.openstreetmap.josm.data.osm.Relation; 25 import org.openstreetmap.josm.data.osm.RelationMember; 26 26 import org.openstreetmap.josm.data.osm.Way; 27 27 import org.openstreetmap.josm.gui.NavigatableComponent; … … 269 269 270 270 public void visitVirtual(Way w) { 271 Iterator<Node> it = w. nodes.iterator();271 Iterator<Node> it = w.getNodes().iterator(); 272 272 if (it.hasNext()) { 273 273 Point lastP = nc.getPoint(it.next()); … … 294 294 */ 295 295 public void visit(Way w) { 296 if (w.incomplete || w. nodes.size() < 2)296 if (w.incomplete || w.getNodesCount() < 2) 297 297 return; 298 298 … … 361 361 362 362 boolean first = true; 363 for (Node n : ((Way) m.member). nodes) {363 for (Node n : ((Way) m.member).getNodes()) { 364 364 if (n.incomplete || n.deleted) continue; 365 365 Point p = nc.getPoint(n);
Note:
See TracChangeset
for help on using the changeset viewer.