42 * Since the JDK is backward compatible with
43 * JDK1.1 API, this class will also function on
44 * Java 2. The JDK introduces improved
45 * API for rendering text however, so the GlyphPainter2
46 * is recommended for the DK.
47 *
48 * @author Timothy Prinzing
49 * @see GlyphView
50 */
51 class GlyphPainter1 extends GlyphView.GlyphPainter {
52
53 /**
54 * Determine the span the glyphs given a start location
55 * (for tab expansion).
56 */
57 public float getSpan(GlyphView v, int p0, int p1,
58 TabExpander e, float x) {
59 sync(v);
60 Segment text = v.getText(p0, p1);
61 int[] justificationData = getJustificationData(v);
62 int width = Utilities.getTabbedTextWidth(v, text, metrics, (int) x, e, p0,
63 justificationData);
64 SegmentCache.releaseSharedSegment(text);
65 return width;
66 }
67
68 public float getHeight(GlyphView v) {
69 sync(v);
70 return metrics.getHeight();
71 }
72
73 /**
74 * Fetches the ascent above the baseline for the glyphs
75 * corresponding to the given range in the model.
76 */
77 public float getAscent(GlyphView v) {
78 sync(v);
79 return metrics.getAscent();
80 }
81
82 /**
|
42 * Since the JDK is backward compatible with
43 * JDK1.1 API, this class will also function on
44 * Java 2. The JDK introduces improved
45 * API for rendering text however, so the GlyphPainter2
46 * is recommended for the DK.
47 *
48 * @author Timothy Prinzing
49 * @see GlyphView
50 */
51 class GlyphPainter1 extends GlyphView.GlyphPainter {
52
53 /**
54 * Determine the span the glyphs given a start location
55 * (for tab expansion).
56 */
57 public float getSpan(GlyphView v, int p0, int p1,
58 TabExpander e, float x) {
59 sync(v);
60 Segment text = v.getText(p0, p1);
61 int[] justificationData = getJustificationData(v);
62
63 Component comp = v.getContainer();
64 FontMetrics metrics1 = comp.getFontMetrics(comp.getFont());
65
66 float width = Utilities.getTabbedTextWidth(v, text, metrics1, x, e, p0,
67 justificationData);
68 SegmentCache.releaseSharedSegment(text);
69 return width;
70 }
71
72 public float getHeight(GlyphView v) {
73 sync(v);
74 return metrics.getHeight();
75 }
76
77 /**
78 * Fetches the ascent above the baseline for the glyphs
79 * corresponding to the given range in the model.
80 */
81 public float getAscent(GlyphView v) {
82 sync(v);
83 return metrics.getAscent();
84 }
85
86 /**
|