Hi Abraham,

"Abraham Rodriguez Mota" <[EMAIL PROTECTED]> wrote on 07/07/2008 
02:09:43 PM:

> I have been trying to find the way to add an "id" attribute to a 
> rectangle using SVGGraphics2D. I got the code shown below. But I 
> haven't found the way to do it. It looks as it is an old issue but i
> couldn't find a concrete answer.

  Yah, there isn't a really good answer, but the following
will work.

> public void paint(SVGGraphics2D g2d) {
>         EventTarget target;
>         g2d.setPaint(Color.red);
>         g2d.fill(new Rectangle(10, 10, 100, 100)); 
>         Element root=svgDocument.getDocumentElement();
>         g2d.getRoot(root);

        Element curr = root;
        Element lc = curr;
        while (lc != null) {
           curr = lc;
           lc = (Element)curr.getLastChild();
        }
        curr.setAttributeNS(null, "id", "some_id_you_want");

> } 

Reply via email to