Class LineMetrics
java.lang.Object
java.awt.font.LineMetrics
The
LineMetrics class allows access to the
metrics needed to layout characters along a line
and to layout of a set of lines. A LineMetrics
object encapsulates the measurement information associated
with a run of text.
Fonts can have different metrics for different ranges of
characters. The getLineMetrics methods of
Font take some text as an argument
and return a LineMetrics object describing the
metrics of the initial number of characters in that text, as
returned by getNumChars().
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract floatReturns the ascent of the text.abstract intReturns the baseline index of the text.abstract float[]Returns the baseline offsets of the text, relative to the baseline of the text.abstract floatReturns the descent of the text.abstract floatReturns the height of the text.abstract floatReturns the leading of the text.abstract intReturns the number of characters (charvalues) in the text whose metrics are encapsulated by thisLineMetricsobject.abstract floatReturns the position of the strike-through line relative to the baseline.abstract floatReturns the thickness of the strike-through line.abstract floatReturns the position of the underline relative to the baseline.abstract floatReturns the thickness of the underline.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
LineMetrics
protected LineMetrics()Constructor for subclasses to call.
-
-
Method Details
-
getNumChars
public abstract int getNumChars()Returns the number of characters (charvalues) in the text whose metrics are encapsulated by thisLineMetricsobject.- Returns:
- the number of characters (
charvalues) in the text with which thisLineMetricswas created.
-
getAscent
public abstract float getAscent()Returns the ascent of the text. The ascent is the distance from the baseline to the ascender line. The ascent usually represents the the height of the capital letters of the text. Some characters can extend above the ascender line.- Returns:
- the ascent of the text.
-
getDescent
public abstract float getDescent()Returns the descent of the text. The descent is the distance from the baseline to the descender line. The descent usually represents the distance to the bottom of lower case letters like 'p'. Some characters can extend below the descender line.- Returns:
- the descent of the text.
-
getLeading
public abstract float getLeading()Returns the leading of the text. The leading is the recommended distance from the bottom of the descender line to the top of the next line.- Returns:
- the leading of the text.
-
getHeight
public abstract float getHeight()Returns the height of the text. The height is equal to the sum of the ascent, the descent and the leading.- Returns:
- the height of the text.
-
getBaselineIndex
public abstract int getBaselineIndex()Returns the baseline index of the text. The index is one ofROMAN_BASELINE,CENTER_BASELINE,HANGING_BASELINE.- Returns:
- the baseline of the text.
-
getBaselineOffsets
public abstract float[] getBaselineOffsets()Returns the baseline offsets of the text, relative to the baseline of the text. The offsets are indexed by baseline index. For example, if the baseline index isCENTER_BASELINEthenoffsets[HANGING_BASELINE]is usually negative,offsets[CENTER_BASELINE]is zero, andoffsets[ROMAN_BASELINE]is usually positive.- Returns:
- the baseline offsets of the text.
-
getStrikethroughOffset
public abstract float getStrikethroughOffset()Returns the position of the strike-through line relative to the baseline.- Returns:
- the position of the strike-through line.
-
getStrikethroughThickness
public abstract float getStrikethroughThickness()Returns the thickness of the strike-through line.- Returns:
- the thickness of the strike-through line.
-
getUnderlineOffset
public abstract float getUnderlineOffset()Returns the position of the underline relative to the baseline.- Returns:
- the position of the underline.
-
getUnderlineThickness
public abstract float getUnderlineThickness()Returns the thickness of the underline.- Returns:
- the thickness of the underline.
-