org.apache.batik.gvt.font
Class AWTGVTFont

java.lang.Object
  extended by org.apache.batik.gvt.font.AWTGVTFont
All Implemented Interfaces:
GVTFont

public class AWTGVTFont
extends Object
implements GVTFont

This is a wrapper class for a java.awt.Font instance.


Field Summary
protected  Font awtFont
           
static float FONT_SIZE
           
protected  float scale
           
protected  float size
           
 
Constructor Summary
AWTGVTFont(Font font)
          Creates a new AWTGVTFont that wraps the given Font.
AWTGVTFont(Font font, float scale)
          Creates a new AWTGVTFont that wraps the given Font.
AWTGVTFont(Map attributes)
          Creates a new AWTGVTFont with the specified attributes.
AWTGVTFont(String name, int style, int size)
          Creates a new AWTGVTFont from the specified name, style and point size.
 
Method Summary
 boolean canDisplay(char c)
          Checks if this font can display the specified character.
 int canDisplayUpTo(char[] text, int start, int limit)
          Indicates whether or not this font can display the characters in the specified text starting at start and ending at limit.
 int canDisplayUpTo(CharacterIterator iter, int start, int limit)
          Indicates whether or not this font can display the the characters in the specified CharacterIterator starting at start and ending at limit.
 int canDisplayUpTo(String str)
          Indicates whether or not this font can display a specified String.
 GVTGlyphVector createGlyphVector(FontRenderContext frc, char[] chars)
          Returns a new GlyphVector object created with the specified array of characters and the specified FontRenderContext.
 GVTGlyphVector createGlyphVector(FontRenderContext frc, CharacterIterator ci)
          Returns a new GlyphVector object created with the specified CharacterIterator and the specified FontRenderContext.
 GVTGlyphVector createGlyphVector(FontRenderContext frc, int[] glyphCodes, CharacterIterator ci)
          Returns a new GlyphVector object created with the specified integer array and the specified FontRenderContext.
 GVTGlyphVector createGlyphVector(FontRenderContext frc, String str)
          Returns a new GlyphVector object created with the specified String and the specified FontRenderContext.
 GVTFont deriveFont(float size)
          Creates a new Font object by replicating the current Font object and applying a new size to it.
 String getFamilyName()
          Returns the font family name of this font.
static AWTGlyphGeometryCache.Value getGlyphGeometry(AWTGVTFont font, char c, GlyphVector gv, int glyphIndex, Point2D glyphPos)
          Returns the geometry of the specified character.
 float getHKern(int glyphCode1, int glyphCode2)
          Returns the horizontal kerning value for this glyph pair.
 GVTLineMetrics getLineMetrics(char[] chars, int beginIndex, int limit, FontRenderContext frc)
          Returns a LineMetrics object created with the specified arguments.
 GVTLineMetrics getLineMetrics(CharacterIterator ci, int beginIndex, int limit, FontRenderContext frc)
          Returns a GVTLineMetrics object created with the specified arguments.
 GVTLineMetrics getLineMetrics(String str, FontRenderContext frc)
          Returns a GVTLineMetrics object created with the specified String and FontRenderContext.
 GVTLineMetrics getLineMetrics(String str, int beginIndex, int limit, FontRenderContext frc)
          Returns a GVTLineMetrics object created with the specified arguments.
 float getSize()
          Returns the size of this font.
 float getVKern(int glyphCode1, int glyphCode2)
          Returns the vertical kerning value for this glyph pair.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.batik.gvt.font.GVTFont
toString
 

Field Detail

awtFont

protected Font awtFont

size

protected float size

scale

protected float scale

FONT_SIZE

public static final float FONT_SIZE
See Also:
Constant Field Values
Constructor Detail

AWTGVTFont

public AWTGVTFont(Font font)
Creates a new AWTGVTFont that wraps the given Font.

Parameters:
font - The font object to wrap.

AWTGVTFont

public AWTGVTFont(Font font,
                  float scale)
Creates a new AWTGVTFont that wraps the given Font.

Parameters:
font - The font object to wrap.
scale - The scale factor to apply to font...

AWTGVTFont

public AWTGVTFont(Map attributes)
Creates a new AWTGVTFont with the specified attributes.

Parameters:
attributes - Contains attributes of the font to create.

AWTGVTFont

public AWTGVTFont(String name,
                  int style,
                  int size)
Creates a new AWTGVTFont from the specified name, style and point size.

Parameters:
name - The name of the new font.
style - The required font style.
size - The required font size.
Method Detail

