1 // Copyright 2004-2005, FreeHEP
2 package hep.wired.heprep.util;
3
4 import java.awt.*;
5 import java.awt.font.*;
6 import java.awt.geom.*;
7 import java.awt.image.*;
8 import java.io.*;
9 import java.text.*;
10 import java.util.*;
11
12 import org.freehep.graphics2d.VectorGraphics;
13 import org.freehep.graphics2d.TagString;
14 import org.freehep.graphicsio.AbstractVectorGraphicsIO;
15
16 /***
17 * Empty Graphics2D class to draw objects into to see if all other drawing
18 * mechanisms work.
19 *
20 * FIXME WIRED-251 should maybe move to FreeHEP...
21 *
22 * @author Mark Donszelmann
23 * @version $Id: NullGraphics2D.java 653 2005-03-01 01:12:16Z duns $
24 */
25 public class NullGraphics2D
26 extends AbstractVectorGraphicsIO {
27 /*================================================================================
28 * Table of Contents:
29 * ------------------
30 * 1. Constructors & Factory Methods
31 * 2. Document Settings
32 * 3. Header, Trailer, Multipage & Comments
33 * 3.1 Header & Trailer
34 * 3.2 MultipageDocument methods
35 * 4. Create & Dispose
36 * 5. Drawing Methods
37 * 5.1. shapes (draw/fill)
38 * 5.1.1. lines, rectangles, round rectangles
39 * 5.1.2. polylines, polygons
40 * 5.1.3. ovals, arcs
41 * 5.1.4. shapes
42 * 5.2. Images
43 * 5.3. Strings
44 * 6. Transformations
45 * 7. Clipping
46 * 8. Graphics State / Settings
47 * 8.1. stroke/linewidth
48 * 8.2. paint/color
49 * 8.3. font
50 * 8.4. rendering hints
51 * 9. Auxiliary
52 * 10. Private/Utility Methos
53 *================================================================================*/
54
55 /*================================================================================
56 * 1. Constructors & Factory Methods
57 *================================================================================*/
58 /***
59 * Creates a null graphics context with dimension 800x600.
60 */
61 public NullGraphics2D() {
62 super(new Dimension(800,600), true);
63 // Create a graphics context with given imageBounds.
64 // This constructor is used by the user to create the initial graphics context.
65 // doRestoreOnDispose is used to call writeGraphicsRestore(),
66 // when the graphics context is being disposed off.
67 }
68
69 /***
70 * Creates a sub context.
71 */
72 protected NullGraphics2D(NullGraphics2D graphics, boolean doRestoreOnDispose) {
73 super(graphics, doRestoreOnDispose);
74 // Create a graphics context from a given graphics context.
75 // This constructor is used by the system to clone a given graphics context.
76 // doRestoreOnDispose is used to call writeGraphicsRestore(),
77 // when the graphics context is being disposed off.
78 }
79
80 /*================================================================================
81 | 2. Document Settings
82 *================================================================================*/
83
84 /*================================================================================
85 | 3. Header, Trailer, Multipage & Comments
86 *================================================================================*/
87 /* 3.1 Header & Trailer */
88 public void writeHeader() throws IOException {
89 }
90
91 public void writeBackground() throws IOException {
92 }
93
94 public void writeTrailer() throws IOException {
95 }
96
97 public void closeStream() throws IOException {
98 }
99
100 /* 3.2 MultipageDocument methods */
101
102 /*================================================================================
103 * 4. Create & Dispose
104 *================================================================================*/
105
106 public Graphics create() {
107 // Create a new graphics context from the current one.
108 try {
109 // Save the current context for restore later.
110 writeGraphicsSave();
111 } catch (IOException e) {
112 }
113 // The correct graphics context should be created.
114 return new NullGraphics2D(this, true);
115 }
116
117 public Graphics create(double x, double y, double width, double height) {
118 // Create a new graphics context from the current one.
119 try {
120 // Save the current context for restore later.
121 writeGraphicsSave();
122 } catch (IOException e) {
123 }
124 // The correct graphics context should be created.
125 VectorGraphics graphics = new NullGraphics2D(this, false);
126 graphics.clipRect(x, y, width, height);
127 return graphics;
128 }
129
130 protected void writeGraphicsSave() throws IOException {
131 }
132
133 protected void writeGraphicsRestore() throws IOException {
134 }
135
136 /*================================================================================
137 | 5. Drawing Methods
138 *================================================================================*/
139 /* 5.1.4. shapes */
140
141 public void draw(Shape shape) {
142 }
143
144 public void fill(Shape shape) {
145 }
146
147 public void fillAndDraw(Shape shape, Color fillColor) {
148 }
149
150 /* 5.2. Images */
151 public void copyArea(int x, int y, int width, int height, int dx, int dy) {
152 }
153
154 protected void writeImage(RenderedImage image, AffineTransform xform, Color bkg) throws IOException {
155 }
156
157 /* 5.3. Strings */
158 protected void writeString(String string, double x, double y) throws IOException {
159 }
160
161 public void drawString(AttributedCharacterIterator iterator, float x, float y) {
162 }
163
164 public void drawGlyphVector(GlyphVector g, float x, float y) {
165 }
166
167 /*================================================================================
168 | 6. Transformations
169 *================================================================================*/
170 protected void writeTransform(AffineTransform t) throws IOException {
171 }
172
173 /*================================================================================
174 | 7. Clipping
175 *================================================================================*/
176 protected void writeClip(Rectangle2D r2d) throws IOException {
177 }
178
179 protected void writeClip(Shape s) throws IOException {
180 }
181
182 /*================================================================================
183 | 8. Graphics State
184 *================================================================================*/
185 /* 8.1. stroke/linewidth */
186 protected void writeWidth(float width) throws IOException {
187 }
188
189 protected void writeCap(int cap) throws IOException {
190 }
191
192 protected void writeJoin(int join) throws IOException {
193 }
194
195 protected void writeMiterLimit(float limit) throws IOException {
196 }
197
198 protected void writeDash(double[] dash, double phase) throws IOException {
199 }
200
201 /* 8.2. paint/color */
202 public void setPaintMode() {
203 }
204
205 public void setXORMode(Color c1) {
206 }
207
208 protected void writePaint(Color p) throws IOException {
209 }
210
211 protected void writePaint(GradientPaint p) throws IOException {
212 }
213
214 protected void writePaint(TexturePaint p) throws IOException {
215 }
216
217 protected void writePaint(Paint p) throws IOException {
218 }
219
220 /* 8.3. font */
221 /* 8.4. rendering hints */
222
223 /*================================================================================
224 | 9. Auxiliary
225 *================================================================================*/
226 public GraphicsConfiguration getDeviceConfiguration() {
227 return null;
228 }
229
230 public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
231 return false;
232 }
233
234 public void writeComment(String comment) throws IOException {
235 }
236
237 public void writeWarning(String warning) {
238 }
239
240 public String toString() {
241 return "NullGraphics2D";
242 }
243 }