1 /*
   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 it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.  Oracle designates this
   7  * particular file as subject to the "Classpath" exception as provided
   8  * 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 WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 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 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 /*
  27  *
  28  * (C) Copyright IBM Corp. 2003, All Rights Reserved
  29  *
  30  */
  31 
  32 package sun.font;
  33 
  34 import java.awt.font.FontRenderContext;
  35 import java.awt.font.LineMetrics;
  36 
  37 /**
  38  * Metrics from a font for layout of characters along a line
  39  * and layout of set of lines.
  40  * This and CoreMetrics replace what was previously a private internal class of Font
  41  */
  42 public final class FontLineMetrics extends LineMetrics implements Cloneable {
  43     public int numchars; // mutated by Font
  44     public final CoreMetrics cm;
  45     public final FontRenderContext frc;
  46 
  47     public FontLineMetrics(int numchars, CoreMetrics cm, FontRenderContext frc) {
  48         this.numchars = numchars;
  49         this.cm = cm;
  50         this.frc = frc;
  51     }
  52 
  53     public int getNumChars() {
  54         return numchars;
  55     }
  56 
  57     public float getAscent() {
  58         return cm.ascent;
  59     }
  60 
  61     public float getDescent() {
  62         return cm.descent;
  63     }
  64 
  65     public float getLeading() {
  66         return cm.leading;
  67     }
  68 
  69     public float getHeight() {
  70         return cm.height;
  71     }
  72 
  73     public int getBaselineIndex() {
  74         return cm.baselineIndex;
  75     }
  76 
  77     public float[] getBaselineOffsets() {
  78         return cm.baselineOffsets.clone();
  79     }
  80 
  81     public float getStrikethroughOffset() {
  82         return cm.strikethroughOffset;
  83     }
  84 
  85     public float getStrikethroughThickness() {
  86         return cm.strikethroughThickness;
  87     }
  88 
  89     public float getUnderlineOffset() {
  90         return cm.underlineOffset;
  91     }
  92 
  93     public float getUnderlineThickness() {
  94         return cm.underlineThickness;
  95     }
  96 
  97     public int hashCode() {
  98         return cm.hashCode();
  99     }
 100 
 101     public boolean equals(Object rhs) {
 102         try {
 103             return cm.equals(((FontLineMetrics)rhs).cm);
 104         }
 105         catch (ClassCastException e) {
 106             return false;
 107         }
 108     }
 109 
 110     public Object clone() {
 111         // frc, cm do not need deep clone
 112         try {
 113             return super.clone();
 114         }
 115         catch (CloneNotSupportedException e) {
 116             throw new InternalError(e);
 117         }
 118     }
 119 }