1 18 package org.apache.batik.gvt.font; 19 20 import java.awt.font.LineMetrics ; 21 22 28 public class GVTLineMetrics { 29 30 protected float ascent; 31 protected int baselineIndex; 32 protected float[] baselineOffsets; 33 protected float descent; 34 protected float height; 35 protected float leading; 36 protected int numChars; 37 protected float strikethroughOffset; 38 protected float strikethroughThickness; 39 protected float underlineOffset; 40 protected float underlineThickness; 41 protected float overlineOffset; 42 protected float overlineThickness; 43 44 50 public GVTLineMetrics(LineMetrics lineMetrics) { 51 this.ascent = lineMetrics.getAscent(); 52 this.baselineIndex = lineMetrics.getBaselineIndex(); 53 this.baselineOffsets = lineMetrics.getBaselineOffsets(); 54 this.descent = lineMetrics.getDescent(); 55 this.height = lineMetrics.getHeight(); 56 this.leading = lineMetrics.getLeading(); 57 this.numChars = lineMetrics.getNumChars(); 58 this.strikethroughOffset = lineMetrics.getStrikethroughOffset(); 59 this.strikethroughThickness = lineMetrics.getStrikethroughThickness(); 60 this.underlineOffset = lineMetrics.getUnderlineOffset(); 61 this.underlineThickness = lineMetrics.getUnderlineThickness(); 62 this.overlineOffset = -this.ascent; 63 this.overlineThickness = this.underlineThickness; 64 } 65 66 67 75 public GVTLineMetrics(LineMetrics lineMetrics, float scaleFactor) { 76 this.ascent = lineMetrics.getAscent() * scaleFactor; 77 this.baselineIndex = lineMetrics.getBaselineIndex(); 78 this.baselineOffsets = lineMetrics.getBaselineOffsets(); 79 for (int i=0; i<baselineOffsets.length; i++) { 80 this.baselineOffsets[i] *= scaleFactor; 81 } 82 this.descent = lineMetrics.getDescent() * scaleFactor; 83 this.height = lineMetrics.getHeight() * scaleFactor; 84 this.leading = lineMetrics.getLeading(); 85 this.numChars = lineMetrics.getNumChars(); 86 this.strikethroughOffset = 87 lineMetrics.getStrikethroughOffset() * scaleFactor; 88 this.strikethroughThickness = 89 lineMetrics.getStrikethroughThickness() * scaleFactor; 90 this.underlineOffset = lineMetrics.getUnderlineOffset() * scaleFactor; 91 this.underlineThickness = 92 lineMetrics.getUnderlineThickness() * scaleFactor; 93 this.overlineOffset = -this.ascent; 94 this.overlineThickness = this.underlineThickness; 95 } 96 97 98 101 public GVTLineMetrics(float ascent, 102 int baselineIndex, 103 float[] baselineOffsets, 104 float descent, 105 float height, 106 float leading, int numChars, 107 float strikethroughOffset, 108 float strikethroughThickness, 109 float underlineOffset, 110 float underlineThickness, 111 float overlineOffset, 112 float overlineThickness) { 113 114 this.ascent = ascent; 115 this.baselineIndex = baselineIndex; 116 this.baselineOffsets = baselineOffsets; 117 this.descent = descent; 118 this.height = height; 119 this.leading = leading; 120 this.numChars = numChars; 121 this.strikethroughOffset = strikethroughOffset; 122 this.strikethroughThickness = strikethroughThickness; 123 this.underlineOffset = underlineOffset; 124 this.underlineThickness = underlineThickness; 125 this.overlineOffset = overlineOffset; 126 this.overlineThickness = overlineThickness; 127 } 128 129 132 public float getAscent() { 133 return ascent; 134 } 135 136 139 public int getBaselineIndex() { 140 return baselineIndex; 141 } 142 143 147 public float[] getBaselineOffsets() { 148 return baselineOffsets; 149 } 150 151 154 public float getDescent() { 155 return descent; 156 } 157 158 161 public float getHeight() { 162 return height; 163 } 164 165 168 public float getLeading() { 169 return leading; 170 } 171 172 176 public int getNumChars() { 177 return numChars; 178 } 179 180 183 public float getStrikethroughOffset() { 184 return strikethroughOffset; 185 } 186 187 190 public float getStrikethroughThickness() { 191 return strikethroughThickness; 192 } 193 194 197 public float getUnderlineOffset() { 198 return underlineOffset; 199 } 200 201 204 public float getUnderlineThickness() { 205 return underlineThickness; 206 } 207 208 211 public float getOverlineOffset() { 212 return overlineOffset; 213 } 214 215 218 public float getOverlineThickness() { 219 return overlineThickness; 220 } 221 222 } 223 | Popular Tags |