jdk/src/share/classes/java/awt/font/LineMetrics.java
author mchung
Tue, 08 Dec 2009 09:02:09 -0800
changeset 4374 f672d9cf521e
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6907568: java/awt/KeyboardFocusManager.java inproperly merged and lost a changeset Summary: Reapply fix for 6879044 in java.awt.KeyboardFocusManager Reviewed-by: dcherepanov, asaha
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1998-2003 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt.font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
* The <code>LineMetrics</code> class allows access to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
* metrics needed to layout characters along a line
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
* and to layout of a set of lines.  A <code>LineMetrics</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
* object encapsulates the measurement information associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
* with a run of text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
* <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
* Fonts can have different metrics for different ranges of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
* characters.  The <code>getLineMetrics</code> methods of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
* {@link java.awt.Font Font} take some text as an argument
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
* and return a <code>LineMetrics</code> object describing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
* metrics of the initial number of characters in that text, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
* returned by {@link #getNumChars}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
public abstract class LineMetrics {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * Returns the number of characters (<code>char</code> values) in the text whose
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * metrics are encapsulated by this <code>LineMetrics</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * @return the number of characters (<code>char</code> values) in the text with which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     *         this <code>LineMetrics</code> was created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    public abstract int getNumChars();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * Returns the ascent of the text.  The ascent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * is the distance from the baseline
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * to the ascender line.  The ascent usually represents the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * the height of the capital letters of the text.  Some characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * can extend above the ascender line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @return the ascent of the text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public abstract float getAscent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * Returns the descent of the text.  The descent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * is the distance from the baseline
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * to the descender line.  The descent usually represents
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * the distance to the bottom of lower case letters like
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * 'p'.  Some characters can extend below the descender
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * @return the descent of the text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public abstract float getDescent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Returns the leading of the text. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * leading is the recommended
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * distance from the bottom of the descender line to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * top of the next line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @return the leading of the text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public abstract float getLeading();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Returns the height of the text.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * height is equal to the sum of the ascent, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * descent and the leading.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @return the height of the text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public abstract float getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * Returns the baseline index of the text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * The index is one of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * {@link java.awt.Font#ROMAN_BASELINE ROMAN_BASELINE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * {@link java.awt.Font#CENTER_BASELINE CENTER_BASELINE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * {@link java.awt.Font#HANGING_BASELINE HANGING_BASELINE}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @return the baseline of the text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public abstract int getBaselineIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Returns the baseline offsets of the text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * relative to the baseline of the text.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * offsets are indexed by baseline index.  For
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * example, if the baseline index is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * <code>CENTER_BASELINE</code> then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * <code>offsets[HANGING_BASELINE]</code> is usually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * negative, <code>offsets[CENTER_BASELINE]</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * is zero, and <code>offsets[ROMAN_BASELINE]</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * is usually positive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @return the baseline offsets of the text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public abstract float[] getBaselineOffsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * Returns the position of the strike-through line
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * relative to the baseline.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @return the position of the strike-through line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    public abstract float getStrikethroughOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Returns the thickness of the strike-through line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @return the thickness of the strike-through line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    public abstract float getStrikethroughThickness();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * Returns the position of the underline relative to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * the baseline.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @return the position of the underline.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public abstract float getUnderlineOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * Returns the thickness of the underline.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @return the thickness of the underline.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    public abstract float getUnderlineThickness();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
}