January 23, 2008

Apache Batik SVG Toolkit Overview

Apache Batik is a Java-based toolkit for applications or applets that want to use images in the Scalable Vector Graphics (SVG) format for various purposes, such as display, generation or manipulation.

The project’s ambition is to give developers a set of modules that can be used together or individually to support specific SVG solutions.

The Batik modules are of one of three types: application modules, core modules and low level modules.

Application modules illustrate how to use the core modules and let users evaluate the Batik software by experimenting with its features. So, the application modules illustrate the functionality that Batik offers. The Batik SVG Toolkit distribution contains a few demos:

  • Squiggle SVG Browser
    The Squiggle SVG Browser lets you view SVG file, zoom, pan and rotate in the content and select text items in the image and much more.

  • SVG Font Converter
    The SVG Font Converter lets developers convert character ranges from the True Type Font format to the SVG Font format to embed in SVG documents. This allows SVG document to be fully self-contained and have their rendered identically on all systems.

  • SVG Rasterizer
    The SVG Rasterizer is a utility that can convert SVG files to a raster format. The tool can convert individual files or sets of files, making it easy to convert entire directories of SVG files. The supported formats are JPEG, PNG, and TIFF, however the design allows new formats to be added easily. In addition (and despite the name) the rasterizer tool can also convert SVG files into PDF.

  • SVG Pretty Printer
    The SVG Pretty Printer lets developers “pretty-up” their SVG files and get their tabulations and other cosmetic parameters in order. It can also be used to modify the DOCTYPE declaration on SVG files.

Core modules are the heart of Batik and the primary deliverables for the projects. These are the modules developers use to manipulate, generate, create, convert, render and view SVG content. They can be used individually or in combination for various purposes, and the application modules offer some usage examples:

  • The SVG generator is a module containing SVGGraphics2D class, that lets all Java applications or applets easily convert their graphics to the SVG format, as easily as they draw to a screen or a printer, by leveraging the Java 2D API’s extensible design.

  • The Swing components module includes, primarily, the JSVGCanvas class, a UI component that can display SVG content and let the user interact with that content (zoom, pan, rotate, select text, etc.).

  • The Bridge module is rarely used directly. It is responsible for creating and maintaining an appropriate object corresponding to an SVG element. The bridge converts an SVG document into the internal representation Batik uses for graphics (GVT, the Graphic Vector Toolkit).

  • The Transcoder is a module that provides a generic API for transcoding an input to an output. This module transcodes an input stream or a document into a particular ouput format, used for converting SVG documents to other types.


Low-level modules are used internally by the core modules to accomplish their work.
These modules are not expected to be used directly by developers using the Batik API. Rather, they support the operation of the core modules. The low level modules include:

  • The Graphic Vector Toolkit (GVT) module, which represents a view of the DOM tree that is more suitable for for rendering and event handling purposes. This module describes DOM tree in terms of a tree of Java graphics objects.

  • The Renderer module is responsible for rendering a GVT tree and any related task. For example, a raster based renderer may perform some caching (the default renderer in Batik does that). However, a renderer could perform any task deemed necessary and does not have to be raster based.

  • The SVG parser module contains parser classes for complex SVG attributes such as the transform or color attributes. Higher level modules rely on the SVG parser module.

Here are small list of projects and products that using Batik SVG Toolkit:

  • The Apache Cocoon project uses Batik to rasterize SVG images.
  • The Apache FOP project uses Batik to handle SVG images. It uses the SVG rasterizer and extends the Batik transcoder architecture to offer SVG to PDF conversion.
  • ElixirTech’s ElixirReport uses Batik for charting and for its SVG component.
  • GLIPS Graffiti is an Open Source Extensible Full Feature Native SVG Editor.
  • eDoc Studio, a page layout package, uses the Batik SVG generator to export pages to SVG.
  • ILOG Discovery Preview, a free visual data analysis tool letting you visualize and edit data sets in a very wide variety of views (2D graphs and charts, various kinds of treemaps, parallel coordinates, parallel histograms and much more), uses the Batik SVG export module.
  • The JFreeChart Project uses Batik to export charts in the SVG format.
  • Lagoon, an XML-based framework for web site maintenance, uses the Batik SVG Rasterizer to render SVG as bitmap graphics for web publishing.
  • ILOG JViews Component Suite, a product for advanced visualization, uses and extends the Batik SVG export module.
  • Lords Map is a program to allow players and visitors to view the current map of various campaigns. Lords Map uses Batik’s SVG DOM and SVG Generator.
  • Luxor XUL is a free, open-source XML User Interface Language (XUL) toolkit in Java released under the GNU GPL that supports hand-picked Mozilla XUL goodies and also includes a ultra-lightweight, multi-threaded web server, a portal engine, a scripting engine, a template engine and much more. Gerard Bauer, the Luxor project lead, has written an extensive SVG presentation.
  • OptimalJ, a UML Class Diagram Editor for NetBeans, uses Batik to export SVG.
  • Sketsa is a vector drawing application based on Batik. With Sketsa, you can create vector graphics that can be scaled and printed at any resolution, without losing detail or clarity.
  • Oracle Corp.’s JDeveloper10i uses Batik to export class diagrams in SVG. It uses the SVG export module.
  • Svolgo, a Graph Visualisation/Transformation Framework for the Semantic Web Cross-model transformation, node and arc diagrams, representation in SVG. This project uses Batik’s SVG DOM implementation.
  • Volity is an open platform for Internet-based multiplayer casual gaming. Its official client, Gamut, uses Batik, allowing developers to create game UI files that use ECMAScript-driven SVG.
  • XWeb, a tool to create websites automatically out of XML input. Uses the Batik SVG Rasterizer.
  • XML_svg2image is a PHP class which translates SVG files to PNG or JPEG using Batik.

If you are interested in Apache Batik SVG Toolkit, you can download it from Apache XML Graphics Project

No comments: