简体   繁体   中英

Zooming SVG using batik?

I would like to zoom in/out on SVG file in java. I would like to do it from the program and can't find a way.

I know you can zoom in/out via mouse or keyboard but that is not what I'm looking for. I'm new to java (2 weeks of learning) and there is probably an easy solution to my problem but I can't find it.

Can anyone help me?

To properly zoom in/out on svg in java you need to use

AffineTransform at = new AffineTransform(); 
at.scale(X,Y); 
svgCanvas.setRenderingTransform(at, true);

Note that you also need viewbox in your XML of svg.

I think you want to call setRenderingTransform on your JSVGCanvas component. The method takes an AffineTransform and a boolean which says whether you want to redraw immediately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM