public static final int drawString(Font font, final String s,
			final int alignment, final int x, final int y, final int width,
			Color color) {
		int resultingXCoordinate = 0;
		if (alignment == Alignment.LEFT) {
			font.drawString(x, y, s, color);
		} else if (alignment == Alignment.CENTER) {
			font.drawString(x + (width / 2) - (font.getWidth(s) / 2), y, s,
					color);
		} else if (alignment == Alignment.RIGHT) {
			font.drawString(x + width - font.getWidth(s), y, s, color);
		} else if (alignment == Alignment.JUSTIFY) {
			// calculate left width
			int leftWidth = width - font.getWidth(s);
			if (leftWidth <= 0) {
				// no width left, use standard draw string
				font.drawString(x, y, s, color);
			}

			return FontUtils.drawJustifiedSpaceSeparatedSubstrings(font, s, x,
					y, FontUtils.calculateWidthOfJustifiedSpaceInPixels(font,
							s, leftWidth));
		}

		return resultingXCoordinate;
	}
public static final int drawString ( Font font , final String s , final int alignment , final int x , final int y , final int width , Color color ) { int resultingXCoordinate = 0 ; if ( alignment == Alignment . LEFT ) { font . drawString ( x , y , s , color ) ; } else if ( alignment == Alignment . CENTER ) { font . drawString ( x + ( width / 2 ) - ( font . getWidth ( s ) / 2 ) , y , s , color ) ; } else if ( alignment == Alignment . RIGHT ) { font . drawString ( x + width - font . getWidth ( s ) , y , s , color ) ; } else if ( alignment == Alignment . JUSTIFY ) { int leftWidth = width - font . getWidth ( s ) ; if ( leftWidth <= 0 ) { font . drawString ( x , y , s , color ) ; } return FontUtils . drawJustifiedSpaceSeparatedSubstrings ( font , s , x , y , FontUtils . calculateWidthOfJustifiedSpaceInPixels ( font , s , leftWidth ) ) ; } return resultingXCoordinate ; }
Draw a string

@param font The font to draw with
@param s The text to draw
@param alignment The alignment to apply
@param x The x location to draw at
@param y The y location to draw at
@param width The width to fill with the string
@param color The color to draw in
@return The final x coordinate of the text