Re: setting SVG_TRANSFORM_ATTRIBUTE after adding element to parent: element doesn't get painted

Thomas DeWeese <[email protected]>
Newsgroups gmane.text.xml.batik.user
Message-ID <CACTtnu0eKSUszJR1Oiy35cGVjnjhMvT_b_qbns8u7jQ5qw90YQ@mail.gmail.com>
Hi Marco,
   It sounds like a bug, but since it seems to depend on a very particular
sequence of events I wonder if you could try and reproduce the bug in a
small standalone example (preferably in javascript, but a Java example will
do).

   Thomas

On Thu, Jun 28, 2012 at 7:56 AM, <[email protected]> wrote:

> Hi,
>
> I have found a strange behaviour.
> I create a <g> element with a <rect> subelement via DOM manipulation.
> The result is something like this:
>
>    <g transform="translate(150, 0)">
>      <rect width="100" height="30" stroke="blue" fill="yellow" />
>    </g>
>
> But if I am doing it this way, it fails:
>
>    final SVGGElement myGElement= (SVGGElement) doc.createElementNS(ns,
> "g");
>    doc.getRootElement().appendChild(myGElement);
>    final SVGRectElement myRectElement= (SVGRectElement)
> doc.createElementNS(ns, "rect");
>    myRectElement.setAttributeNS(null, "stroke", "blue");
>    myRectElement.setAttributeNS(null, "fill", "yellow");
>    myRectElement.setAttributeNS(null, "width", "100");
>    myRectElement.setAttributeNS(null, "height", "30");
>    myGElement.appendChild(myRectElement);
>    myGElement.setAttributeNS(null, "transform", "translate(150, 0)");
>
> The problem is: Train doesn't get painted. Not even after calling
> canvas.repaint().
>
> Of course I am doing this in the thread of the update manager. All other
> things I am painting do appear correctly.
> The interesing thing is, if I translate the <g> object so that the new
> location intersects the original location (0, 0), the part of the train in
> the intersection is correctly painted.
>
> If I set the "transform" attribute _before_ adding myGElement to its
> parent, everything works well. Only when doing this _after_ adding it to
> its parent, it fails.
>
> BUT: Another strange behaviour. Assume the above (failing) code snippet
> and insert a
>    myRectElement.setAttributeNS(null, "fill", "red");
> _after_ adding myRectElement to its parent (the <g> element)
> the whole train is getting painted correctly (with the new fill color)!
>
> What is the problem? Is it a bug? Am I doing something wrong?
>
>
> Regards
> Marco
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.