You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Jahirul Islam <ja...@agilisys.co.uk> on 2005/03/09 14:40:14 UTC

Re: GVT Tree and SVG DOM

Hi,

Why does the bridgeContext.getElement(gNode) return nulls always? I need 
to get hold of the Svg element for a given graphic node. I has look at 
the source code for BridgeContext.getElement(..) method , it performs 
lookup against the nodeElementMap member to return the svg element, 
however, when I inspect nodeElementMap in debugger, it shows up as null. 
What am i doing wrong.

here's the code snippet that builds the GVT



            SVGDocument svgDocument = factory.createSVGDocument(uri);
            UserAgentAdapter userAgentAdapter = new UserAgentAdapter();
            BridgeContext bridgeContext = new 
BridgeContext(userAgentAdapter);
            GVTBuilder gvtBuilder = new GVTBuilder();
            GraphicsNode graphicsNode = gvtBuilder.build(bridgeContext, 
svgDocument);

             .... do something

             Element svgElement = bridgeContext.getElement(childGNode);



           


>Hi,
>
>I need to rasterize a single SVG DOM node. I thought transferring the SVG Document into a GVT Tree and render a single GVT Node by using its paint method might be a good idea:
>
>UserAgent myUserAgent = new SVGAbstractTranscoderUserAgent();
>GraphicsNode gvtRoot = new GVTBuilder().build(new BridgeContext(myUserAgent), document);
>
>Unfortunately I didn't find a way of mapping back the GVT node to a SVG node - so if I get an arbitrary SVG node of the transferred Document - how may I find the corresponding GVT node out of the GVT Tree? Do both trees necessarily have an identical structure - that is: may I simply traverse the DOM tree until I reached the node  and apply the same path to the GVT Tree in order to get the corresponding GVT node? Is there a more clever way?
>Thanks in advance,
>christian
>
>-----------
>
>Hi,
>
>> Unfortunately I didn't find a way of mapping back the GVT node to a SVG node - so if I get an arbitrary SVG node of the transferred Document - how may I find the corresponding GVT node out of the GVT Tree? Do both trees necessarily have an identical structure - that is: may I simply traverse the DOM tree until I reached the node  and apply the same path to the GVT Tree in order to get the corresponding GVT node? Is there a more clever way?
>> Thanks in advance,
>> christian
>
>I think you can use bridgeContext eg:
>- bridgeContext.getElement(graphicsNode); // get the SVG node by
>supplying GVT Node
>- bridgeContext.getGraphicsNode(svgElement); // get the GVT node by
>supplying SVG Node
>
>Regards
>Tonny Kohar
>-- 
>Sketsa 
>SVG Graphics Editor
>http://www.kiyut.com
>
>
>
>------------------------
>



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


Re: GVT Tree and SVG DOM

Posted by Tonny Kohar <to...@kiyut.com>.
Hi,

> Why does the bridgeContext.getElement(gNode) return nulls always? I need 
> to get hold of the Svg element for a given graphic node. I has look at 
> the source code for BridgeContext.getElement(..) method , it performs 
> lookup against the nodeElementMap member to return the svg element, 
> however, when I inspect nodeElementMap in debugger, it shows up as null. 
> What am i doing wrong.

If I am not wrong, make sure that the SVG Node you looking for is
displayable and rendered. It means non displayable element eg: <desc>
will always null, but element like <rect> and currently displayed will
be ok.

Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com


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