Class TextRenderer

java.lang.Object
host.anzo.commons.graphics.text.TextRenderer

public final class TextRenderer extends Object
A class which provides static methods for rendering text using alignment.
  • Method Details

    • drawString

      public static Rectangle drawString(Graphics g, String text, Font font, Color color, Rectangle bounds)
      Draws a string onto a Graphics handle, using a Font, Color and target bounds to calculate the location and automatic wrapping of text. The align property determines where the text will be positioned.
      Parameters:
      g - A Graphics handle which is the target of the draw operation
      text - A String containing the text to draw
      font - The Font to use when drawing the text
      color - The Color to use when drawing the text
      bounds - A Rectangle representing the bounds of the text
      Returns:
      A Rectangle representing the bounds consumed by the text
    • drawString

      public static Rectangle drawString(Graphics g, String text, Font font, Color color, Rectangle bounds, TextAlignment align)
      Draws a string onto a Graphics handle, using a Font, Color and target bounds to calculate the location and automatic wrapping of text. The align property determines where the text will be positioned.
      Parameters:
      g - A Graphics handle which is the target of the draw operation
      text - A String containing the text to draw
      font - The Font to use when drawing the text
      color - The Color to use when drawing the text
      bounds - A Rectangle representing the bounds of the text
      align - A TextAlignment value representing the location to draw the text, relative to the bounds
      Returns:
      A Rectangle representing the bounds consumed by the text
    • drawString

      public static Rectangle drawString(Graphics g, String text, Font font, Color color, Rectangle bounds, TextAlignment align, int format)
      Draws a string onto a Graphics handle, using a Font, Color and target bounds to calculate the location and automatic wrapping of text. The align property determines where the text will be positioned.
      Parameters:
      g - A Graphics handle which is the target of the draw operation
      text - A String containing the text to draw
      font - The Font to use when drawing the text
      color - The Color to use when drawing the text
      bounds - A Rectangle representing the bounds of the text
      align - A TextAlignment value representing the location to draw the text, relative to the bounds
      format - Additional formatting flags to use when drawing (see TextFormat class)
      Returns:
      A Rectangle representing the bounds consumed by the text