java.lang.Object
io.github.palexdev.materialfx.utils.TextUtils
Utils class for JavaFX's
Labels
and MFXLabels
.-
Method Summary
Modifier and TypeMethodDescriptionstatic double
computeLabelHeight
(Font font, String text) Computes the min height of a text node.static SizeBean
computeLabelSizes
(Font font, String text) Computes both the width and the height of aLabel
for the given font and text.static double
computeLabelWidth
(Label label) Computes the min width for the specifiedLabel
so that all the text is visible.static double
computeLabelWidth
(Font font, String text) Computes the min width of a text node so that all the text is visible.static double
computeTextHeight
(Font font, String text) Computes the min height of a text node.static double
computeTextWidth
(Font font, String text) Computes the min width of a text node so that all the text is visible.static boolean
isLabelTruncated
(Label label) Checks if the text of the specifiedLabel
is truncated.static void
registerTruncatedLabelListener
(BooleanProperty isTruncated, Label label) Registers a listener to the specifiedLabel
which checks if the text is truncated and updates the specified boolean property accordingly.
-
Method Details
-
isLabelTruncated
Checks if the text of the specifiedLabel
is truncated.- Parameters:
label
- The specified label
-
registerTruncatedLabelListener
Registers a listener to the specifiedLabel
which checks if the text is truncated and updates the specified boolean property accordingly.- Parameters:
isTruncated
- The boolean property to changelabel
- The specified label
-
computeLabelWidth
Computes the min width of a text node so that all the text is visible. UsesNodeUtils.getRegionWidth(Region)
.Uses
Label
as helper.- Parameters:
font
- the label fonttext
- the label text
-
computeLabelHeight
Computes the min height of a text node.Uses
Label
as helper.- Parameters:
font
- the node fonttext
- the node text
-
computeLabelSizes
Computes both the width and the height of aLabel
for the given font and text.- Returns:
- the bean containing the computed values
-
computeTextWidth
Computes the min width of a text node so that all the text is visible.Uses
Text
as helper.- Parameters:
font
- the node fonttext
- the node text
-
computeTextHeight
Computes the min height of a text node.Uses
Text
as helper.- Parameters:
font
- the node fonttext
- the node text
-
computeLabelWidth
Computes the min width for the specifiedLabel
so that all the text is visible.Uses
Note: this works only after the label has been laid out.computeTextWidth(Font, String)
, but also takes into account the label's graphic bounds (if not null) and theLabeled.graphicTextGapProperty()
.
-