Changeset 11692 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2017-03-05T17:31:39+01:00 (7 years ago)
Author:
michael2402
Message:

Repsect alpha component of mapcss text/halo color, use opacity to multiply.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/TextLabel.java

    r10748 r11692  
    146146        Color color = c.get(TEXT_COLOR, defaultTextColor, Color.class);
    147147        float alpha = c.get(TEXT_OPACITY, 1f, Float.class);
    148         color = new Color(color.getRed(), color.getGreen(),
    149                 color.getBlue(), Utils.colorFloat2int(alpha));
     148        color = Utils.alphaMultiply(color, alpha);
    150149
    151150        Float haloRadius = c.get(TEXT_HALO_RADIUS, null, Float.class);
     
    156155        if (haloRadius != null) {
    157156            haloColor = c.get(TEXT_HALO_COLOR, Utils.complement(color), Color.class);
    158             float haloAlpha = c.get(TEXT_HALO_OPACITY, 1f, Float.class);
    159             haloColor = new Color(haloColor.getRed(), haloColor.getGreen(),
    160                     haloColor.getBlue(), Utils.colorFloat2int(haloAlpha));
     157            float haloAlphaFactor = c.get(TEXT_HALO_OPACITY, 1f, Float.class);
     158            haloColor = Utils.alphaMultiply(haloColor, haloAlphaFactor);
    161159        }
    162160
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r11493 r11692  
    295295
    296296    /**
     297     * Multiply the alpha value of the given color with the factor. The alpha value is clamped to 0..255
     298     * @param color The color
     299     * @param alphaFactor The factor to multiply alpha with.
     300     * @return The new color.
     301     * @since 11692
     302     */
     303    public static Color alphaMultiply(Color color, float alphaFactor) {
     304        int alpha = Utils.colorFloat2int(Utils.colorInt2float(color.getAlpha()) * alphaFactor);
     305        alpha = clamp(alpha, 0, 255);
     306        return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
     307    }
     308
     309    /**
    297310     * Returns the complementary color of {@code clr}.
    298311     * @param clr the color to complement
Note: See TracChangeset for help on using the changeset viewer.