com.swfm.mica.core
Class MiFont

java.lang.Object
  extended byjava.awt.Font
      extended bycom.swfm.mica.core.MiFont
All Implemented Interfaces:
java.io.Serializable

public class MiFont
extends java.awt.Font

This class wraps the AWT Font class. This was done for both efficiency and to protect Mica against changes to the AWT Font class.

Version:
%I% %G%
Author:
Michael L. Davis
See Also:
#MiFontManager, Serialized Form

Field Summary
static int BOLD
           
static int ITALIC
           
static int PLAIN
           
static int STRIKEOUT
           
static int UNDERLINE
           
static int VALID_AWT_STYLES_MASK
           
   
Constructor Summary
MiFont(java.lang.String name)
          Constructs a new PLAIN, 12 pont MiFont of the given typeface family name.
MiFont(java.lang.String name, int style, int size)
          Constructs a new MiFont.
 
Method Summary
 boolean equals(java.lang.Object other)
           
 int getAverageCharWidth()
          Get the average width of all characters in this font.
 java.lang.String getFullName()
           
 int getHeight()
          Get the height of a line of characters in this font.
 int getMaxCharHeight()
          Get the maximum height of all characters in this font.
 int getMaxCharWidth()
          Get the maximum width of all characters in this font.
 int getMaximumDescent()
          Get the maximum decent of text in this font.
 java.lang.String getName()
          Return the name (type face) of this font.
 int getPointSize()
          Return the point size of this font.
 MiSize getSize(char ch, MiSize size)
          Get the size of the given character in this font.
 MiSize getSize(java.lang.String text)
          Get the size of the given text string in this font.
 MiSize getSize(java.lang.String text, MiSize size)
          Get the size of the given text string in this font.
 int getStyle()
          Return the style of this font.
 int getWidth(char ch)
          Get the width of the given character in this font.
 int getWidth(java.lang.String text)
          Get the width of the given text string in this font.
 int hashCode()
           
 boolean isBold()
          Return whether or not text drawn with this font is bold.
 boolean isItalic()
          Return whether or not text drawn with this font is italic.
 boolean isStrikeOut()
          Return whether or not text drawn with this font is striked-out.
 boolean isUnderlined()
          Return whether or not text drawn with this font is underlined.
 MiFont setBold(boolean flag)
          Make and return a font exactly like this font but with a different BOLD style.
 MiFont setItalic(boolean flag)
          Make and return a font exactly like this font but with a different ITALIC style.
 MiFont setName(java.lang.String name)
          Make and return a font exactly like this font but with a different type face.
 MiFont setPointSize(int points)
          Make and return a font exactly like this font but with a different point size.
 MiFont setStrikeOut(boolean flag)
          Make and return a font exactly like this font but with a different STRIKEOUT style.
 MiFont setUnderlined(boolean flag)
          Make and return a font exactly like this font but with a different UNDERLINE style.
 
Methods inherited from class java.awt.Font
canDisplay, canDisplayUpTo, canDisplayUpTo, canDisplayUpTo, createFont, createGlyphVector, createGlyphVector, createGlyphVector, createGlyphVector, decode, deriveFont, deriveFont, deriveFont, deriveFont, deriveFont, deriveFont, getAttributes, getAvailableAttributes, getBaselineFor, getFamily, getFamily, getFont, getFont, getFont, getFontName, getFontName, getItalicAngle, getLineMetrics, getLineMetrics, getLineMetrics, getLineMetrics, getMaxCharBounds, getMissingGlyphCode, getNumGlyphs, getPeer, getPSName, getSize, getSize2D, getStringBounds, getStringBounds, getStringBounds, getStringBounds, getTransform, hasUniformLineMetrics, isPlain, isTransformed, layoutGlyphVector, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PLAIN

public static final int PLAIN
See Also:
Constant Field Values

BOLD

public static final int BOLD
See Also:
Constant Field Values

ITALIC

public static final int ITALIC
See Also:
Constant Field Values

UNDERLINE

public static final int UNDERLINE
See Also:
Constant Field Values

STRIKEOUT

public static final int STRIKEOUT
See Also:
Constant Field Values

VALID_AWT_STYLES_MASK

public static final int VALID_AWT_STYLES_MASK
See Also:
Constant Field Values
Constructor Detail

MiFont

