xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Meves Kai (ext)" <Kai.Meves....@ptd.siemens.de>
Subject RE: Centering the SVG - Differences among affineTransforms
Date Fri, 14 Jan 2005 07:58:57 GMT
Hello,

>  2 - How do the coords in AffineTransform, returned by
> "svgCanvas.getViewBoxTransform()",   work?
>  Neither the screens corrds nor the canvas corrds worked appropriately
> when I tried to use translation operations.
> 
> 3 - Are there some way to map canvas coords to screen coords 
> and vice-versa?

Yes, of course there is. What you get by calling getViewBoxTransform() is
the current Transformation Matrix, Batik uses to do the Transformation from
world coordinates to screen coordinates. You can do something like this:

AffineTransform affTrans = myCanvas.getViewBoxTransform(); 
affTrans.transform(point1,point2) //where point1 and point2 are some Point2D

and you get the screen coordinates from the world coordinates that are
stored in point1 as result in point2.

If you want to do it the other way round (screen coordinates to world
coordinates), you need to use the inverse of the Transform Matrix, which you
get by

affTransInv = affTrans.createInverse();

I hope that I remembered all of this correctly... :-)

Kind regards,
Kai.

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


Mime
View raw message