KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > font > LineMetrics


1 /*
2  * @(#)LineMetrics.java 1.20 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 /*
8 * @(#)LineMetrics.java 1.4 98/09/21
9 */

10
11 package java.awt.font;
12
13 /**
14 * The <code>LineMetrics</code> class allows access to the
15 * metrics needed to layout characters along a line
16 * and to layout of a set of lines. A <code>LineMetrics</code>
17 * object encapsulates the measurement information associated
18 * with a run of text.
19 * <p>
20 * Fonts can have different metrics for different ranges of
21 * characters. The <code>getLineMetrics</code> methods of
22 * {@link java.awt.Font Font} take some text as an argument
23 * and return a <code>LineMetrics</code> object describing the
24 * metrics of the initial number of characters in that text, as
25 * returned by {@link #getNumChars}.
26 */

27
28
29 public abstract class LineMetrics {
30
31
32     /**
33      * Returns the number of characters (<code>char</code> values) in the text whose
34      * metrics are encapsulated by this <code>LineMetrics</code>
35      * object.
36      * @return the number of characters (<code>char</code> values) in the text with which
37      * this <code>LineMetrics</code> was created.
38      */

39     public abstract int getNumChars();
40
41     /**
42      * Returns the ascent of the text. The ascent
43      * is the distance from the baseline
44      * to the ascender line. The ascent usually represents the
45      * the height of the capital letters of the text. Some characters
46      * can extend above the ascender line.
47      * @return the ascent of the text.
48      */

49     public abstract float getAscent();
50
51     /**
52      * Returns the descent of the text. The descent
53      * is the distance from the baseline
54      * to the descender line. The descent usually represents
55      * the distance to the bottom of lower case letters like
56      * 'p'. Some characters can extend below the descender
57      * line.
58      * @return the descent of the text.
59      */

60     public abstract float getDescent();
61
62     /**
63      * Returns the leading of the text. The
64      * leading is the recommended
65      * distance from the bottom of the descender line to the
66      * top of the next line.
67      * @return the leading of the text.
68      */

69     public abstract float getLeading();
70
71     /**
72      * Returns the height of the text. The
73      * height is equal to the sum of the ascent, the
74      * descent and the leading.
75      * @return the height of the text.
76      */

77     public abstract float getHeight();
78
79     /**
80      * Returns the baseline index of the text.
81      * The index is one of
82      * {@link java.awt.Font#ROMAN_BASELINE ROMAN_BASELINE},
83      * {@link java.awt.Font#CENTER_BASELINE CENTER_BASELINE},
84      * {@link java.awt.Font#HANGING_BASELINE HANGING_BASELINE}.
85      * @return the baseline of the text.
86      */

87     public abstract int getBaselineIndex();
88
89     /**
90      * Returns the baseline offsets of the text,
91      * relative to the baseline of the text. The
92      * offsets are indexed by baseline index. For
93      * example, if the baseline index is
94      * <code>CENTER_BASELINE</code> then
95      * <code>offsets[HANGING_BASELINE]</code> is usually
96      * negative, <code>offsets[CENTER_BASELINE]</code>
97      * is zero, and <code>offsets[ROMAN_BASELINE]</code>
98      * is usually positive.
99      * @return the baseline offsets of the text.
100      */

101     public abstract float[] getBaselineOffsets();
102
103     /**
104      * Returns the position of the strike-through line
105      * relative to the baseline.
106      * @return the position of the strike-through line.
107      */

108     public abstract float getStrikethroughOffset();
109
110     /**
111      * Returns the thickness of the strike-through line.
112      * @return the thickness of the strike-through line.
113      */

114     public abstract float getStrikethroughThickness();
115
116     /**
117      * Returns the position of the underline relative to
118      * the baseline.
119      * @return the position of the underline.
120      */

121     public abstract float getUnderlineOffset();
122
123     /**
124      * Returns the thickness of the underline.
125      * @return the thickness of the underline.
126      */

127     public abstract float getUnderlineThickness();
128 }
129
Popular Tags