简体   繁体   English

使用蜡染缩放 SVG?

[英]Zooming SVG using batik?

I would like to zoom in/out on SVG file in java.我想放大/缩小 java 中的 SVG 文件。 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.我是 java(学习 2 周)的新手,我的问题可能有一个简单的解决方案,但我找不到。

Can anyone help me?谁能帮我?

To properly zoom in/out on svg in java you need to use要正确放大/缩小 java 中的 svg,您需要使用

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

Note that you also need viewbox in your XML of svg.请注意,您还需要 svg 的 XML 中的视图框。

I think you want to call setRenderingTransform on your JSVGCanvas component.我想你想在你的 JSVGCanvas 组件上调用 setRenderingTransform 。 The method takes an AffineTransform and a boolean which says whether you want to redraw immediately.该方法采用 AffineTransform 和 boolean 表示您是否要立即重绘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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