jdk/src/share/classes/java/awt/font/GlyphVector.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 5506 202f599c92aa
child 23010 6dadb192ad81
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @author Charlton Innovations, Inc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
package java.awt.font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.Graphics2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.Font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.Polygon;        // remind - need a floating point version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.geom.Point2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.geom.Rectangle2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.geom.AffineTransform;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.awt.Shape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.awt.font.GlyphMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.awt.font.GlyphJustificationInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * A <code>GlyphVector</code> object is a collection of glyphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * containing geometric information for the placement of each glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * in a transformed coordinate space which corresponds to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * device on which the <code>GlyphVector</code> is ultimately
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * displayed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * The <code>GlyphVector</code> does not attempt any interpretation of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * the sequence of glyphs it contains.  Relationships between adjacent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * glyphs in sequence are solely used to determine the placement of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * the glyphs in the visual coordinate space.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * Instances of <code>GlyphVector</code> are created by a {@link Font}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * In a text processing application that can cache intermediate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * representations of text, creation and subsequent caching of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <code>GlyphVector</code> for use during rendering is the fastest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * method to present the visual representation of characters to a user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * A <code>GlyphVector</code> is associated with exactly one
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <code>Font</code>, and can provide data useful only in relation to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * this <code>Font</code>.  In addition, metrics obtained from a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <code>GlyphVector</code> are not generally geometrically scaleable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * since the pixelization and spacing are dependent on grid-fitting
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * algorithms within a <code>Font</code>.  To facilitate accurate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * measurement of a <code>GlyphVector</code> and its component
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * glyphs, you must specify a scaling transform, anti-alias mode, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * fractional metrics mode when creating the <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * These characteristics can be derived from the destination device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * For each glyph in the <code>GlyphVector</code>, you can obtain:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * <li>the position of the glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * <li>the transform associated with the glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * <li>the metrics of the glyph in the context of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *   <code>GlyphVector</code>.  The metrics of the glyph may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *   different under different transforms, application specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *   rendering hints, and the specific instance of the glyph within
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *   the <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * Altering the data used to create the <code>GlyphVector</code> does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * alter the state of the <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * Methods are provided to adjust the positions of the glyphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * within the <code>GlyphVector</code>.  These methods are most
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * appropriate for applications that are performing justification
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * operations for the presentation of the glyphs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * Methods are provided to transform individual glyphs within the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * <code>GlyphVector</code>.  These methods are primarily useful for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * special effects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * Methods are provided to return both the visual, logical, and pixel bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * of the entire <code>GlyphVector</code> or of individual glyphs within
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * the <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * Methods are provided to return a {@link Shape} for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * <code>GlyphVector</code>, and for individual glyphs within the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * @see Font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * @see GlyphMetrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * @see TextLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * @author Charlton Innovations, Inc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
public abstract class GlyphVector implements Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    // methods associated with creation-time state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * Returns the <code>Font</code> associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @return <code>Font</code> used to create this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @see Font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public abstract Font getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * Returns the {@link FontRenderContext} associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @return <code>FontRenderContext</code> used to create this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @see FontRenderContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @see Font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public abstract FontRenderContext getFontRenderContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    // methods associated with the GlyphVector as a whole
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * Assigns default positions to each glyph in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * <code>GlyphVector</code>. This can destroy information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * generated during initial layout of this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public abstract void performDefaultLayout();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Returns the number of glyphs in this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @return number of glyphs in this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public abstract int getNumGlyphs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * Returns the glyphcode of the specified glyph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * This return value is meaningless to anything other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * than the <code>Font</code> object that created this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @param glyphIndex the index into this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * that corresponds to the glyph from which to retrieve the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * glyphcode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @return the glyphcode of the glyph at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * <code>glyphIndex</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * is less than 0 or greater than or equal to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * number of glyphs in this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public abstract int getGlyphCode(int glyphIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * Returns an array of glyphcodes for the specified glyphs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * The contents of this return value are meaningless to anything other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * than the <code>Font</code> used to create this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * <code>GlyphVector</code>.  This method is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * for convenience and performance when processing glyphcodes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * If no array is passed in, a new array is created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @param beginGlyphIndex the index into this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *   <code>GlyphVector</code> at which to start retrieving glyphcodes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @param numEntries the number of glyphcodes to retrieve
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @param codeReturn the array that receives the glyphcodes and is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *   then returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @return an array of glyphcodes for the specified glyphs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @throws IllegalArgumentException if <code>numEntries</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *   less than 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @throws IndexOutOfBoundsException if <code>beginGlyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     *   is less than 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * @throws IndexOutOfBoundsException if the sum of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *   <code>beginGlyphIndex</code> and <code>numEntries</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *   greater than the number of glyphs in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *   <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    public abstract int[] getGlyphCodes(int beginGlyphIndex, int numEntries,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                                        int[] codeReturn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * Returns the character index of the specified glyph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * The character index is the index of the first logical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * character represented by the glyph.  The default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * implementation assumes a one-to-one, left-to-right mapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * of glyphs to characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @param glyphIndex the index of the glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * @return the index of the first character represented by the glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    public int getGlyphCharIndex(int glyphIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        return glyphIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * Returns the character indices of the specified glyphs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * The character index is the index of the first logical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * character represented by the glyph.  Indices are returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * in glyph order.  The default implementation invokes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * getGlyphCharIndex for each glyph, and subclassers will probably
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * want to override this implementation for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * Use this method for convenience and performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * in processing of glyphcodes. If no array is passed in,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * a new array is created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @param beginGlyphIndex the index of the first glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * @param numEntries the number of glyph indices
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * @param codeReturn the array into which to return the character indices
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @return an array of character indices, one per glyph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    public int[] getGlyphCharIndices(int beginGlyphIndex, int numEntries,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                                     int[] codeReturn) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        if (codeReturn == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            codeReturn = new int[numEntries];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        for (int i = 0, j = beginGlyphIndex; i < numEntries; ++i, ++j) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            codeReturn[i] = getGlyphCharIndex(j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return codeReturn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * Returns the logical bounds of this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * This method is used when positioning this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * in relation to visually adjacent <code>GlyphVector</code> objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @return a {@link Rectangle2D} that is the logical bounds of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public abstract Rectangle2D getLogicalBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * Returns the visual bounds of this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * The visual bounds is the bounding box of the outline of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * <code>GlyphVector</code>.  Because of rasterization and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * alignment of pixels, it is possible that this box does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * enclose all pixels affected by rendering this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @return a <code>Rectangle2D</code> that is the bounding box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * of this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    public abstract Rectangle2D getVisualBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * Returns the pixel bounds of this <code>GlyphVector</code> when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * rendered in a graphics with the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * <code>FontRenderContext</code> at the given location.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * renderFRC need not be the same as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * <code>FontRenderContext</code> of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * <code>GlyphVector</code>, and can be null.  If it is null, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * <code>FontRenderContext</code> of this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * is used.  The default implementation returns the visual bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * offset to x, y and rounded out to the next integer value (i.e. returns an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * integer rectangle which encloses the visual bounds) and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * ignores the FRC.  Subclassers should override this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * @param renderFRC the <code>FontRenderContext</code> of the <code>Graphics</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @param x the x-coordinate at which to render this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @param y the y-coordinate at which to render this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * @return a <code>Rectangle</code> bounding the pixels that would be affected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    public Rectangle getPixelBounds(FontRenderContext renderFRC, float x, float y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                Rectangle2D rect = getVisualBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                int l = (int)Math.floor(rect.getX() + x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                int t = (int)Math.floor(rect.getY() + y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                int r = (int)Math.ceil(rect.getMaxX() + x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                int b = (int)Math.ceil(rect.getMaxY() + y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                return new Rectangle(l, t, r - l, b - t);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * Returns a <code>Shape</code> whose interior corresponds to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * visual representation of this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * @return a <code>Shape</code> that is the outline of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    public abstract Shape getOutline();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * Returns a <code>Shape</code> whose interior corresponds to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * visual representation of this <code>GlyphVector</code> when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * rendered at x,&nbsp;y.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @param x the X coordinate of this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * @param y the Y coordinate of this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @return a <code>Shape</code> that is the outline of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     *   <code>GlyphVector</code> when rendered at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     *   coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    public abstract Shape getOutline(float x, float y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Returns a <code>Shape</code> whose interior corresponds to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * visual representation of the specified glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * within this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * The outline returned by this method is positioned around the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * origin of each individual glyph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @param glyphIndex the index into this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * @return a <code>Shape</code> that is the outline of the glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     *   at the specified <code>glyphIndex</code> of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     *   <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     *   is less than 0 or greater than or equal to the number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     *   of glyphs in this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    public abstract Shape getGlyphOutline(int glyphIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * Returns a <code>Shape</code> whose interior corresponds to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * visual representation of the specified glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * within this <code>GlyphVector</code>, offset to x,&nbsp;y.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * The outline returned by this method is positioned around the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * origin of each individual glyph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * @param glyphIndex the index into this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * @param x the X coordinate of the location of this {@code GlyphVector}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @param y the Y coordinate of the location of this {@code GlyphVector}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @return a <code>Shape</code> that is the outline of the glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *   at the specified <code>glyphIndex</code> of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     *   <code>GlyphVector</code> when rendered at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *   coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     *   is less than 0 or greater than or equal to the number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     *   of glyphs in this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    public Shape getGlyphOutline(int glyphIndex, float x, float y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        Shape s = getGlyphOutline(glyphIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        AffineTransform at = AffineTransform.getTranslateInstance(x,y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        return at.createTransformedShape(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * Returns the position of the specified glyph relative to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * origin of this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * If <code>glyphIndex</code> equals the number of of glyphs in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * this <code>GlyphVector</code>, this method returns the position after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * the last glyph. This position is used to define the advance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * the entire <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * @param glyphIndex the index into this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * @return a {@link Point2D} object that is the position of the glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     *   at the specified <code>glyphIndex</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     *   is less than 0 or greater than the number of glyphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     *   in this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * @see #setGlyphPosition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    public abstract Point2D getGlyphPosition(int glyphIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * Sets the position of the specified glyph within this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * If <code>glyphIndex</code> equals the number of of glyphs in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * this <code>GlyphVector</code>, this method sets the position after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * the last glyph. This position is used to define the advance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * the entire <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * @param glyphIndex the index into this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * @param newPos the <code>Point2D</code> at which to position the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     *   glyph at the specified <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     *   is less than 0 or greater than the number of glyphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *   in this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * @see #getGlyphPosition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    public abstract void setGlyphPosition(int glyphIndex, Point2D newPos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * Returns the transform of the specified glyph within this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * <code>GlyphVector</code>.  The transform is relative to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * glyph position.  If no special transform has been applied,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * <code>null</code> can be returned.  A null return indicates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * an identity transform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * @param glyphIndex the index into this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * @return an {@link AffineTransform} that is the transform of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     *   the glyph at the specified <code>glyphIndex</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     *   is less than 0 or greater than or equal to the number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     *   of glyphs in this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @see #setGlyphTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    public abstract AffineTransform getGlyphTransform(int glyphIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * Sets the transform of the specified glyph within this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * <code>GlyphVector</code>.  The transform is relative to the glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * position.  A <code>null</code> argument for <code>newTX</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * indicates that no special transform is applied for the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * glyph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * This method can be used to rotate, mirror, translate and scale the
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
   398
     * glyph.  Adding a transform can result in significant performance changes.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @param glyphIndex the index into this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * @param newTX the new transform of the glyph at <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     *   is less than 0 or greater than or equal to the number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     *   of glyphs in this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * @see #getGlyphTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    public abstract void setGlyphTransform(int glyphIndex, AffineTransform newTX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * Returns flags describing the global state of the GlyphVector.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * Flags not described below are reserved.  The default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * implementation returns 0 (meaning false) for the position adjustments,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * transforms, rtl, and complex flags.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * Subclassers should override this method, and make sure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * it correctly describes the GlyphVector and corresponds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * to the results of related calls.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @return an int containing the flags describing the state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * @see #FLAG_HAS_POSITION_ADJUSTMENTS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * @see #FLAG_HAS_TRANSFORMS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * @see #FLAG_RUN_RTL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * @see #FLAG_COMPLEX_GLYPHS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * @see #FLAG_MASK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    public int getLayoutFlags() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * A flag used with getLayoutFlags that indicates that this <code>GlyphVector</code> has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * per-glyph transforms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    public static final int FLAG_HAS_TRANSFORMS = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * A flag used with getLayoutFlags that indicates that this <code>GlyphVector</code> has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * position adjustments.  When this is true, the glyph positions don't match the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * accumulated default advances of the glyphs (for example, if kerning has been done).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    public static final int FLAG_HAS_POSITION_ADJUSTMENTS = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * A flag used with getLayoutFlags that indicates that this <code>GlyphVector</code> has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * a right-to-left run direction.  This refers to the glyph-to-char mapping and does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * not imply that the visual locations of the glyphs are necessarily in this order,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * although generally they will be.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    public static final int FLAG_RUN_RTL = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * A flag used with getLayoutFlags that indicates that this <code>GlyphVector</code> has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * a complex glyph-to-char mapping (one that does not map glyphs to chars one-to-one in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * strictly ascending or descending order matching the run direction).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    public static final int FLAG_COMPLEX_GLYPHS = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * A mask for supported flags from getLayoutFlags.  Only bits covered by the mask
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * should be tested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    public static final int FLAG_MASK =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        FLAG_HAS_TRANSFORMS |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        FLAG_HAS_POSITION_ADJUSTMENTS |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        FLAG_RUN_RTL |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        FLAG_COMPLEX_GLYPHS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * Returns an array of glyph positions for the specified glyphs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * This method is used for convenience and performance when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * processing glyph positions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * If no array is passed in, a new array is created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * Even numbered array entries beginning with position zero are the X
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * coordinates of the glyph numbered <code>beginGlyphIndex + position/2</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * Odd numbered array entries beginning with position one are the Y
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * coordinates of the glyph numbered <code>beginGlyphIndex + (position-1)/2</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * If <code>beginGlyphIndex</code> equals the number of of glyphs in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * this <code>GlyphVector</code>, this method gets the position after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * the last glyph and this position is used to define the advance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * the entire <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * @param beginGlyphIndex the index at which to begin retrieving
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     *   glyph positions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * @param numEntries the number of glyphs to retrieve
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * @param positionReturn the array that receives the glyph positions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     *   and is then returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * @return an array of glyph positions specified by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     *  <code>beginGlyphIndex</code> and <code>numEntries</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * @throws IllegalArgumentException if <code>numEntries</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     *   less than 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @throws IndexOutOfBoundsException if <code>beginGlyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     *   is less than 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @throws IndexOutOfBoundsException if the sum of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     *   <code>beginGlyphIndex</code> and <code>numEntries</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     *   is greater than the number of glyphs in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     *   <code>GlyphVector</code> plus one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    public abstract float[] getGlyphPositions(int beginGlyphIndex, int numEntries,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                                              float[] positionReturn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * Returns the logical bounds of the specified glyph within this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * These logical bounds have a total of four edges, with two edges
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * parallel to the baseline under the glyph's transform and the other two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * edges are shared with adjacent glyphs if they are present.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * method is useful for hit-testing of the specified glyph,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * positioning of a caret at the leading or trailing edge of a glyph,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * and for drawing a highlight region around the specified glyph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * @param glyphIndex the index into this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     *   that corresponds to the glyph from which to retrieve its logical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     *   bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * @return  a <code>Shape</code> that is the logical bounds of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     *   glyph at the specified <code>glyphIndex</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     *   is less than 0 or greater than or equal to the number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     *   of glyphs in this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * @see #getGlyphVisualBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    public abstract Shape getGlyphLogicalBounds(int glyphIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * Returns the visual bounds of the specified glyph within the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * The bounds returned by this method is positioned around the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * origin of each individual glyph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * @param glyphIndex the index into this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     *   that corresponds to the glyph from which to retrieve its visual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     *   bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * @return a <code>Shape</code> that is the visual bounds of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     *   glyph at the specified <code>glyphIndex</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     *   is less than 0 or greater than or equal to the number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     *   of glyphs in this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * @see #getGlyphLogicalBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    public abstract Shape getGlyphVisualBounds(int glyphIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * Returns the pixel bounds of the glyph at index when this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * <code>GlyphVector</code> is rendered in a <code>Graphics</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * given <code>FontRenderContext</code> at the given location. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * renderFRC need not be the same as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * <code>FontRenderContext</code> of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * <code>GlyphVector</code>, and can be null.  If it is null, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * <code>FontRenderContext</code> of this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * is used.  The default implementation returns the visual bounds of the glyph,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * offset to x, y and rounded out to the next integer value, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * ignores the FRC.  Subclassers should override this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * @param index the index of the glyph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * @param renderFRC the <code>FontRenderContext</code> of the <code>Graphics</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * @param x the X position at which to render this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * @param y the Y position at which to render this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * @return a <code>Rectangle</code> bounding the pixels that would be affected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    public Rectangle getGlyphPixelBounds(int index, FontRenderContext renderFRC, float x, float y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                Rectangle2D rect = getGlyphVisualBounds(index).getBounds2D();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                int l = (int)Math.floor(rect.getX() + x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                int t = (int)Math.floor(rect.getY() + y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                int r = (int)Math.ceil(rect.getMaxX() + x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                int b = (int)Math.ceil(rect.getMaxY() + y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                return new Rectangle(l, t, r - l, b - t);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * Returns the metrics of the glyph at the specified index into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * @param glyphIndex the index into this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     *   that corresponds to the glyph from which to retrieve its metrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * @return a {@link GlyphMetrics} object that represents the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     *   metrics of the glyph at the specified <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     *   into this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     *   is less than 0 or greater than or equal to the number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     *   of glyphs in this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    public abstract GlyphMetrics getGlyphMetrics(int glyphIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * Returns the justification information for the glyph at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * the specified index into this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * @param glyphIndex the index into this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     *   that corresponds to the glyph from which to retrieve its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     *   justification properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * @return a {@link GlyphJustificationInfo} object that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     *   represents the justification properties of the glyph at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     *   specified <code>glyphIndex</code> into this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     *   <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * @throws IndexOutOfBoundsException if <code>glyphIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     *   is less than 0 or greater than or equal to the number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     *   of glyphs in this <code>GlyphVector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    public abstract GlyphJustificationInfo getGlyphJustificationInfo(int glyphIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    // general utility methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * Tests if the specified <code>GlyphVector</code> exactly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * equals this <code>GlyphVector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * @param set the specified <code>GlyphVector</code> to test
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * @return <code>true</code> if the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     *   <code>GlyphVector</code> equals this <code>GlyphVector</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     *   <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    public abstract boolean equals(GlyphVector set);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
}