Module MaterialFX

Class TextUtils

java.lang.Object
io.github.palexdev.materialfx.utils.TextUtils

public class TextUtils extends Object
Utils class for JavaFX's Labels and MFXLabels.
  • Method Details

    • isLabelTruncated

      public static boolean isLabelTruncated(Label label)
      Checks if the text of the specified Label is truncated.
      Parameters:
      label - The specified label
    • registerTruncatedLabelListener

      public static void registerTruncatedLabelListener(BooleanProperty isTruncated, Label label)
      Registers a listener to the specified Label which checks if the text is truncated and updates the specified boolean property accordingly.
      Parameters:
      isTruncated - The boolean property to change
      label - The specified label
    • computeLabelWidth

      public static double computeLabelWidth(Font font, String text)
      Computes the min width of a text node so that all the text is visible. Uses NodeUtils.getRegionWidth(Region).

      Uses Label as helper.

      Parameters:
      font - the label font
      text - the label text
    • computeLabelHeight

      public static double computeLabelHeight(Font font, String text)
      Computes the min height of a text node.

      Uses Label as helper.

      Parameters:
      font - the node font
      text - the node text
    • computeLabelSizes

      public static SizeBean computeLabelSizes(Font font, String text)
      Computes both the width and the height of a Label for the given font and text.
      Returns:
      the bean containing the computed values
    • computeTextWidth

      public static double computeTextWidth(Font font, String text)
      Computes the min width of a text node so that all the text is visible.

      Uses Text as helper.

      Parameters:
      font - the node font
      text - the node text
    • computeTextHeight

      public static double computeTextHeight(Font font, String text)
      Computes the min height of a text node.

      Uses Text as helper.

      Parameters:
      font - the node font
      text - the node text
    • computeLabelWidth

      public static double computeLabelWidth(Label label)
      Computes the min width for the specified Label so that all the text is visible.

      Uses computeTextWidth(Font, String), but also takes into account the label's graphic bounds (if not null) and the Labeled.graphicTextGapProperty().

      Note: this works only after the label has been laid out.