gpt4 book ai didi

eclipse-rcp - 一起使用 Eclipse RCP 和 Apache Batik

转载 作者:行者123 更新时间:2023-12-03 22:48:09 25 4
gpt4 key购买 nike

是否可以在使用 Eclipse RCP 开发的应用程序中使用所有 Batik 组件?能否请您指出相关文档。

最佳答案

查看以下链接:

  1. http://sourceforge.net/projects/svgplugin/
  2. 您还可以使用 SWT/AWT Bridge。查看SWT Snippet Page.

>> SWT/AWT & Batik 示例代码

import java.awt.BorderLayout;
import java.io.File;
import java.io.IOException;

import javax.swing.JComponent;
import javax.swing.JPanel;

import org.apache.batik.swing.JSVGCanvas;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class BatikTest
{

public static void main(String[] args)
{
// Uncomment the below lines and set proper values if you are behind a proxy server
///System.setProperty("http.proxyHost", "");
///System.setProperty("http.proxyPort", "");

final Display display = new Display();
final Shell shell = new Shell(display);
shell.setSize(200, 120);
shell.setText("SWT Batik Example");
shell.setLayout(new GridLayout());
shell.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));


Composite composite = new Composite(shell, SWT.EMBEDDED);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

java.awt.Frame locationFrame = SWT_AWT.new_Frame(composite);
locationFrame.add(createComponents(new File("batik3D.svg")));

locationFrame.pack();
//shell.pack();


shell.open();
while(!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}

private static JComponent createComponents(File f)
{
// Create a panel and add the button, status label and the SVG canvas.
final JPanel panel = new JPanel(new BorderLayout());
JSVGCanvas svgCanvas = new JSVGCanvas();

panel.add("Center", svgCanvas);


try {
svgCanvas.setURI(f.toURI().toURL().toString());
} catch (IOException ex) {
ex.printStackTrace();
return null;
}

return panel;
}
}

>>输出

enter image description here

关于eclipse-rcp - 一起使用 Eclipse RCP 和 Apache Batik,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5935347/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com