Path: blob/master/src/java.desktop/share/classes/sun/font/ExtendedTextLabel.java
41155 views
/*1* Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24/*25*26* (C) Copyright IBM Corp. 1998-2003- All Rights Reserved.27*/2829package sun.font;3031import java.awt.Font;3233import java.awt.font.GlyphJustificationInfo;34import java.awt.font.LineMetrics;3536import java.awt.geom.Point2D;37import java.awt.geom.Rectangle2D;3839/**40* An extension of TextLabel that maintains information41* about characters.42*/4344public abstract class ExtendedTextLabel extends TextLabel45implements TextLineComponent{46/**47* Return the number of characters represented by this label.48*/49public abstract int getNumCharacters();5051/**52* Return the line metrics for all text in this label.53*/54public abstract CoreMetrics getCoreMetrics();5556/**57* Return the x location of the character at the given logical index.58*/59public abstract float getCharX(int logicalIndex);6061/**62* Return the y location of the character at the given logical index.63*/64public abstract float getCharY(int logicalIndex);6566/**67* Return the advance of the character at the given logical index.68*/69public abstract float getCharAdvance(int logicalIndex);7071/**72* Return the visual bounds of the character at the given logical index.73* This bounds encloses all the pixels of the character when the label is rendered74* at x, y.75*/76public abstract Rectangle2D getCharVisualBounds(int logicalIndex, float x, float y);7778/**79* Return the visual index of the character at the given logical index.80*/81public abstract int logicalToVisual(int logicalIndex);8283/**84* Return the logical index of the character at the given visual index.85*/86public abstract int visualToLogical(int visualIndex);8788/**89* Return the logical index of the character, starting with the character at90* logicalStart, whose accumulated advance exceeds width. If the advances of91* all characters do not exceed width, return getNumCharacters. If width is92* less than zero, return logicalStart - 1.93*/94public abstract int getLineBreakIndex(int logicalStart, float width);9596/**97* Return the accumulated advances of all characters between logicalStart and98* logicalLimit.99*/100public abstract float getAdvanceBetween(int logicalStart, int logicalLimit);101102/**103* Return whether a caret can exist on the leading edge of the104* character at offset. If the character is part of a ligature105* (for example) a caret may not be appropriate at offset.106*/107public abstract boolean caretAtOffsetIsValid(int offset);108109/**110* A convenience overload of getCharVisualBounds that defaults the label origin111* to 0, 0.112*/113public Rectangle2D getCharVisualBounds(int logicalIndex) {114return getCharVisualBounds(logicalIndex, 0, 0);115}116117public abstract TextLineComponent getSubset(int start, int limit, int dir);118119/**120* Return the number of justification records this uses.121*/122public abstract int getNumJustificationInfos();123124/**125* Return GlyphJustificationInfo objects for the characters between126* charStart and charLimit, starting at offset infoStart. Infos127* will be in visual order. All positions between infoStart and128* getNumJustificationInfos will be set. If a position corresponds129* to a character outside the provided range, it is set to null.130*/131public abstract void getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit);132133/**134* Apply deltas to the data in this component, starting at offset135* deltaStart, and return the new component. There are two floats136* for each justification info, for a total of 2 * getNumJustificationInfos.137* The first delta is the left adjustment, the second is the right138* adjustment.139* <p>140* If flags[0] is true on entry, rejustification is allowed. If141* the new component requires rejustification (ligatures were142* formed or split), flags[0] will be set on exit.143*/144public abstract TextLineComponent applyJustificationDeltas(float[] deltas, int deltaStart, boolean[] flags);145}146147148