@Test public void drawRightText2() throws Exception { graphics.setFont(FontUtil.getLiberationSansRegular().deriveFont(Font.PLAIN, 10)); Java2DStringUtilities.drawString(graphics, RIGHT, x, y, "ABCD"); ImageAssert.compareImages("textUtilities.4", image); }
public static void drawString(Graphics2D g, Alignment alignment, int x, int y, String text) { Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(text, g); g.drawString(text, alignment.stringRightSide(stringBounds, x), alignment.stringBaseline(stringBounds, y)); }
Java2DStringUtilities { public static void drawString(Graphics2D g, Alignment alignment, int x, int y, String text) { Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(text, g); g.drawString(text, alignment.stringRightSide(stringBounds, x), alignment.stringBaseline(stringBounds, y)); } }
Java2DStringUtilities { public static void drawString(Graphics2D g, Alignment alignment, int x, int y, String text) { Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(text, g); g.drawString(text, alignment.stringRightSide(stringBounds, x), alignment.stringBaseline(stringBounds, y)); }  }
Java2DStringUtilities { public static void drawString(Graphics2D g, Alignment alignment, int x, int y, String text) { Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(text, g); g.drawString(text, alignment.stringRightSide(stringBounds, x), alignment.stringBaseline(stringBounds, y)); }  static void drawString(Graphics2D g, Alignment alignment, int x, int y, String text); }
Java2DStringUtilities { public static void drawString(Graphics2D g, Alignment alignment, int x, int y, String text) { Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(text, g); g.drawString(text, alignment.stringRightSide(stringBounds, x), alignment.stringBaseline(stringBounds, y)); }  static void drawString(Graphics2D g, Alignment alignment, int x, int y, String text);  }