- Timestamp:
- 2015-11-24T20:49:07+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm/visitor/paint
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java
r8968 r9061 49 49 /** Preference: should only the data area outline be drawn */ 50 50 private boolean outlineOnly; 51 /** Preference: if unclosed areas should be drawn differently for partial fill */ 52 private boolean unclosedAreaHighlight; 53 /** Preference: width of unclosed area highlight */ 54 private double unclosedAreaHighlightWidth; 51 55 /** Color Preference for selected objects */ 52 56 private Color selectedColor; … … 106 110 107 111 outlineOnly = Main.pref.getBoolean("draw.data.area_outline_only", false); 112 unclosedAreaHighlight = Main.pref.getBoolean("draw.unclosed_area_partial_fill_highlight", true); 113 unclosedAreaHighlightWidth = Main.pref.getDouble("draw.unclosed_area_partial_fill_highlight.width", 80); 108 114 } 109 115 … … 346 352 return outlineOnly; 347 353 } 354 355 /** 356 * Determines if unclosed areas should be drawn differently for partial fill. 357 * 358 * @return {@code true} if unclosed areas should be drawn differently for partial fill 359 */ 360 public boolean isUnclosedAreaHighlight() { 361 return unclosedAreaHighlight; 362 } 363 364 /** 365 * Returns the width of unclosed area highlight 366 * @return the width of unclosed area highlight 367 */ 368 public double getUnclosedAreaHighlightWidth() { 369 return unclosedAreaHighlightWidth; 370 } 348 371 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r9059 r9061 333 333 private boolean showIcons; 334 334 private boolean isOutlineOnly; 335 private boolean isUnclosedAreaHighlight; 336 private double unclosedAreaHighlightWidth; 335 337 336 338 private Font orderFont; … … 451 453 } 452 454 453 protected void drawArea(OsmPrimitive osm, Path2D.Double path, Color color, MapImage fillImage, Float extent, 455 /** 456 * Worker function for drawing areas. 457 * 458 * @param osm the primitive 459 * @param path the path object for the area that should be drawn; in case 460 * of multipolygons, this can path can be a complex shape with one outer 461 * polygon and one or more inner polygons 462 * @param color The color to fill the area with. 463 * @param fillImage The image to fill the area with. Overrides color. 464 * @param extent if not null, area will be filled partially; specifies, how 465 * far to fill from the boundary towards the center of the area; 466 * if null, area will be filled completely 467 * @param unClosedHighlight true, if the fact that the way / multipolygon is not 468 * properly closed should be highlighted; this parameter is only used 469 * for partial fill ({@code extent != null}), otherwise it is ignored 470 * @param disabled If this should be drawn with a special disabled style. 471 * @param text The text to write on the area. 472 */ 473 protected void drawArea(OsmPrimitive osm, Path2D.Double path, Color color, MapImage fillImage, Float extent, boolean unClosedHighlight, 454 474 boolean disabled, TextElement text) { 455 475 … … 466 486 g.fill(area); 467 487 } else { 468 Shape clip = g.getClip(); 469 g.clip(area); 470 g.setStroke(new BasicStroke(2 * extent, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); 471 g.draw(area); 472 g.setClip(clip); 488 if (unClosedHighlight) { 489 g.setStroke(new BasicStroke((int)(unclosedAreaHighlightWidth / 100 * extent), 490 BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); 491 g.draw(area); 492 } else { 493 Shape clip = g.getClip(); 494 g.clip(area); 495 g.setStroke(new BasicStroke(2 * extent, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); 496 g.draw(area); 497 g.setClip(clip); 498 } 473 499 } 474 500 } else { … … 483 509 g.fill(area); 484 510 } else { 485 Shape clip = g.getClip(); 486 BasicStroke stroke = new BasicStroke(2 * extent, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); 487 g.clip(stroke.createStrokedShape(area)); 488 g.fill(area); 489 g.setClip(clip); 511 if (unClosedHighlight) { 512 g.setStroke(new BasicStroke((int)(unclosedAreaHighlightWidth / 100 * extent), 513 BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); 514 g.draw(area); 515 } else { 516 Shape clip = g.getClip(); 517 BasicStroke stroke = new BasicStroke(2 * extent, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); 518 g.clip(stroke.createStrokedShape(area)); 519 g.fill(area); 520 g.setClip(clip); 521 } 490 522 } 491 523 g.setPaintMode(); … … 592 624 drawArea(r, p, 593 625 pd.selected ? paintSettings.getRelationSelectedColor(color.getAlpha()) : color, 594 fillImage, extent, disabled, text); 626 fillImage, extent, 627 isUnclosedAreaHighlight && extent != null && !pd.isClosed(), 628 disabled, text); 595 629 } 596 630 } … … 609 643 */ 610 644 public void drawArea(Way w, Color color, MapImage fillImage, Float extent, boolean disabled, TextElement text) { 611 drawArea(w, getPath(w), color, fillImage, extent, disabled, text);645 drawArea(w, getPath(w), color, fillImage, extent, isUnclosedAreaHighlight && !w.isClosed(), disabled, text); 612 646 } 613 647 … … 1464 1498 showIcons = paintSettings.getShowIconsDistance() > circum; 1465 1499 isOutlineOnly = paintSettings.isOutlineOnly(); 1500 isUnclosedAreaHighlight = paintSettings.isUnclosedAreaHighlight(); 1501 unclosedAreaHighlightWidth = paintSettings.getUnclosedAreaHighlightWidth(); 1466 1502 orderFont = new Font(Main.pref.get("mappaint.font", "Droid Sans"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8)); 1467 1503 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java
r9059 r9061 360 360 resetNodes(event.getDataset()); 361 361 } 362 } 363 364 public boolean isClosed() { 365 if (nodes.size() < 3 || nodes.get(0) != nodes.get(nodes.size() - 1)) return false; 366 for (PolyData inner : inners) { 367 if (!inner.isClosed()) return false; 368 } 369 return true; 362 370 } 363 371 }
Note:
See TracChangeset
for help on using the changeset viewer.