Class LabelUtils

java.lang.Object
VASSAL.tools.image.LabelUtils

public class LabelUtils extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    drawHTMLLabel(Graphics g, String text, int x, int y, Font f, int hAlign, int vAlign, Color fgColor, Color bgColor, Color borderColor, Component comp, int objectWidth, int textPad, int minWidth, int extraBorder)
     
    static void
    drawHTMLLabel(Graphics g, String text, int x, int y, Font f, int hAlign, int vAlign, Color fgColor, Color bgColor, Color borderColor, Component comp, int objectWidth, int textPad, int minWidth, int extraBorder, int extraTop, int extraBottom, boolean allowHTML)
    Draw an HTML-compliant text label with appropriate alignment and foreground/background color, plus a border box, and extra configuration parameters.
    static void
    drawLabel(Graphics g, String text, int x, int y, int hAlign, int vAlign, Color fgColor, Color bgColor)
    Draw a non-HTML text label with appropriate alignment and foreground/background color
    static void
    drawLabel(Graphics g, String text, int x, int y, Font f, int hAlign, int vAlign, Color fgColor, Color bgColor, Color borderColor)
    Draw a non-HTML text label with appropriate alignment and foreground/background color, plus a border box
    static void
    drawLabel(Graphics g, String text, int x, int y, Font f, int hAlign, int vAlign, Color fgColor, Color bgColor, Color borderColor, int objectWidth, int textPad, int minWidth, int extraBorder)
    Draw a non-HTML text label with appropriate alignment and foreground/background color, plus a border box, and extra configuration parameters
    static void
    drawLabelBox(Graphics2D g, Font font, String s, int imageWidth, int stringWidth, int height)
     
    labelBoxImage(Font font, String s, int minWidth, int height)
     
    static int
     
    Create a viewable representation of a null or empty image to use as a place holder in Configurers.
    noImageBoxImage(int w, int h, double scale)
    Create a viewable representation of a null or empty image to use as a place holder in Configurers

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • drawLabel

      public static void drawLabel(Graphics g, String text, int x, int y, int hAlign, int vAlign, Color fgColor, Color bgColor)
      Draw a non-HTML text label with appropriate alignment and foreground/background color
      Parameters:
      g - Graphics Object
      text - text to draw
      x - x location
      y - y location
      hAlign - Horizontal alignment (LEFT, RIGHT, or CENTER)
      vAlign - Vertical alignment (TOP, BOTTOM, or CENTER)
      fgColor - Foreground Color
      bgColor - Background Color
    • drawLabel

      public static void drawLabel(Graphics g, String text, int x, int y, Font f, int hAlign, int vAlign, Color fgColor, Color bgColor, Color borderColor)
      Draw a non-HTML text label with appropriate alignment and foreground/background color, plus a border box
      Parameters:
      g - Graphics Object
      text - text to draw
      x - x location
      y - y location
      hAlign - Horizontal alignment (LEFT, RIGHT, or CENTER)
      vAlign - Vertical alignment (TOP, BOTTOM, or CENTER)
      fgColor - Foreground Color
      bgColor - Background Color
      borderColor - Box color around border
    • drawLabel

      public static void drawLabel(Graphics g, String text, int x, int y, Font f, int hAlign, int vAlign, Color fgColor, Color bgColor, Color borderColor, int objectWidth, int textPad, int minWidth, int extraBorder)
      Draw a non-HTML text label with appropriate alignment and foreground/background color, plus a border box, and extra configuration parameters
      Parameters:
      g - Graphics Object
      text - text to draw
      x - x location
      y - y location
      hAlign - Horizontal alignment (LEFT, RIGHT, or CENTER)
      vAlign - Vertical alignment (TOP, BOTTOM, or CENTER)
      fgColor - Foreground Color
      bgColor - Background Color
      borderColor - Box color around border
      objectWidth - 0 for default, or width of an optional "master object" inside of which the label is being drawn (allows better alignment options)
      textPad - 0 for default, or extra padding around text in all 4 directions
      minWidth - 0 for default, or minimum width of text box
      extraBorder - 0 for default, or number of pixels of extra thickness of border box
    • drawHTMLLabel

      public static void drawHTMLLabel(Graphics g, String text, int x, int y, Font f, int hAlign, int vAlign, Color fgColor, Color bgColor, Color borderColor, Component comp, int objectWidth, int textPad, int minWidth, int extraBorder)
    • drawHTMLLabel

      public static void drawHTMLLabel(Graphics g, String text, int x, int y, Font f, int hAlign, int vAlign, Color fgColor, Color bgColor, Color borderColor, Component comp, int objectWidth, int textPad, int minWidth, int extraBorder, int extraTop, int extraBottom, boolean allowHTML)
      Draw an HTML-compliant text label with appropriate alignment and foreground/background color, plus a border box, and extra configuration parameters. Supports "Quick Colors".
      Parameters:
      g - Graphics Object
      text - text to draw
      x - x location
      y - y location
      hAlign - Horizontal alignment (LEFT, RIGHT, or CENTER)
      vAlign - Vertical alignment (TOP, BOTTOM, or CENTER)
      fgColor - Foreground Color
      bgColor - Background Color
      borderColor - Box color around border
      comp - Component we are drawing on
      objectWidth - 0 for default, or width of an optional "master object" inside of which the label is being drawn (allows better alignment options)
      textPad - 0 for default, or extra padding around text in all 4 directions
      minWidth - 0 for default, or minimum width of text box
      extraBorder - 0 for default, or number of pixels of extra thickness of border box
    • labelWidth

      public static int labelWidth(Font font, String s)
    • drawLabelBox

      public static void drawLabelBox(Graphics2D g, Font font, String s, int imageWidth, int stringWidth, int height)
    • labelBoxImage

      public static BufferedImage labelBoxImage(Font font, String s, int minWidth, int height)
    • noImageBoxImage

      public static BufferedImage noImageBoxImage(int w, int h, double scale)
      Create a viewable representation of a null or empty image to use as a place holder in Configurers. * The image will contain the translated text for the key Editor.ImageUtils.no_image
      Parameters:
      w - Minimum width for generated the image
      h - Height of the generated image
      scale - Scale factor for font
      Returns:
      Viewable null image
    • noImageBoxImage

      public static BufferedImage noImageBoxImage()
      Create a viewable representation of a null or empty image to use as a place holder in Configurers. The image will contain the translated text for the key Editor.ImageUtils.no_image
      Returns:
      Viewable null image