2011-05-09 123 views

回答

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 
3

看一看下面的鏈接:

  1. http://sourceforge.net/projects/svgplugin/
  2. 您也可以使用SWT/AWT Bridge。見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