About the project

Eclipse SWTChart Project - Extending the export options

See Eclipse SWTChart on Eclipse, Github
See this project on Google Summer of code
Mentor - Philip Wenig

Project Goals and deliverables

  1. Add SVG export option
  2. Add PDF and EPS export option

SVG Export

SVG files are nothing but XML graphics files. We can generate SVG files for our charts using the Apache XMLGraphics project. This project has an open-source license and is already available under Eclipse Orbit.

The Apache Batik is a sub-project of the Apache XMLGraphics project and has a built in SVGGenerator class ​https://xmlgraphics.apache.org/batik/using/svg-generator.html
On the Java platform, all rendering goes through the Graphics2D abstract class, which offers methods such as drawRect, fillRect, and drawString. There are specialized implementations of this abstract class for each type of output, such as a screen or a printer. SVGGraphics2D is a new implementation of that interface that generates SVG content instead of drawing to a screen or a printer.

In order to use this interface we first need to create a Graphics2D implementation of our chart which involves converting org.eclipse.swt.gc object to java.awt.Graphics2D

PR for this change : https://github.com/eclipse/swtchart/pull/61

Once we have created a Graphics2D object, we can use it to create our SVG file.

PR for this : https://github.com/eclipse/swtchart/pull/67

Some sample exports:

EPS and PDF Export

Exporting to EPS and PDF is not very straightforward like exporting to SVG. Though the Apache XMLGraphics project has an option to create EPS files, but the functionality is pretty basic. The other option is to create a SVG file and transcode it to EPS or PDF using Apache FOP. Unfortunately, Apache FOP is not a part of Eclipse Orbit and isn’t supported out-of-the box like Apache Batik. The good news is that the EPSTranscoder and PDFTranscoder will be moved to the Transcoder package in Batik and in a future release, we can extend this functionality in SWTChart.

Some sample exports: PDF Export EPS Export

Support or Contact

Sanatt Abrol