xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: Identifying SVG DOM node equivalents in GVT
Date Thu, 21 Sep 2006 10:16:00 GMT
Hi Erik,

Erik Bunn <ebu@basen.net> wrote on 09/21/2006 04:45:04 AM:

> Is there a way of identifying the counterpart of an id'ed SVG node in 
> a GVT tree?

   You can use 'BridgeContext.getGraphicsNode(Element e)' to
get the peer of an Element.  For this to work you need to set
the BridgeContext to 'dynamic' mode 
"BridgeContext.setDynamicState(DYNAMIC)" before building
the GVT tree.

> I'll expound; I may be approaching SVG from a different direction 
> than some.
> 
> An artist designs an appealing SVG icon for a steam engine. He 
> publishes it in my system, informing me that within the SVG document, 
> the color of SVG node 'foo' indicates operational status (green == 
> good, red == broken), and that the rotation angle of SVG node 'bar' 
> indicates temperature and should be between 0 and 180 degrees.
> 
> I currently load the icon as an SVG DOM tree. I look up nodes 'foo' 
> and 'bar', and, performing some nasty attribute manipulations, 
> programmatically inject the current engine status and boiler 
> temperature values measured from my favorite steam engine into the 
> DOM. (Identifying the nodes intended for manipulation is relatively 
> easy using JXPath, but changing SVG element attributes like this is 
> just stupid.)
> 
> If I could identify those same graphical elements in the transformed 
> GVT tree, I could just use the nice GraphicsNode API for the 
> transformations. However, while I imagine that there's a strong 
> correlation between GVT branches and SVG DOM branches, I don't see 
> anything like id's being offered at the API level on the GVT side.
> 
> Hmm. Or should I stick to the SVG DOM side? Looks like I could use 
> org.w3c.dom.svg.SVGLocatable.getTransform() and 
> CSSStylableElement.setComputedStyleMap() to fill most of my needs, 
> with a little type casting after the JXPath lookup.

   I would fairly strongly suggest that you use the SVG DOM.

   I would avoid 'setComputedStyleMap' you should be able to use
SVGStylable.getStyle().setProperty(String prop, String val, String 
priority)
(most/all SVG elements implement SVGStylable, you can simply
pass "" for priority).

   And yes the SVGLocatable interface is the right interface
for querying and manipulating the transform.  Also don't be
afraid to insert additional grouping elements to adjust the
transform.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message