Hi, I am trying build a JSVGCanvas that automatically zooms the SVG image it displays, depending on a given strategy.
Possible strategies are: * Zoom the image to fit into the canvas (do not respect aspect ratio) * Zoom the image to fit into the canvas, but respect aspect ratio (zoom until either width or height of the canvas is filled) * Zoom to canvas width (if the height of the image is larger than the height of the canvas, some part of the image will be outside of the viewport) (As I understand all these cases and a lot more are defined in the SVG standard in the preserveAspectRatio attribute: > http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute) The first one works quite well. The second one works, when the image will always be centered. But the second one does _not_ work, if I want the image always in the top left corner of the canvas. The example application and SVG file are attached to this mail. I did it like Heinz Doerr describes in this Thread: > http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/200906.mbox/%3c4a3e3c33.60...@ecoms.de%3e If I change the SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN in line 17 to SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_NONE (first case) or SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID (second case, working) everything is quite well. But using SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN (second case, not working) It doesn't: When the application starts, the image is always displayed as expected. But when extending the width of the window, the image starts beginning to move out of the canvas on the top. Addionally when lowering the width of the window, the image starts to move down inside the canvas (not staying in the top left corner). Some questions arise: 1. Is overriding calculateViewingTransform(String, SVGSVGElement) the correct way to achieve this? 2. What am I doing wrong here (or where is my misunderstanding)? 3. Where can I get more information about utilizing batik in such a way? The classes and methods I am using and overriding here aren't documented very good... PS: I am using batik 1.7 with JDK 1.6 Regards Marco --------------------------------------------------------------------- To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org