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

Displaying Generated SVG Documents

To add a ‘view’ feature to the application you built in Chapter 2, you need to do these.

  1. Instead of immediately saving the generated document in a file, you pass it to an instance of JSVGCanvas. JSVGCanvas is one of Batik’s core components specifically designed to display SVG contents. Since JSVGCanvas is a Swing component, it is really easy to add it to a Swing application.

  2. To make it more interesting than just creating shapes of the same size, provide a couple of JSpinner components that can be used to change shape sizes and border widths. In addition, the generated shapes should appear in random places on the canvas. Figure 3.1 shows the application after this new feature is added.

Figure 3.1. The new extended ...

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