Thanks for the suggestion. Unfortunately I get identical results using this method, a null pointer exception on the getPropertyCSSValue (). Is there something else I need to do to calculate the stroke? Perhaps I am missing something in the setup. I am creating the document from a file stream using the following snippet I found in the docs somewhere:

String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory (parser); SVGDocument doc = (SVGDocument)f.createDocument ("http:internal", is);

After that I use getElementsByTagName() to find the paths, which I am then using as the element in your example code. Does anything look out of place?

Thanks, James.

On Feb 2, 2006, at 8:36 PM, Tonny Kohar wrote:

Hi,

On Thu, 2006-02-02 at 15:26 -0500, James Balnaves wrote:
When I try this, the CSSStyleDeclaration ends up containing an
"element" member of type SVGOMPathElement that has attributes "fill"
and "d", but the CSSStyleDeclaration "values" member HashMap is empty.
When I call style.getPropertyCSSValue("stroke") I get a null pointer
exception, even though this value exists up in the main svg element.

How about something like this
ViewCSS viewCSS =
(ViewCSS)element.getOwnerDocument().getDocumentElement();
CSSStyleDeclaration computedStyle =
viewCSS.getComputedStyle(element,null);
SVGPaint svgPaint =
(SVGPaint)computedStyle.getPropertyCSSValue (SVGConstants.SVG_STROKE_ATTRIBUTE);
Color color = null;
if (svgPaint.getPaintType() == SVGPaint.SVG_PAINTTYPE_RGBCOLOR) {
RGBColor rgbColor = svgPaint.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);
} else if (svgPaint.getPaintType() ==
SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR) {
        // this is the color keyword eg: black, blue, green, aliceblue,etc
// please check with the SVG / CSS Dom for the exact RGB value for this
color keyword
                            } else if (svgPaint.getPaintType() ==
SVGPaint....) {


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

Reply via email to