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