public final class Util extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
checkText(String text,
Graphics2D g,
int widthLimit)
Checks to see if text will fit in a given width, using the same method
used to find limit width in
chopText(java.lang.String, java.awt.Graphics2D, int) . |
static String |
chopText(String textIn,
Graphics2D g,
int widthLimit)
Chops text to fit in a given width, while showing the start of the text.
|
static String |
chopTextLeft(String textIn,
Graphics2D g,
int widthLimit)
Chops text to fit in a given width, while showing the end of the text.
|
static String |
encodeChar(char chr)
Encodes a char in ASCII Java source format for a char literal, replacing
newlines with \n, single quotes with \', etc.
|
static String |
encodeString(String str,
boolean isDisplay)
Encodes a String in ASCII Java source format for a string, replacing
newlines with \n, double quotes with \", etc.
|
static Rectangle |
getScrolledRect(JComponent c)
Gets the portion of a component that is visible through its nearest
viewport ancestor.
|
static char |
hexChar(int digit)
Gets a hex digit for a specified decimal value.
|
public static boolean checkText(String text, Graphics2D g, int widthLimit)
chopText(java.lang.String, java.awt.Graphics2D, int)
.text
- the text to be checked.g
- graphics that will be used to render text.widthLimit
- maximum width of chopped text.public static String chopText(String textIn, Graphics2D g, int widthLimit)
textIn
- the text to be chopped.g
- graphics that will be used to render text.widthLimit
- maximum width of chopped text.public static String chopTextLeft(String textIn, Graphics2D g, int widthLimit)
textIn
- the text to be chopped.g
- graphics that will be used to render text.widthLimit
- maximum width of chopped text.public static String encodeChar(char chr)
chr
- the char to encode.public static String encodeString(String str, boolean isDisplay)
str
- the string to encode.isDisplay
- true if the result should be for display purposes only,
false otherwise.public static Rectangle getScrolledRect(JComponent c)
c
- the component of interest.public static char hexChar(int digit)
digit
- the decimal value.