com.tensegrity.graphics
Class FontFormat

java.lang.Object
  extended bycom.tensegrity.graphics.FontFormat
All Implemented Interfaces:
Format

public final class FontFormat
extends java.lang.Object
implements Format

FontFormat represents a format for fonts. This format consists of the following attributes:

The family attribute defines the font family. The family of the font is sometimes also called the name of the font. The available families are system dependent because each system has installed its own fonts. This may even differ between several installations of the same system.

The size attribute defines the size of the font. This value is not given in device coordinates. Moreover it is dependent on the context the font lies within.

The weight attribute defines the weight the font is drawn with. At the actual state of development the font supports only the NORMAL (or PLAIN) and BOLD weights.

The color attribute defines the color the font is drawn with. The color is represented by an int that defines the values for the red, green and blue components as illustrated by the following hexadecimal pattern:
0x00rrggbb
where rr stands for the red component, gg stands for the green component and bb stands for the blue component of the color.

The italic flag indicates whether the font is illustrated italic or not.

The underlined flag indicates whether the font has a line below each letter or not.

The strikethrough flag indicates whether each letter is crossed by a line or not.

Since the FontFormat is an object that is frequently used within the graphics framework and all frameworks that use the graphics framework FontFormats are subject of pooling. The pooling of the FontFormat instances is being done by the FormatPool. To get more informations about this class take a look at the documentation about the FormatPool.

In order to pool a FontFormat it has to be immutable because maybe many objects have a reference on the same FontFormat and modifying the FontFormat will affect all these objects.

For the pooling also an unique expression is needed so that a FontFormat can be surely identified. The unique expression is called the canonical description. This canonical description is made up of the attributes a FontFormat consists of and it can be gained by Format.getCanonicalDescription().

A FontFormat can only be created by using the FormatPool.parseFontFormat(String) method to ensure a correct pooling behavior. You can obtain the canonical description by calling the on of the static methods called getCanonicalDescription().

A FontFormat is usually applied to a Primitive (e.g. Label2D) by calling the Primitive.setFontFormat(FontFormat) method.

A FontFormat consists of the following attributes:

Version:
$Id: FontFormat.java,v 1.42 2006/03/02 10:43:59 BurkhardWick Exp $
Author:
MichaelKegel

Field Summary
static int BOLD
          The weights a FontFormat supports.
protected static java.lang.String CANONIC_DESCRIPTION_DELIMITER
          Delimitier for the canonical description.
protected static java.lang.String CANONIC_DESCRIPTION_SUBDESC_END
          End token for a description in a sublevel.
protected static java.lang.String CANONIC_DESCRIPTION_SUBDESC_START
          Start token for a description in a sublevel.
static java.lang.String DEFAULT_FAMILY
          Default font family of a FontFormat.
static FontFormat DEFAULT_FONT_FORMAT
          Default font format.
static int DEFAULT_SIZE
          Default size of a FontFormat.
static int EXTRABOLD
          The weights a FontFormat supports.
static int EXTRALIGHT
          The weights a FontFormat supports.
static int HEAVY
          The weights a FontFormat supports.
static int LIGHT
          The weights a FontFormat supports.
static int MEDIUM
          The weights a FontFormat supports.
static int NONE
          The weights a FontFormat supports.
static int NORMAL
          The weights a FontFormat supports.
static int SEMIBOLD
          The weights a FontFormat supports.
static int THIN
          The weights a FontFormat supports.
protected static java.lang.String TOKEN_COLOR
          Enumeration that tells about the canonical description tokens.
protected static java.lang.String TOKEN_FAMILY
          Enumeration that tells about the canonical description tokens.
protected static java.lang.String TOKEN_ITALIC
          Enumeration that tells about the canonical description tokens.
protected static java.lang.String TOKEN_SIZE
          Enumeration that tells about the canonical description tokens.
protected static java.lang.String TOKEN_STRIKETHROUGH
          Enumeration that tells about the canonical description tokens.
protected static java.lang.String TOKEN_STRIKETHROUGHSTROKE
          Enumeration that tells about the canonical description tokens.
protected static java.lang.String TOKEN_UNDERLINE
          Enumeration that tells about the canonical description tokens.
