KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > jsf > el > TextGraphics2D


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.test.jsf.el;
21
22 import java.awt.Color JavaDoc;
23 import java.awt.Component JavaDoc;
24 import java.awt.Composite JavaDoc;
25 import java.awt.Font JavaDoc;
26 import java.awt.FontMetrics JavaDoc;
27 import java.awt.Graphics JavaDoc;
28 import java.awt.Graphics2D JavaDoc;
29 import java.awt.GraphicsConfiguration JavaDoc;
30 import java.awt.Image JavaDoc;
31 import java.awt.Paint JavaDoc;
32 import java.awt.Rectangle JavaDoc;
33 import java.awt.RenderingHints JavaDoc;
34 import java.awt.Shape JavaDoc;
35 import java.awt.Stroke JavaDoc;
36 import java.awt.font.FontRenderContext JavaDoc;
37 import java.awt.font.GlyphVector JavaDoc;
38 import java.awt.geom.AffineTransform JavaDoc;
39 import java.awt.image.BufferedImage JavaDoc;
40 import java.awt.image.BufferedImageOp JavaDoc;
41 import java.awt.image.ImageObserver JavaDoc;
42 import java.awt.image.RenderedImage JavaDoc;
43 import java.awt.image.renderable.RenderableImage JavaDoc;
44 import java.text.AttributedCharacterIterator JavaDoc;
45 import java.util.Map JavaDoc;
46
47
48 /** Renders all drawString(...) into StringBuffer.
49  *
50  * @author Martin.Schovanek@sun.com
51  */

