Class TextRenderUtils

java.lang.Object
ActiverseUtils.TextRenderUtils

public final class TextRenderUtils extends Object
Shared text layout helpers for menu/HUD rendering.
  • Method Details

    • centeredX

      public static int centeredX(Graphics2D g2d, String text, int containerX, int containerWidth)
      Returns an x-position that horizontally centers text in a container.
      Parameters:
      g2d - Graphics context used for font metrics
      text - Text to measure (null-safe)
      containerX - Left coordinate of the container
      containerWidth - Container width in pixels
      Returns:
      Pixel x position for centered baseline drawing
    • drawCenteredX

      public static void drawCenteredX(Graphics2D g2d, String text, int y, int containerX, int containerWidth)
      Draws text horizontally centered in a container rectangle.
      Parameters:
      g2d - Graphics context used for measurement and drawing
      text - Text to draw (null-safe)
      y - Baseline y coordinate
      containerX - Left coordinate of the container
      containerWidth - Container width in pixels
    • drawCenteredX

      public static void drawCenteredX(Graphics2D g2d, String text, int y, int screenWidth)
      Draws text centered in the full width [0, screenWidth].
      Parameters:
      g2d - Graphics context
      text - Text to draw (null-safe)
      y - Baseline y coordinate
      screenWidth - Full drawable width