O'Reilly logo

Java™ Drawing with Apache Batik: A Tutorial by Alexander Kolesnikov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building an SVG Document

In this section you create an SVG document and use the Batik API to create a Document object that represents the SVG document. First of all, the SVG document in Listing 5.1 was acceptable but it could have been created in a more efficient way. The modified version of the code in Listing 5.1 is given in Listing 5.2.

Listing 5.2. The enhanced version of the SVG document in Listing 5.1
<?xml version="1.0" encoding="utf-8"?> <svg width="400" height="400" xmlns="http://www.w3.org/2000/svg"> <circle fill="yellow" stroke="lime" stroke-width="20" r="45" cx="197" cy="110"/> <rect fill="silver" width="90" height="90" x="276" y="19" stroke-width="20" stroke="red"/> <circle fill="yellow" stroke="lime" stroke-width="20" r="45" cx="332" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required