52 public class TextGraphics2D extends Graphics2D JavaDoc {
53     StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
54     Component JavaDoc dummy;
55     Font JavaDoc font;
56     
57     /**
58      * Creates a new instance of TextGraphics2D
59      */

60     public TextGraphics2D(Component JavaDoc component) {
61         dummy = component;
62     }
63     
64     public TextGraphics2D() {
65         this(null);
66     }
67     
68     public String JavaDoc getText() {
69         return buf.toString();
70     }
71     
72     public String JavaDoc getTextUni() {
73         String JavaDoc str;
74         int start;
75         StringBuffer JavaDoc buf = new StringBuffer JavaDoc().append(this.buf);
76         while ((start=buf.indexOf(" ")) > -1) {
77             buf.deleteCharAt(start);
78         }
79         str = buf.toString();
80         // remove '...' ussually rendered when the left epression is too long
81
str = str.replaceAll("[.]{3} ?", "");
82         return str;
83     }
84     
85     public void clearRect(int param, int param1, int param2, int param3) {
86     }
87     
88     public void clipRect(int param, int param1, int param2, int param3) {
89     }
90     
91     public void copyArea(int param, int param1, int param2, int param3,
92             int param4, int param5) {
93     }
94     
95     public Graphics JavaDoc create() {
96         return new TextGraphics2D(dummy);
97     }
98     
99     public void dispose() {
100     }
101     
102     public void drawArc(int param, int param1, int param2, int param3,
103             int param4, int param5) {
104     }
105     
106     public boolean drawImage(Image JavaDoc image, int param, int param2,
107             ImageObserver JavaDoc imageObserver) {
108         return true;
109     }
110     
111     public boolean drawImage(Image JavaDoc image, int param, int param2, Color JavaDoc color,
112             ImageObserver JavaDoc imageObserver) {
113         return true;
114     }
115     
116     public boolean drawImage(Image JavaDoc image, int param, int param2, int param3,
117             int param4, ImageObserver JavaDoc imageObserver) {
118         return true;
119     }
120     
121     public boolean drawImage(Image JavaDoc image, int param, int param2, int param3,
122             int param4, Color JavaDoc color, ImageObserver JavaDoc imageObserver) {
123         return true;
124     }
125     
126     public boolean drawImage(Image JavaDoc image, int param, int param2, int param3,
127             int param4, int param5, int param6, int param7, int param8,
128             ImageObserver JavaDoc imageObserver) {
129         return true;
130     }
131     
132     public boolean drawImage(Image JavaDoc image, int param, int param2, int param3,
133             int param4, int param5, int param6, int param7, int param8,
134             Color JavaDoc color, ImageObserver JavaDoc imageObserver) {
135         return true;
136     }
137     
138     public void drawLine(int param, int param1, int param2, int param3) {
139     }
140     
141     public void drawOval(int param, int param1, int param2, int param3) {
142     }
143     
144     public void drawPolygon(int[] values, int[] values1, int param) {
145     }
146     
147     public void drawPolyline(int[] values, int[] values1, int param) {
148     }
149     
150     public void drawRoundRect(int param, int param1, int param2, int param3,
151             int param4, int param5) {
152     }
153     
154     public void drawString(String JavaDoc str, int x, int y) {
155         drawString(str, (float) x, (float) y);
156     }
157     
158     public void drawString(AttributedCharacterIterator JavaDoc iterator, int x, int y) {
159         drawString(iterator, (float) x, (float) y);
160     }
161     
162     public void fillArc(int param, int param1, int param2, int param3, int param4,
163             int param5) {
164     }
165     
166     public void fillOval(int param, int param1, int param2, int param3) {
167     }
168     
169     public void fillPolygon(int[] values, int[] values1, int param) {
170     }
171     
172     public void fillRect(int param, int param1, int param2, int param3) {
173     }
174     
175     public void fillRoundRect(int param, int param1, int param2, int param3,
176             int param4, int param5) {
177     }
178     
179     public Shape JavaDoc getClip() {
180         return null;
181     }
182     
183     public Rectangle JavaDoc getClipBounds() {
184         return null;
185     }
186     
187     public Color JavaDoc getColor() {
188         return null;
189     }
190     
191     public Font JavaDoc getFont() {
192         if(font != null) return font;
193         if (dummy == null) return null;
194         return dummy.getFont();
195     }
196     
197     public FontMetrics JavaDoc getFontMetrics(Font JavaDoc font) {
198         if (dummy == null) return null;
199         return dummy.getFontMetrics(dummy.getFont());
200     }
201     
202     public void setClip(Shape JavaDoc shape) {
203     }
204     
205     public void setClip(int param, int param1, int param2, int param3) {
206     }
207     
208     public void setColor(Color JavaDoc color) {
209     }
210     
211     public void setFont(Font JavaDoc font) {
212         this.font=font;
213     }
214     
215     public void setPaintMode() {
216     }
217     
218     public void setXORMode(Color JavaDoc color) {
219     }
220     
221     public void translate(int param, int param1) {
222     }
223     
224     public void addRenderingHints(Map JavaDoc map) {
225     }
226     
227     public void clip(Shape JavaDoc shape) {
228     }
229     
230     public void draw(Shape JavaDoc shape) {
231     }
232     
233     public void drawGlyphVector(GlyphVector JavaDoc glyphVector, float param,
234             float param2) {
235     }
236     
237     public boolean drawImage(Image JavaDoc image, AffineTransform JavaDoc affineTransform,
238             ImageObserver JavaDoc imageObserver) {
239         return true;
240     }
241     
242     public void drawImage(BufferedImage JavaDoc bufferedImage,
243             BufferedImageOp JavaDoc bufferedImageOp, int param, int param3) {
244     }
245     
246     public void drawRenderableImage(RenderableImage JavaDoc renderableImage,
247             AffineTransform JavaDoc affineTransform) {
248     }
249     
250     public void drawRenderedImage(RenderedImage JavaDoc renderedImage,
251             AffineTransform JavaDoc affineTransform) {
252     }
253     
254     public void drawString(String JavaDoc str, float x, float y) {
255         if (buf.length()>0 && buf.charAt(buf.length()-1) != ' ') {
256             buf.append(' ');
257         }
258         buf.append(str);
259     }
260     
261     public void drawString(AttributedCharacterIterator JavaDoc iterator,
262             float x, float y) {
263         if (buf.length()>0 && buf.charAt(buf.length()-1)!=' ') {
264             buf.append(' ');
265         }
266         for (char c=iterator.first(); c != iterator.DONE; c=iterator.next()) {
267             buf.append(c);
268         }
269     }
270     
271     public void fill(Shape JavaDoc shape) {
272     }
273     
274     public Color JavaDoc getBackground() {
275         if (dummy == null) return null;
276         return dummy.getBackground();
277     }
278     
279     public Composite JavaDoc getComposite() {
280         return null;
281     }
282     
283     public GraphicsConfiguration JavaDoc getDeviceConfiguration() {
284         return null;
285     }
286     
287     public FontRenderContext JavaDoc getFontRenderContext() {
288         if (dummy == null) return null;
289         return ((Graphics2D JavaDoc) dummy.getGraphics()).getFontRenderContext();
290     }
291     
292     public Paint JavaDoc getPaint() {
293         return null;
294     }
295     
296     public Object JavaDoc getRenderingHint(RenderingHints.Key JavaDoc key) {
297         return null;
298     }
299     
300     public RenderingHints JavaDoc getRenderingHints() {
301         return null;
302     }
303     
304     public Stroke JavaDoc getStroke() {
305         return null;
306     }
307     
308     public AffineTransform JavaDoc getTransform() {
309         return null;
310     }
311     
312     public boolean hit(Rectangle JavaDoc rectangle, Shape JavaDoc shape, boolean param) {
313         return true;
314     }
315     
316     public void rotate(double param) {
317     }
318     
319     public void rotate(double param, double param1, double param2) {
320     }
321     
322     public void scale(double param, double param1) {
323     }
324     
325     public void setBackground(Color JavaDoc color) {
326     }
327     
328     public void setComposite(Composite JavaDoc composite) {
329     }
330     
331     public void setPaint(Paint JavaDoc paint) {
332     }
333     
334     public void setRenderingHint(RenderingHints.Key JavaDoc key, Object JavaDoc obj) {
335     }
336     
337     public void setRenderingHints(Map JavaDoc map) {
338     }
339     
340     public void setStroke(Stroke JavaDoc stroke) {
341     }
342     
343     public void setTransform(AffineTransform JavaDoc affineTransform) {
344     }
345     
346     public void shear(double param, double param1) {
347     }
348     
349     public void transform(AffineTransform JavaDoc affineTransform) {
350     }
351     
352     public void translate(double param, double param1) {
353     }
354 }
355
Popular Tags