jdk/src/share/classes/javax/swing/text/GlyphPainter1.java
author xdono
Mon, 15 Dec 2008 16:55:25 -0800
changeset 1639 a97859015238
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6785258: Update copyright year Summary: Update copyright for files that have been modified starting July 2008 to Dec 2008 Reviewed-by: katleman, ohair, tbell
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 1999-2006 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
package javax.swing.text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * A class to perform rendering of the glyphs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * This can be implemented to be stateless, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * to hold some information as a cache to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * facilitate faster rendering and model/view
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * translation.  At a minimum, the GlyphPainter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * allows a View implementation to perform its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * duties independent of a particular version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * of JVM and selection of capabilities (i.e.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * shaping for i18n, etc).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * This implementation is intended for operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * under the JDK1.1 API of the Java Platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * Since the JDK is backward compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * JDK1.1 API, this class will also function on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * Java 2.  The JDK introduces improved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * API for rendering text however, so the GlyphPainter2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * is recommended for the DK.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @author  Timothy Prinzing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * @see GlyphView
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
class GlyphPainter1 extends GlyphView.GlyphPainter {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * Determine the span the glyphs given a start location
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * (for tab expansion).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    public float getSpan(GlyphView v, int p0, int p1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                         TabExpander e, float x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        sync(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        Segment text = v.getText(p0, p1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        int[] justificationData = getJustificationData(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        int width = Utilities.getTabbedTextWidth(v, text, metrics, (int) x, e, p0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                                                 justificationData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        SegmentCache.releaseSharedSegment(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        return width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public float getHeight(GlyphView v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        sync(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        return metrics.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Fetches the ascent above the baseline for the glyphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * corresponding to the given range in the model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public float getAscent(GlyphView v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        sync(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        return metrics.getAscent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * Fetches the descent below the baseline for the glyphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * corresponding to the given range in the model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public float getDescent(GlyphView v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        sync(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        return metrics.getDescent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * Paints the glyphs representing the given range.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public void paint(GlyphView v, Graphics g, Shape a, int p0, int p1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        sync(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        Segment text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        TabExpander expander = v.getTabExpander();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : a.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        // determine the x coordinate to render the glyphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        int x = alloc.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        int p = v.getStartOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        int[] justificationData = getJustificationData(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        if (p != p0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            text = v.getText(p, p0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            int width = Utilities.getTabbedTextWidth(v, text, metrics, x, expander, p,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                                                     justificationData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            x += width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            SegmentCache.releaseSharedSegment(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        // determine the y coordinate to render the glyphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        int y = alloc.y + metrics.getHeight() - metrics.getDescent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        // render the glyphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        text = v.getText(p0, p1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        g.setFont(metrics.getFont());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        Utilities.drawTabbedText(v, text, x, y, g, expander,p0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                                 justificationData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        SegmentCache.releaseSharedSegment(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public Shape modelToView(GlyphView v, int pos, Position.Bias bias,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                             Shape a) throws BadLocationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        sync(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : a.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        int p0 = v.getStartOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        int p1 = v.getEndOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        TabExpander expander = v.getTabExpander();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        Segment text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        if(pos == p1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            // The caller of this is left to right and borders a right to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            // left view, return our end location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            return new Rectangle(alloc.x + alloc.width, alloc.y, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                                 metrics.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        if ((pos >= p0) && (pos <= p1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            // determine range to the left of the position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            text = v.getText(p0, pos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            int[] justificationData = getJustificationData(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            int width = Utilities.getTabbedTextWidth(v, text, metrics, alloc.x, expander, p0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                                                     justificationData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            SegmentCache.releaseSharedSegment(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            return new Rectangle(alloc.x + width, alloc.y, 0, metrics.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        throw new BadLocationException("modelToView - can't convert", p1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * Provides a mapping from the view coordinate space to the logical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * coordinate space of the model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @param v the view containing the view coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @param x the X coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @param y the Y coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @param a the allocated region to render into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @param biasReturn always returns <code>Position.Bias.Forward</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *   as the zero-th element of this array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @return the location within the model that best represents the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *  given point in the view
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @see View#viewToModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    public int viewToModel(GlyphView v, float x, float y, Shape a,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                           Position.Bias[] biasReturn) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        sync(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : a.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        int p0 = v.getStartOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        int p1 = v.getEndOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        TabExpander expander = v.getTabExpander();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        Segment text = v.getText(p0, p1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        int[] justificationData = getJustificationData(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        int offs = Utilities.getTabbedTextOffset(v, text, metrics,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                                                 alloc.x, (int) x, expander, p0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                                                 justificationData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        SegmentCache.releaseSharedSegment(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        int retValue = p0 + offs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        if(retValue == p1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            // No need to return backward bias as GlyphPainter1 is used for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            // ltr text only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            retValue--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        biasReturn[0] = Position.Bias.Forward;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        return retValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * Determines the best location (in the model) to break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * the given view.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * This method attempts to break on a whitespace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * location.  If a whitespace location can't be found, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * nearest character location is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @param v the view
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @param p0 the location in the model where the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *  fragment should start its representation >= 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @param pos the graphic location along the axis that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *  broken view would occupy >= 0; this may be useful for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     *  things like tab calculations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @param len specifies the distance into the view
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *  where a potential break is desired >= 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @return the model location desired for a break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @see View#breakView
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    public int getBoundedPosition(GlyphView v, int p0, float x, float len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        sync(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        TabExpander expander = v.getTabExpander();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        Segment s = v.getText(p0, v.getEndOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        int[] justificationData = getJustificationData(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        int index = Utilities.getTabbedTextOffset(v, s, metrics, (int)x, (int)(x+len),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                                                  expander, p0, false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                                                  justificationData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        SegmentCache.releaseSharedSegment(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        int p1 = p0 + index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        return p1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    void sync(GlyphView v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        Font f = v.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        if ((metrics == null) || (! f.equals(metrics.getFont()))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            // fetch a new FontMetrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            Container c = v.getContainer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            metrics = (c != null) ? c.getFontMetrics(f) :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                Toolkit.getDefaultToolkit().getFontMetrics(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
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
     * @return justificationData from the ParagraphRow this GlyphView
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * is in or {@code null} if no justification is needed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    private int[] getJustificationData(GlyphView v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        View parent = v.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        int [] ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        if (parent instanceof ParagraphView.Row) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            ParagraphView.Row row = ((ParagraphView.Row) parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            ret = row.justificationData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    // --- variables ---------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    FontMetrics metrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
}