KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Copyright 2000-2001,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.AffineTransform JavaDoc;
23 import java.awt.geom.Rectangle2D JavaDoc;
24
25 /**
26  * A graphics node which provides a placeholder for another graphics node. This
27  * node is self defined except that it delegates to the enclosed (proxied)
28  * graphics node, its paint routine and bounds computation.
29  *
30  * @author <a HREF="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
31  * @version $Id: ProxyGraphicsNode.java,v 1.12 2005/03/27 08:58:34 cam Exp $
32  */

33 public class ProxyGraphicsNode extends AbstractGraphicsNode {
34
35     /**
36      * The graphics node to proxy.
37      */

38     protected GraphicsNode source;
39
40     /**
41      * Constructs a new empty proxy graphics node.
42      */

43     public ProxyGraphicsNode() {}
44
45     /**
46      * Sets the graphics node to proxy to the specified graphics node.
47      *
48      * @param source the graphics node to proxy
49      */

50     public void setSource(GraphicsNode source) {
51         this.source = source;
52     }
53
54     /**
55      * Returns the proxied graphics node.
56      */

57     public GraphicsNode getSource() {
58         return source;
59     }
60
61     /**
62      * Paints this node without applying Filter, Mask, Composite and clip.
63      *
64      * @param g2d the Graphics2D to use
65      */

66     public void primitivePaint(Graphics2D JavaDoc g2d) {
67         if (source != null) {
68             source.paint(g2d);
69         }
70     }
71
72     /**
73      * Returns the bounds of the area covered by this node's primitive paint.
74      */

75     public Rectangle2D JavaDoc getPrimitiveBounds() {
76         if (source == null)
77             return null;
78
79         return source.getBounds();
80     }
81
82     /**
83      * Returns the bounds of this node's primitivePaint after applying
84      * the input transform (if any), concatenated with this node's
85      * transform (if any).
86      *
87      * @param txf the affine transform with which this node's transform should
88      * be concatenated. Should not be null. */

89     public Rectangle2D JavaDoc getTransformedPrimitiveBounds(AffineTransform JavaDoc txf) {
90         if (source == null)
91             return null;
92
93         AffineTransform JavaDoc t = txf;
94         if (transform != null) {
95             t = new AffineTransform JavaDoc(txf);
96             t.concatenate(transform);
97         }
98         return source.getTransformedPrimitiveBounds(t);
99     }
100
101     /**
102      * Returns the bounds of the area covered by this node, without
103      * taking any of its rendering attribute into account. That is,
104      * exclusive of any clipping, masking, filtering or stroking, for
105      * example.
106      */

107     public Rectangle2D JavaDoc getGeometryBounds() {
108         if (source == null)
109             return null;
110
111         return source.getGeometryBounds();
112     }
113
114     /**
115      * Returns the bounds of the sensitive area covered by this node,
116      * This includes the stroked area but does not include the effects
117      * of clipping, masking or filtering. The returned value is
118      * transformed by the concatenation of the input transform and
119      * this node's transform.
120      *
121      * @param txf the affine transform with which this node's
122      * transform should be concatenated. Should not be null.
123      */

124     public Rectangle2D JavaDoc getTransformedGeometryBounds(AffineTransform JavaDoc txf) {
125         if (source == null)
126             return null;
127
128         AffineTransform JavaDoc t = txf;
129         if (transform != null) {
130             t = new AffineTransform JavaDoc(txf);
131             t.concatenate(transform);
132         }
133         return source.getTransformedGeometryBounds(t);
134     }
135
136
137     /**
138      * Returns the bounds of the sensitive area covered by this node,
139      * This includes the stroked area but does not include the effects
140      * of clipping, masking or filtering.
141      */

142     public Rectangle2D JavaDoc getSensitiveBounds() {
143         if (source == null)
144             return null;
145
146         return source.getSensitiveBounds();
147     }
148
149     /**
150      * Returns the outline of this node.
151      */

152     public Shape JavaDoc getOutline() {
153         if (source == null)
154             return null;
155
156         return source.getOutline();
157     }
158 }
159
Popular Tags