Ignore:
Timestamp:
2015-11-24T20:49:07+01:00 (8 years ago)
Author:
bastiK
Message:

mappaint partial fill: render unclosed areas differently (margin on both sites) (see #12104)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r9059 r9061  
    333333    private boolean showIcons;
    334334    private boolean isOutlineOnly;
     335    private boolean isUnclosedAreaHighlight;
     336    private double unclosedAreaHighlightWidth;
    335337
    336338    private Font orderFont;
     
    451453    }
    452454
    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,
    454474            boolean disabled, TextElement text) {
    455475
     
    466486                    g.fill(area);
    467487                } 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                    }
    473499                }
    474500            } else {
     
    483509                    g.fill(area);
    484510                } 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                    }
    490522                }
    491523                g.setPaintMode();
     
    592624                drawArea(r, p,
    593625                        pd.selected ? paintSettings.getRelationSelectedColor(color.getAlpha()) : color,
    594                         fillImage, extent, disabled, text);
     626                        fillImage, extent,
     627                        isUnclosedAreaHighlight && extent != null && !pd.isClosed(),
     628                        disabled, text);
    595629            }
    596630        }
     
    609643     */
    610644    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);
    612646    }
    613647
     
    14641498        showIcons = paintSettings.getShowIconsDistance() > circum;
    14651499        isOutlineOnly = paintSettings.isOutlineOnly();
     1500        isUnclosedAreaHighlight = paintSettings.isUnclosedAreaHighlight();
     1501        unclosedAreaHighlightWidth = paintSettings.getUnclosedAreaHighlightWidth();
    14661502        orderFont = new Font(Main.pref.get("mappaint.font", "Droid Sans"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8));
    14671503
Note: See TracChangeset for help on using the changeset viewer.