1 19 20 package org.netbeans.test.jsf.el; 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 String getTextUni() { 73 String str; 74 int start; 75 StringBuffer buf = new StringBuffer ().append(this.buf); 76 while ((start=buf.indexOf(" ")) > -1) { 77 buf.deleteCharAt(start); 78 } 79 str = buf.toString(); 80 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 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 image, int param, int param2, 107 ImageObserver imageObserver) { 108 return true; 109 } 110 111 public boolean drawImage(Image image, int param, int param2, Color color, 112 ImageObserver imageObserver) { 113 return true; 114 } 115 116 public boolean drawImage(Image image, int param, int param2, int param3, 117 int param4, ImageObserver imageObserver) { 118 return true; 119 } 120 121 public boolean drawImage(Image image, int param, int param2, int param3, 122 int param4, Color color, ImageObserver imageObserver) { 123 return true; 124 } 125 126 public boolean drawImage(Image image, int param, int param2, int param3, 127 int param4, int param5, int param6, int param7, int param8, 128 ImageObserver imageObserver) { 129 return true; 130 } 131 132 public boolean drawImage(Image image, int param, int param2, int param3, 133 int param4, int param5, int param6, int param7, int param8, 134 Color color, ImageObserver 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 str, int x, int y) { 155 drawString(str, (float) x, (float) y); 156 } 157 158 public void drawString(AttributedCharacterIterator 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 getClip() { 180 return null; 181 } 182 183 public Rectangle getClipBounds() { 184 return null; 185 } 186 187 public Color getColor() { 188 return null; 189 } 190 191 public Font getFont() { 192 if(font != null) return font; 193 if (dummy == null) return null; 194 return dummy.getFont(); 195 } 196 197 public FontMetrics getFontMetrics(Font font) { 198 if (dummy == null) return null; 199 return dummy.getFontMetrics(dummy.getFont()); 200 } 201 202 public void setClip(Shape shape) { 203 } 204 205 public void setClip(int param, int param1, int param2, int param3) { 206 } 207 208 public void setColor(Color color) { 209 } 210 211 public void setFont(Font font) { 212 this.font=font; 213 } 214 215 public void setPaintMode() { 216 } 217 218 public void setXORMode(Color color) { 219 } 220 221 public void translate(int param, int param1) { 222 } 223 224 public void addRenderingHints(Map map) { 225 } 226 227 public void clip(Shape shape) { 228 } 229 230 public void draw(Shape shape) { 231 } 232 233 public void drawGlyphVector(GlyphVector glyphVector, float param, 234 float param2) { 235 } 236 237 public boolean drawImage(Image image, AffineTransform affineTransform, 238 ImageObserver imageObserver) { 239 return true; 240 } 241 242 public void drawImage(BufferedImage bufferedImage, 243 BufferedImageOp bufferedImageOp, int param, int param3) { 244 } 245 246 public void drawRenderableImage(RenderableImage renderableImage, 247 AffineTransform affineTransform) { 248 } 249 250 public void drawRenderedImage(RenderedImage renderedImage, 251 AffineTransform affineTransform) { 252 } 253 254 public void drawString(String 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 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 shape) { 272 } 273 274 public Color getBackground() { 275 if (dummy == null) return null; 276 return dummy.getBackground(); 277 } 278 279 public Composite getComposite() { 280 return null; 281 } 282 283 public GraphicsConfiguration getDeviceConfiguration() { 284 return null; 285 } 286 287 public FontRenderContext getFontRenderContext() { 288 if (dummy == null) return null; 289 return ((Graphics2D ) dummy.getGraphics()).getFontRenderContext(); 290 } 291 292 public Paint getPaint() { 293 return null; 294 } 295 296 public Object getRenderingHint(RenderingHints.Key key) { 297 return null; 298 } 299 300 public RenderingHints getRenderingHints() { 301 return null; 302 } 303 304 public Stroke getStroke() { 305 return null; 306 } 307 308 public AffineTransform getTransform() { 309 return null; 310 } 311 312 public boolean hit(Rectangle rectangle, Shape 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 color) { 326 } 327 328 public void setComposite(Composite composite) { 329 } 330 331 public void setPaint(Paint paint) { 332 } 333 334 public void setRenderingHint(RenderingHints.Key key, Object obj) { 335 } 336 337 public void setRenderingHints(Map map) { 338 } 339 340 public void setStroke(Stroke stroke) { 341 } 342 343 public void setTransform(AffineTransform affineTransform) { 344 } 345 346 public void shear(double param, double param1) { 347 } 348 349 public void transform(AffineTransform affineTransform) { 350 } 351 352 public void translate(double param, double param1) { 353 } 354 } 355 | Popular Tags |