- Timestamp:
- 2009-01-20T18:26:59+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r1287 r1313 223 223 for (int i : is) segSet.add( 224 224 Pair.sort(new Pair<Node,Node>(w.nodes.get(i), w.nodes.get(i+1)))); 225 for (int i : is) wnew. nodes.add(i + 1, n);225 for (int i : is) wnew.addNode(i + 1, n); 226 226 227 227 cmds.add(new ChangeCommand(insertPoint.getKey(), wnew)); … … 287 287 if(way != null) { 288 288 int nodeCount=0; 289 for (Node p : way.nodes) 289 for (Node p : way.nodes) 290 290 if(p.equals(n0)) nodeCount++; 291 291 if(nodeCount > 1) way = null; … … 294 294 if (way == null) { 295 295 way = new Way(); 296 way. nodes.add(n0);296 way.addNode(n0); 297 297 cmds.add(new AddCommand(way)); 298 298 } else { … … 309 309 // Connected to a node that's already in the way 310 310 if(way != null && way.nodes.contains(n)) { 311 System.out.println("Stop drawing, node is part of current way");311 //System.out.println("Stop drawing, node is part of current way"); 312 312 wayIsFinished = true; 313 313 selection.clear(); 314 314 //Main.map.selectMapMode(new SelectAction(Main.map)); 315 315 } 316 316 317 317 // Add new node to way 318 if (way.nodes.get(way.nodes.size() - 1) == n0) { 319 way.nodes.add(n); 320 } else { 321 way.nodes.add(0, n); 322 } 318 if (way.nodes.get(way.nodes.size() - 1) == n0) 319 way.addNode(n); 320 else 321 way.addNode(0, n); 323 322 324 323 extendedWay = true; … … 327 326 328 327 String title; 329 if (!extendedWay && !newNode) {330 return; // We didn't do anything.331 } else if (!extendedWay) {332 if (reuseWays.isEmpty()) {328 if (!extendedWay) { 329 if (!newNode) 330 return; // We didn't do anything. 331 else if (reuseWays.isEmpty()) 333 332 title = tr("Add node"); 334 } else {333 else 335 334 title = tr("Add node into way"); 336 }337 335 for (Way w : reuseWays) w.selected = false; 338 336 Main.ds.setSelected(n); -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r1221 r1313 228 228 Node n4 = new Node(Main.proj.eastNorth2latlon(en4)); 229 229 Way wnew = new Way(selectedSegment.way); 230 wnew. nodes.add(selectedSegment.lowerIndex+1, n3);231 wnew. nodes.add(selectedSegment.lowerIndex+1, n4);232 if (wnew.nodes.size() == 4) wnew. nodes.add(n1);230 wnew.addNode(selectedSegment.lowerIndex+1, n3); 231 wnew.addNode(selectedSegment.lowerIndex+1, n4); 232 if (wnew.nodes.size() == 4) wnew.addNode(n1); 233 233 Collection<Command> cmds = new LinkedList<Command>(); 234 234 cmds.add(new AddCommand(n4)); -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r1245 r1313 177 177 Way w = virtualWay.way; 178 178 Way wnew = new Way(w); 179 wnew. nodes.add(virtualWay.lowerIndex+1, virtualNode);179 wnew.addNode(virtualWay.lowerIndex+1, virtualNode); 180 180 virtualCmds.add(new ChangeCommand(w, wnew)); 181 181 virtualCmds.add(new MoveCommand(virtualNode, dx, dy)); -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r1270 r1313 56 56 errors = null; 57 57 } 58 /* This should not be called from outside. Fixing the UI to add relevant 59 get/set functions calling this implecitely is prefered, so we can have 60 transparent cache handling in the future. */ 61 protected void clearCached() 62 { 63 mappaintVisibleCode = 0; 64 mappaintDrawnCode = 0; 65 mappaintStyle = null; 66 } 58 67 /* end of mappaint data */ 59 68 … … 279 288 tagged = osm.tagged; 280 289 incomplete = osm.incomplete; 281 mappaintStyle = null; 290 clearCached(); 291 clearErrors(); 282 292 } 283 293 -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r1270 r1313 30 30 public Integer mappaintDrawnAreaCode = 0; 31 31 /* end of mappaint data */ 32 32 @Override protected void clearCached() 33 { 34 super.clearCached(); 35 isMappaintArea = false; 36 mappaintDrawnAreaCode = 0; 37 } 38 33 39 public void visitNodes(Visitor v) { 34 40 for (Node n : this.nodes) … … 126 132 } 127 133 134 public void addNode(Node n) 135 { 136 clearCached(); 137 nodes.add(n); 138 } 139 140 public void addNode(int offs, Node n) 141 { 142 clearCached(); 143 nodes.add(offs, n); 144 } 145 128 146 public Boolean isClosed() { 129 147 int s = nodes.size(); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r1310 r1313 93 93 public ElemStyle getPrimitiveStyle(OsmPrimitive osm) { 94 94 if(!useStyleCache) 95 return (styles != null) ? (IconElemStyle)styles.get(osm) : null;95 return (styles != null) ? styles.get(osm) : null; 96 96 97 97 if(osm.mappaintStyle == null && styles != null) { 98 osm.mappaintStyle = 98 osm.mappaintStyle = styles.get(osm); 99 99 if(osm instanceof Way) 100 100 ((Way)osm).isMappaintArea = styles.isArea(osm); 101 101 } 102 102 return osm.mappaintStyle; 103 } 104 105 public IconElemStyle getPrimitiveNodeStyle(OsmPrimitive osm) { 106 if(!useStyleCache) 107 return (styles != null) ? styles.getIcon(osm) : null; 108 109 if(osm.mappaintStyle == null && styles != null) 110 osm.mappaintStyle = styles.getIcon(osm); 111 112 return (IconElemStyle)osm.mappaintStyle; 103 113 } 104 114 … … 417 427 } 418 428 419 public void drawSelectedRelation(Relation r)420 {421 for (RelationMember m : r.members)422 {423 if (m.member != null && !m.member.incomplete && !m.member.deleted424 && !(m.member instanceof Relation))425 {426 /* nodes drawn on second call */427 if(!(m.member instanceof Node))428 drawSelectedMember(m.member, styles != null ? styles.get(m.member)429 : null, true, true);430 }431 }432 }433 434 429 public void drawSelectedMember(OsmPrimitive osm, ElemStyle style, Boolean area, 435 430 Boolean areaselected) … … 463 458 464 459 r.mappaintVisibleCode = 0; 465 /* TODO implement visible handling for relations too */466 460 467 461 // TODO: is it possible to do this like the nodes/ways code? … … 469 463 return; 470 464 471 // draw multipolygon relations including their ways 472 // other relations are only drawn when selected 473 474 // we are in the "draw selected" phase 475 // TODO: is it necessary to check for r.selected? 476 if(r.selected && selectedCall) 465 if(selectedCall) 477 466 { 478 467 for (RelationMember m : r.members) 479 468 { 480 469 if (m.member != null && !m.member.incomplete && !m.member.deleted 481 && (drawRestriction || m.member instanceof Node))482 { 483 drawSelectedMember(m.member, styles != null ? styles.get(m.member) : null, true, true);470 && m.member instanceof Node) 471 { 472 drawSelectedMember(m.member, styles != null ? getPrimitiveStyle(m.member) : null, true, true); 484 473 } 485 474 } 486 475 return; 487 476 } 488 489 if (drawMultipolygon && r.keys != null && "multipolygon".equals(r.keys.get("type"))) 490 { 491 drawMultipolygon(r); 492 return; 493 } 494 495 if (drawRestriction && r.keys != null && "restriction".equals(r.keys.get("type"))) 477 else if (drawMultipolygon && r.keys != null && "multipolygon".equals(r.keys.get("type"))) 478 { 479 if(drawMultipolygon(r)) 480 return; 481 } 482 else if (drawRestriction && r.keys != null && "restriction".equals(r.keys.get("type"))) 496 483 { 497 484 drawRestriction(r); 498 return; 499 } 500 501 if(r.selected) 502 drawSelectedRelation(r); 503 } 504 485 } 486 487 if(r.selected) /* draw ways*/ 488 { 489 for (RelationMember m : r.members) 490 { 491 if (m.member != null && !m.member.incomplete && !m.member.deleted 492 && m.member instanceof Way) /* nodes drawn on second call */ 493 { 494 drawSelectedMember(m.member, styles != null ? getPrimitiveStyle(m.member) 495 : null, true, true); 496 } 497 } 498 } 499 } 505 500 506 501 // this current experimental implementation will only work for standard restrictions: … … 724 719 } 725 720 726 IconElemStyle nodeStyle = (IconElemStyle)getPrimitiveStyle(r);721 IconElemStyle nodeStyle = getPrimitiveNodeStyle(r); 727 722 728 723 if (nodeStyle == null) { … … 748 743 } 749 744 750 public voiddrawMultipolygon(Relation r) {745 public Boolean drawMultipolygon(Relation r) { 751 746 Collection<Way> inner = new LinkedList<Way>(); 752 747 Collection<Way> outer = new LinkedList<Way>(); … … 754 749 Collection<Way> outerclosed = new LinkedList<Way>(); 755 750 Boolean incomplete = false; 751 Boolean drawn = false; 756 752 757 753 r.clearErrors(); … … 787 783 outer.add(w); 788 784 else if(r.selected) 789 drawSelectedMember(m.member, styles != null ? styles.get(m.member) : null, true, true); 785 drawSelectedMember(m.member, styles != null 786 ? getPrimitiveStyle(m.member) : null, true, true); 790 787 } 791 788 } … … 798 795 } 799 796 800 ElemStyle wayStyle = styles != null ? styles.get(r) : null;797 ElemStyle wayStyle = styles != null ? getPrimitiveStyle(r) : null; 801 798 if(styles != null && (wayStyle == null || !(wayStyle instanceof AreaElemStyle))) 802 799 { … … 806 803 wayStyle = styles.get(w); 807 804 } 805 r.mappaintStyle = wayStyle; 808 806 } 809 807 … … 814 812 Collection<Way> join = new LinkedList<Way>(); 815 813 814 drawn = true; 816 815 for (Way w : outer) 817 816 { … … 954 953 for (Way wOuter : outer) 955 954 wOuter.mappaintVisibleCode = viewid; 956 return ;955 return drawn; 957 956 } 958 957 for (Way wInner : inner) 959 958 { 960 ElemStyle innerStyle = styles.get(wInner);959 ElemStyle innerStyle = getPrimitiveStyle(wInner); 961 960 if(innerStyle == null) 962 961 { … … 988 987 for (Way wOuter : outer) 989 988 { 990 ElemStyle outerStyle = styles.get(wOuter);989 ElemStyle outerStyle = getPrimitiveStyle(wOuter); 991 990 if(outerStyle == null) 992 991 { … … 1016 1015 } 1017 1016 } 1018 else if(r.selected) 1019 drawSelectedRelation(r); 1017 return drawn; 1020 1018 } 1021 1019 -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r1295 r1313 29 29 areas = new HashMap<String, AreaElemStyle>(); 30 30 } 31 private ElemStyle getNode(Map<String, String> keys)31 private IconElemStyle getNode(Map<String, String> keys) 32 32 { 33 33 IconElemStyle ret = null; … … 120 120 { 121 121 return (osm.keys == null) ? null : 122 ((osm instanceof Node || osm instanceof Relation) ? getNode(osm.keys) : get(osm.keys)); 122 ((osm instanceof Node) ? getNode(osm.keys) : get(osm.keys)); 123 } 124 125 public IconElemStyle getIcon(OsmPrimitive osm) 126 { 127 return (osm.keys == null) ? null : getNode(osm.keys); 123 128 } 124 129
Note:
See TracChangeset
for help on using the changeset viewer.