KickJava   Java API By Example, From Geeks To Geeks.

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


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.Composite JavaDoc;
21 import java.awt.Graphics2D JavaDoc;
22 import java.awt.RenderingHints JavaDoc;
23 import java.awt.Shape JavaDoc;
24 import java.awt.geom.AffineTransform JavaDoc;
25 import java.awt.geom.Point2D JavaDoc;
26 import java.awt.geom.Rectangle2D JavaDoc;
27 import java.lang.ref.WeakReference JavaDoc;
28 import java.util.Map JavaDoc;
29
30 import org.apache.batik.ext.awt.image.renderable.ClipRable;
31 import org.apache.batik.ext.awt.image.renderable.Filter;
32 import org.apache.batik.gvt.filter.Mask;
33
34 /**
35  * The base class for all graphics nodes. A GraphicsNode encapsulates
36  * graphical attributes and can perform atomic operations of a complex
37  * rendering.
38  *
39  * @author <a HREF="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
40  * @author <a HREF="mailto:etissandier@ilog.fr">Emmanuel Tissandier</a>
41  * @version $Id: GraphicsNode.java,v 1.39 2005/03/27 08:58:34 cam Exp $
42  */

43 public interface GraphicsNode {
44
45     /**
46      * Indicates that this graphics node can be the target for events when it
47      * is visible and when the mouse is over the "painted" area.
48      */

49     public static final int VISIBLE_PAINTED = 0;
50
51     /**
52      * Indicates that this graphics node can be the target for events when it
53      * is visible and when the mouse is over the filled area if any.
54      */

55     public static final int VISIBLE_FILL = 1;
56
57     /**
58      * Indicates that this graphics node can be the target for events when it
59      * is visible and when the mouse is over the stroked area if any.
60      */

61     public static final int VISIBLE_STROKE = 2;
62
63     /**
64      * Indicates that this graphics node can be the target for events when it
65      * is visible and whatever is the filled and stroked area.
66      */

67     public static final int VISIBLE = 3;
68
69     /**
70      * Indicates that this graphics node can be the target for events when the
71      * mouse is over the painted area whatever or not it is the visible.
72      */

73     public static final int PAINTED = 4;
74
75     /**
76      * Indicates that this graphics node can be the target for events when the
77      * mouse is over the filled area whatever or not it is the visible.
78      */

79     public static final int FILL = 5;
80
81     /**
82      * Indicates that this graphics node can be the target for events when the
83      * mouse is over the stroked area whatever or not it is the visible.
84      */

85     public static final int STROKE = 6;
86
87     /**
88      * Indicates that this graphics node can be the target for events if any
89      * cases.
90      */

91     public static final int ALL = 7;
92
93     /**
94      * Indicates that this graphics node can not be the target for events.
95      */

96     public static final int NONE = 8;
97
98     /**
99      * The identity affine transform matrix used to draw renderable images.
100      */

101     public static final AffineTransform JavaDoc IDENTITY = new AffineTransform JavaDoc();
102
103     /**
104      * Returns a canonical WeakReference to this GraphicsNode.
105      * This is suitable for use as a key value in a hash map
106      */

107     WeakReference JavaDoc getWeakReference();
108
109     //
110
// Properties methods
111
//
112

113     /**
114      * Returns the type that describes how this graphics node reacts to events.
115      *
116      * @return VISIBLE_PAINTED | VISIBLE_FILL | VISIBLE_STROKE | VISIBLE |
117      * PAINTED | FILL | STROKE | ALL | NONE
118      */

119     int getPointerEventType();
120
121     /**
122      * Sets the type that describes how this graphics node reacts to events.
123      *
124      * @param pointerEventType VISIBLE_PAINTED | VISIBLE_FILL | VISIBLE_STROKE |
125      * VISIBLE | PAINTED | FILL | STROKE | ALL | NONE
126      */

127     void setPointerEventType(int pointerEventType);
128
129     /**
130      * Sets the transform of this node.
131      *
132      * @param newTransform the new transform of this node
133      */

134     void setTransform(AffineTransform JavaDoc newTransform);
135
136     /**
137      * Returns the transform of this node or null if any.
138      */

139     AffineTransform JavaDoc getTransform();
140
141     /**
142      * Returns the inverse transform for this node.
143      */

144     AffineTransform JavaDoc getInverseTransform();
145
146     /**
147      * Returns the concatenated transform of this node. That is, this
148      * node's transform preconcatenated with it's parent's transforms.
149      */

150     AffineTransform JavaDoc getGlobalTransform();
151
152     /**
153      * Sets the composite of this node.
154      *
155      * @param newComposite the composite of this node
156      */

157     void setComposite(Composite JavaDoc newComposite);
158
159     /**
160      * Returns the composite of this node or null if any.
161      */

162     Composite JavaDoc getComposite();
163
164     /**
165      * Sets if this node is visible or not depending on the specified value.
166      *
167      * @param isVisible If true this node is visible
168      */

169     void setVisible(boolean isVisible);
170
171     /**
172      * Returns true if this node is visible, false otherwise.
173      */

174     boolean isVisible();
175
176     /**
177      * Sets the clipping filter of this node.
178      *
179      * @param newClipper the new clipping filter of this node
180      */

181     void setClip(ClipRable newClipper);
182
183     /**
184      * Returns the clipping filter of this node or null if any.
185      */

186     ClipRable getClip();
187
188     /**
189      * Maps the specified key to the specified value in the rendering hints of
190      * this node.
191      *
192      * @param key the key of the hint to be set
193      * @param value the value indicating preferences for the specified
194      * hint category.
195      */

196     void setRenderingHint(RenderingHints.Key JavaDoc key, Object JavaDoc value);
197
198     /**
199      * Copies all of the mappings from the specified Map to the
200      * rendering hints of this node.
201      *
202      * @param hints the rendering hints to be set
203      */

204     void setRenderingHints(Map JavaDoc hints);
205
206     /**
207      * Sets the rendering hints of this node.
208      *
209      * @param newHints the new rendering hints of this node
210      */

211     void setRenderingHints(RenderingHints JavaDoc newHints);
212
213     /**
214      * Returns the rendering hints of this node or null if any.
215      */

216     RenderingHints JavaDoc getRenderingHints();
217
218     /**
219      * Sets the mask of this node.
220      *
221      * @param newMask the new mask of this node
222      */

223     void setMask(Mask newMask);
224
225     /**
226      * Returns the mask of this node or null if any.
227      */

228     Mask getMask();
229
230     /**
231      * Sets the filter of this node.
232      *
233      * @param newFilter the new filter of this node
234      */

235     void setFilter(Filter newFilter);
236
237     /**
238      * Returns the filter of this node or null if any.
239      */

240     Filter getFilter();
241
242     /**
243      * Returns the GraphicsNodeRable for this node. This
244      * GraphicsNodeRable is the Renderable (Filter) before any of the
245      * filter operations have been applied.
246      */

247     Filter getGraphicsNodeRable(boolean createIfNeeded);
248
249     /**
250      * Returns the GraphicsNodeRable for this node. This
251      * GraphicsNodeRable is the Renderable (Filter) after all of the
252      * filter operations have been applied.
253      */

254     Filter getEnableBackgroundGraphicsNodeRable(boolean createIfNeeded);
255
256     //
257
// Drawing methods
258
//
259

260     /**
261      * Paints this node.
262      *
263      * @param g2d the Graphics2D to use
264      */

265     void paint(Graphics2D JavaDoc g2d);
266
267     /**
268      * Paints this node without applying Filter, Mask, Composite, and clip.
269      *
270      * @param g2d the Graphics2D to use
271      */

272     void primitivePaint(Graphics2D JavaDoc g2d);
273
274     //
275
// Event support methods
276
//
277

278     /**
279      * Dispatches the specified event to the interested registered listeners.
280      * @param evt the event to dispatch
281      */

282     // void dispatchEvent(GraphicsNodeEvent evt);
283

284     /**
285      * Adds the specified graphics node mouse listener to receive graphics node
286      * mouse events from this node.
287      *
288      * @param l the graphics node mouse listener to add
289      */

290     // void addGraphicsNodeMouseListener(GraphicsNodeMouseListener l);
291

292     /**
293      * Removes the specified graphics node mouse listener so that it no longer
294      * receives graphics node mouse events from this node.
295      *
296      * @param l the graphics node mouse listener to remove
297      */

298     // void removeGraphicsNodeMouseListener(GraphicsNodeMouseListener l);
299

300     /**
301      * Adds the specified graphics node key listener to receive graphics node
302      * key events from this node.
303      *
304      * @param l the graphics node key listener to add
305      */

306     // void addGraphicsNodeKeyListener(GraphicsNodeKeyListener l);
307

308     /**
309      * Removes the specified graphics node key listener so that it no longer
310      * receives graphics node key events from this node.
311      *
312      * @param l the graphics node key listener to remove
313      */

314     // void removeGraphicsNodeKeyListener(GraphicsNodeKeyListener l);
315

316     /**
317      * Dispatches a graphics node mouse event to this node or one of its child.
318      *
319      * @param evt the evt to dispatch
320      */

321     // void processMouseEvent(GraphicsNodeMouseEvent evt);
322

323     /**
324      * Dispatches a graphics node key event to this node or one of its child.
325      *
326      * @param evt the evt to dispatch
327      */

328     // void processKeyEvent(GraphicsNodeKeyEvent evt);
329

330     /**
331      * Returns an array of listeners that were added to this node and of the
332      * specified type.
333      *
334      * @param listenerType the type of the listeners to return
335      */

336     // EventListener [] getListeners(Class listenerType);
337

338     //
339
// Structural methods
340
//
341

342     /**
343      * Returns the parent of this node or null if any.
344      */

345     CompositeGraphicsNode getParent();
346
347     /**
348      * Returns the root of the GVT tree or null if the node is not part of a GVT
349      * tree.
350      */

351     RootGraphicsNode getRoot();
352
353     //
354
// Geometric methods
355
//
356

357     /**
358      * Returns the bounds of this node in user space. This includes primitive
359      * paint, filtering, clipping and masking.
360      */

361     Rectangle2D JavaDoc getBounds();
362
363     /**
364      * Returns the bounds of this node after applying the input transform
365      * (if any), concatenated with this node's transform (if any).
366      *
367      * @param txf the affine transform with which this node's transform should
368      * be concatenated. Should not be null.
369      */

370     Rectangle2D JavaDoc getTransformedBounds(AffineTransform JavaDoc txf);
371
372     /**
373      * Returns the bounds of the area covered by this node's primitive
374      * paint. This is the painted region of fill and stroke but does
375      * not account for clipping, masking or filtering.
376      */

377     Rectangle2D JavaDoc getPrimitiveBounds();
378
379     /**
380      * Returns the bounds of this node's primitivePaint after applying
381      * the input transform (if any), concatenated with this node's
382      * transform (if any).
383      *
384      * @param txf the affine transform with which this node's transform should
385      * be concatenated. Should not be null.
386      */

387     Rectangle2D JavaDoc getTransformedPrimitiveBounds(AffineTransform JavaDoc txf);
388
389     /**
390      * Returns the bounds of the area covered by this node, without
391      * taking any of its rendering attribute into account. That is,
392      * exclusive of any clipping, masking, filtering or stroking, for
393      * example.
394      */

395     Rectangle2D JavaDoc getGeometryBounds();
396
397     /**
398      * Returns the bounds of the area covered by this node, without
399      * taking any of its rendering attribute into accoun. That is,
400      * exclusive of any clipping, masking, filtering or stroking, for
401      * example. The returned value is transformed by the concatenation
402      * of the input transform and this node's transform.
403      *
404      * @param txf the affine transform with which this node's transform should
405      * be concatenated. Should not be null.
406      */

407     Rectangle2D JavaDoc getTransformedGeometryBounds(AffineTransform JavaDoc txf);
408
409     /**
410      * Returns the bounds of the sensitive area covered by this node,
411      * This includes the stroked area but does not include the effects
412      * of clipping, masking or filtering.
413      */

414     Rectangle2D JavaDoc getSensitiveBounds();
415
416     /**
417      * Returns the bounds of the sensitive area covered by this node,
418      * This includes the stroked area but does not include the effects
419      * of clipping, masking or filtering. The returned value is
420      * transformed by the concatenation of the input transform and
421      * this node's transform.
422      *
423      * @param txf the affine transform with which this node's
424      * transform should be concatenated. Should not be null.
425      */

426     Rectangle2D JavaDoc getTransformedSensitiveBounds(AffineTransform JavaDoc txf);
427
428     /**
429      * Returns true if the specified Point2D is inside the boundary of this
430      * node, false otherwise.
431      *
432      * @param p the specified Point2D in the user space
433      */

434     boolean contains(Point2D JavaDoc p);
435
436     /**
437      * Returns true if the interior of this node intersects the interior of a
438      * specified Rectangle2D, false otherwise.
439      *
440      * @param r the specified Rectangle2D in the user node space
441      */

442     boolean intersects(Rectangle2D JavaDoc r);
443
444     /**
445      * Returns the GraphicsNode containing point p if this node or one of its
446      * children is sensitive to mouse events at p.
447      *
448      * @param p the specified Point2D in the user space
449      */

450     GraphicsNode nodeHitAt(Point2D JavaDoc p);
451
452     /**
453      * Returns the outline of this node.
454      */

455     Shape JavaDoc getOutline();
456 }
457
Popular Tags