protected static java.lang.String TOKEN_UNDERLINESTROKE
          Enumeration that tells about the canonical description tokens.
protected static java.lang.String TOKEN_WEIGHT
          Enumeration that tells about the canonical description tokens.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 boolean getBold()
          Returns a boolean that indicates whether the font is BOLD or not.
 java.lang.String getCanonicalDescription()
          Returns the canonical description of a FontFormat.
static java.lang.String getCanonicalDescription(int size, int weight, java.lang.String family, int color, boolean italic, boolean underline, boolean strikethrough)
          Returns the canonical description of a FontFormat.
static java.lang.String getCanonicalDescription(int size, int weight, java.lang.String family, int color, boolean italic, boolean underline, boolean strikethrough, StrokeFormat underlineStroke, StrokeFormat strikethroughStroke)
          Returns the canonical description of a FontFormat.
static java.lang.String getCanonicalDescription(java.lang.String size, java.lang.String weight, java.lang.String family, java.lang.String color, java.lang.String italic, java.lang.String underline, java.lang.String strikethrough)
          Returns the canonical description of a FontFormat.
static java.lang.String getCanonicalDescription(java.lang.String size, java.lang.String weight, java.lang.String family, java.lang.String color, java.lang.String italic, java.lang.String underline, java.lang.String strikethrough, java.lang.String underlineStroke, java.lang.String strikethroughStroke)
          Returns the canonical description of a FontFormat.
 int getColor()
          Returns the color of the font.
 java.lang.String getFamily()
          Returns a String that represents the family of the font.
 java.lang.Object[] getFormatData()
          Returns an array filled with the attributes of the FontFormat.
 boolean getItalic()
          Returns a boolean that indicates whether the font is italic or not.
 int getSize()
          Returns the size of the font
 boolean getStrikethrough()
          Returns a boolean that indicates whether the font is striketrough or not.
 StrokeFormat getStrikethroughStroke()
          Returns the stroke format that should be used for strikethroughs
 boolean getUnderline()
          Returns a boolean that indicates whether the font is underlined or not.
 StrokeFormat getUnderlineStroke()
          Returns the stroke format that should be used for underlines
 int getWeight()
          Retuns a constant that represents the weight of the font.
 int hashCode()
           
 boolean isVisible()
          Returns a boolean that indicates whether the font is visible or not.
 java.lang.String toString()
          Returns a String that represent the FontFormat and all of the attributes of it.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
The weights a FontFormat supports.

See Also:
Constant Field Values

THIN

public static final int THIN
The weights a FontFormat supports.

See Also:
Constant Field Values

EXTRALIGHT

public static final int EXTRALIGHT
The weights a FontFormat supports.

See Also:
Constant Field Values

LIGHT

public static final int LIGHT
The weights a FontFormat supports.

See Also:
Constant Field Values

NORMAL

public static final int NORMAL
The weights a FontFormat supports.

See Also:
Constant Field Values

MEDIUM

public static final int MEDIUM
The weights a FontFormat supports.

See Also:
Constant Field Values

SEMIBOLD

public static final int SEMIBOLD
The weights a FontFormat supports.

See Also:
Constant Field Values

BOLD

public static final int BOLD
The weights a FontFormat supports.

See Also:
Constant Field Values

EXTRABOLD

public static final int EXTRABOLD
The weights a FontFormat supports.

See Also:
Constant Field Values

HEAVY

public static final int HEAVY
The weights a FontFormat supports.

See Also:
Constant Field Values

DEFAULT_SIZE

public static final int DEFAULT_SIZE
Default size of a FontFormat.

See Also:
Constant Field Values

DEFAULT_FAMILY

public static final java.lang.String DEFAULT_FAMILY
Default font family of a FontFormat.

See Also:
Constant Field Values

DEFAULT_FONT_FORMAT

public static final FontFormat DEFAULT_FONT_FORMAT
Default font format.


CANONIC_DESCRIPTION_DELIMITER

protected static final java.lang.String CANONIC_DESCRIPTION_DELIMITER
Delimitier for the canonical description.

See Also:
Constant Field Values

CANONIC_DESCRIPTION_SUBDESC_START

