1 7 8 22 23 package java.awt.font; 24 25 import java.awt.geom.Rectangle2D ; 26 import java.awt.Graphics2D ; 27 import java.awt.Font ; 28 29 44 public abstract class GraphicAttribute { 45 46 private int fAlignment; 47 48 51 public static final int TOP_ALIGNMENT = -1; 52 53 56 public static final int BOTTOM_ALIGNMENT = -2; 57 58 61 public static final int ROMAN_BASELINE = Font.ROMAN_BASELINE; 62 63 66 public static final int CENTER_BASELINE = Font.CENTER_BASELINE; 67 68 71 public static final int HANGING_BASELINE = Font.HANGING_BASELINE; 72 73 79 protected GraphicAttribute(int alignment) { 80 if (alignment < BOTTOM_ALIGNMENT || alignment > HANGING_BASELINE) { 81 throw new IllegalArgumentException ("bad alignment"); 82 } 83 fAlignment = alignment; 84 } 85 86 92 public abstract float getAscent(); 93 94 100 public abstract float getDescent(); 101 102 111 public abstract float getAdvance(); 112 113 124 public Rectangle2D getBounds() { 125 float ascent = getAscent(); 126 return new Rectangle2D.Float (0, -ascent, 127 getAdvance(), ascent+getDescent()); 128 } 129 130 138 public abstract void draw(Graphics2D graphics, float x, float y); 139 140 146 public final int getAlignment() { 147 148 return fAlignment; 149 } 150 151 159 public GlyphJustificationInfo getJustificationInfo() { 160 161 float advance = getAdvance(); 163 164 return new GlyphJustificationInfo ( 165 advance, false, 2, advance/3, advance/3, false, 1, 0, 0); } 175 } 176 | Popular Tags |