1 7 8 11 12 package java.awt.font; 13 14 import java.awt.Graphics2D ; 15 import java.awt.Font ; 16 import java.awt.Polygon ; import java.awt.Rectangle ; 18 import java.awt.geom.Point2D ; 19 import java.awt.geom.Rectangle2D ; 20 import java.awt.geom.AffineTransform ; 21 import java.awt.Shape ; 22 import java.awt.font.GlyphMetrics ; 23 import java.awt.font.GlyphJustificationInfo ; 24 25 91 92 public abstract class GlyphVector implements Cloneable { 93 94 98 105 public abstract Font getFont(); 106 107 115 public abstract FontRenderContext getFontRenderContext(); 116 117 121 126 public abstract void performDefaultLayout(); 127 128 132 public abstract int getNumGlyphs(); 133 134 148 public abstract int getGlyphCode(int glyphIndex); 149 150 172 public abstract int[] getGlyphCodes(int beginGlyphIndex, int numEntries, 173 int[] codeReturn); 174 175 185 public int getGlyphCharIndex(int glyphIndex) { 186 return glyphIndex; 187 } 188 189 205 public int[] getGlyphCharIndices(int beginGlyphIndex, int numEntries, 206 int[] codeReturn) { 207 if (codeReturn == null) { 208 codeReturn = new int[numEntries]; 209 } 210 for (int i = 0, j = beginGlyphIndex; i < numEntries; ++i, ++j) { 211 codeReturn[i] = getGlyphCharIndex(j); 212 } 213 return codeReturn; 214 } 215 216 223 public abstract Rectangle2D getLogicalBounds(); 224 225 234 public abstract Rectangle2D getVisualBounds(); 235 236 254 public Rectangle getPixelBounds(FontRenderContext renderFRC, float x, float y) { 255 Rectangle2D rect = getVisualBounds(); 256 int l = (int)Math.floor(rect.getX() + x); 257 int t = (int)Math.floor(rect.getY() + y); 258 int r = (int)Math.ceil(rect.getMaxX() + x); 259 int b = (int)Math.ceil(rect.getMaxY() + y); 260 return new Rectangle (l, t, r - l, b - t); 261 } 262 263 264 270 public abstract Shape getOutline(); 271 272 281 public abstract Shape getOutline(float x, float y); 282 283 297 public abstract Shape getGlyphOutline(int glyphIndex); 298 299 317 public Shape getGlyphOutline(int glyphIndex, float x, float y) { 318 Shape s = getGlyphOutline(glyphIndex); 319 AffineTransform at = AffineTransform.getTranslateInstance(x,y); 320 return at.createTransformedShape(s); 321 } 322 323 338 public abstract Point2D getGlyphPosition(int glyphIndex); 339 340 355 public abstract void setGlyphPosition(int glyphIndex, Point2D newPos); 356 357 371 public abstract AffineTransform getGlyphTransform(int glyphIndex); 372 373 388 public abstract void setGlyphTransform(int glyphIndex, AffineTransform newTX); 389 390 406 public int getLayoutFlags() { 407 return 0; 408 } 409 410 415 public static final int FLAG_HAS_TRANSFORMS = 1; 416 417 423 public static final int FLAG_HAS_POSITION_ADJUSTMENTS = 2; 424 425 432 public static final int FLAG_RUN_RTL = 4; 433 434 440 public static final int FLAG_COMPLEX_GLYPHS = 8; 441 442 447 public static final int FLAG_MASK = 448 FLAG_HAS_TRANSFORMS | 449 FLAG_HAS_POSITION_ADJUSTMENTS | 450 FLAG_RUN_RTL | 451 FLAG_COMPLEX_GLYPHS; 452 453 482 public abstract float[] getGlyphPositions(int beginGlyphIndex, int numEntries, 483 float[] positionReturn); 484 485 504 public abstract Shape getGlyphLogicalBounds(int glyphIndex); 505 506 521 public abstract Shape getGlyphVisualBounds(int glyphIndex); 522 523 540 public Rectangle getGlyphPixelBounds(int index, FontRenderContext renderFRC, float x, float y) { 541 Rectangle2D rect = getGlyphVisualBounds(index).getBounds2D(); 542 int l = (int)Math.floor(rect.getX() + x); 543 int t = (int)Math.floor(rect.getY() + y); 544 int r = (int)Math.ceil(rect.getMaxX() + x); 545 int b = (int)Math.ceil(rect.getMaxY() + y); 546 return new Rectangle (l, t, r - l, b - t); 547 } 548 549 561 public abstract GlyphMetrics getGlyphMetrics(int glyphIndex); 562 563 577 public abstract GlyphJustificationInfo getGlyphJustificationInfo(int glyphIndex); 578 579 583 591 public abstract boolean equals(GlyphVector set); 592 } 593 | Popular Tags |