public class TLcdTTFIcon extends Object implements ILcdIcon
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:
\u0100
for the dialog font
TLcdTextIcon
,
Serialized FormConstructor and Description |
---|
TLcdTTFIcon()
Construct 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.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Makes
Object.clone() public. |
boolean |
equals(Object aObject)
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 |
getCharacter()
Gets the character to display.
|
Color |
getColor()
Gets the color of the character.
|
Font |
getFont()
Gets the icon's font.
|
char |
getFontOffset()
Gets the font offset.
|
int |
getIconHeight()
Returns the font size as an approximation for the icon height.
|
int |
getIconWidth()
Returns the font size as an approximation for the icon width.
|
double |
getRotation()
Gets the rotation.
|
boolean |
isUseFontOffset()
Shows if offset is used.
|
void |
paintIcon(Component c,
Graphics g,
int aX,
int aY)
Draw the
ILcdIcon at the specified location. |
void |
setCharacter(char aCharacter)
Sets the character to display.
|
void |
setColor(Color aColor)
Sets the color of the character.
|
void |
setFont(Font aFont)
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.
|
String |
toString() |
public TLcdTTFIcon()
public TLcdTTFIcon(TLcdTTFIcon aIcon)
aIcon
- the icon to copy.public TLcdTTFIcon(char aCharacter, Font aFont, Color aColor)
aCharacter
- the character to display.aFont
- the Font to display the character in.aColor
- the Color to display the character in.public TLcdTTFIcon(char aCharacter, Font aFont, Color aColor, double aRotation)
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.public void paintIcon(Component c, Graphics g, int aX, int aY)
ILcdIcon
ILcdIcon
at the specified location. ILcdIcon
implementations
may use the Component
argument to get properties useful for
painting, e.g. the foreground or background color.paintIcon
in interface ILcdIcon
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.public Object clone()
ILcdCloneable
Makes Object.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 );
}
}
clone
in interface ILcdCloneable
clone
in class Object
Object.clone()
public int getIconWidth()
getIconWidth
in interface ILcdIcon
public int getIconHeight()
getIconHeight
in interface ILcdIcon
public boolean equals(Object aObject)
public void setFont(Font aFont)
aFont
- the font to set.getFont()
public Font getFont()
setFont(java.awt.Font)
public void setCharacter(char aCharacter)
aCharacter
- the character to display.getCharacter()
public char getCharacter()
setCharacter(char)
public void setColor(Color aColor)
aColor
- the color of the character.getColor()
public Color getColor()
setColor(java.awt.Color)
public void setFontOffset(char aOffset)
aOffset
- the offset to use to calculate the character to display.getFontOffset()
public char getFontOffset()
setFontOffset(char)
public boolean isUseFontOffset()
setUseFontOffset(boolean)
public void setUseFontOffset(boolean aUseFontOffset)
aUseFontOffset
- true to use the font offset.isUseFontOffset()
public void setRotation(double aRotation)
aRotation
- the rotation of the character.getRotation()
public double getRotation()
setRotation(double)
protected char findFontOffset(Font aFont)
aFont
- the font to find the offset for.