protected static final java.lang.String CANONIC_DESCRIPTION_SUBDESC_START
Start token for a description in a sublevel.

See Also:
Constant Field Values

CANONIC_DESCRIPTION_SUBDESC_END

protected static final java.lang.String CANONIC_DESCRIPTION_SUBDESC_END
End token for a description in a sublevel.

See Also:
Constant Field Values

TOKEN_SIZE

protected static final java.lang.String TOKEN_SIZE
Enumeration that tells about the canonical description tokens.

See Also:
Constant Field Values

TOKEN_WEIGHT

protected static final java.lang.String TOKEN_WEIGHT
Enumeration that tells about the canonical description tokens.

See Also:
Constant Field Values

TOKEN_FAMILY

protected static final java.lang.String TOKEN_FAMILY
Enumeration that tells about the canonical description tokens.

See Also:
Constant Field Values

TOKEN_COLOR

protected static final java.lang.String TOKEN_COLOR
Enumeration that tells about the canonical description tokens.

See Also:
Constant Field Values

TOKEN_ITALIC

protected static final java.lang.String TOKEN_ITALIC
Enumeration that tells about the canonical description tokens.

See Also:
Constant Field Values

TOKEN_UNDERLINE

protected static final java.lang.String TOKEN_UNDERLINE
Enumeration that tells about the canonical description tokens.

See Also:
Constant Field Values

TOKEN_STRIKETHROUGH

protected static final java.lang.String TOKEN_STRIKETHROUGH
Enumeration that tells about the canonical description tokens.

See Also:
Constant Field Values

TOKEN_UNDERLINESTROKE

protected static final java.lang.String TOKEN_UNDERLINESTROKE
Enumeration that tells about the canonical description tokens.

See Also:
Constant Field Values

TOKEN_STRIKETHROUGHSTROKE

protected static final java.lang.String TOKEN_STRIKETHROUGHSTROKE
Enumeration that tells about the canonical description tokens.

See Also:
Constant Field Values
Method Detail

getSize

public int getSize()
Returns the size of the font

Returns:
int the size of the font

getWeight

public int getWeight()
Retuns a constant that represents the weight of the font. The constants are defined in this class. Notice that at the actual state of development only NORMAL and BOLD are supported.

Returns:
int the weight constant that represents the actual weight of the font

getFamily

public java.lang.String getFamily()
Returns a String that represents the family of the font.

Returns:
String the font family

getColor

public int getColor()
Returns the color of the font. The color is represented by an int that defines the values for the red, green and blue components as illustrated by the following hexadecimal pattern:
0x00rrggbb
where rr stands for the red component, gg stands for the green component and bb stands for the blue component of the color.

Returns:
int the color used for drawing a character

getBold

public boolean getBold()
Returns a boolean that indicates whether the font is BOLD or not.

Returns:
boolean flag that indicates a bold font

getItalic

public boolean getItalic()
Returns a boolean that indicates whether the font is italic or not.

Returns:
boolean flag that indicates an italic font

getUnderline

public boolean getUnderline()
Returns a boolean that indicates whether the font is underlined or not. Notice that at the actual state of development underlined fonts are not supported.

Returns:
boolean flag that indicates an underlined font

getStrikethrough

public boolean getStrikethrough()
Returns a boolean that indicates whether the font is striketrough or not. Notice that at the actual state of development strikethrough fonts are not supported.

Returns:
boolean flag that indicates a strikethrough font

isVisible

public boolean isVisible()
Returns a boolean that indicates whether the font is visible or not. Notice that at the actual state of development invisible fonts are not supported.

Returns:
boolean flag that indicates a visible font

getFormatData

public java.lang.Object[] getFormatData()
Returns an array filled with the attributes of the FontFormat. The indices of the attributes are given by constants defined in this class. This array is used by Renderers and Devices. To get more informations about this objects take a look at the documentation of Renderer and Device

Returns:
int[] the array with the attributes if the FontFormat

getCanonicalDescription

public java.lang.String getCanonicalDescription()
Returns the canonical description of a FontFormat. For instance this description is used for the pooling of FontFormats. It can also be used to compare two instances of a FontFormat.

Specified by:
getCanonicalDescription in interface Format
Returns:
String the canonical description of a FontFormat

toString

public java.lang.String toString()
Returns a String that represent the FontFormat and all of the attributes of it. For instance this representation can be used for tracing purposes and such.

Specified by:
toString in interface Format
Returns:
String the textual representation of the FontFormat

hashCode

public int hashCode()

equals

public boolean equals(java.lang.Object o)

getCanonicalDescription

public static final java.lang.String getCanonicalDescription(int size,
                                                             int weight,
                                                             java.lang.String family,
                                                             int color,
                                                             boolean italic,
                                                             boolean underline,
                                                             boolean strikethrough)
Returns the canonical description of a FontFormat. For instance this description is used for the pooling of FontFormats. It can also be used to compare two instances of a FontFormat.

Parameters:
size - the size of a FontFormat
weight - the weight of a FontFormat
family - the family of a FontFormat
color - the color of a FontFormat
italic - the italic indicator of a FontFormat
underline - the underline indicator of a FontFormat
strikethrough - the strikethrough indicator of a FontFormat
Returns:
String the canonical description of a FontFormat

getCanonicalDescription

public static final java.lang.String getCanonicalDescription(int size,
                                                             int weight,
                                                             java.lang.String family,
                                                             int color,
                                                             boolean italic,
                                                             boolean underline,
                                                             boolean strikethrough,
                                                             StrokeFormat underlineStroke,
                                                             StrokeFormat strikethroughStroke)
Returns the canonical description of a FontFormat. For instance this description is used for the pooling of FontFormats. It can also be used to compare two instances of a FontFormat.

Parameters:
size - the size of a FontFormat
weight - the weight of a FontFormat
family - the family of a FontFormat
color - the color of a FontFormat
italic - the italic indicator of a FontFormat
underline - the underline indicator of a FontFormat
strikethrough - the strikethrough indicator of a FontFormat
underlineStroke -
strikethroughStroke -
Returns:
String the canonical description of a FontFormat

getCanonicalDescription

public static final java.lang.String getCanonicalDescription(java.lang.String size,
                                                             java.lang.String weight,
                                                             java.lang.String family,
                                                             java.lang.String color,
                                                             java.lang.String italic,
                                                             java.lang.String underline,
                                                             java.lang.String strikethrough)
Returns the canonical description of a FontFormat. For instance this description is used for the pooling of FontFormats. It can also be used to compare two instances of a FontFormat.
PRECONDITION:none of the arguments must be null

Parameters:
size - the size of a FontFormat
weight - the weight of a FontFormat
family - the family of a FontFormat
color - the color of a FontFormat
italic - the italic indicator of a FontFormat
underline - the underline indicator of a FontFormat
strikethrough - the strikethrough indicator of a FontFormat
Returns:
String the canonical description of a FontFormat

getCanonicalDescription

public static final java.lang.String getCanonicalDescription(java.lang.String size,
                                                             java.lang.String weight,
                                                             java.lang.String family,
                                                             java.lang.String color,
                                                             java.lang.String italic,
                                                             java.lang.String underline,
                                                             java.lang.String strikethrough,
                                                             java.lang.String underlineStroke,
                                                             java.lang.String strikethroughStroke)
Returns the canonical description of a FontFormat. For instance this description is used for the pooling of FontFormats. It can also be used to compare two instances of a FontFormat.
PRECONDITION:none of the arguments must be null

Parameters:
size - the size of a FontFormat
weight - the weight of a FontFormat
family - the family of a FontFormat
color - the color of a FontFormat
italic - the italic indicator of a FontFormat
underline - the underline indicator of a FontFormat
strikethrough - the strikethrough indicator of a FontFormat
underlineStroke - The stroke to use for the underline
strikethroughStroke - The stroke to use for the strikethrough
Returns:
String the canonical description of a FontFormat

getUnderlineStroke

public StrokeFormat getUnderlineStroke()
Returns the stroke format that should be used for underlines

Returns:
the stroke format that should be used for underlines

getStrikethroughStroke

public StrokeFormat getStrikethroughStroke()
Returns the stroke format that should be used for strikethroughs

Returns:
the stroke format that should be used for strikethroughs


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.