public MiFont(java.lang.String name)
Constructs a new PLAIN, 12 pont MiFont of the given typeface family name.

Parameters:
name - the family name

MiFont

public MiFont(java.lang.String name,
              int style,
              int size)
Constructs a new MiFont. The valid family names are found in MiFontManager.getFontList(). The valid styles are PLAIN, BOLD, ITALIC, UNDERLINE, STRIKEOUT in any combination (i.e. ITALIC + UNDERLINE).

Parameters:
name - the family name
style - the style of the font
size - the size of the font in points
See Also:
MiFontManager.getFontList()
Method Detail

getMaxCharWidth

public int getMaxCharWidth()
Get the maximum width of all characters in this font.

Returns:
the maximum width

getAverageCharWidth

public int getAverageCharWidth()
Get the average width of all characters in this font.

Returns:
the average width

getMaxCharHeight

public int getMaxCharHeight()
Get the maximum height of all characters in this font.

Returns:
the maximum height

getWidth

public int getWidth(char ch)
Get the width of the given character in this font.

Parameters:
ch - the character to get the width of
Returns:
the width of the character

getHeight

public int getHeight()
Get the height of a line of characters in this font.

Returns:
the height of the character

getSize

public MiSize getSize(char ch,
                      MiSize size)
Get the size of the given character in this font.

Parameters:
ch - the character to get the height of
size - the (returned) size of the character
Returns:
the size of the character

getMaximumDescent

public int getMaximumDescent()
Get the maximum decent of text in this font. The decent is the part of a character that extends below the baseline (for example the characters j and q have a non-zero decent). Returned decent is in pixels.

Returns:
the maximum decent of this font.

getWidth

public int getWidth(java.lang.String text)
Get the width of the given text string in this font. Returned width is in pixels.

Returns:
the width of the text string

getSize

public MiSize getSize(java.lang.String text,
                      MiSize size)
Get the size of the given text string in this font. Returned size is in pixels.

Parameters:
size - the (returned) size of the text string
Returns:
the size of the text string

getSize

public MiSize getSize(java.lang.String text)
Get the size of the given text string in this font.

Returns:
the size of the text string

getStyle

public int getStyle()
Return the style of this font. Possible styles are: PLAIN, BOLD, ITALIC, UNDERLINE, STRIKEOUT in any combination (i.e. ITALIC + UNDERLINE).

Returns:
the style

setName

public MiFont setName(java.lang.String name)
Make and return a font exactly like this font but with a different type face.

Parameters:
name - the new font's type face.
Returns:
the new font

getName

public java.lang.String getName()
Return the name (type face) of this font.

Returns:
the font name

getFullName

public java.lang.String getFullName()

setPointSize

public MiFont setPointSize(int points)
Make and return a font exactly like this font but with a different point size.

Parameters:
points - the returned font's point size.
Returns:
the new font

getPointSize

public int getPointSize()
Return the point size of this font.

Returns:
the point size

setBold

public MiFont setBold(boolean flag)
Make and return a font exactly like this font but with a different BOLD style.

Parameters:
flag - whether the returned font will have the BOLD style
Returns:
the new font

isBold

public boolean isBold()
Return whether or not text drawn with this font is bold.

Returns:
true is this font has the BOLD style

setItalic

public MiFont setItalic(boolean flag)
Make and return a font exactly like this font but with a different ITALIC style.

Parameters:
flag - whether the returned font will have the ITALIC style
Returns:
the new font

isItalic

public boolean isItalic()
Return whether or not text drawn with this font is italic.

Returns:
true is this font has the ITALIC style

setUnderlined

public MiFont setUnderlined(boolean flag)
Make and return a font exactly like this font but with a different UNDERLINE style.

Parameters:
flag - whether the returned font will have the UNDERLINE style
Returns:
the new font

isUnderlined

public boolean isUnderlined()
Return whether or not text drawn with this font is underlined.

Returns:
true is this font has the UNDERLINE style

setStrikeOut

public MiFont setStrikeOut(boolean flag)
Make and return a font exactly like this font but with a different STRIKEOUT style.

Parameters:
flag - whether the returned font will have the STRIKEOUT style
Returns:
the new font

isStrikeOut

public boolean isStrikeOut()
Return whether or not text drawn with this font is striked-out.

Returns:
true is this font has the STRIKEOUT style

hashCode

public int hashCode()

equals

public boolean equals(java.lang.Object other)