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 Lukasz Matuszczak <l....@atrem.pl> on 2006/03/20 17:03:07 UTC

translated initial transform problem

Hello,

I have a problem with JSVGCanvas considering the initial transform of the 
document. The typical situation in all examples I saw is that setURI or 
setDocument method of a JSVGCanvas object is called when the JSVGCanvas is 
already added to some swing container which is already visible. I want the 
JSVGCanvas to set document in background and then I want to add it to some swing 
container (AFAIK it should be rendered then because of componentResized event 
listener added in JGVTComponent constructor).
Unfortunately in such case the rendered document looks strange, precisely the 
top left corner of viewbox is put precisely in the middle of JSVGCanvas 
component.

I have prepared the test case which is based on JSVG class from contrib. I call 
the setUri method, then I wait 2 seconds and add JSVGCanvas to previously 
prepared JPanel.

You can observe the problem in batik 1.6 and also in the newest batik nightly.

Regards,
Lukasz Matuszczak 

Re: translated initial transform problem

Posted by Lukasz Matuszczak <l....@atrem.pl>.
>   The request for the rendering goes through 'renderGVTTree' you could
> have
> your subclass check to see if the Component has a parent (getParent).
> If not
> you can just return.  I don't think this will have any bad side
> effects... 

Thanks. It works :).

Regards,
Lukasz Matuszczak


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


Re: translated initial transform problem

Posted by th...@kodak.com.
Hi Lukasz,

"Lukasz Matuszczak" <l....@atrem.pl> wrote on 03/20/2006 01:37:50 
PM:

> thomas.deweese@kodak.com wrote:
> >        Try setting the size of the canvas before you set the URI.

> Thanks for this tip ! :). Because I have no idea what the final size of 
> component will be, I set the size to (1,1). However this solution has 
one 
> disadvantage. The rendering occurs even before the component is added to 

> container so after that we have another rendering with different size. 
Two 
> renderings can sometimes be time-consuming if documents are big. Do you 
have any 
> clues how could I override updateRendingTransform() method (or maybe 
some other 
> methods) so it won't be confused by first setting size after gvt build 
> completed?

   The request for the rendering goes through 'renderGVTTree' you could 
have
your subclass check to see if the Component has a parent (getParent).  If 
not
you can just return.  I don't think this will have any bad side effects...



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


Re: translated initial transform problem

Posted by Lukasz Matuszczak <l....@atrem.pl>.
thomas.deweese@kodak.com wrote:
> Hi Lukasz,
>
>        Try setting the size of the canvas before you set the URI.  The
> size doesn't even have to be exact, it's just that with no size it
> gets a little confused when it has to resize and it is trying to keep
> the 'center'
> of the canvas on the screen.

Thanks for this tip ! :). Because I have no idea what the final size of 
component will be, I set the size to (1,1). However this solution has one 
disadvantage. The rendering occurs even before the component is added to 
container so after that we have another rendering with different size. Two 
renderings can sometimes be time-consuming if documents are big. Do you have any 
clues how could I override updateRendingTransform() method (or maybe some other 
methods) so it won't be confused by first setting size after gvt build 
completed?

Regards,
Lukasz Matuszczak 



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


Re: translated initial transform problem

Posted by th...@kodak.com.
Hi Lukasz,

        Try setting the size of the canvas before you set the URI.  The
size doesn't even have to be exact, it's just that with no size it gets a
little confused when it has to resize and it is trying to keep the 
'center'
of the canvas on the screen.

"Lukasz Matuszczak" <l....@atrem.pl> wrote on 03/20/2006 11:03:07 
AM:

> Hello,
> 
> I have a problem with JSVGCanvas considering the initial transform of 
the 
> document. The typical situation in all examples I saw is that setURI or 
> setDocument method of a JSVGCanvas object is called when the JSVGCanvas 
is 
> already added to some swing container which is already visible. I want 
the 
> JSVGCanvas to set document in background and then I want to add it to 
some swing 
> container (AFAIK it should be rendered then because of componentResized 
event 
> listener added in JGVTComponent constructor).
> Unfortunately in such case the rendered document looks strange, 
precisely the 
> top left corner of viewbox is put precisely in the middle of JSVGCanvas 
> component.
> 
> I have prepared the test case which is based on JSVG class from contrib. 
I call 
> the setUri method, then I wait 2 seconds and add JSVGCanvas to 
previously 
> prepared JPanel.
> 
> You can observe the problem in batik 1.6 and also in the newest batik 
nightly.
> 
> Regards,
> Lukasz Matuszczak 
> [attachment "test.svg" deleted by Thomas E. DeWeese/449433/EKC] 
[attachment 
> "JSVG.java" deleted by Thomas E. DeWeese/449433/EKC] 
> ---------------------------------------------------------------------
> 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