本文整理汇总了Java中org.apache.batik.swing.JSVGCanvas.setEnableImageZoomInteractor方法的典型用法代码示例。如果您正苦于以下问题:Java JSVGCanvas.setEnableImageZoomInteractor方法的具体用法?Java JSVGCanvas.setEnableImageZoomInteractor怎么用?Java JSVGCanvas.setEnableImageZoomInteractor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.batik.swing.JSVGCanvas
的用法示例。
在下文中一共展示了JSVGCanvas.setEnableImageZoomInteractor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMainComponent
import org.apache.batik.swing.JSVGCanvas; //导入方法依赖的package包/类
@Override
protected JComponent createMainComponent() {
//scene = new Scene();
//JScrollPane scenePane = new JScrollPane(scene.createView());
JSVGCanvas svgCanvas = new JSVGCanvas();
svgCanvas.setEnableImageZoomInteractor(true);
svgCanvas.setEnablePanInteractor(true);
svgCanvas.setEnableZoomInteractor(true);
return svgCanvas;
}
示例2: GraphPanel
import org.apache.batik.swing.JSVGCanvas; //导入方法依赖的package包/类
public GraphPanel(KinDiagramPanel kinDiagramPanel, final ArbilWindowManager arbilWindowManager, SessionStorage sessionStorage, ArbilDataNodeLoader dataNodeLoader) {
this.kinDiagramPanel = kinDiagramPanel;
this.dialogHandler = arbilWindowManager;
this.sessionStorage = sessionStorage;
this.dataNodeLoader = dataNodeLoader;
// this.entityCollection = entityCollection;
dataStoreSvg = new DataStoreSvg();
entitySvg = new EntitySvg(dialogHandler);
dataStoreSvg.setDefaults();
svgUpdateHandler = new SvgUpdateHandler(this, kinDiagramPanel, dialogHandler);
selectedGroupId = new ArrayList<UniqueIdentifier>();
graphPanelSize = new GraphPanelSize();
this.setLayout(new BorderLayout());
boolean eventsEnabled = true;
boolean selectableText = false;
svgCanvas = new JSVGCanvas(new GraphUserAgent(this, dialogHandler, dataNodeLoader), eventsEnabled, selectableText);
// svgCanvas.setMySize(new Dimension(600, 400));
svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
// drawNodes();
svgCanvas.setEnableImageZoomInteractor(false);
svgCanvas.setEnablePanInteractor(false);
svgCanvas.setEnableRotateInteractor(false);
svgCanvas.setEnableZoomInteractor(false);
svgCanvas.addMouseWheelListener(new MouseWheelListener() {
public void mouseWheelMoved(final MouseWheelEvent e) {
UpdateManager updateManager = svgCanvas.getUpdateManager();
if (updateManager != null) {
updateManager.getUpdateRunnableQueue().invokeLater(new Runnable() {
public void run() {
double scale = 1 - e.getUnitsToScroll() / 10.0;
double tx = -e.getX() * (scale - 1);
double ty = -e.getY() * (scale - 1);
// System.out.println("scale: " + scale);
// System.out.println("scale: " + svgCanvas.getRenderingTransform().getScaleX());
AffineTransform at = new AffineTransform();
if (e.isAltDown()) {
at.translate(tx, ty);
at.scale(scale, scale);
} else if (e.isShiftDown()) {
at.translate(-tx, 0);
} else {
at.translate(0, -ty);
}
at.concatenate(svgCanvas.getRenderingTransform());
// System.out.println("new scale: " + at.getScaleX());
if (at.getScaleX() > 0.1) {
svgCanvas.setRenderingTransform(at);
}
}
});
}
e.consume();
// show a ToolTip or StatusBar to give hints "Hold modifier + mouse wheel to zoom"
GraphPanel.this.kinDiagramPanel.setStatusBarText("hint: alt + mouse wheel to zoom; shift + mouse wheel to pan; mouse wheel to scroll.");
}
});
// svgCanvas.setEnableResetTransformInteractor(true);
// svgCanvas.setDoubleBufferedRendering(true); // todo: look into reducing the noticable aliasing on the canvas
jSVGScrollPane = new JSVGScrollPane(svgCanvas);
// svgCanvas.setBackground(Color.LIGHT_GRAY);
this.add(BorderLayout.CENTER, jSVGScrollPane);
}