java.lang.Object
io.github.palexdev.materialfx.utils.TextUtils
Utils class for JavaFX's
Labels and MFXLabels.-
Method Summary
Modifier and TypeMethodDescriptionstatic doublecomputeLabelHeight(Font font, String text) Computes the min height of a text node.static SizeBeancomputeLabelSizes(Font font, String text) Computes both the width and the height of aLabelfor the given font and text.static doublecomputeLabelWidth(Label label) Computes the min width for the specifiedLabelso that all the text is visible.static doublecomputeLabelWidth(Font font, String text) Computes the min width of a text node so that all the text is visible.static doublecomputeTextHeight(Font font, String text) Computes the min height of a text node.static doublecomputeTextWidth(Font font, String text) Computes the min width of a text node so that all the text is visible.static booleanisLabelTruncated(Label label) Checks if the text of the specifiedLabelis truncated.static voidregisterTruncatedLabelListener(BooleanProperty isTruncated, Label label) Registers a listener to the specifiedLabelwhich checks if the text is truncated and updates the specified boolean property accordingly.
-
Method Details
-
isLabelTruncated
Checks if the text of the specifiedLabelis truncated.- Parameters:
label- The specified label
-
registerTruncatedLabelListener
Registers a listener to the specifiedLabelwhich 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
Labelas helper.- Parameters:
font- the label fonttext- the label text
-
computeLabelHeight
Computes the min height of a text node.Uses
Labelas helper.- Parameters:
font- the node fonttext- the node text
-
computeLabelSizes
Computes both the width and the height of aLabelfor 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
Textas helper.- Parameters:
font- the node fonttext- the node text
-
computeTextHeight
Computes the min height of a text node.Uses
Textas helper.- Parameters:
font- the node fonttext- the node text
-
computeLabelWidth
Computes the min width for the specifiedLabelso 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().
-