是否可以在 Eclipse RCP 开发的应用程序中使用所有 Batik 组件?你能指点我相关的文件吗?
问问题
3013 次
2 回答
3
看看下面的链接:
- http://sourceforge.net/projects/svgplugin/
- 您也可以使用
SWT/AWT Bridge
. 请参阅SWT 代码段页面。
>> SWT/AWT & Batik Sample Code
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;
}
}
>>Output
于 2011-05-09T13:39:38.723 回答
1
可以在 Eclipse RCP 应用程序中使用蜡染,因为 e4 使用 CSS 引擎。请参阅http://www.eclipse.org/orbit以获取包含许多蜡染包的最新稳定版本。例如,在我们的 RCP 应用程序中,我们使用以下 + 一些支持 w3c 包:
org.apache.batik.css_1.6.0.v201011041432.jar
org.apache.batik.util_1.6.0.v201011041432.jar
org.apache.batik.util.gui_1.6.0.v201011041432.jar
org.apache.batik.xml_1.6.0.v201011041432.jar
于 2011-05-09T12:36:49.217 回答