Using Eclipse RCP and Apache Batik Together

Can I use all the components of Batik in an application developed in Eclipse RCP? Could you please indicate the relevant documentation to me.

+3
source share
2 answers

You can use batik in RCP eclipse applications, since e4 uses the CSS mechanism. See http://www.eclipse.org/orbit for the latest stable build, which includes a number of batik packages. For example, in our RCP application, we use the following + some supporting w3c packages:

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
+1
source

Take a look at the following link:

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

+3
source

All Articles