Class TextLayoutUtils

java.lang.Object
org.jjazz.uiutilities.api.TextLayoutUtils

public final class TextLayoutUtils extends Object
Utilities related to text layout and TextLayoutPart.
Author:
Miloslav Metelka
  • Method Details

    • getHeight

      public static int getHeight(TextLayout textLayout, FontRenderContext frc)
      Return the minimum height value of using getPixelBounds() or using getAscent().

      Useful to take into account differences on the Mac OS Retina. Works with uppercase TextLayout only !

      Parameters:
      textLayout -
      frc -
      Returns:
    • getHeight2

      public static int getHeight2(TextLayout textLayout, FontRenderContext frc)
      Return the height of the TextLayout using getPixelBounds().

      Parameters:
      textLayout -
      frc -
      Returns:
    • getWidth

      public static float getWidth(TextLayout textLayout, String textLayoutText, boolean isItalic)
      Compute a most appropriate width of the given text layout.

      Take into account bug on MacOSX Retina HiDPI screens.

      Parameters:
      textLayout -
      textLayoutText -
      isItalic -
      Returns:
      float Equivalent to an integer value.
    • toStringShort

      public static String toStringShort(TextLayout textLayout)
    • toString

      public static String toString(TextLayout textLayout)
    • getRealAlloc

      public static Shape getRealAlloc(TextLayout textLayout, Rectangle2D textLayoutRect, TextHitInfo startHit, TextHitInfo endHit)
      Get real allocation (possibly not rectangular) of a part of layout.
      It's used when rendering the text layout for filling background highlights of the view.
      Parameters:
      textLayout -
      textLayoutRect -
      startHit -
      endHit -
      Returns:
    • shape2Bounds

      public static Rectangle2D.Double shape2Bounds(Shape s)
    • debugChar

      public static void debugChar(StringBuffer sb, char ch)
      Append the character description to the given string buffer translating the special characters (and '\') into escape sequences.
      Parameters:
      sb - non-null string buffer to append to.
      ch - character to be debugged.
    • debugChar

      public static void debugChar(StringBuilder sb, char ch)
      Append the character description to the given string builder translating the special characters (and '\') into escape sequences.
      Parameters:
      sb - non-null string buffer to append to.
      ch - character to be debugged.
    • debugChar

      public static String debugChar(char ch)
      Return the text description of the given character translating the special characters (and '\') into escape sequences.
      Parameters:
      ch - char to debug.
      Returns:
      non-null debug text.
    • debugText

      public static void debugText(StringBuffer sb, CharSequence text)
      Append the text description to the given string buffer translating the special characters (and '\') into escape sequences.
      Parameters:
      sb - non-null string buffer to append to.
      text - non-null text to be debugged.
    • debugText

      public static void debugText(StringBuilder sb, CharSequence text)
      Append the text description to the given string builder translating the special characters (and '\') into escape sequences.
      Parameters:
      sb - non-null string builder to append to.
      text - non-null text to be debugged.
    • debugText

      public static String debugText(CharSequence text)
      Create text description as String translating the special characters (and '\') into escape sequences.
      Parameters:
      text - non-null text to be debugged.
      Returns:
      non-null string containing the debug text.