Changeset 14583 in josm
- Timestamp:
- 2018-12-22T08:49:30+01:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r14557 r14583 88 88 import org.openstreetmap.josm.tools.JosmRuntimeException; 89 89 import org.openstreetmap.josm.tools.Logging; 90 import org.openstreetmap.josm.tools.ShapeClipper; 90 91 import org.openstreetmap.josm.tools.Utils; 91 92 import org.openstreetmap.josm.tools.bugreport.BugReport; … … 437 438 */ 438 439 protected void drawArea(MapViewPath path, Color color, 439 MapImage fillImage, Float extent, Path2D.DoublepfClip, boolean disabled) {440 MapImage fillImage, Float extent, MapViewPath pfClip, boolean disabled) { 440 441 if (!isOutlineOnly && color.getAlpha() != 0) { 441 442 Shape area = path; … … 478 479 * 479 480 */ 480 private void computeFill(Shape shape, Float extent, Path2D.DoublepfClip, float mitterLimit) {481 private void computeFill(Shape shape, Float extent, MapViewPath pfClip, float mitterLimit) { 481 482 if (extent == null) { 482 483 g.fill(shape); … … 485 486 Shape clip = shape; 486 487 if (pfClip != null) { 487 clip = pfClip .createTransformedShape(mapState.getAffineTransform());488 clip = pfClip; 488 489 } 489 490 g.clip(clip); … … 515 516 continue; 516 517 } 517 MapViewPath p = new MapViewPath(mapState); 518 p.appendFromEastNorth(pd.get()); 519 p.setWindingRule(Path2D.WIND_EVEN_ODD); 520 Path2D.Double pfClip = null; 518 MapViewPath p = shapeEastNorthToMapView(pd.get()); 519 MapViewPath pfClip = null; 521 520 if (extent != null) { 522 521 if (!usePartialFill(pd.getAreaAndPerimeter(null), extent, extentThreshold)) { 523 522 extent = null; 524 523 } else if (!pd.isClosed()) { 525 pfClip = getPFClip(pd, extent * scale);524 pfClip = shapeEastNorthToMapView(getPFClip(pd, extent * scale)); 526 525 } 527 526 } … … 531 530 } 532 531 } 532 } 533 534 /** 535 * Convert shape in EastNorth coordinates to MapViewPath and remove invisible parts. 536 * For complex shapes this improves performance drastically because the methods in Graphics2D.clip() and Graphics2D.draw() are rather slow. 537 * @param shape the shape to convert 538 * @return the converted shape 539 */ 540 private MapViewPath shapeEastNorthToMapView(Path2D.Double shape) { 541 MapViewPath convertedShape = null; 542 if (shape != null) { 543 convertedShape = new MapViewPath(mapState); 544 convertedShape.appendFromEastNorth(shape); 545 convertedShape.setWindingRule(Path2D.WIND_EVEN_ODD); 546 547 Rectangle2D extViewBBox = mapState.getViewClipRectangle().getInView(); 548 if (!extViewBBox.contains(convertedShape.getBounds2D())) { 549 // remove invisible parts of shape 550 Path2D.Double clipped = ShapeClipper.clipShape(convertedShape, extViewBBox); 551 if (clipped != null) { 552 convertedShape.reset(); 553 convertedShape.append(clipped, false); 554 } 555 } 556 } 557 return convertedShape; 533 558 } 534 559 … … 547 572 */ 548 573 public void drawArea(IWay<?> w, Color color, MapImage fillImage, Float extent, Float extentThreshold, boolean disabled) { 549 Path2D.DoublepfClip = null;574 MapViewPath pfClip = null; 550 575 if (extent != null) { 551 576 if (!usePartialFill(Geometry.getAreaAndPerimeter(w.getNodes()), extent, extentThreshold)) { 552 577 extent = null; 553 578 } else if (!w.isClosed()) { 554 pfClip = getPFClip(w, extent * scale);579 pfClip = shapeEastNorthToMapView(getPFClip(w, extent * scale)); 555 580 } 556 581 }
Note:
See TracChangeset
for help on using the changeset viewer.