0N/A/*
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A *
0N/A */
0N/A
0N/A/*
0N/A *
0N/A * (C) Copyright IBM Corp. 2003, All Rights Reserved
0N/A *
0N/A */
0N/A
0N/Apackage sun.font;
0N/A
0N/Aimport java.awt.font.LineMetrics;
0N/Aimport java.awt.font.GraphicAttribute;
0N/A
0N/Apublic final class CoreMetrics {
0N/A
0N/A public CoreMetrics(float ascent,
0N/A float descent,
0N/A float leading,
0N/A float height,
0N/A int baselineIndex,
0N/A float[] baselineOffsets,
0N/A float strikethroughOffset,
0N/A float strikethroughThickness,
0N/A float underlineOffset,
0N/A float underlineThickness,
0N/A float ssOffset,
0N/A float italicAngle) {
0N/A this.ascent = ascent;
0N/A this.descent = descent;
0N/A this.leading = leading;
0N/A this.height = height;
0N/A this.baselineIndex = baselineIndex;
0N/A this.baselineOffsets = baselineOffsets;
0N/A this.strikethroughOffset = strikethroughOffset;
0N/A this.strikethroughThickness = strikethroughThickness;
0N/A this.underlineOffset = underlineOffset;
0N/A this.underlineThickness = underlineThickness;
0N/A this.ssOffset = ssOffset;
0N/A this.italicAngle = italicAngle;
0N/A }
0N/A
0N/A public static CoreMetrics get(LineMetrics lm) {
0N/A return ((FontLineMetrics)lm).cm;
0N/A }
0N/A
0N/A public final int hashCode() {
0N/A return Float.floatToIntBits(ascent + ssOffset);
0N/A }
0N/A
0N/A public final boolean equals(Object rhs) {
0N/A try {
0N/A return equals((CoreMetrics)rhs);
0N/A }
0N/A catch(ClassCastException e) {
0N/A return false;
0N/A }
0N/A }
0N/A
0N/A public final boolean equals(CoreMetrics rhs) {
0N/A if (rhs != null) {
0N/A if (this == rhs) {
0N/A return true;
0N/A }
0N/A
0N/A return ascent == rhs.ascent
0N/A && descent == rhs.descent
0N/A && leading == rhs.leading
0N/A && baselineIndex == rhs.baselineIndex
0N/A && baselineOffsets[0] == rhs.baselineOffsets[0]
0N/A && baselineOffsets[1] == rhs.baselineOffsets[1]
0N/A && baselineOffsets[2] == rhs.baselineOffsets[2]
0N/A && strikethroughOffset == rhs.strikethroughOffset
0N/A && strikethroughThickness == rhs.strikethroughThickness
0N/A && underlineOffset == rhs.underlineOffset
0N/A && underlineThickness == rhs.underlineThickness
0N/A && ssOffset == rhs.ssOffset
0N/A && italicAngle == rhs.italicAngle;
0N/A }
0N/A return false;
0N/A }
0N/A
0N/A // fullOffsets is an array of 5 baseline offsets,
0N/A // roman, center, hanging, bottom, and top in that order
0N/A // this does NOT add the ssOffset
0N/A public final float effectiveBaselineOffset(float[] fullOffsets) {
0N/A switch (baselineIndex) {
0N/A case GraphicAttribute.TOP_ALIGNMENT:
0N/A return fullOffsets[4] + ascent;
0N/A case GraphicAttribute.BOTTOM_ALIGNMENT:
0N/A return fullOffsets[3] - descent;
0N/A default:
0N/A return fullOffsets[baselineIndex];
0N/A }
0N/A }
0N/A
0N/A public final float ascent;
0N/A public final float descent;
0N/A public final float leading;
0N/A public final float height;
0N/A public final int baselineIndex;
0N/A public final float[] baselineOffsets; // !! this is a hole, don't expose this class
0N/A public final float strikethroughOffset;
0N/A public final float strikethroughThickness;
0N/A public final float underlineOffset;
0N/A public final float underlineThickness;
0N/A public final float ssOffset;
0N/A public final float italicAngle;
0N/A}