Skip to content

DrawText

final class DrawText
Package: dev.joid.lib.draw.text · Module: core · Source: DrawText.java

Draws and measures text, on one line or wrapped in a box.

Reach it through DrawUtils.TEXT. Positions and sizes are in design pixels; every method returns the bounds of what it drew, and a text cut or wrapped to fit a box returns the width of the box. Markup tags inside the text are never cut in half when a line wraps or is cut, and the elements of a Text share one baseline.

ReturnsSignatureSummary
DrawTextinst() factoryReturns the shared instance, the one in DrawUtils.TEXT.

ReturnsSignatureSummary
FontBoundsdrawText(double x, double y, Text text)Draws the text on one line, placed around x, y by its alignment: START puts its left or top edge there, CENTER its middle, END its right or bottom edge.
FontBoundsdrawText(double x, double y, double width, double height, Text text, TextMode mode)Draws the text in the box at x, y of width × height, aligned inside it, with the given TextMode.
FontBoundsdrawText(double x, double y, String text, TextInfo info, Align alignX, Align alignY)Draws a string on one line with info, placed around x, y by the horizontal and vertical alignments.
FontBoundsdrawText(double x, double y, double width, double height, String text, TextInfo info, Align alignX, Align alignY, TextOverflow overflow, TextMode mode)Draws a string in a box, with its alignments, its overflow marker and its mode.
List<Text>getLines(double width, Text text)Splits the text into the lines that SPLIT draws for width, each a Text with the same alignment and overflow.
List<String>getLines(double width, String text, TextInfo info)Splits a string into the lines that fit width with info.

DrawText inst() factory

Returns the shared instance, the one in DrawUtils.TEXT.

FontBounds drawText(double x, double y, Text text)

Draws the text on one line, placed around x, y by its alignment: START puts its left or top edge there, CENTER its middle, END its right or bottom edge.

FontBounds drawText(double x, double y, double width, double height, Text text, TextMode mode)

Draws the text in the box at x, y of width × height, aligned inside it, with the given TextMode.

FontBounds drawText(double x, double y, String text, TextInfo info, Align alignX, Align alignY)

Draws a string on one line with info, placed around x, y by the horizontal and vertical alignments.

FontBounds drawText(double x, double y, double width, double height, String text, TextInfo info, Align alignX, Align alignY, TextOverflow overflow, TextMode mode)

Draws a string in a box, with its alignments, its overflow marker and its mode.

List<Text> getLines(double width, Text text)

Splits the text into the lines that SPLIT draws for width, each a Text with the same alignment and overflow. A line breaks at a line break or a <br> tag, otherwise at the last space that fits; only a word wider than the whole line is cut.

List<String> getLines(double width, String text, TextInfo info)

Splits a string into the lines that fit width with info.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page