1 18 package org.apache.batik.svggen; 19 20 import java.awt.Color ; 21 import java.awt.Graphics2D ; 22 import java.awt.RenderingHints ; 23 24 31 public class TextSpacePreserve implements Painter { 32 public void paint(Graphics2D g) { 33 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 34 RenderingHints.VALUE_ANTIALIAS_ON); 35 36 g.setPaint(Color.black); 38 int legendX = 10, legendY = 12; 39 g.translate(0, 30); 40 41 42 g.drawString(" space before.", legendX, legendY); 44 g.drawString("Multiple spaces between A and B: A B", legendX, legendY + 20); 45 g.drawString("This is a first line\n and this is a second line starting with spaces", 46 legendX, legendY + 40); 47 g.drawString("Should have no trailing spaces", legendX, legendY + 60); 48 } 49 } 50 | Popular Tags |