Changeset 16700 in josm


Ignore:
Timestamp:
2020-06-21T18:53:41+02:00 (12 days ago)
Author:
simon04
Message:

fix #18213 - MapCSS: add support for repeat-image-opacity

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r16393 r16700  
    66import java.awt.Color;
    77import java.awt.Component;
     8import java.awt.Composite;
    89import java.awt.Dimension;
    910import java.awt.Font;
     
    682683     * @param spacing spacing between two images
    683684     * @param phase initial spacing
     685     * @param opacity the opacity
    684686     * @param align alignment of the image. The top, center or bottom edge can be aligned with the way.
    685687     */
    686688    public void drawRepeatImage(IWay<?> way, MapImage pattern, boolean disabled, double offset, double spacing, double phase,
    687             LineImageAlignment align) {
     689                                float opacity, LineImageAlignment align) {
    688690        final int imgWidth = pattern.getWidth();
    689691        final double repeat = imgWidth + spacing;
     
    730732                int sx1 = Math.max(0, -x);
    731733                int sx2 = imgWidth - Math.max(0, x + imgWidth - (int) Math.ceil(segmentLength));
     734                Composite saveComposite = g.getComposite();
     735                g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity));
    732736                g.drawImage(image, x + sx1, dy1, x + sx2, dy2, sx1, 0, sx2, imgHeight, null);
     737                g.setComposite(saveComposite);
    733738                imageStart += repeat;
    734739            }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/RepeatImageElement.java

    r16630 r16700  
    6767    public float phase;
    6868    /**
     69     * The opacity
     70     */
     71    public float opacity;
     72    /**
    6973     * The alignment of the image
    7074     */
     
    8185     * @param spacing The space between the images
    8286     * @param phase The offset of the first image along the way
     87     * @param opacity The opacity
    8388     * @param align The alignment of the image
    8489     */
    85     public RepeatImageElement(Cascade c, MapImage pattern, float offset, float spacing, float phase, LineImageAlignment align) {
     90    public RepeatImageElement(Cascade c, MapImage pattern, float offset, float spacing, float phase, float opacity, LineImageAlignment align) {
    8691        super(c, 2.9f);
    8792        CheckParameterUtil.ensureParameterNotNull(pattern);
     
    9196        this.spacing = spacing;
    9297        this.phase = phase;
     98        this.opacity = opacity;
    9399        this.align = align;
    94100    }
     
    107113        float spacing = c.get(REPEAT_IMAGE_SPACING, 0f, Float.class);
    108114        float phase = -c.get(REPEAT_IMAGE_PHASE, 0f, Float.class);
     115        float opacity = c.get(REPEAT_IMAGE_OPACITY, 1f, Float.class);
    109116
    110117        LineImageAlignment align = LineImageAlignment.CENTER;
     
    116123        }
    117124
    118         return new RepeatImageElement(c, pattern, offset, spacing, phase, align);
     125        return new RepeatImageElement(c, pattern, offset, spacing, phase, opacity, align);
    119126    }
    120127
     
    124131        if (primitive instanceof IWay) {
    125132            IWay<?> w = (IWay<?>) primitive;
    126             painter.drawRepeatImage(w, pattern, painter.isInactiveMode() || w.isDisabled(), offset, spacing, phase, align);
     133            painter.drawRepeatImage(w, pattern, painter.isInactiveMode() || w.isDisabled(), offset, spacing, phase, opacity, align);
    127134        }
    128135    }
     
    148155    @Override
    149156    public int hashCode() {
    150         return Objects.hash(super.hashCode(), pattern, offset, spacing, phase, align);
     157        return Objects.hash(super.hashCode(), pattern, offset, spacing, phase, opacity, align);
    151158    }
    152159
     
    155162        return "RepeatImageStyle{" + super.toString() + "pattern=[" + pattern +
    156163                "], offset=" + offset + ", spacing=" + spacing +
    157                 ", phase=" + -phase + ", align=" + align + '}';
     164                ", phase=" + -phase + ", opacity=" + opacity + ", align=" + align + '}';
    158165    }
    159166}
Note: See TracChangeset for help on using the changeset viewer.