001 /*
002 * Copyright 1998-2003 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 /*
026 * @(#)LineMetrics.java 1.4 98/09/21
027 */
028
029 package java.awt.font;
030
031 /**
032 * The <code>LineMetrics</code> class allows access to the
033 * metrics needed to layout characters along a line
034 * and to layout of a set of lines. A <code>LineMetrics</code>
035 * object encapsulates the measurement information associated
036 * with a run of text.
037 * <p>
038 * Fonts can have different metrics for different ranges of
039 * characters. The <code>getLineMetrics</code> methods of
040 * {@link java.awt.Font Font} take some text as an argument
041 * and return a <code>LineMetrics</code> object describing the
042 * metrics of the initial number of characters in that text, as
043 * returned by {@link #getNumChars}.
044 */
045
046 public abstract class LineMetrics {
047
048 /**
049 * Returns the number of characters (<code>char</code> values) in the text whose
050 * metrics are encapsulated by this <code>LineMetrics</code>
051 * object.
052 * @return the number of characters (<code>char</code> values) in the text with which
053 * this <code>LineMetrics</code> was created.
054 */
055 public abstract int getNumChars();
056
057 /**
058 * Returns the ascent of the text. The ascent
059 * is the distance from the baseline
060 * to the ascender line. The ascent usually represents the
061 * the height of the capital letters of the text. Some characters
062 * can extend above the ascender line.
063 * @return the ascent of the text.
064 */
065 public abstract float getAscent();
066
067 /**
068 * Returns the descent of the text. The descent
069 * is the distance from the baseline
070 * to the descender line. The descent usually represents
071 * the distance to the bottom of lower case letters like
072 * 'p'. Some characters can extend below the descender
073 * line.
074 * @return the descent of the text.
075 */
076 public abstract float getDescent();
077
078 /**
079 * Returns the leading of the text. The
080 * leading is the recommended
081 * distance from the bottom of the descender line to the
082 * top of the next line.
083 * @return the leading of the text.
084 */
085 public abstract float getLeading();
086
087 /**
088 * Returns the height of the text. The
089 * height is equal to the sum of the ascent, the
090 * descent and the leading.
091 * @return the height of the text.
092 */
093 public abstract float getHeight();
094
095 /**
096 * Returns the baseline index of the text.
097 * The index is one of
098 * {@link java.awt.Font#ROMAN_BASELINE ROMAN_BASELINE},
099 * {@link java.awt.Font#CENTER_BASELINE CENTER_BASELINE},
100 * {@link java.awt.Font#HANGING_BASELINE HANGING_BASELINE}.
101 * @return the baseline of the text.
102 */
103 public abstract int getBaselineIndex();
104
105 /**
106 * Returns the baseline offsets of the text,
107 * relative to the baseline of the text. The
108 * offsets are indexed by baseline index. For
109 * example, if the baseline index is
110 * <code>CENTER_BASELINE</code> then
111 * <code>offsets[HANGING_BASELINE]</code> is usually
112 * negative, <code>offsets[CENTER_BASELINE]</code>
113 * is zero, and <code>offsets[ROMAN_BASELINE]</code>
114 * is usually positive.
115 * @return the baseline offsets of the text.
116 */
117 public abstract float[] getBaselineOffsets();
118
119 /**
120 * Returns the position of the strike-through line
121 * relative to the baseline.
122 * @return the position of the strike-through line.
123 */
124 public abstract float getStrikethroughOffset();
125
126 /**
127 * Returns the thickness of the strike-through line.
128 * @return the thickness of the strike-through line.
129 */
130 public abstract float getStrikethroughThickness();
131
132 /**
133 * Returns the position of the underline relative to
134 * the baseline.
135 * @return the position of the underline.
136 */
137 public abstract float getUnderlineOffset();
138
139 /**
140 * Returns the thickness of the underline.
141 * @return the thickness of the underline.
142 */
143 public abstract float getUnderlineThickness();
144 }
|