Hi,

On Fri, 2007-02-02 at 06:27 -0800, Ludwig Reiter wrote:
> Hi all,
> 
> is there an easy way in the code of batik to parse an svg color attribute
> string to a java color object?
> I know there must be some code, but I haven't find it yet.

You could use the following sample

public static final Color getColor(SVGColor svgColor) {
        Color color = null;
        RGBColor rgbColor = svgColor.getRGBColor();
        CSSPrimitiveValue redValue = rgbColor.getRed();
        CSSPrimitiveValue blueValue = rgbColor.getBlue();
        CSSPrimitiveValue greenValue = rgbColor.getGreen();
        float r = redValue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
        float g =
greenValue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
        float b = blueValue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
        color = new Color((int)r,(int)g,(int)b);
        
        return color;
    }

Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to