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 Sven Andres <an...@project-syntropy.de> on 2009/08/14 17:34:11 UTC

direct access to tree to modify a shown SVG-Document?

Hello all.

Currently I simply show a SVGDocument in a JSVGCanvas. 
Now I'm trying to modify the content of the tree e.g. by adding nodes or
grouping nodes together... (later this should happen on user-iteraction, but
for now I want to do it hard-coded just to see how it works)

I had some success by adding Nodes to the root-element of the SVGDocument
itself (JSVGCanvas.getSVGDocument().getRootElement().appendChild(xxx) )but
these changes are not shown in the canvas until the GVTTree is rebuilt which
I would like to leave out...

I guess it would do what I would like to get when I modify the
SVGDocument-Object and then calling the
JSVGCanvas.setSVGDocument(xxx)-Function but I assume this would rebuild the
whole tree which would not be as interactive as I would like it to be...

So is there a way to directly access and modify the tree that is finally
rendered into the canvas? I tried to get to the JSVGCanvas.gvtroot (although
I do not know yet, if this is the correct tree) but i could not find a way
to access it...

So now the questions...
1.
Which is the tree-structure that is accessed by the Renderer and is there
any way to modify it directly, so that the changes are visible without
explicitly rebuilding the complete tree?
2.
Is there any way to save these changes back to a SVG-file? This works
perfectly when I modify the SVGDocument-Object, but if the rendering tree is
modifyied I guess this will not be as easy, although it would be really nice
if I'm wrong here ^^


So I hope somebody can help me here.

Best Regards,
Sven
-- 
View this message in context: http://www.nabble.com/direct-access-to-tree-to-modify-a-shown-SVG-Document--tp24973683p24973683.html
Sent from the Batik - Users mailing list archive at Nabble.com.

Re: direct access to tree to modify a shown SVG-Document?

Posted by Helder Magalhães <he...@gmail.com>.
Hi Sven,

> This is a duplicate thread (of another one created one minute
> before)... I'd suggest replying to the original thread only.

Correction: the previous thread was deleted (on the Nabble interface),
although the mailing list has triggered the messages (I've received
two messages). I'd rewrite my suggestion to use this thread instead...

Helder

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


Re: direct access to tree to modify a shown SVG-Document?

Posted by Helder Magalhães <he...@gmail.com>.
Hi Sven,

This is a duplicate thread (of another one created one minute
before)... I'd suggest replying to the original thread only.

Regards,
 Helder

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


Re: direct access to tree to modify a shown SVG-Document?

Posted by Helder Magalhães <he...@gmail.com>.
Hi Sven,


> Hello all. [...]

It might been some mess up made my your mailing list interface
(Nabble), but I've noticed the whole message was sent in a single
line...? Please separate sentences (using paragraphs, for example) in
order to separate ideas and ease the reply process. ;-)


> Now I'm
> trying to modify the content of the tree e.g. by adding nodes or grouping
> nodes together... (later this should happen on user-iteraction, but for now
> I want to do it hard-coded just to see how it works)

I'd say using the DOM is the proper way of accomplishing that.


> I had some success by
> adding Nodes to the root-element of the SVGDocument itself
> (JSVGCanvas.getSVGDocument().getRootElement().appendChild(xxx) )but these
> changes are not shown in the canvas until the GVTTree is rebuilt [...]

I'm not very familiar with the Batik GVT internals but I'd say that
setting the document state to dynamic [1] should take care of handling
those changes in an efficient way. :-)


> [...] which I
> would like to leave out...

Why would you like to leave the GVTTree rebuild out? Describing your
intention [2] might help... If you are following the recommended way
to manipulate the document [3], then you probably won't need to bother
with the underlying lower level internals. :-)


> I guess it would do what I would like to get when
> I modify the SVGDocument-Object and then calling the
> JSVGCanvas.setSVGDocument(xxx)-Function but I assume this would rebuild the
> whole tree which would not be as interactive as I would like it to be... So
> is there a way to directly access and modify the tree that is finally
> rendered into the canvas?

Yup, see above.


> So now the questions... 1. Which is the tree-structure that
> is accessed by the Renderer and is there any way to modify it directly, so
> that the changes are visible without explicitly rebuilding the complete
> tree?

As stated, you may use the DOM or the GVT trees.


> 2. Is there any way to save these changes back to a SVG-file? This
> works perfectly when I modify the SVGDocument-Object, but if the rendering
> tree is modifyied I guess this will not be as easy, although it would be
> really nice if I'm wrong here ^^

Well, if you use the DOM this is straightforward: you only need to
serialize it whenever desired (see the SVG generator [4], for
example). I'm not sure if that's also true when using the GVT tree...


> So I hope somebody can help me here. Best Regards, Sven

Hope this helps,
 Helder


[1] http://xmlgraphics.apache.org/batik/faq.html#dom-modifications-do-not-display
[2] http://catb.org/~esr/faqs/smart-questions.html#goal
[3] http://xmlgraphics.apache.org/batik/using/scripting/java.html
[4] http://xmlgraphics.apache.org/batik/using/svg-generator.html

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