/** * Parse a color from a string and return it. In the case of an error * this function will return the color white. * * @param color * The color definition in string form. * @return * The interpreted color or a default of white. */ public static Color getColor(String color) { return getColor(color, Color.WHITE); }
/** * Parse a color from a string, combine it with separately defined alpha and return * it. In the case of an error this function will return the color white. * * @param color * The color definition in string form. * @param alpha * The alpha value (0-255) in int form. * * @return * The interpreted color or a default of white. */ public static Color getColorWithAlpha (String color, int alpha) { return getColorWithAlpha(color, alpha, Color.WHITE); }
ColorRampParameter.getColor(getPropertyValue(COLOR1)) : islight? new Color(55,55,55) : Color.WHITE; int alpha1 = getPropertyValue(ALPHA1); if (-1 == alpha1) alpha1 = (int) Math.floor(255*opacity); Color startColor = ColorRampParameter.getColorWithAlpha(getPropertyValue(COLOR1), alpha1); int alpha2 = getPropertyValue(ALPHA2); if (-1 == alpha2) alpha2 = (int) Math.floor(255*opacity); Color endColor = ColorRampParameter.getColorWithAlpha(getPropertyValue(COLOR2), alpha2); ramp = new SingleGradientColorRamp(startColor, endColor);
/** * Parse a color from a string, combine it with separately defined alpha and return * it. In the case of an error this function will return the color white. * * @param color * The color definition in string form. * @param alpha * The alpha value (0-255) in int form. * * @return * The interpreted color or a default of white. */ public static Color getColorWithAlpha (String color, int alpha, Color defaultColor) { Color base = getColor(color, defaultColor); alpha = Math.min(Math.max(alpha, 0), 255); return new Color(base.getRed(), base.getGreen(), base.getBlue(), alpha); } }
colors.add(ColorRampParameter.getColorWithAlpha(color, alpha));