Class TextRenderer
java.lang.Object
de.gurkenlabs.litiengine.graphics.TextRenderer
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic Rectangle2DgetBounds(Graphics2D g, String text) Retrieve the bounds of some text if it was to be drawn on the specified Graphics2Dstatic doublegetHeight(Graphics2D g, String text) Retrieve the height of some text if it was to be drawn on the specified Graphics2Dstatic doublegetWidth(Graphics2D g, String text) Retrieve the width of some text if it was to be drawn on the specified Graphics2Dstatic voidrender(Graphics2D g, String text, double x, double y) Draw text at the given coordinates.static voidrender(Graphics2D g, String text, double x, double y, boolean antiAliasing) Draw text at the given coordinates.static voidrender(Graphics2D g, String text, Align align, Valign valign, double offsetX, double offsetY) Draws text with the specified alignment.static voidrender(Graphics2D g, String text, Point2D location) static voidrender(Graphics2D g, String text, Point2D location, boolean antiAliasing) static voidrender(Graphics2D g, String text, Rectangle2D bounds, Align alignment, Valign verticalAlignment, boolean scaleFont) static voidrender(Graphics2D g, String text, Rectangle2D bounds, Align align, Valign valign, double offsetX, double offsetY, boolean scaleFont) Draws text within the given boundaries using the specified alignment and scales the font size, if desired.static voidrenderRotated(Graphics2D g, String text, double x, double y, double angle) static voidrenderRotated(Graphics2D g, String text, double x, double y, double angle, boolean antiAliasing) static voidrenderRotated(Graphics2D g, String text, Point2D location, double angle) static voidrenderRotated(Graphics2D g, String text, Point2D location, double angle, boolean antiAliasing) static voidrenderWithLinebreaks(Graphics2D g, String text, double x, double y, double lineWidth) Draw text at the given coordinates with a maximum line width for automatic line breaks.static voidrenderWithLinebreaks(Graphics2D g, String text, double x, double y, double lineWidth, boolean antiAliasing) Draw text at the given coordinates with a maximum line width for automatic line breaks and a provided Anti-Aliasing parameter.static voidrenderWithLinebreaks(Graphics2D g, String text, Align align, Valign valign, double x, double y, double width, double height, boolean antiAliasing) Draw text at the given coordinates with a maximum line width for automatic line breaks and a provided Anti-Aliasing parameter.static voidrenderWithLinebreaks(Graphics2D g, String text, Point2D location, double lineWidth) static voidrenderWithLinebreaks(Graphics2D g, String text, Point2D location, double lineWidth, boolean antiAliasing) static voidrenderWithOutline(Graphics2D g, String text, double x, double y, double width, double height, Color outlineColor, float stroke, Align align, Valign valign, boolean antiAliasing) Draw text at the given coordinates with an outline in the provided color and a provided Anti-Aliasing parameter.static voidrenderWithOutline(Graphics2D g, String text, double x, double y, Color outlineColor) Draw text at the given coordinates with an outline in the provided color.static voidrenderWithOutline(Graphics2D g, String text, double x, double y, Color outlineColor, boolean antiAliasing) static voidrenderWithOutline(Graphics2D g, String text, double x, double y, Color outlineColor, float stroke, boolean antiAliasing) Draw text at the given coordinates with an outline in the provided color and a provided Anti-Aliasing parameter.static voidrenderWithOutline(Graphics2D g, String text, Point2D location, Color outlineColor) static voidrenderWithOutline(Graphics2D g, String text, Point2D location, Color outlineColor, boolean antiAliasing)
-
Method Details
-
render
Draw text at the given coordinates. This variant of drawText() uses RenderingHints.VALUE_TEXT_ANTIALIAS_OFF as Anti-Aliasing method by standard. For other Anti-Aliasing options, please use the drawText()-variant with five parameters.- Parameters:
g- the Graphics2D object to draw ontext- the String to be distributed over all generated linesx- the min x coordinatey- the min y coordinate
-
render
-
render
public static void render(Graphics2D g, String text, Align align, Valign valign, double offsetX, double offsetY) Draws text with the specified alignment.- Parameters:
g- the Graphics2D object to draw ontext- the String to be distributed over all generated linesalign- The horizontal alignment.valign- The vertical alignment.offsetX- The horizontal offset that is added to the alignment.offsetY- The vertical offset that is added to the alignment.
-
render
public static void render(Graphics2D g, String text, Rectangle2D bounds, Align alignment, Valign verticalAlignment, boolean scaleFont) -
render
public static void render(Graphics2D g, String text, Rectangle2D bounds, Align align, Valign valign, double offsetX, double offsetY, boolean scaleFont) Draws text within the given boundaries using the specified alignment and scales the font size, if desired.- Parameters:
g- the Graphics2D object to draw ontext- the String to be distributed over all generated linesbounds- the Rectangle defining the boundaries used for alignment and scaling.align- The horizontal alignment.valign- The vertical alignment.offsetX- The horizontal offset that is added to the alignment.offsetY- The vertical offset that is added to the alignment.scaleFont- if true, scale the font so that the text will fit inside the given rectangle. If not, use the Graphics context's previous font size.
-
render
Draw text at the given coordinates. This variant of drawText() uses a provided AntiAliasing parameter.- Parameters:
g- the Graphics2D object to draw ontext- the String to be distributed over all generated linesx- the min x coordinatey- the min y coordinateantiAliasing- Configure whether or not to render the text with antialiasing.- See Also:
-
render
-
renderRotated
public static void renderRotated(Graphics2D g, String text, double x, double y, double angle, boolean antiAliasing) -
renderRotated
-
renderRotated
-
renderRotated
public static void renderRotated(Graphics2D g, String text, Point2D location, double angle, boolean antiAliasing) -
renderWithLinebreaks
public static void renderWithLinebreaks(Graphics2D g, String text, double x, double y, double lineWidth) Draw text at the given coordinates with a maximum line width for automatic line breaks. This variant of drawTextWithAutomaticLinebreaks() uses RenderingHints.VALUE_TEXT_ANTIALIAS_OFF as Anti-Aliasing method by standard. For other Anti-Aliasing options, please use the drawTextWithAutomaticLinebreaks()-variant with six parameters.- Parameters:
g- the Graphics2D object to draw ontext- the String to be distributed over all generated linesx- the min x coordinatey- the min y coordinatelineWidth- the max line width
-
renderWithLinebreaks
public static void renderWithLinebreaks(Graphics2D g, String text, Point2D location, double lineWidth) -
renderWithLinebreaks
public static void renderWithLinebreaks(Graphics2D g, String text, double x, double y, double lineWidth, boolean antiAliasing) Draw text at the given coordinates with a maximum line width for automatic line breaks and a provided Anti-Aliasing parameter.- Parameters:
g- the Graphics2D object to draw ontext- the String to be distributed over all generated linesx- the min x coordinatey- the min y coordinatelineWidth- the max line widthantiAliasing- Configure whether or not to render the text with antialiasing.- See Also:
-
renderWithLinebreaks
public static void renderWithLinebreaks(Graphics2D g, String text, Align align, Valign valign, double x, double y, double width, double height, boolean antiAliasing) Draw text at the given coordinates with a maximum line width for automatic line breaks and a provided Anti-Aliasing parameter.- Parameters:
g- the Graphics2D object to draw ontext- the String to be distributed over all generated linesalign- The horizontal alignment.valign- The vertical alignment.x- the min x coordinatey- the min y coordinatewidth- the line widthheight- the line height.antiAliasing- Configure whether or not to render the text with antialiasing.- See Also:
-
renderWithLinebreaks
public static void renderWithLinebreaks(Graphics2D g, String text, Point2D location, double lineWidth, boolean antiAliasing) -
renderWithOutline
public static void renderWithOutline(Graphics2D g, String text, double x, double y, Color outlineColor) Draw text at the given coordinates with an outline in the provided color. This variant of drawTextWithShadow() doesn't use Anti-Aliasing. For other Anti-Aliasing options, please specify the boolean value that controls it.- Parameters:
g- the Graphics2D object to draw ontext- the String to be distributed over all generated linesx- the min x coordinatey- the min y coordinateoutlineColor- the outline color
-
renderWithOutline
public static void renderWithOutline(Graphics2D g, String text, Point2D location, Color outlineColor) -
renderWithOutline
public static void renderWithOutline(Graphics2D g, String text, double x, double y, Color outlineColor, boolean antiAliasing) -
renderWithOutline
public static void renderWithOutline(Graphics2D g, String text, double x, double y, Color outlineColor, float stroke, boolean antiAliasing) Draw text at the given coordinates with an outline in the provided color and a provided Anti-Aliasing parameter.- Parameters:
g- the Graphics2D object to draw ontext- the String to be distributed over all generated linesx- the min x coordinatey- the min y coordinateoutlineColor- the outline colorstroke- the width of the outlineantiAliasing- the Anti-Aliasing object (e.g. RenderingHints.VALUE_TEXT_ANTIALIAS_OFF)- See Also:
-
renderWithOutline
public static void renderWithOutline(Graphics2D g, String text, double x, double y, double width, double height, Color outlineColor, float stroke, Align align, Valign valign, boolean antiAliasing) Draw text at the given coordinates with an outline in the provided color and a provided Anti-Aliasing parameter.- Parameters:
g- the Graphics2D object to draw ontext- the String to be distributed over all generated linesx- the min x coordinatey- the min y coordinatewidth- the width of the bounding box in which the text will be alignedheight- the height of the bounding box in which the text will be alignedoutlineColor- the outline colorstroke- the thickness of the outlinealign- The horizontal alignment.valign- The vertical alignment.antiAliasing- Configure whether or not to render the text with antialiasing.- See Also:
-
renderWithOutline
public static void renderWithOutline(Graphics2D g, String text, Point2D location, Color outlineColor, boolean antiAliasing) -
getBounds
Retrieve the bounds of some text if it was to be drawn on the specified Graphics2D- Parameters:
g- The Graphics2D object to be drawn ontext- The string to calculate the bounds of- Returns:
- The bounds of the specified String in the specified Graphics context.
- See Also:
-
getWidth
Retrieve the width of some text if it was to be drawn on the specified Graphics2D- Parameters:
g- The Graphics2D object to be drawn ontext- The string to retrieve the width of- Returns:
- The width of the specified text
-
getHeight
Retrieve the height of some text if it was to be drawn on the specified Graphics2D- Parameters:
g- The Graphics2D object to be drawn ontext- The string to retrieve the height of- Returns:
- The height of the specified text
-
enableTextAntiAliasing
-