Class TextSizingUtility

  • All Implemented Interfaces:
    ITextSizing

    public class TextSizingUtility
    extends java.lang.Object
    implements ITextSizing
    Utility class to define the dimensions of texts used with a certain font.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2013 Created on Aug 4, 2013
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javafx.geometry.Dimension2D calculate​(int size, javafx.scene.text.Font font)
      Calculate the dimensions of a string using the font with the number of characters.
      javafx.geometry.Dimension2D calculate​(java.lang.String text, javafx.scene.text.Font font)
      Calculate the dimensions of a string using the font with the characters in the string.
      (package private) double computeTextHeight​(javafx.scene.text.Font font, java.lang.String text, double wrappingWidth)  
      (package private) double computeTextHeight​(javafx.scene.text.Font font, java.lang.String text, double wrappingWidth, double lineSpacing)  
      (package private) double computeTextWidth​(javafx.scene.text.Font font, java.lang.String text, double wrappingWidth)  
      int guessNumberOfCharacters​(double destWidth, javafx.scene.text.Font font)
      Guess the number of characters that can be displayed in destWidth.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TextSizingUtility

        public TextSizingUtility()
    • Method Detail

      • computeTextWidth

        double computeTextWidth​(javafx.scene.text.Font font,
                                java.lang.String text,
                                double wrappingWidth)
      • computeTextHeight

        double computeTextHeight​(javafx.scene.text.Font font,
                                 java.lang.String text,
                                 double wrappingWidth)
      • computeTextHeight

        double computeTextHeight​(javafx.scene.text.Font font,
                                 java.lang.String text,
                                 double wrappingWidth,
                                 double lineSpacing)
      • calculate

        public javafx.geometry.Dimension2D calculate​(int size,
                                                     javafx.scene.text.Font font)
        Calculate the dimensions of a string using the font with the number of characters. The height and width are the maximum value, the width of a character is an average value.
        Specified by:
        calculate in interface ITextSizing
        Parameters:
        size - number of carachters for wich to calculate the dimensions
        font - to be used
        Returns:
        dimensions of a String containing Tg to calculate the heigth and n for the width calculation.
      • guessNumberOfCharacters

        public int guessNumberOfCharacters​(double destWidth,
                                           javafx.scene.text.Font font)
        Guess the number of characters that can be displayed in destWidth. The number is guessed as an arbitrary width per character for the font is assumed.
        Parameters:
        destWidth - destination with
        font - to used for the text
        Returns:
        number of characters that should match into destWidth
      • calculate

        public javafx.geometry.Dimension2D calculate​(java.lang.String text,
                                                     javafx.scene.text.Font font)
        Calculate the dimensions of a string using the font with the characters in the string. The height and width are the maximum value. The text will not be wrapped.
        Specified by:
        calculate in interface ITextSizing
        Parameters:
        text - for which to calculate the dimensions
        font - to be used for the calculation
        Returns:
        Bounding box for the text using font.