public class FontManager
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
FontManager.EnvironmentFontTable
The font-table associated with a certain environment.
|
private static class |
FontManager.WorkArea
Context-local data for this font manager.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
ALERT_BOX_FONT
Reference to the alert box font, a system font.
|
private static java.util.Map<java.lang.String,java.lang.Integer> |
browseCellBottomTextOffset
Map "font key" -> "offset of a text in a browse cell, from the cell bottom" (in pixels).
|
static int |
DEFAULT_FIXED_FONT
Reference for the default fixed font.
|
static int |
DEFAULT_FONT
Reference for the default font.
|
private static ContextLocal<FontManager.WorkArea> |
local
Context local instance of this class.
|
private static CentralLogger |
LOG
logger
|
static int |
MENU_FONT
Reference to the menu font, a system font.
|
static int |
PRINT_FONT
Reference to the print font.
|
static int |
STACK_TRACE_WINDOW_FONT
Reference to the stack trace window font, a system font.
|
static int |
SYSTEM_FONT_BASE
The base for the system fonts.
|
static int |
TOOLTIP_FONT
Reference to the tooltip font, a system font
|
static int |
UNDEFINED_FONT
Reference for the undefined font.
|
static int |
WINDOW_TITLE_FONT
Reference to the window title font, a system font.
|
| Constructor and Description |
|---|
FontManager() |
| Modifier and Type | Method and Description |
|---|---|
static void |
adjustFontTableSize(Window<?> window,
int numEntries)
Set the number of entries in the font-table.
|
static void |
deregisterFontTable(Window<?> window,
ScreenDriver<?> driver)
Deregister the font-table associated with this window.
|
static int |
fontTableSize(Window<?> window)
Get the number of entries in the font-table.
|
static int |
getBrowseCellBottomTextOffset(FontDetails font)
Get offset of a text drawn with the specific font in a browse cell, from the cell bottom
(in pixels).
|
static int |
getClientTextWidth(java.lang.String text,
Window<?> window,
int font,
ScreenDriver<?> driver)
Get the pixel width for the specified text and font from the native client environment.
|
static FontDetails |
getCustomFont(java.lang.String name,
int size,
boolean bold,
boolean italic,
boolean underline)
Creates the specified font with the driver and returns its description.
|
static FontDetails |
getFontDetails(TitledWindow<?> window,
int font)
Resolve the font details associated with the given font.
|
static int |
getFontHeight(TitledWindow<?> window,
FontDetails font,
java.lang.Integer fontIndex,
ScreenDriver<?> driver)
Get the height of the given font.
|
static int |
getFontHeight(TitledWindow<?> window,
int font,
ScreenDriver<?> driver)
Get the height of the given font.
|
private static int |
getFontHeight(TitledWindow<?> window,
java.lang.String key,
java.lang.Integer fontIndex,
ScreenDriver<?> driver)
Get the height of the given font.
|
static java.lang.String |
getFontKey(java.lang.String name,
int size,
boolean bold,
boolean italic,
boolean underline)
Get a key describing the given font.
|
static java.lang.String |
getFontKey(java.lang.String name,
int size,
boolean bold,
boolean italic,
boolean underline,
boolean symbolic,
int webScale)
Get a key describing the given font.
|
static java.lang.String |
getFontKey(TitledWindow<?> window,
int font,
ScreenDriver<?> driver)
Resolve the font key associated with the given font, in the current window's font-table.
|
static int |
getFontWidth(TitledWindow<?> window,
FontDetails font,
ScreenDriver<?> driver)
Get the width of the given font.
|
static int |
getFontWidth(TitledWindow<?> window,
int font,
ScreenDriver<?> driver)
Get the width of the given font.
|
private static int |
getFontWidth(TitledWindow<?> window,
java.lang.String key,
java.lang.Integer fontIndex,
ScreenDriver<?> driver)
Get the width of the given font.
|
static int |
getMaxFontWidth(TitledWindow<?> window,
FontDetails font,
ScreenDriver<?> driver)
Get the maximum font width for the given font.
|
static int |
getMaxFontWidth(TitledWindow<?> window,
int font,
ScreenDriver<?> driver)
Get the maximum font width for the given font.
|
static int |
getMaxFontWidth(TitledWindow<?> window,
java.lang.String key,
java.lang.Integer fontIndex,
ScreenDriver<?> driver)
Get the maximum font width for the given font.
|
static int |
getPixelsPerColumn(ScreenDriver<?> driver)
Get the PIXELS-PER-COLUMN value for this client session.
|
static int |
getPixelsPerRow(ScreenDriver<?> driver)
Get the PIXELS-PER-ROW value for this client session.
|
static int |
getTextHeight(java.lang.String text,
Window<?> window,
int font,
ScreenDriver<?> driver)
Get the height of the specified text, in pixels, using the specified font.
|
private static java.lang.String |
getTextKey(java.lang.String fontKey,
java.lang.String text)
Get the key for the text drawn using the specific font.
|
private static int[] |
getTextMetrics(java.lang.String text,
Window<?> window,
FontDetails font,
ScreenDriver<?> driver)
|
private static int[] |
getTextMetrics(java.lang.String text,
Window<?> window,
int font,
ScreenDriver<?> driver)
|
private static int[] |
getTextMetrics(java.lang.String text,
Window<?> window,
java.lang.String key,
ScreenDriver<?> driver)
|
static int |
getTextWidth(java.lang.String text,
Window<?> window,
FontDetails font,
ScreenDriver<?> driver)
Get the width of the specified text, in pixels, using the specified font.
|
static int |
getTextWidth(java.lang.String text,
Window<?> window,
int font,
ScreenDriver<?> driver)
Get the width of the specified text, in pixels, using the specified font.
|
private static int |
getTextWidth(java.lang.String text,
Window<?> window,
java.lang.String key,
ScreenDriver<?> driver)
Get the width of the specified text, in pixels, using the specified font.
|
static void |
init(ServerExports server,
int textMetricsCacheSize)
Initialize the font manager's helpers.
|
static boolean |
isFixedSize(TitledWindow<?> window,
int font,
ScreenDriver<?> driver)
Check if the system font from the given font table entry is a fixed-size font.
|
static boolean |
isThreeD()
Get the state of the
use-3d-size flag. |
private static FontManager.WorkArea |
locate()
Locate the context-local data of this class.
|
static FontDetails<?> |
registerFontDetails(int windowId,
FontDetails<?> font)
Registers and fills legacy font metrics if it is not in the font cache.
|
static void |
registerFontResolver(Window<?> window,
Widget<?> widget,
GuiFontResolver fontResolver)
Registers the given font resolver for the given widget.
|
static void |
registerFontTable(Window<?> window,
ScreenDriver<?> driver)
Compute and register the window's font-table.
|
static void |
removeFontResolver(Window<?> window)
Removes the font cache associated with the given window.
|
static void |
removeFontResolver(Window<?> window,
AbstractWidget<?> widget)
Removes the registered font resolver for the given widget.
|
static void |
removeFontResolver(Window<?> window,
AbstractWidget<?> widget,
boolean orphan)
Removes the registered font resolver for the given widget.
|
static int |
resolveFont(int font,
boolean fixedSize)
If the given font is undefined, default to either the
DEFAULT_FONT or
-2, depending on whether a fixed font is required or not. |
static FontDetails<?> |
resolveFont(Window<?> window,
int font,
ScreenDriver<?> driver)
Resolve a font instance associated with the specified font entry in the window's
font table.
|
static void |
setFont(Window<?> window,
int fontRef,
FontDetails<?> fd)
Sets a specific font to the font-table at a specific index.
|
static void |
setTextMetrics(java.lang.String fontKey,
java.lang.String text,
int width,
int height)
Set metrics for the text drawn with the specific font.
|
static void |
setThreeD(boolean isThreeD)
Set the state of the
use-3d-size flag. |
static void |
unload(java.lang.String envName)
Unload environment.
|
static void |
updateFontResolvers(Window<?> window,
AbstractWidget<?> widget)
Update font resolvers for the detached widget.
|
public static final int UNDEFINED_FONT
public static final int DEFAULT_FONT
public static final int DEFAULT_FIXED_FONT
public static final int SYSTEM_FONT_BASE
public static final int WINDOW_TITLE_FONT
public static final int ALERT_BOX_FONT
public static final int STACK_TRACE_WINDOW_FONT
public static final int MENU_FONT
public static final int PRINT_FONT
public static final int TOOLTIP_FONT
private static final CentralLogger LOG
private static java.util.Map<java.lang.String,java.lang.Integer> browseCellBottomTextOffset
private static final ContextLocal<FontManager.WorkArea> local
public static int getFontHeight(TitledWindow<?> window, int font, ScreenDriver<?> driver)
window - The window from which the font-table is used.font - Font index.driver - The reference screen driver.public static int getFontHeight(TitledWindow<?> window, FontDetails font, java.lang.Integer fontIndex, ScreenDriver<?> driver)
window - The window from which the font-table is used.font - The font details.fontIndex - Font index, for logging purposes. null if the font has no index.driver - The reference screen driver.private static int getFontHeight(TitledWindow<?> window, java.lang.String key, java.lang.Integer fontIndex, ScreenDriver<?> driver)
window - The window from which the font-table is used.key - Font key.fontIndex - Font index, for logging purposes. null if the font has no index.driver - The reference screen driver.public static boolean isFixedSize(TitledWindow<?> window, int font, ScreenDriver<?> driver)
window - The window for which the font-table is retrieved.font - The font number in the window's font table.driver - The active screen driver.true if the associated font is fixed-size.public static int getFontWidth(TitledWindow<?> window, FontDetails font, ScreenDriver<?> driver)
window - The window from which the font-table is used.font - Font details.driver - The reference screen driver.public static int getFontWidth(TitledWindow<?> window, int font, ScreenDriver<?> driver)
window - The window from which the font-table is used.font - Font index.driver - The reference screen driver.private static int getFontWidth(TitledWindow<?> window, java.lang.String key, java.lang.Integer fontIndex, ScreenDriver<?> driver)
window - The window from which the font-table is used.key - Font key.fontIndex - Font index, for logging purposes. null if the font has no index.driver - The reference screen driver.public static FontDetails<?> registerFontDetails(int windowId, FontDetails<?> font)
windowId - ID of the current window.font - The new selected fontnull if
the font is null.public static int getMaxFontWidth(TitledWindow<?> window, FontDetails font, ScreenDriver<?> driver)
window - The window for which the font-table is retrieved.font - The font number in the window's font table.driver - The active screen driver.public static int getMaxFontWidth(TitledWindow<?> window, int font, ScreenDriver<?> driver)
window - The window for which the font-table is retrieved.font - The font number in the window's font table.driver - The active screen driver.public static int getMaxFontWidth(TitledWindow<?> window, java.lang.String key, java.lang.Integer fontIndex, ScreenDriver<?> driver)
window - The window for which the font-table is retrieved.key - Font key.fontIndex - Font index, for logging purposes. null if the font has no index.driver - The active screen driver.public static void registerFontResolver(Window<?> window, Widget<?> widget, GuiFontResolver fontResolver)
window - The given windowwidget - The widget associated with the given font resolverfontResolver - The given font resolverpublic static void removeFontResolver(Window<?> window)
window - The given windowpublic static void removeFontResolver(Window<?> window, AbstractWidget<?> widget)
window - The given windowwidget - The given widgetpublic static void removeFontResolver(Window<?> window, AbstractWidget<?> widget, boolean orphan)
window - The given windowwidget - The given widgetorphan - Indicates that the provided widget is detached from its window but still not destroyed.public static void updateFontResolvers(Window<?> window, AbstractWidget<?> widget)
window - The given windowwidget - The given detached widgetpublic static FontDetails<?> resolveFont(Window<?> window, int font, ScreenDriver<?> driver)
window - The window from which the font-table is used.font - The entry in the font-table.driver - The reference screen driver.public static int getTextWidth(java.lang.String text,
Window<?> window,
FontDetails font,
ScreenDriver<?> driver)
text - The text.window - The window from which the font-table is used.font - The font details.driver - The reference screen driver.public static int getTextWidth(java.lang.String text,
Window<?> window,
int font,
ScreenDriver<?> driver)
text - The text.window - The window from which the font-table is used.font - The entry in the font-table.driver - The reference screen driver.private static int getTextWidth(java.lang.String text,
Window<?> window,
java.lang.String key,
ScreenDriver<?> driver)
text - The text.window - The window from which the font-table is used.key - The font key.driver - The reference screen driver.public static int getTextHeight(java.lang.String text,
Window<?> window,
int font,
ScreenDriver<?> driver)
text - The text.window - The window from which the font-table is used.font - The entry in the font-table.driver - The reference screen driver.public static int getPixelsPerColumn(ScreenDriver<?> driver)
driver - The reference screen driver.public static int getPixelsPerRow(ScreenDriver<?> driver)
driver - The reference screen driver.public static void registerFontTable(Window<?> window, ScreenDriver<?> driver)
The same font-table may be shared by one or more windows.
window - The window.driver - The reference screen driver.public static void deregisterFontTable(Window<?> window, ScreenDriver<?> driver)
window - The window.driver - The reference screen driver.public static void adjustFontTableSize(Window<?> window, int numEntries)
window - The window from which the font-table is used.numEntries - The new size of the font-table.public static int fontTableSize(Window<?> window)
window - The window from which the font-table is used.public static java.lang.String getFontKey(java.lang.String name,
int size,
boolean bold,
boolean italic,
boolean underline)
name - The font name.size - The font point size.bold - Flag indicating if the font style is bold.italic - Flag indicating if the font style is italic.underline - Flag indicating if the font style is underline.public static java.lang.String getFontKey(java.lang.String name,
int size,
boolean bold,
boolean italic,
boolean underline,
boolean symbolic,
int webScale)
name - The font name.size - The font point size.bold - Flag indicating if the font style is bold.italic - Flag indicating if the font style is italic.underline - Flag indicating if the font style is underline.symbolic - Flag indicating if the font style is symbolic.webScale - The threshold for which web text scale should be applied.public static java.lang.String getFontKey(TitledWindow<?> window, int font, ScreenDriver<?> driver)
window - The window from which the font-table is used.font - The entry in the font-table.driver - The reference screen driver.public static FontDetails getFontDetails(TitledWindow<?> window, int font)
window - The window from which the font-table is used, may be null.font - The entry in the font-table.public static void unload(java.lang.String envName)
UNLOAD environment statement is executed.envName - Environment name.public static void init(ServerExports server, int textMetricsCacheSize)
server - The server exports.public static boolean isThreeD()
use-3d-size flag.public static void setThreeD(boolean isThreeD)
use-3d-size flag.isThreeD - The new state of this flag.public static int resolveFont(int font,
boolean fixedSize)
DEFAULT_FONT or
-2, depending on whether a fixed font is required or not.font - The font number.fixedSize - Flag indicating if a fixed-size font is needed, if the font is
undefined.public static int getBrowseCellBottomTextOffset(FontDetails font)
font - Font used in the browse cell.public static void setFont(Window<?> window, int fontRef, FontDetails<?> fd)
window - The window from which the font-table is used.fontRef - The index of the font.fd - The new font details to replace th old one at fontRef for the specified
window.public static void setTextMetrics(java.lang.String fontKey,
java.lang.String text,
int width,
int height)
fontKey - The key for the font used to draw the text.text - The text.width - Text width.height - Text height.public static FontDetails getCustomFont(java.lang.String name, int size, boolean bold, boolean italic, boolean underline)
name - Font name.size - Font point size.bold - Bold style flag.italic - Italic style flag.underline - Underline style flag.private static FontManager.WorkArea locate()
FontManager.WorkArea instance.java.lang.IllegalStateException - If the FontManager.WorkArea has not been FontManager.WorkArea.initialized.public static int getClientTextWidth(java.lang.String text,
Window<?> window,
int font,
ScreenDriver<?> driver)
text - The text.window - The window from which the font-table is used.font - The entry in the font-table.driver - The reference screen driver.private static int[] getTextMetrics(java.lang.String text,
Window<?> window,
int font,
ScreenDriver<?> driver)
cache or metrics.
If not present, ask the server-side for the metrics.
text - The text.window - The window from which the font-table is used.font - The entry in the font-table.driver - The reference screen driver.private static int[] getTextMetrics(java.lang.String text,
Window<?> window,
FontDetails font,
ScreenDriver<?> driver)
cache or metrics.
If not present, ask the server-side for the metrics.
text - The text.window - The window from which the font-table is used.font - The font details.driver - The reference screen driver.private static int[] getTextMetrics(java.lang.String text,
Window<?> window,
java.lang.String key,
ScreenDriver<?> driver)
cache or metrics.
If not present, ask the server-side for the metrics.
text - The text.window - The window from which the font-table is used.key - Font key.driver - The reference screen driver.private static java.lang.String getTextKey(java.lang.String fontKey,
java.lang.String text)
fontKey - The key for the font used to draw the text.text - The text.