canDisplay

public boolean canDisplay(char c)
Checks if this font can display the specified character.

Specified by:
canDisplay in interface GVTFont
Parameters:
c - The character to check.
Returns:
Whether or not the character can be displayed.

canDisplayUpTo

public int canDisplayUpTo(char[] text,
                          int start,
                          int limit)
Indicates whether or not this font can display the characters in the specified text starting at start and ending at limit.

Specified by:
canDisplayUpTo in interface GVTFont
Parameters:
text - An array containing the characters to check.
start - The index of the first character to check.
limit - The index of the last character to check.
Returns:
The index of the first char this font cannot display. Will be -1 if it can display all characters in the specified range.

canDisplayUpTo

public int canDisplayUpTo(CharacterIterator iter,
                          int start,
                          int limit)
Indicates whether or not this font can display the the characters in the specified CharacterIterator starting at start and ending at limit.

Specified by:
canDisplayUpTo in interface GVTFont

canDisplayUpTo

public int canDisplayUpTo(String str)
Indicates whether or not this font can display a specified String.

Specified by:
canDisplayUpTo in interface GVTFont

createGlyphVector

public GVTGlyphVector createGlyphVector(FontRenderContext frc,
                                        char[] chars)
Returns a new GlyphVector object created with the specified array of characters and the specified FontRenderContext.

Specified by:
createGlyphVector in interface GVTFont

createGlyphVector

public GVTGlyphVector createGlyphVector(FontRenderContext frc,
                                        CharacterIterator ci)
Returns a new GlyphVector object created with the specified CharacterIterator and the specified FontRenderContext.

Specified by:
createGlyphVector in interface GVTFont

createGlyphVector

public GVTGlyphVector createGlyphVector(FontRenderContext frc,
                                        int[] glyphCodes,
                                        CharacterIterator ci)
Returns a new GlyphVector object created with the specified integer array and the specified FontRenderContext.

Specified by:
createGlyphVector in interface GVTFont

createGlyphVector

public GVTGlyphVector createGlyphVector(FontRenderContext frc,
                                        String str)
Returns a new GlyphVector object created with the specified String and the specified FontRenderContext.

Specified by:
createGlyphVector in interface GVTFont

deriveFont

public GVTFont deriveFont(float size)
Creates a new Font object by replicating the current Font object and applying a new size to it.

Specified by:
deriveFont in interface GVTFont

getFamilyName

public String getFamilyName()
Description copied from interface: GVTFont
Returns the font family name of this font.

Specified by:
getFamilyName in interface GVTFont

getLineMetrics

public GVTLineMetrics getLineMetrics(char[] chars,
                                     int beginIndex,
                                     int limit,
                                     FontRenderContext frc)
Returns a LineMetrics object created with the specified arguments.

Specified by:
getLineMetrics in interface GVTFont

getLineMetrics

public GVTLineMetrics getLineMetrics(CharacterIterator ci,
                                     int beginIndex,
                                     int limit,
                                     FontRenderContext frc)
Returns a GVTLineMetrics object created with the specified arguments.

Specified by:
getLineMetrics in interface GVTFont

getLineMetrics

public GVTLineMetrics getLineMetrics(String str,
                                     FontRenderContext frc)
Returns a GVTLineMetrics object created with the specified String and FontRenderContext.

Specified by:
getLineMetrics in interface GVTFont

getLineMetrics

public GVTLineMetrics getLineMetrics(String str,
                                     int beginIndex,
                                     int limit,
                                     FontRenderContext frc)
Returns a GVTLineMetrics object created with the specified arguments.

Specified by:
getLineMetrics in interface GVTFont

getSize

public float getSize()
Returns the size of this font.

Specified by:
getSize in interface GVTFont

getHKern

public float getHKern(int glyphCode1,
                      int glyphCode2)
Returns the horizontal kerning value for this glyph pair.

Specified by:
getHKern in interface GVTFont

getVKern

public float getVKern(int glyphCode1,
                      int glyphCode2)
Returns the vertical kerning value for this glyph pair.

Specified by:
getVKern in interface GVTFont

getGlyphGeometry

public static AWTGlyphGeometryCache.Value getGlyphGeometry(AWTGVTFont font,
                                                           char c,
                                                           GlyphVector gv,
                                                           int glyphIndex,
                                                           Point2D glyphPos)
Returns the geometry of the specified character. This method also put the in cache the geometry associated to the specified character if needed.



Copyright © 2008 Apache Software Foundation. All Rights Reserved.