Hi Thomas,

I think that your code works making the assumption that the added element is
always the last children in the document, but I need to added elements in
different locations through the SVG tree. I also thought that using a
Document Fragment and doing what you propouse could resolve the problem but
I that is to complex for something that commun, isn't it?.


thanks

Abraham

On 7/8/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> 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