Class TLcdTTFIcon
- All Implemented Interfaces:
ILcdIcon
,ILcdCloneable
,Serializable
,Cloneable
char
.
Some fonts (usually symbol fonts) display their characters in a range not starting
from \u0000
. Mapping the font to a range starting from \u0000
is hidden from the user
by most applications, so that they can still display the symbols while using the
standard keyboard keys. TLcdTTFIcon
uses a heuristic to calculate a font
offset to hide this mapping from the user, the first time the font is used. This heuristic
may fail and return an incorrect offset and then the user will have to set the offset manually
with setFontOffset(char)
. This will set the font the offset only for the TLcdTTFIcon
it is applied to, not to all icons that use that font.
The heuristic traverses the whole unicode range per 0x100
characters pages and returns
as offset the page from which it can display the highest number of characters using
Font.canDisplay(char)
.
Remarks:
- The heuristic returns
\u0100
for the dialog font
- See Also:
-
Constructor Summary
ConstructorDescriptionConstruct a default True Type Font icon: the character A in black Arial font, size 10.TLcdTTFIcon
(char aCharacter, Font aFont, Color aColor) Constructs a True Type Font icon displaying the given character in the given font and color.TLcdTTFIcon
(char aCharacter, Font aFont, Color aColor, double aRotation) Constructs a rotated True Type Font icon displaying the given character in the given font and color, with the given rotation angle.TLcdTTFIcon
(TLcdTTFIcon aIcon) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionclone()
MakesObject.clone()
public.boolean
Compares this object to aObject, by checking the font, the character, the color, the rotation and the offset.protected char
findFontOffset
(Font aFont) This method finds the best offset for this icon's font.char
Gets the character to display.getColor()
Gets the color of the character.getFont()
Gets the icon's font.char
Gets the font offset.int
Returns the font size as an approximation for the icon height.int
Returns the font size as an approximation for the icon width.double
Gets the rotation.boolean
Shows if offset is used.void
Draw theILcdIcon
at the specified location.void
setCharacter
(char aCharacter) Sets the character to display.void
Sets the color of the character.void
Set the icon's font.void
setFontOffset
(char aOffset) Sets the font offset.void
setRotation
(double aRotation) Sets the rotation of the icon.void
setUseFontOffset
(boolean aUseFontOffset) Use the offset or not.toString()
-
Constructor Details
-
TLcdTTFIcon
public TLcdTTFIcon()Construct a default True Type Font icon: the character A in black Arial font, size 10. -
TLcdTTFIcon
Copy constructor.- Parameters:
aIcon
- the icon to copy.
-
TLcdTTFIcon
Constructs a True Type Font icon displaying the given character in the given font and color.- Parameters:
aCharacter
- the character to display.aFont
- the Font to display the character in.aColor
- the Color to display the character in.
-
TLcdTTFIcon
Constructs a rotated True Type Font icon displaying the given character in the given font and color, with the given rotation angle.- Parameters:
aCharacter
- the character to display.aFont
- the Font to display the character in.aColor
- the Color to display the character in.aRotation
- the rotation given in radials.
-
-
Method Details
-
paintIcon
Description copied from interface:ILcdIcon
Draw theILcdIcon
at the specified location.ILcdIcon
implementations may use theComponent
argument to get properties useful for painting, e.g. the foreground or background color.- Specified by:
paintIcon
in interfaceILcdIcon
- Parameters:
c
- a Component to retrieve properties from.g
- the Graphics on which the icon will be painted.aX
- the x position where the icon will be painted. x is the first coordinate of the top left corner point of the icon.aY
- the y position where the icon will be painted. y is the second coordinate of the top left corner point of the icon.
-
toString
-
clone
Description copied from interface:ILcdCloneable
Makes
When for example extending fromObject.clone()
public.java.lang.Object
, it can be implemented like this:public Object clone() { try { return super.clone(); } catch ( CloneNotSupportedException e ) { // Cannot happen: extends from Object and implements Cloneable (see also Object.clone) throw new RuntimeException( e ); } }
- Specified by:
clone
in interfaceILcdCloneable
- Overrides:
clone
in classObject
- See Also:
-
getIconWidth
public int getIconWidth()Returns the font size as an approximation for the icon width.- Specified by:
getIconWidth
in interfaceILcdIcon
- Returns:
- the font size as an approximation for the icon width.
-
getIconHeight
public int getIconHeight()Returns the font size as an approximation for the icon height.- Specified by:
getIconHeight
in interfaceILcdIcon
- Returns:
- the font size as an approximation for the icon height.
-
equals
Compares this object to aObject, by checking the font, the character, the color, the rotation and the offset. -
setFont
Set the icon's font. If needed the best offset is calculated.- Parameters:
aFont
- the font to set.- See Also:
-
getFont
Gets the icon's font.- Returns:
- the icon's font.
- See Also:
-
setCharacter
public void setCharacter(char aCharacter) Sets the character to display.- Parameters:
aCharacter
- the character to display.- See Also:
-
getCharacter
public char getCharacter()Gets the character to display.- Returns:
- the character to display.
- See Also:
-
setColor
Sets the color of the character.- Parameters:
aColor
- the color of the character.- See Also:
-
getColor
Gets the color of the character.- Returns:
- the color of the character.
- See Also:
-
setFontOffset
public void setFontOffset(char aOffset) Sets the font offset. Manually setting the offset overrides the calculated offset. The font offset is a translation of the unicode, which can be useful for symbol fonts.- Parameters:
aOffset
- the offset to use to calculate the character to display.- See Also:
-
getFontOffset
public char getFontOffset()Gets the font offset.- Returns:
- the font offset.
- See Also:
-
isUseFontOffset
public boolean isUseFontOffset()Shows if offset is used.- Returns:
- true if an offset for the font has to be used.
- See Also:
-
setUseFontOffset
public void setUseFontOffset(boolean aUseFontOffset) Use the offset or not.- Parameters:
aUseFontOffset
- true to use the font offset.- See Also:
-
setRotation
public void setRotation(double aRotation) Sets the rotation of the icon. Has no effect in Java 1.1.- Parameters:
aRotation
- the rotation of the character.- See Also:
-
getRotation
public double getRotation()Gets the rotation.- Returns:
- the rotation of the character.
- See Also:
-
findFontOffset
This method finds the best offset for this icon's font. The heuristic used to determine the best offset is the number of characters that can be displayed in a range of characters.- Parameters:
aFont
- the font to find the offset for.- Returns:
- best offset based on a heuristic
-