|
|||||||||
| Home >> All >> java >> [ awt overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.awt
Class FontMetrics

java.lang.Objectjava.awt.FontMetrics
- All Implemented Interfaces:
- java.io.Serializable
- public abstract class FontMetrics
- extends java.lang.Object
- implements java.io.Serializable
- extends java.lang.Object
This class returns information about the display characteristics of a font. It is abstract, and concrete subclasses should implement at least the following methods:
- getAscent()
- getDescent()
- getLeading()
- getMaxAdvance()
- charWidth(char)
- charsWidth(char[], int, int)
| Field Summary | |
protected Font |
font
This is the font for which metrics will be returned. |
private static java.awt.font.FontRenderContext |
gRC
|
private static long |
serialVersionUID
|
| Constructor Summary | |
protected |
FontMetrics(Font font)
Initializes a new instance of FontMetrics for the
specified font. |
| Method Summary | |
int |
bytesWidth(byte[] buf,
int offset,
int len)
Returns the total width of the specified byte array. |
int |
charsWidth(char[] buf,
int offset,
int len)
Returns the total width of the specified character array. |
int |
charWidth(char ch)
Returns the width of the specified character. |
int |
charWidth(int ch)
Returns the width of the specified character. |
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. |
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. |
Font |
getFont()
Returns the font that this object is creating metric information fo. |
private java.awt.font.FontRenderContext |
getFontRenderContext(Graphics context)
|
int |
getHeight()
Returns the height of a line in this font. |
int |
getLeading()
Returns the leading, or spacing between lines, for this font. |
java.awt.font.LineMetrics |
getLineMetrics(char[] chars,
int begin,
int limit,
Graphics g)
Returns a java.awt.font.LineMetrics object constructed with the specified text and the java.awt.font.FontRenderContext 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. |
java.awt.font.LineMetrics |
getLineMetrics(java.text.CharacterIterator ci,
int begin,
int limit,
Graphics g)
Returns a java.awt.font.LineMetrics object constructed with the specified text and the java.awt.font.FontRenderContext 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. |
java.awt.font.LineMetrics |
getLineMetrics(java.lang.String text,
Graphics g)
Returns a java.awt.font.LineMetrics object constructed with the specified text and the java.awt.font.FontRenderContext 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. |
java.awt.font.LineMetrics |
getLineMetrics(java.lang.String text,
int begin,
int limit,
Graphics g)
Returns a java.awt.font.LineMetrics object constructed with the specified text and the java.awt.font.FontRenderContext 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. |
int |
getMaxAdvance()
Returns the width of the widest character in the font. |
int |
getMaxAscent()
Returns the maximum ascent value. |
java.awt.geom.Rectangle2D |
getMaxCharBounds(Graphics context)
Returns the bounds of the largest character in a Graphics context. |
int |
getMaxDecent()
Deprecated. This method is deprecated in favor of getMaxDescent(). |
int |
getMaxDescent()
Returns the maximum descent value. |
java.awt.geom.Rectangle2D |
getStringBounds(char[] chars,
int beginIndex,
int limit,
Graphics context)
|
java.awt.geom.Rectangle2D |
getStringBounds(java.text.CharacterIterator ci,
int beginIndex,
int limit,
Graphics context)
|
java.awt.geom.Rectangle2D |
getStringBounds(java.lang.String str,
Graphics context)
|
java.awt.geom.Rectangle2D |
getStringBounds(java.lang.String str,
int beginIndex,
int limit,
Graphics context)
|
int[] |
getWidths()
Returns the widths of the first 256 characters in the font. |
boolean |
hasUniformLineMetrics()
Returns if the font has uniform line metrics. |
int |
stringWidth(java.lang.String str)
Returns the total width of the specified string |
java.lang.String |
toString()
Returns a string representation of this object. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
font
protected Font font
- This is the font for which metrics will be returned.
gRC
private static final java.awt.font.FontRenderContext gRC
| Constructor Detail |
FontMetrics
protected FontMetrics(Font font)
- Initializes a new instance of
FontMetricsfor the specified font.
| Method Detail |
getFont
public Font getFont()
- Returns the font that this object is creating metric information fo.
getLeading
public int getLeading()
- Returns the leading, or spacing between lines, for this font.
getAscent
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.
getDescent
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.
getHeight
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.
getMaxAscent
public int getMaxAscent()
- Returns the maximum ascent value. This is the maximum distance any
character in the font rised above the baseline.
getMaxDescent
public int getMaxDescent()
- Returns the maximum descent value. This is the maximum distance any
character in the font extends below the baseline.
getMaxDecent
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 value. This is the maximum distance any character in the font extends below the baseline.
getMaxAdvance
public int getMaxAdvance()
- Returns the width of the widest character in the font.
charWidth
public int charWidth(int ch)
- Returns the width of the specified character.
charWidth
public int charWidth(char ch)
- Returns the width of the specified character.
stringWidth
public int stringWidth(java.lang.String str)
- Returns the total width of the specified string
charsWidth
public int charsWidth(char[] buf,
int offset,
int len)
- Returns the total width of the specified character array.
bytesWidth
public int bytesWidth(byte[] buf,
int offset,
int len)
- Returns the total width of the specified byte array.
getWidths
public int[] getWidths()
- Returns the widths of the first 256 characters in the font.
toString
public java.lang.String toString()
- Returns a string representation of this object.
getLineMetrics
public java.awt.font.LineMetrics getLineMetrics(java.lang.String text, Graphics g)
- Returns a java.awt.font.LineMetrics object constructed with the
specified text and the java.awt.font.FontRenderContext 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.
getLineMetrics
public java.awt.font.LineMetrics getLineMetrics(java.lang.String text, int begin, int limit, Graphics g)
- Returns a java.awt.font.LineMetrics object constructed with the
specified text and the java.awt.font.FontRenderContext 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.
getLineMetrics
public java.awt.font.LineMetrics getLineMetrics(char[] chars, int begin, int limit, Graphics g)
- Returns a java.awt.font.LineMetrics object constructed with the
specified text and the java.awt.font.FontRenderContext 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.
getMaxCharBounds
public java.awt.geom.Rectangle2D getMaxCharBounds(Graphics context)
- Returns the bounds of the largest character in a Graphics context.
getLineMetrics
public java.awt.font.LineMetrics getLineMetrics(java.text.CharacterIterator ci, int begin, int limit, Graphics g)
- Returns a java.awt.font.LineMetrics object constructed with the
specified text and the java.awt.font.FontRenderContext 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.
getStringBounds
public java.awt.geom.Rectangle2D getStringBounds(java.lang.String str, Graphics context)
getStringBounds
public java.awt.geom.Rectangle2D getStringBounds(java.lang.String str, int beginIndex, int limit, Graphics context)
getStringBounds
public java.awt.geom.Rectangle2D getStringBounds(char[] chars, int beginIndex, int limit, Graphics context)
getStringBounds
public java.awt.geom.Rectangle2D getStringBounds(java.text.CharacterIterator ci, int beginIndex, int limit, Graphics context)
getFontRenderContext
private java.awt.font.FontRenderContext getFontRenderContext(Graphics context)
hasUniformLineMetrics
public boolean hasUniformLineMetrics()
- Returns if the font has uniform line metrics.
|
|||||||||
| Home >> All >> java >> [ awt overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
java.awt.FontMetrics