Package org.jjazz.uiutilities.api
Class TextLayoutUtils
java.lang.Object
org.jjazz.uiutilities.api.TextLayoutUtils
Utilities related to text layout and TextLayoutPart.
- Author:
- Miloslav Metelka
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
debugChar
(char ch) Return the text description of the given character translating the special characters (and '\') into escape sequences.static void
debugChar
(StringBuffer sb, char ch) Append the character description to the given string buffer translating the special characters (and '\') into escape sequences.static void
debugChar
(StringBuilder sb, char ch) Append the character description to the given string builder translating the special characters (and '\') into escape sequences.static String
debugText
(CharSequence text) Create text description as String translating the special characters (and '\') into escape sequences.static void
debugText
(StringBuffer sb, CharSequence text) Append the text description to the given string buffer translating the special characters (and '\') into escape sequences.static void
debugText
(StringBuilder sb, CharSequence text) Append the text description to the given string builder translating the special characters (and '\') into escape sequences.static int
getHeight
(TextLayout textLayout, FontRenderContext frc) Return the minimum height value of using getPixelBounds() or using getAscent().static int
getHeight2
(TextLayout textLayout, FontRenderContext frc) Return the height of the TextLayout using getPixelBounds().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.static float
getWidth
(TextLayout textLayout, String textLayoutText, boolean isItalic) Compute a most appropriate width of the given text layout.static Rectangle2D.Double
static String
toString
(TextLayout textLayout) static String
toStringShort
(TextLayout textLayout)
-
Method Details
-
getHeight
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
Return the height of the TextLayout using getPixelBounds().- Parameters:
textLayout
-frc
-- Returns:
-
getWidth
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
-
toString
-
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
-
debugChar
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
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
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
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
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
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.
-