Changeset 3824 in josm for trunk/src/org/openstreetmap/josm/data/osm
- Timestamp:
- 2011-01-27T21:18:27+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r3731 r3824 26 26 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError; 27 27 import org.openstreetmap.josm.data.osm.visitor.Visitor; 28 import org.openstreetmap.josm.gui.mappaint. ElemStyle;28 import org.openstreetmap.josm.gui.mappaint.StyleCache; 29 29 import org.openstreetmap.josm.tools.CheckParameterUtil; 30 30 import org.openstreetmap.josm.tools.Predicate; … … 299 299 * MAPPAINT 300 300 *--------*/ 301 public ElemStyle mappaintStyle = null;301 public StyleCache mappaintStyle = null; 302 302 public int mappaintDrawnCode = 0; 303 303 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintVisitor.java
r3822 r3824 1 / * License: GPL. Copyright 2007 by Immanuel Scholz and others */1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.data.osm.visitor.paint; 3 4 /* To enable debugging or profiling remove the double / signs */5 3 6 4 import java.awt.Graphics2D; … … 38 36 import org.openstreetmap.josm.gui.mappaint.LineElemStyle; 39 37 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 40 import org.openstreetmap.josm.gui.mappaint.S impleNodeElemStyle;38 import org.openstreetmap.josm.gui.mappaint.StyleCache; 41 39 42 40 public class MapPaintVisitor implements PaintVisitor { … … 70 68 } 71 69 72 public ElemStyle getPrimitiveStyle(OsmPrimitive osm, boolean nodefault) {70 public StyleCache getPrimitiveStyle(OsmPrimitive osm, boolean nodefault) { 73 71 if(osm.mappaintStyle == null) 74 72 { … … 79 77 } 80 78 } 81 if (osm.mappaintStyle == null) {79 if (osm.mappaintStyle.equals(StyleCache.EMPTY_STYLECACHE)) { 82 80 if(osm instanceof Node) 83 osm.mappaintStyle = S impleNodeElemStyle.INSTANCE;81 osm.mappaintStyle = StyleCache.SIMPLE_NODE_STYLECACHE;// SimpleNodeElemStyle.INSTANCE; 84 82 else if (osm instanceof Way) 85 osm.mappaintStyle = LineElemStyle.UNTAGGED_WAY;86 } 87 } 88 if (nodefault && osm.mappaintStyle == LineElemStyle.UNTAGGED_WAY)89 return null;83 osm.mappaintStyle = StyleCache.UNTAGGED_WAY_STYLECACHE;//LineElemStyle.UNTAGGED_WAY; 84 } 85 } 86 if (nodefault && osm.mappaintStyle.equals(StyleCache.UNTAGGED_WAY_STYLECACHE)) 87 return StyleCache.EMPTY_STYLECACHE; 90 88 return osm.mappaintStyle; 91 89 } 92 90 93 91 public IconElemStyle getPrimitiveNodeStyle(OsmPrimitive osm) { 94 if(osm.mappaintStyle == null && styles != null) 95 osm.mappaintStyle = styles.getIcon(osm); 96 97 return (IconElemStyle)osm.mappaintStyle; 92 if(osm.mappaintStyle == null && styles != null) { 93 IconElemStyle icon = styles.getIcon(osm); 94 osm.mappaintStyle = StyleCache.create(icon); 95 return icon; 96 } 97 for (ElemStyle s : osm.mappaintStyle.getStyles()) { 98 if (s instanceof IconElemStyle) 99 return (IconElemStyle) s; 100 } 101 return null; 98 102 } 99 103 … … 115 119 return; 116 120 117 ElemStyle nodeStyle = getPrimitiveStyle(n, false); 118 119 if (isZoomOk(nodeStyle)) { 120 nodeStyle.paintPrimitive(n, paintSettings, painter, data.isSelected(n), 121 false); 121 StyleCache sc = getPrimitiveStyle(n, false); 122 123 for (ElemStyle s : sc.getStyles()) { 124 if (isZoomOk(s)) { 125 s.paintPrimitive(n, paintSettings, painter, data.isSelected(n), false); 126 } 127 122 128 } 123 129 } … … 158 164 return; 159 165 160 ElemStyle wayStyle = getPrimitiveStyle(w, false); 161 162 if(!isZoomOk(wayStyle)) 163 return; 164 165 if(wayStyle instanceof LineElemStyle) { 166 wayStyle.paintPrimitive(w, paintSettings, painter, data.isSelected(w), false); 167 } else if (wayStyle instanceof AreaElemStyle) { 168 AreaElemStyle areaStyle = (AreaElemStyle) wayStyle; 169 /* way with area style */ 170 if (fillAreas > dist) 171 { 172 areaStyle.paintPrimitive(w, paintSettings, painter, data.isSelected(w), false); 173 } 174 areaStyle.getLineStyle().paintPrimitive(w, paintSettings, painter, data.isSelected(w), false); 166 StyleCache sc = getPrimitiveStyle(w, false); 167 for (ElemStyle s : sc.getStyles()) { 168 if(!isZoomOk(s)) 169 return; 170 if (fillAreas > dist || !(s instanceof AreaElemStyle)) { 171 s.paintPrimitive(w, paintSettings, painter, data.isSelected(w), false); 172 } 175 173 } 176 174 } … … 369 367 multipolygon.load(r); 370 368 371 ElemStyle wayStyle = getPrimitiveStyle(r, false); 369 AreaElemStyle areaStyle = null; 370 LineElemStyle lineStyle = null; 371 for (ElemStyle s : getPrimitiveStyle(r, false).getStyles()) { 372 if (s instanceof AreaElemStyle) { 373 areaStyle = (AreaElemStyle) s; 374 } else if (s instanceof LineElemStyle) { 375 lineStyle = (LineElemStyle) s; 376 } 377 } 372 378 373 379 boolean disabled = r.isDisabled(); 374 380 // If area style was not found for relation then use style of ways 375 if(styles != null && !(wayStyle instanceof AreaElemStyle)) {381 if(styles != null && areaStyle == null) { 376 382 for (Way w : multipolygon.getOuterWays()) { 377 wayStyle = styles.getArea(w); 383 for (ElemStyle s : styles.getArea(w).getStyles()) { 384 if (s instanceof AreaElemStyle) { 385 areaStyle = (AreaElemStyle) s; 386 } else if (s instanceof LineElemStyle) { 387 lineStyle = (LineElemStyle) s; 388 } 389 } 378 390 disabled = disabled || w.isDisabled(); 379 if( wayStyle != null) {391 if(areaStyle != null) { 380 392 break; 381 393 } … … 383 395 } 384 396 385 if ( wayStyle instanceof AreaElemStyle) {386 boolean zoomok = isZoomOk( wayStyle);397 if (areaStyle != null) { 398 boolean zoomok = isZoomOk(areaStyle); 387 399 boolean visible = false; 388 400 … … 390 402 391 403 if(zoomok && !disabled && !multipolygon.getOuterWays().isEmpty()) { 392 AreaElemStyle areaStyle = (AreaElemStyle)wayStyle;393 404 for (PolyData pd : multipolygon.getCombinedPolygons()) { 394 405 Polygon p = pd.get(); … … 399 410 boolean selected = pd.selected || data.isSelected(r); 400 411 painter.drawArea(p, selected ? paintSettings.getRelationSelectedColor() 401 : areaStyle.color, painter.getAreaName(r));412 : areaStyle.color, painter.getAreaName(r)); 402 413 visible = true; 403 414 } … … 407 418 return drawn; 408 419 for (Way wInner : multipolygon.getInnerWays()) { 409 ElemStyle innerStyle = getPrimitiveStyle(wInner, true); 410 if(innerStyle == null) { 420 StyleCache inner = getPrimitiveStyle(wInner, true); 421 AreaElemStyle innerArea = null; 422 for (ElemStyle s : inner.getStyles()) { 423 if (s instanceof AreaElemStyle) { 424 innerArea = (AreaElemStyle) s; 425 break; 426 } 427 } 428 429 if(inner.getStyles().isEmpty()) { 411 430 if (data.isSelected(wInner) || disabled) 412 431 continue; 413 432 if(zoomok && (wInner.mappaintDrawnCode != paintid || multipolygon.getOuterWays().isEmpty())) { 414 ((AreaElemStyle)wayStyle).getLineStyle().paintPrimitive(wInner, paintSettings,415 painter, (data.isSelected(wInner) || data.isSelected(r)), false);433 lineStyle.paintPrimitive(wInner, paintSettings, 434 painter, (data.isSelected(wInner) || data.isSelected(r)), false); 416 435 } 417 436 wInner.mappaintDrawnCode = paintid; 418 437 } 419 else 420 { 421 if(wayStyle.equals(innerStyle)) 422 { 438 else { 439 if(areaStyle.equals(innerArea)) { 423 440 wInner.mappaintDrawnAreaCode = paintid; 424 if(!data.isSelected(wInner))425 {441 442 if(!data.isSelected(wInner)) { 426 443 wInner.mappaintDrawnCode = paintid; 427 444 drawWay(wInner, 0); … … 431 448 } 432 449 for (Way wOuter : multipolygon.getOuterWays()) { 433 ElemStyle outerStyle = getPrimitiveStyle(wOuter, true); 434 if(outerStyle == null) { 450 StyleCache outer = getPrimitiveStyle(wOuter, true); 451 boolean hasOuterArea = false; 452 for (ElemStyle s : outer.getStyles()) { 453 if (s instanceof AreaElemStyle) { 454 hasOuterArea = true; 455 break; 456 } 457 } 458 459 if (outer.getStyles().isEmpty()) { 435 460 // Selected ways are drawn at the very end 436 461 if (data.isSelected(wOuter)) 437 462 continue; 438 463 if(zoomok) { 439 ((AreaElemStyle)wayStyle).getLineStyle().paintPrimitive(wOuter, paintSettings, painter,440 (data.isSelected(wOuter) || data.isSelected(r)), r.isSelected());464 lineStyle.paintPrimitive(wOuter, paintSettings, painter, 465 (data.isSelected(wOuter) || data.isSelected(r)), r.isSelected()); 441 466 } 442 467 wOuter.mappaintDrawnCode = paintid; 443 } else if (outerStyle instanceof AreaElemStyle) {468 } else if (hasOuterArea) { 444 469 wOuter.mappaintDrawnAreaCode = paintid; 445 470 if(!data.isSelected(wOuter)) { … … 512 537 /* Shows areas before non-areas */ 513 538 public void visitAll(final DataSet data, boolean virtual, Bounds bounds) { 539 //long start = System.currentTimeMillis(); 514 540 BBox bbox = new BBox(bounds); 515 541 this.data = data; … … 616 642 OsmPrimitive osm = m.getMember(); 617 643 if(osm.isDrawable()) { 618 ElemStyle style= getPrimitiveStyle(m.getMember(), false);644 StyleCache sc = getPrimitiveStyle(m.getMember(), false); 619 645 if(osm instanceof Way) 620 646 { 621 if(style instanceof AreaElemStyle) {622 ((AreaElemStyle)style).getLineStyle().paintPrimitive(osm, paintSettings, painter, true, true);623 } else {624 style.paintPrimitive(osm, paintSettings, painter, data.isSelected(osm), true);647 for (ElemStyle s : sc.getStyles()) { 648 if (!(s instanceof AreaElemStyle)) { 649 s.paintPrimitive(osm, paintSettings, painter, data.isSelected(osm), true); 650 } 625 651 } 626 652 } 627 653 else if(osm instanceof Node) 628 654 { 629 if(isZoomOk(style)) { 630 style.paintPrimitive(osm, paintSettings, painter, data.isSelected(osm), true); 655 for (ElemStyle s : sc.getStyles()) { 656 if (isZoomOk(s)) { 657 s.paintPrimitive(osm, paintSettings, painter, data.isSelected(osm), true); 658 } 631 659 } 632 660 } … … 648 676 649 677 painter.drawVirtualNodes(data.searchWays(bbox)); 678 //System.err.println("PAINTING TOOK "+(System.currentTimeMillis() - start)); 650 679 } 651 680
Note:
See TracChangeset
for help on using the changeset viewer.