Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.awt.FontMetrics
Constructor Summary | |
|
Method Summary | |
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
Font |
|
int |
|
int |
|
LineMetrics |
|
LineMetrics |
|
LineMetrics |
|
LineMetrics |
|
int |
|
int |
|
Rectangle2D |
|
int |
|
int |
|
Rectangle2D |
|
Rectangle2D |
|
Rectangle2D |
|
Rectangle2D |
|
int[] |
|
boolean |
|
int |
|
String |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
protected FontMetrics(Font font)
Initializes a new instance ofFontMetrics
for the specified font.
- Parameters:
font
- The font to return metric information for.
public int bytesWidth(byte[] buf, int offset, int len)
Returns the total width of the specified byte array.
- Parameters:
buf
- The byte array containing the data.offset
- The offset into the array to start calculating from.len
- The total number of bytes to process.
- Returns:
- The width of the requested characters.
public int charWidth(char ch)
Returns the width of the specified character.
- Parameters:
ch
- The character to return the width of.
- Returns:
- The width of the specified character.
public int charWidth(int ch)
Returns the width of the specified character.
- Parameters:
ch
- The character to return the width of.
- Returns:
- The width of the specified character.
public int charsWidth(char[] buf, int offset, int len)
Returns the total width of the specified character array.
- Parameters:
buf
- The character array containing the data.offset
- The offset into the array to start calculating from.len
- The total number of bytes to process.
- Returns:
- The width of the requested characters.
public int getAscent()
Returns the ascent of the font, which is the distance from the base to the top of the majority of characters in the set. Some characters can exceed this value however.
- Returns:
- The font ascent.
public int getDescent()
Returns the descent of the font, which is the distance from the base to the bottom of the majority of characters in the set. Some characters can exceed this value however.
- Returns:
- The font descent.
public Font getFont()
Returns the font that this object is creating metric information fo.
- Returns:
- The font for this object.
public int getHeight()
Returns the height of a line in this font. This will be the sum of the leading, the ascent, and the descent.
- Returns:
- The height of the font.
public int getLeading()
Returns the leading, or spacing between lines, for this font.
- Returns:
- The font leading.
public LineMetrics getLineMetrics(char[] chars, int begin, int limit, Graphics g)
Returns aLineMetrics
object constructed with the specified text and theFontRenderContext
of the Graphics object when it is an instance of Graphics2D or a generic FontRenderContext with a null transform, not anti-aliased and not using fractional metrics.
- Parameters:
chars
- The string to calculate metrics from.begin
- Index of first character intext
to measure.limit
- Index of last character intext
to measure.g
- The Graphics object that will be used.
- Returns:
- A new
LineMetrics
object.
- Throws:
IndexOutOfBoundsException
- if the range [begin, limit] is invalid intext
.
public LineMetrics getLineMetrics(String text, int begin, int limit, Graphics g)
Returns aLineMetrics
object constructed with the specified text and theFontRenderContext
of the Graphics object when it is an instance of Graphics2D or a generic FontRenderContext with a null transform, not anti-aliased and not using fractional metrics.
- Parameters:
text
- The string to calculate metrics from.begin
- Index of first character intext
to measure.limit
- Index of last character intext
to measure.g
- The Graphics object that will be used.
- Returns:
- A new
LineMetrics
object.
- Throws:
IndexOutOfBoundsException
- if the range [begin, limit] is invalid intext
.
public LineMetrics getLineMetrics(String text, Graphics g)
Returns aLineMetrics
object constructed with the specified text and theFontRenderContext
of the Graphics object when it is an instance of Graphics2D or a generic FontRenderContext with a null transform, not anti-aliased and not using fractional metrics.
- Parameters:
text
- The string to calculate metrics from.g
- The Graphics object that will be used.
- Returns:
- A new
LineMetrics
object.
public LineMetrics getLineMetrics(CharacterIterator ci, int begin, int limit, Graphics g)
Returns aLineMetrics
object constructed with the specified text and theFontRenderContext
of the Graphics object when it is an instance of Graphics2D or a generic FontRenderContext with a null transform, not anti-aliased and not using fractional metrics.
- Parameters:
ci
- An iterator over the string to calculate metrics from.begin
- Index of first character intext
to measure.limit
- Index of last character intext
to measure.g
- The Graphics object that will be used.
- Returns:
- A new
LineMetrics
object.
- Throws:
IndexOutOfBoundsException
- if the range [begin, limit] is invalid intext
.
public int getMaxAdvance()
Returns the width of the widest character in the font.
- Returns:
- The width of the widest character in the font.
public int getMaxAscent()
Returns the maximum ascent value. This is the maximum distance any character in the font rised above the baseline.
- Returns:
- The maximum ascent for this font.
public Rectangle2D getMaxCharBounds(Graphics context)
Returns the bounds of the largest character in a Graphics context.
- Parameters:
context
- the Graphics context object.
- Returns:
- a
Rectangle2D
representing the bounds
public int getMaxDecent()
Deprecated. This method is deprecated in favor of
getMaxDescent()
.Returns the maximum descent value. This is the maximum distance any character in the font extends below the baseline.
- Returns:
- The maximum descent for this font.
public int getMaxDescent()
Returns the maximum descent value. This is the maximum distance any character in the font extends below the baseline.
- Returns:
- The maximum descent for this font.
public Rectangle2D getStringBounds(char[] chars, int beginIndex, int limit, Graphics context)
public Rectangle2D getStringBounds(String str, int beginIndex, int limit, Graphics context)
public Rectangle2D getStringBounds(CharacterIterator ci, int beginIndex, int limit, Graphics context)
public int[] getWidths()
Returns the widths of the first 256 characters in the font.
- Returns:
- The widths of the first 256 characters in the font.
public boolean hasUniformLineMetrics()
Returns if the font has uniform line metrics.
- See Also:
Font.hasUniformLineMetrics()
public int stringWidth(String str)
Returns the total width of the specified string
- Parameters:
str
- The string to return the width of.
- Returns:
- The width of the string.