Class TextRenderUtils
java.lang.Object
ActiverseUtils.TextRenderUtils
Shared text layout helpers for menu/HUD rendering.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intcenteredX(Graphics2D g2d, String text, int containerX, int containerWidth) Returns an x-position that horizontally centers text in a container.static voiddrawCenteredX(Graphics2D g2d, String text, int y, int screenWidth) Draws text centered in the full width [0, screenWidth].static voiddrawCenteredX(Graphics2D g2d, String text, int y, int containerX, int containerWidth) Draws text horizontally centered in a container rectangle.
-
Method Details
-
centeredX
Returns an x-position that horizontally centers text in a container.- Parameters:
g2d- Graphics context used for font metricstext- Text to measure (null-safe)containerX- Left coordinate of the containercontainerWidth- 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 drawingtext- Text to draw (null-safe)y- Baseline y coordinatecontainerX- Left coordinate of the containercontainerWidth- Container width in pixels
-
drawCenteredX
Draws text centered in the full width [0, screenWidth].- Parameters:
g2d- Graphics contexttext- Text to draw (null-safe)y- Baseline y coordinatescreenWidth- Full drawable width
-