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 Thomas DeWeese <th...@gmail.com> on 2012/06/29 13:13:07 UTC

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

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, <ml...@mherrn.de> 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: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>

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

Posted by ml...@mherrn.de.
Hi Thomas,

I tried to reproduce it in a simple standalone app. Unfortunately I didn't
manage to reproduce it there. It only happens in the context of my larger
application.
So it seems I have to leave this alone until I stumple upon it again.


Regards
Marco

> 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, <ml...@mherrn.de> 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: batik-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>>
>>
>



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