Hi Michael,
I think the element has to be 'part of the document' for styling to
work properly (otherwise the cascade is wonky).
So you will need to append it to the Document (preferably where it will be
rendered) before querying style info
otherwise it could inherit values other than the CSS 'defaults'.
"Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> wrote on
03/08/2006 02:09:45 PM:
> OK, long time getting to it, but I'm finally messing with this
> SVGStylable interface. When I take an SVG element and try to cast it to
> an SVGStylable, everything works. It seems that calling getStyle()
> results in an NPE if no style attribute currently exists. In some
> cases, it breaks even if it does exist!
>
> I try to create a "layer" in my document and default it to being
> visible:
>
> element = svgDocument.createElementNS(SVGConstants.SVG_NAMESPACE_URI,
> SVGConstants.SVG_G_TAG);
> element.setAttribute(Constants.PNTR_EVTS_ATTR,
> SVGConstants.SVG_NONE_VALUE);
> SVGStylable stylable = (SVGStylable) element;
>
> // This causes an NPE!
> stylable.getStyle().setProperty("visibility", "visible", "");
>
> // So I try this instead...
> element.setAttribute(Constants.STYLE_ATTR,Constants.VISIBILITY_ATTR + ":
> " + Constants.VISIBLE_VALUE);
>
> // Which works until I try to check its visibility elsewhere:
> public static boolean isVisible(Element element) {
> SVGStylable stylable = (SVGStylable) element;
>
> // NPE here again.
> String visible =
>
> stylable.getStyle().getPropertyValue(Constants.VISIBILITY_ATTR);
>
> return visible.equalsIgnoreCase(Constants.VISIBLE_VALUE);
> }
>
> Any help?
>
> Michael Bishop
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Thursday, December 22, 2005 7:47 PM
> To: [email protected]
> Subject: RE: Seemingly simple question...
>
> Hi Michael,
>
> "Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> wrote on
>
> 12/22/2005 04:13:34 PM:
>
> > OK, well in that case, working with CSS won't be so bad. Now on the
> SAC
> > page, they have their own implementation, and they also say that Batik
> > has an implementation. What kind of object is "e" where you can call
> > getStyle() on it? Do you use the Batik 1.2 SAC or the standalone SAC
> > 1.3?
>
> 'e' is any 'graphics' SVG Element from the DOM.
>
> e = document.getElementById("myG");
>
> You will want to cast it to a 'org.w3c.dom.svg.SVGStylable'
> interface.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]