一起使用 Eclipse RCP 和 Apache Batik

发布于 2024-11-05 21:31:51 字数 60 浏览 0 评论 0原文

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

Is it possible to use all the Batik components in an application developed in Eclipse RCP?
Can you please point me to relevant documentation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北座城市 2024-11-12 21:31:51

查看以下链接:

  1. http://sourceforge.net/projects/svgplugin/
  2. 另外您可以使用SWT/AWT Bridge。请参阅 SWT 代码片段页面。

>>> SWT/AWT 和蜡染示例代码

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;
    }
}

>>输出

在此处输入图像描述

Have a look at the following link:

  1. http://sourceforge.net/projects/svgplugin/
  2. Also you can use the SWT/AWT Bridge. See the SWT Snippet Page.

>> 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

enter image description here

潇烟暮雨 2024-11-12 21:31:51

可以在 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

It is possible to use batik in eclipse RCP apps, as e4 uses the CSS engine. See http://www.eclipse.org/orbit for the latest stable build that includes a number of the batik bundles. Ex, in our RCP app we use the following + some supporting w3c bundles:

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文