1 19 20 package swingwt.awt.font; 21 22 import swingwt.awt.*; 23 import swingwt.awt.geom.*; 24 25 public abstract class GlyphVector implements Cloneable { 26 27 public static final int FLAG_HAS_TRANSFORMS = 1; 28 public static final int FLAG_HAS_POSITION_ADJUSTMENTS = 2; 29 public static final int FLAG_RUN_RTL = 4; 30 public static final int FLAG_COMPLEX_GLYPHS = 8; 31 public static final int FLAG_MASK = 32 FLAG_HAS_TRANSFORMS | 33 FLAG_HAS_POSITION_ADJUSTMENTS | 34 FLAG_RUN_RTL | 35 FLAG_COMPLEX_GLYPHS; 36 37 public abstract Font getFont(); 38 public abstract FontRenderContext getFontRenderContext(); 39 public abstract void performDefaultLayout(); 40 public abstract int getNumGlyphs(); 41 public abstract int getGlyphCode(int glyphIndex); 42 public abstract int[] getGlyphCodes(int beginGlyphIndex, int numEntries, 43 int[] codeReturn); 44 45 public int getGlyphCharIndex(int glyphIndex) { 46 return glyphIndex; 47 } 48 public int[] getGlyphCharIndices(int beginGlyphIndex, int numEntries, 49 int[] codeReturn) { 50 if (codeReturn == null) { 51 codeReturn = new int[numEntries]; 52 } 53 for (int i = 0, j = beginGlyphIndex; i < numEntries; ++i, ++j) { 54 codeReturn[i] = getGlyphCharIndex(j); 55 } 56 return codeReturn; 57 } 58 public abstract Rectangle2D getLogicalBounds(); 59 public abstract Rectangle2D getVisualBounds(); 60 public Rectangle getPixelBounds(FontRenderContext renderFRC, float x, float y) { 61 Rectangle2D rect = getVisualBounds(); 62 int l = (int)Math.floor(rect.getX() + x); 63 int t = (int)Math.floor(rect.getY() + y); 64 int r = (int)Math.ceil(rect.getMaxX() + x); 65 int b = (int)Math.ceil(rect.getMaxY() + y); 66 return new Rectangle(l, t, r - l, b - t); 67 } 68 69 public abstract Shape getOutline(); 70 public abstract Shape getOutline(float x, float y); 71 public abstract Shape getGlyphOutline(int glyphIndex); 72 public Shape getGlyphOutline(int glyphIndex, float x, float y) { 73 Shape s = getGlyphOutline(glyphIndex); 74 AffineTransform at = AffineTransform.getTranslateInstance(x,y); 75 return at.createTransformedShape(s); 76 } 77 public abstract Point2D getGlyphPosition(int glyphIndex); 78 public abstract void setGlyphPosition(int glyphIndex, Point2D newPos); 79 public abstract AffineTransform getGlyphTransform(int glyphIndex); 80 public abstract void setGlyphTransform(int glyphIndex, AffineTransform newTX); 81 public int getLayoutFlags() { 82 return 0; 83 } 84 85 public abstract float[] getGlyphPositions(int beginGlyphIndex, int numEntries, 86 float[] positionReturn); 87 public abstract Shape getGlyphLogicalBounds(int glyphIndex); 88 public abstract Shape getGlyphVisualBounds(int glyphIndex); 89 public Rectangle getGlyphPixelBounds(int index, FontRenderContext renderFRC, float x, float y) { 90 Rectangle2D rect = getGlyphVisualBounds(index).getBounds2D(); 91 int l = (int)Math.floor(rect.getX() + x); 92 int t = (int)Math.floor(rect.getY() + y); 93 int r = (int)Math.ceil(rect.getMaxX() + x); 94 int b = (int)Math.ceil(rect.getMaxY() + y); 95 return new Rectangle(l, t, r - l, b - t); 96 } 97 public abstract GlyphMetrics getGlyphMetrics(int glyphIndex); 98 public abstract GlyphJustificationInfo getGlyphJustificationInfo(int glyphIndex); 99 public abstract boolean equals(GlyphVector set); 100 } 101 102 | Popular Tags |