Hi Erik,
Erik Bunn <[EMAIL PROTECTED]> wrote on 09/26/2006 03:36:34 AM:
> On Sep 21, 2006, at 13:16 , [EMAIL PROTECTED] wrote:
>
> > I would avoid 'setComputedStyleMap' you should be able to use
> > SVGStylable.getStyle().setProperty(String prop, String val, String
> > priority)
>
> It took me a while to get this to work: I had to manually force a
> CSSEngine to my parsed SVGDocument, otherwise Batik throws an NPE.
> Can anyone point out what goes wrong in the following? (The following
> is just a synopsis of my code, as always, but checked for consistency
> with the actual implementation.)
Yes, you need to boot the CSS and SVG DOM's before you use them
(from the Wiki):
http://wiki.apache.org/xmlgraphics-batik/BootSvgAndCssDom
> Is there something obvious I'm missing when I assume the above should
> just work?
Yes, initially we just give you the Core DOM. If you want to
the SVG DOM (SVGLocatable, etc) or CSS DOM (SVGStylable) you
need to bring them up (they add significant weight to the dom
and useful stuff can be done without them, of course more useful
stuff can be done with them ;).
It would be nice if we brought these API's up the first time
you hit them but we would have to assume an awful lot of stuff
and people might think it was weird that we potentially read a
bunch of files (i.e. style sheets, script etc) when you ask for
the bounding box of something....
> One way of forcing functionality is to add the following at *) :
>
> SVGDOMImplementation di = (SVGDOMImplementation)
> m_factory.getDOMImplementation( "1.1" );
> UserAgent ua = new UserAgentAdapter();
> BridgeContext bc = new BridgeContext( ua );
> di.createCSSEngine( (SVGOMDocument)doc, bc );
This might in theory just boot the CSS DOM, which might
be faster/lighter but also totally unknown territory.
> (To complicate matters, I actually tend to clone 'doc' and play with
> the copy. In that case, I will have to manually set the CSSEngine of
> the copy, as well.
Yes, any copies will need to have the SVG/CSS Dom's brought up.
Since you are going to be rendering them anyway you need to build
the GVT tree (which boots the SVG and CSS DOM) so there isn't really
additional work here.
> I've just given the clone the same instance as 'doc' use;
> not sure if this is good.)
Same instance of what? The UserAgent and DOM Impl would be fine
everything else will cause you trouble eventually.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]