KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > gvt > TextPainter


1 /*
2
3    Copyright 2000-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.gvt;
19
20 import java.awt.Graphics2D JavaDoc;
21 import java.awt.Shape JavaDoc;
22 import java.awt.geom.Rectangle2D JavaDoc;
23
24 import org.apache.batik.gvt.text.Mark;
25
26 /**
27  * Renders the attributed character iterator of a <tt>TextNode</tt>.
28  *
29  * @author <a HREF="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
30  * @version $Id: TextPainter.java,v 1.20 2005/03/27 08:58:34 cam Exp $
31  */

32 public interface TextPainter {
33
34     /**
35      * Paints the specified attributed character iterator using the specified
36      * Graphics2D and context and font context.
37      *
38      * @param node the TextNode to paint
39      * @param g2d the Graphics2D to use
40      */

41     void paint(TextNode node, Graphics2D JavaDoc g2d);
42
43     /**
44      * Initiates a text selection on a particular AttributedCharacterIterator,
45      * using the text/font metrics employed by this TextPainter instance.
46      */

47     Mark selectAt(double x, double y, TextNode node);
48
49     /**
50      * Continues a text selection on a particular AttributedCharacterIterator,
51      * using the text/font metrics employed by this TextPainter instance.
52      */

53     Mark selectTo(double x, double y, Mark beginMark);
54
55     /**
56      * Selects the first glyph in the text node.
57      */

58     Mark selectFirst(TextNode node);
59
60
61     /**
62      * Selects the last glyph in the text node.
63      */

64     Mark selectLast(TextNode node);
65
66     /**
67      * Returns a mark for the char at index in node's
68      * AttributedCharacterIterator. Leading edge indicates if the
69      * mark should be considered immediately 'before' glyph or
70      * after
71      */

72      Mark getMark(TextNode node, int index, boolean beforeGlyph);
73
74     /**
75      * Get an array of index pairs corresponding to the indices within an
76      * AttributedCharacterIterator regions bounded by two Marks.
77      *
78      * Note that the instances of Mark passed to this function <em>must
79      * come</em> from the same TextPainter that generated them via selectAt()
80      * and selectTo(), since the TextPainter implementation may rely on hidden
81      * implementation details of its own Mark implementation. */

82     int[] getSelected(Mark start, Mark finish);
83     
84
85     /**
86      * Get a Shape in userspace coords which encloses the textnode
87      * glyphs bounded by two Marks.
88      * Note that the instances of Mark passed to this function
89      * <em>must come</em>
90      * from the same TextPainter that generated them via selectAt() and
91      * selectTo(), since the TextPainter implementation may rely on hidden
92      * implementation details of its own Mark implementation.
93      */

94     Shape JavaDoc getHighlightShape(Mark beginMark, Mark endMark);
95
96     /**
97      * Get a Shape in userspace coords which defines the textnode
98      * glyph outlines.
99      * @param node the TextNode to measure
100      */

101     Shape JavaDoc getOutline(TextNode node);
102
103     /**
104      * Get a Rectangle2D in userspace coords which encloses the textnode
105      * glyphs rendered bounds (includes stroke etc).
106      * @param node the TextNode to measure
107      */

108     Rectangle2D JavaDoc getBounds2D(TextNode node);
109
110     /**
111      * Get a Rectangle2D in userspace coords which encloses the textnode
112      * glyphs just including the geometry info.
113      * @param node the TextNode to measure
114      */

115     Rectangle2D JavaDoc getGeometryBounds(TextNode node);
116 }
117
118
Popular Tags