I think , the following code snippet will be helpful.
public static CSSOMComputedStyle getComputedStyle(Element element) {
ViewCSS viewCSS = (ViewCSS) element.getOwnerDocument()
.getDocumentElement();
CSSOMComputedStyle computedStyle = (CSSOMComputedStyle) viewCSS
.getComputedStyle(element, null);
return computedStyle;
}
CSSOMComputedStyle computedStyle = getComputedStyle(element);
String type=SVGConstants.SVG_FILL_ATTRIBUTE;
if (computedStyle.getPropertyCSSValue(type) instanceof SVGPaint) {
SVGPaint svgPaint = (SVGPaint) computedStyle
.getPropertyCSSValue(type);
}else{
SVGColor SVGclr = (SVGColor) computedStyle
.getPropertyCSSValue(type);
}
best regards
Sujesh
On 2/5/07, Ludwig Reiter <[EMAIL PROTECTED]> wrote:
Hi,
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;
}
that looks good to me, but I don't know where to get the SVGColor object.
I've got an AbstractElement and can get it's attributes as String.
(It's a SVGRectElement - I suppose).
So where can I get the SVGColor from?
Thx,
Ludwig Reiter
--
View this message in context:
http://www.nabble.com/Parsing-svg-color-to-java-Color-tf3161121.html#a8804006
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]