bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington/*
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This code is free software; you can redistribute it and/or modify it
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * under the terms of the GNU General Public License version 2 only, as
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * published by the Free Software Foundation. Oracle designates this
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * particular file as subject to the "Classpath" exception as provided
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * by Oracle in the LICENSE file that accompanied this code.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This code is distributed in the hope that it will be useful, but WITHOUT
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * version 2 for more details (a copy is included in the LICENSE file that
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * accompanied this code).
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You should have received a copy of the GNU General Public License version
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * 2 along with this work; if not, write to the Free Software Foundation,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * or visit www.oracle.com if you need additional information or have any
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * questions.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/*
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (C) Copyright IBM Corp. 2003, All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage sun.font;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.awt.font.FontRenderContext;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.awt.font.LineMetrics;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Metrics from a font for layout of characters along a line
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * and layout of set of lines.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This and CoreMetrics replace what was previously a private internal class of Font
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic final class FontLineMetrics extends LineMetrics implements Cloneable {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public int numchars; // mutated by Font
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final CoreMetrics cm;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final FontRenderContext frc;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public FontLineMetrics(int numchars, CoreMetrics cm, FontRenderContext frc) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.numchars = numchars;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.cm = cm;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.frc = frc;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final int getNumChars() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return numchars;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final float getAscent() {
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington return cm.ascent;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final float getDescent() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return cm.descent;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final float getLeading() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return cm.leading;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final float getHeight() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return cm.height;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final int getBaselineIndex() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return cm.baselineIndex;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final float[] getBaselineOffsets() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (float[])cm.baselineOffsets.clone();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final float getStrikethroughOffset() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return cm.strikethroughOffset;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final float getStrikethroughThickness() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return cm.strikethroughThickness;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final float getUnderlineOffset() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return cm.underlineOffset;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final float getUnderlineThickness() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return cm.underlineThickness;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final int hashCode() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return cm.hashCode();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final boolean equals(Object rhs) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return cm.equals(((FontLineMetrics)rhs).cm);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster catch (ClassCastException e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final Object clone() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // frc, cm do not need deep clone
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return super.clone();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster catch (CloneNotSupportedException e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw new InternalError();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster