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

Text Layout

This section explains how you can change the text layout.

Vertical Text

To write vertically, you assign tb (top to bottom) to the writing-mode attribute of the text element. To see how it works, I changed the drawText method in our SVG Writer Plus.

Let all the tspan elements be text elements. Of course you append them to the root element, and not to an existing text element. Consider the new version of the drawText method shown in Listing 6.7.

Listing 6.7. The new version of drawText
protected void drawText(final String txt) { // If there is no proper text, do nothing if (txt.trim().equals("")) return; // As usual, we put our code into a Runnable object Runnable r = new Runnable() { public void run() { // Get a reference to the root ...

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