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 "Fiebig, Sebastian" <Se...@danet.de> on 2009/03/26 15:32:51 UTC

Add an id to elements providing meta information

 

Hello!

 

When trying to add an id attribute to elements just created using
SVGGraphics2D, all elements get deleted. This is caused by the method
getRoot() which calls getRoot(null). But why?

Here is my code:

 

Node elem = svgGenerator.getRoot(); 

while (elem.getLastChild() != null) {

    elem = elem.getLastChild();

}

Element lastElement = (Element)elem;

lastElement.setAttribute("id", "1");

 

This example comes from here:
http://www.nabble.com/SVGGraphics2D-and-id-td4325094.html

 

My initial intention was to add links to my SVG elements. So this
approach seems to be the best and only. After providing ids I could add
links easily. If one has got another approach, I would appreciate it
very much!

 

Sincerely yours,

 

Sebastian

 


Re: Add an id to elements providing meta information

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

> When trying to add an id attribute to elements just created using
> SVGGraphics2D, all elements get deleted. This is caused by the method
> getRoot() which calls getRoot(null). But why?

I didn't investigate this properly before replying but, while taking a
glance at the documentation [1], it sounds like you may not be doing
the right thing (this snippet is from the "How to view the generated
SVG document" [2] section):

        // Populate the document root with the generated SVG content.
        Element root = doc.getDocumentElement();
        g.getRoot(root);

Can you provide more information on your work flow (generating
graphics information, modifying, displaying, etc.) or a more detailed
code snippet?

Hope this helps,
 Helder

[1] http://xmlgraphics.apache.org/batik/using/svg-generator.html
[2] http://xmlgraphics.apache.org/batik/using/svg-generator.html#view

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


Re: Add an id to elements providing meta information

Posted by dinko <di...@fotonmanipulator.com>.
Hi Sebastian,
thank you very much. i was starting to go crazy over this one. Your post
solved the problem. did you maybe, in the meantime, find some better
solution to adding id attribute for new elements added trough the
SVGGraphics2D?



--
View this message in context: http://batik.2283329.n4.nabble.com/Add-an-id-to-elements-providing-meta-information-tp2978822p4655212.html
Sent from the Batik - Users mailing list archive at Nabble.com.

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