To add a ‘view’ feature to the application you built in Chapter 2, you need to do these.
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.
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.