public class TextHandler
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int[] |
bitmap_font_image_ids |
static short[][] |
bitmap_font_info |
static byte[][] |
enc_strings |
static TextHandler |
instance
Our instance
|
static byte[] |
languages
2 bytes stored for each language included in this build.
|
static int |
MD_TEXT_GUIDELINE_TYPE_MASK |
static int |
set_font |
static int[] |
system_font_colours |
static javax.microedition.lcdui.Font[] |
system_fonts |
static int |
TEXTFLAG_CONTAINS_HYPHENATION_GUIDELINES |
Constructor and Description |
---|
TextHandler() |
Modifier and Type | Method and Description |
---|---|
int |
closestMatchDeviceLocaleLanguageID()
Performs some string matching logic to try and determine the closest match to the given device locale from those available in this build.
|
int |
closestMatchLocaleLanguageID(java.lang.String locale)
Performs some string matching logic to try and determine the closest match to the given locale from those available in this build.
|
DateFormat |
createLocalizedDateFormat(java.lang.String format)
Create a new
DateFormat Object appropriate for the currently loaded language. |
void |
drawChars(javax.microedition.lcdui.Graphics g,
char[] chars,
int x,
int y,
int anchor,
int char_width)
Draws a char-array to the screen.
|
void |
drawCharsExtended(javax.microedition.lcdui.Graphics g,
char[] chars,
int start_index,
int length,
int x,
int y,
int anchor,
int char_width)
Draws a char-array to the screen.
|
void |
drawCharsOrString(javax.microedition.lcdui.Graphics g,
java.lang.String s,
char[] chars,
int start_index,
int length,
int x,
int y,
int anchor,
int char_width)
Draws a char-array or a String to the screen (pass in one or the other).
|
void |
drawSplitString(javax.microedition.lcdui.Graphics g,
java.lang.String[] strings,
int x,
int y,
int anchor,
int line_height)
Draws a previously-split String-array at a particular position.
|
void |
drawString(javax.microedition.lcdui.Graphics g,
java.lang.String s,
int x,
int y,
int anchor,
int char_width)
Draws a String to the screen.
|
int |
getBitmapFontCharacterIndex(int font_id,
char c)
Returns the index of the character into the font's character array (or -1 if it doesn't exist).
|
int |
getCharsWidth(int font_id,
char[] chars)
Returns the width of a particular String stored as a char-array
|
int |
getCharWidth(int font_id,
char c)
Returns the width of particular character
|
byte[] |
getENCString(int text_id)
Returns a specified encoded-string
|
byte[] |
getENCStringFromString(java.lang.String string)
Converts a String to an encoded-string.
|
int |
getFontHeight(int font_id)
Returns the height of a specific font
|
static java.lang.String |
getLanguageIDString(int lang_id)
Returns a string representation of the specified language
|
java.lang.String |
getLoadedLocale()
Get the currently loaded language, as a String.
|
int |
getMaxStringWidths(int font_id,
java.lang.String[] s)
Returns the maximum width of an array of Strings
|
java.lang.String |
getString(int text_id)
Returns a specified String.
|
java.lang.String |
getStringFromENCString(byte[] encoded_string)
Converts an encoded-string to a String.
|
int |
getStringWidth(int font_id,
java.lang.String s)
Returns the width of a particular String
|
byte[] |
insertENCStringIntoENCString(byte[] enc_into,
java.lang.String replace,
byte[] enc_replace_with)
Inserts an encoded-string into another encoded-string.
|
java.lang.String |
insertENCStringIntoString(java.lang.String into,
java.lang.String replace,
byte[] enc_replace_with)
Inserts an encoded-string into a String
|
byte[] |
insertStringIntoENCString(byte[] enc_into,
java.lang.String replace,
java.lang.String replace_with)
Inserts a String into an encoded-string.
|
static java.lang.String |
insertStringIntoString(java.lang.String into,
java.lang.String replace,
java.lang.String replace_with)
Inserts a String into another String
|
int |
loadBitmapFont(int res_id,
int palette_id)
Loads a bitmap font and returns its ID.
|
void |
loadLanguage(int lang_id)
Loads a single language (only one can be kept in memory at a time)
|
int |
loadSystemFont(int face,
int style,
int size,
int colour)
Loads a system font and returns its ID
|
static int |
numLanguagesIncluded()
Returns the number of languages included in this build.
|
static java.lang.String |
replaceHardSpaces(java.lang.String string)
Replaces hard spaces ('�' / character-0xa0) in a String with spaces
|
void |
setFont(javax.microedition.lcdui.Graphics g,
int font_id)
Sets the current font to be used in drawing
|
java.lang.String[] |
splitENCString(byte[] encoded_string,
int font_id,
int max_width)
Split an encoded string based on a specified font and maximum pixel width (will use the hyphenation guideline included).
|
java.lang.String[] |
splitString(java.lang.String string,
int font_id,
int max_width)
Split a String based on a specified font and maximum pixel width
|
void |
unloadFont(int font_id)
Removes a particular font from memory
|
public static TextHandler instance
public static final int TEXTFLAG_CONTAINS_HYPHENATION_GUIDELINES
public static final int MD_TEXT_GUIDELINE_TYPE_MASK
public static javax.microedition.lcdui.Font[] system_fonts
public static int[] system_font_colours
public static int[] bitmap_font_image_ids
public static short[][] bitmap_font_info
public static int set_font
public static byte[] languages
public static byte[][] enc_strings
public void loadLanguage(int lang_id)
public int closestMatchLocaleLanguageID(java.lang.String locale)
public int closestMatchDeviceLocaleLanguageID()
public static int numLanguagesIncluded()
public static java.lang.String getLanguageIDString(int lang_id)
public java.lang.String getStringFromENCString(byte[] encoded_string)
public byte[] getENCStringFromString(java.lang.String string)
public byte[] getENCString(int text_id)
public java.lang.String getString(int text_id)
public java.lang.String[] splitENCString(byte[] encoded_string, int font_id, int max_width)
public java.lang.String[] splitString(java.lang.String string, int font_id, int max_width)
public static java.lang.String replaceHardSpaces(java.lang.String string)
public static java.lang.String insertStringIntoString(java.lang.String into, java.lang.String replace, java.lang.String replace_with)
public byte[] insertENCStringIntoENCString(byte[] enc_into, java.lang.String replace, byte[] enc_replace_with)
public byte[] insertStringIntoENCString(byte[] enc_into, java.lang.String replace, java.lang.String replace_with)
public java.lang.String insertENCStringIntoString(java.lang.String into, java.lang.String replace, byte[] enc_replace_with)
public int loadSystemFont(int face, int style, int size, int colour)
public int loadBitmapFont(int res_id, int palette_id)
public void unloadFont(int font_id)
public int getBitmapFontCharacterIndex(int font_id, char c)
public int getFontHeight(int font_id)
public int getMaxStringWidths(int font_id, java.lang.String[] s)
public int getStringWidth(int font_id, java.lang.String s)
public int getCharsWidth(int font_id, char[] chars)
public int getCharWidth(int font_id, char c)
public void setFont(javax.microedition.lcdui.Graphics g, int font_id)
public void drawCharsOrString(javax.microedition.lcdui.Graphics g, java.lang.String s, char[] chars, int start_index, int length, int x, int y, int anchor, int char_width)
g
- Graphics objectss
- Stringchars
- Char-array for the stringstart_index
- Start index in the String or Char-array to display fromlength
- Number of characters to display from the start_indexx
- Xy
- Yanchor
- Anchorchar_width
- Set this to -1 for a proportional font drawing, otherwise this is the pixel-width used for each characterpublic void drawCharsExtended(javax.microedition.lcdui.Graphics g, char[] chars, int start_index, int length, int x, int y, int anchor, int char_width)
public void drawChars(javax.microedition.lcdui.Graphics g, char[] chars, int x, int y, int anchor, int char_width)
public void drawString(javax.microedition.lcdui.Graphics g, java.lang.String s, int x, int y, int anchor, int char_width)
public void drawSplitString(javax.microedition.lcdui.Graphics g, java.lang.String[] strings, int x, int y, int anchor, int line_height)
g
- The Graphics objectstrings
- The split string-arrayx
- Xy
- Yanchor
- Anchorline_height
- The vertical pixel-spacing from the top of one line to the top of the nextpublic DateFormat createLocalizedDateFormat(java.lang.String format)
DateFormat
Object appropriate for the currently loaded language.format
- a String template for the DateFormat class.public java.lang.String getLoadedLocale()
null
if no language has been loaded.