KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > DebugGraphics


1 /*
2  * @(#)DebugGraphics.java 1.25 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing;
9
10 import java.awt.*;
11 import java.awt.image.*;
12 import java.text.AttributedCharacterIterator JavaDoc;
13
14 /**
15  * Graphics subclass supporting graphics debugging. Overrides most methods
16  * from Graphics. DebugGraphics objects are rarely created by hand. They
17  * are most frequently created automatically when a JComponent's
18  * debugGraphicsOptions are changed using the setDebugGraphicsOptions()
19  * method.
20  * <p>
21  * NOTE: You must turn off double buffering to use DebugGraphics:
22  * RepaintManager repaintManager = RepaintManager.currentManager(component);
23  * repaintManager.setDoubleBufferingEnabled(false);
24  *
25  * @see JComponent#setDebugGraphicsOptions
26  * @see RepaintManager#currentManager
27  * @see RepaintManager#setDoubleBufferingEnabled
28  *
29  * @version 1.25 12/19/03
30  * @author Dave Karlton
31  */

32 public class DebugGraphics extends Graphics {
33     Graphics graphics;
34     Image buffer;
35     int debugOptions;
36     int graphicsID = graphicsCount++;
37     int xOffset, yOffset;
38     private static int graphicsCount = 0;
39
40     /** Log graphics operations. */
41     public static final int LOG_OPTION = 1 << 0;
42     /** Flash graphics operations. */
43     public static final int FLASH_OPTION = 1 << 1;
44     /** Show buffered operations in a separate <code>Frame</code>. */
45     public static final int BUFFERED_OPTION = 1 << 2;
46     /** Don't debug graphics operations. */
47     public static final int NONE_OPTION = -1;
48
49     static {
50         JComponent.DEBUG_GRAPHICS_LOADED = true;
51     }
52
53     /**
54      * Constructs a new debug graphics context that supports slowed
55      * down drawing.
56      */

57     public DebugGraphics() {
58         super();
59         buffer = null;
60         xOffset = yOffset = 0;
61     }
62
63     /**
64      * Constructs a debug graphics context from an existing graphics
65      * context that slows down drawing for the specified component.
66      *
67      * @param graphics the Graphics context to slow down
68      * @param component the JComponent to draw slowly
69      */

70     public DebugGraphics(Graphics graphics, JComponent JavaDoc component) {
71         this(graphics);
72         setDebugOptions(component.shouldDebugGraphics());
73     }
74
75     /**
76      * Constructs a debug graphics context from an existing graphics
77      * context that supports slowed down drawing.
78      *
79      * @param graphics the Graphics context to slow down
80      */

81     public DebugGraphics(Graphics graphics) {
82         this();
83         this.graphics = graphics;
84     }
85
86     /**
87      * Overrides <code>Graphics.create</code> to return a DebugGraphics object.
88      */

89     public Graphics create() {
90         DebugGraphics JavaDoc debugGraphics;
91
92         debugGraphics = new DebugGraphics JavaDoc();
93         debugGraphics.graphics = graphics.create();
94         debugGraphics.debugOptions = debugOptions;
95         debugGraphics.buffer = buffer;
96
97         return debugGraphics;
98     }
99
100     /**
101      * Overrides <code>Graphics.create</code> to return a DebugGraphics object.
102      */

103     public Graphics create(int x, int y, int width, int height) {
104         DebugGraphics JavaDoc debugGraphics;
105
106         debugGraphics = new DebugGraphics JavaDoc();
107         debugGraphics.graphics = graphics.create(x, y, width, height);
108         debugGraphics.debugOptions = debugOptions;
109         debugGraphics.buffer = buffer;
110         debugGraphics.xOffset = xOffset + x;
111         debugGraphics.yOffset = yOffset + y;
112
113         return debugGraphics;
114     }
115
116
117     //------------------------------------------------
118
// NEW METHODS
119
//------------------------------------------------
120

121     /**
122      * Sets the Color used to flash drawing operations.
123      */

124     public static void setFlashColor(Color flashColor) {
125         info().flashColor = flashColor;
126     }
127
128     /**
129      * Returns the Color used to flash drawing operations.
130      * @see #setFlashColor
131      */

132     public static Color flashColor() {
133         return info().flashColor;
134     }
135
136     /**
137      * Sets the time delay of drawing operation flashing.
138      */

139     public static void setFlashTime(int flashTime) {
140         info().flashTime = flashTime;
141     }
142
143     /**
144      * Returns the time delay of drawing operation flashing.
145      * @see #setFlashTime
146      */

147     public static int flashTime() {
148         return info().flashTime;
149     }
150
151     /**
152      * Sets the number of times that drawing operations will flash.
153      */

154     public static void setFlashCount(int flashCount) {
155         info().flashCount = flashCount;
156     }
157
158     /** Returns the number of times that drawing operations will flash.
159       * @see #setFlashCount
160       */

161     public static int flashCount() {
162         return info().flashCount;
163     }
164
165     /** Sets the stream to which the DebugGraphics logs drawing operations.
166       */

167     public static void setLogStream(java.io.PrintStream JavaDoc stream) {
168         info().stream = stream;
169     }
170
171     /** Returns the stream to which the DebugGraphics logs drawing operations.
172       * @see #setLogStream
173       */

174     public static java.io.PrintStream JavaDoc logStream() {
175         return info().stream;
176     }
177
178     /** Sets the Font used for text drawing operations.
179       */

180     public void setFont(Font aFont) {
181         if (debugLog()) {
182             info().log(toShortString() + " Setting font: " + aFont);
183         }
184         graphics.setFont(aFont);
185     }
186
187     /** Returns the Font used for text drawing operations.
188       * @see #setFont
189       */

190     public Font getFont() {
191         return graphics.getFont();
192     }
193
194     /** Sets the color to be used for drawing and filling lines and shapes.
195       */

196     public void setColor(Color aColor) {
197         if (debugLog()) {
198             info().log(toShortString() + " Setting color: " + aColor);
199         }
200         graphics.setColor(aColor);
201     }
202
203     /** Returns the Color used for text drawing operations.
204       * @see #setColor
205       */

206     public Color getColor() {
207         return graphics.getColor();
208     }
209
210
211     //-----------------------------------------------
212
// OVERRIDDEN METHODS
213
//------------------------------------------------
214

215     /**
216      * Overrides <code>Graphics.getFontMetrics</code>.
217      */

218     public FontMetrics getFontMetrics() {
219         return graphics.getFontMetrics();
220     }
221
222     /**
223      * Overrides <code>Graphics.getFontMetrics</code>.
224      */

225     public FontMetrics getFontMetrics(Font f) {
226         return graphics.getFontMetrics(f);
227     }
228
229     /**
230      * Overrides <code>Graphics.translate</code>.
231      */

232     public void translate(int x, int y) {
233         if (debugLog()) {
234             info().log(toShortString() +
235                 " Translating by: " + new Point(x, y));
236         }
237         xOffset += x;
238         yOffset += y;
239         graphics.translate(x, y);
240     }
241
242     /**
243      * Overrides <code>Graphics.setPaintMode</code>.
244      */

245     public void setPaintMode() {
246         if (debugLog()) {
247             info().log(toShortString() + " Setting paint mode");
248         }
249         graphics.setPaintMode();
250     }
251
252     /**
253      * Overrides <code>Graphics.setXORMode</code>.
254      */

255     public void setXORMode(Color aColor) {
256         if (debugLog()) {
257             info().log(toShortString() + " Setting XOR mode: " + aColor);
258         }
259         graphics.setXORMode(aColor);
260     }
261
262     /**
263      * Overrides <code>Graphics.getClipBounds</code>.
264      */

265     public Rectangle getClipBounds() {
266         return graphics.getClipBounds();
267     }
268
269     /**
270      * Overrides <code>Graphics.clipRect</code>.
271      */

272     public void clipRect(int x, int y, int width, int height) {
273         graphics.clipRect(x, y, width, height);
274         if (debugLog()) {
275             info().log(toShortString() +
276                 " Setting clipRect: " + (new Rectangle(x, y, width, height)) +
277                 " New clipRect: " + graphics.getClip());
278         }
279     }
280
281     /**
282      * Overrides <code>Graphics.setClip</code>.
283      */

284     public void setClip(int x, int y, int width, int height) {
285         graphics.setClip(x, y, width, height);
286         if (debugLog()) {
287             info().log(toShortString() +
288                         " Setting new clipRect: " + graphics.getClip());
289         }
290     }
291
292     /**
293      * Overrides <code>Graphics.getClip</code>.
294      */

295     public Shape getClip() {
296         return graphics.getClip();
297     }
298
299     /**
300      * Overrides <code>Graphics.setClip</code>.
301      */

302     public void setClip(Shape clip) {
303         graphics.setClip(clip);
304         if (debugLog()) {
305             info().log(toShortString() +
306                        " Setting new clipRect: " + graphics.getClip());
307         }
308     }
309
310     /**
311      * Overrides <code>Graphics.drawRect</code>.
312      */

313     public void drawRect(int x, int y, int width, int height) {
314         DebugGraphicsInfo JavaDoc info = info();
315
316         if (debugLog()) {
317             info().log(toShortString() +
318                       " Drawing rect: " +
319                       new Rectangle(x, y, width, height));
320         }
321
322         if (isDrawingBuffer()) {
323             if (debugBuffered()) {
324                 Graphics debugGraphics = debugGraphics();
325
326                 debugGraphics.drawRect(x, y, width, height);
327                 debugGraphics.dispose();
328             }
329         } else if (debugFlash()) {
330             Color oldColor = getColor();
331             int i, count = (info.flashCount * 2) - 1;
332
333             for (i = 0; i < count; i++) {
334                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
335                 graphics.drawRect(x, y, width, height);
336                 Toolkit.getDefaultToolkit().sync();
337                 sleep(info.flashTime);
338             }
339             graphics.setColor(oldColor);
340         }
341         graphics.drawRect(x, y, width, height);
342     }
343
344     /**
345      * Overrides <code>Graphics.fillRect</code>.
346      */

347     public void fillRect(int x, int y, int width, int height) {
348         DebugGraphicsInfo JavaDoc info = info();
349
350         if (debugLog()) {
351             info().log(toShortString() +
352                       " Filling rect: " +
353                       new Rectangle(x, y, width, height));
354         }
355
356         if (isDrawingBuffer()) {
357             if (debugBuffered()) {
358                 Graphics debugGraphics = debugGraphics();
359
360                 debugGraphics.fillRect(x, y, width, height);
361                 debugGraphics.dispose();
362             }
363         } else if (debugFlash()) {
364             Color oldColor = getColor();
365             int i, count = (info.flashCount * 2) - 1;
366
367             for (i = 0; i < count; i++) {
368                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
369                 graphics.fillRect(x, y, width, height);
370                 Toolkit.getDefaultToolkit().sync();
371                 sleep(info.flashTime);
372             }
373             graphics.setColor(oldColor);
374         }
375         graphics.fillRect(x, y, width, height);
376     }
377
378     /**
379      * Overrides <code>Graphics.clearRect</code>.
380      */

381     public void clearRect(int x, int y, int width, int height) {
382         DebugGraphicsInfo JavaDoc info = info();
383
384         if (debugLog()) {
385             info().log(toShortString() +
386                       " Clearing rect: " +
387                       new Rectangle(x, y, width, height));
388         }
389
390         if (isDrawingBuffer()) {
391             if (debugBuffered()) {
392                 Graphics debugGraphics = debugGraphics();
393
394                 debugGraphics.clearRect(x, y, width, height);
395                 debugGraphics.dispose();
396             }
397         } else if (debugFlash()) {
398             Color oldColor = getColor();
399             int i, count = (info.flashCount * 2) - 1;
400
401             for (i = 0; i < count; i++) {
402                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
403                 graphics.clearRect(x, y, width, height);
404                 Toolkit.getDefaultToolkit().sync();
405                 sleep(info.flashTime);
406             }
407             graphics.setColor(oldColor);
408         }
409         graphics.clearRect(x, y, width, height);
410     }
411
412     /**
413      * Overrides <code>Graphics.drawRoundRect</code>.
414      */

415     public void drawRoundRect(int x, int y, int width, int height,
416                               int arcWidth, int arcHeight) {
417         DebugGraphicsInfo JavaDoc info = info();
418
419         if (debugLog()) {
420             info().log(toShortString() +
421                       " Drawing round rect: " +
422                       new Rectangle(x, y, width, height) +
423                       " arcWidth: " + arcWidth +
424                       " archHeight: " + arcHeight);
425         }
426         if (isDrawingBuffer()) {
427             if (debugBuffered()) {
428                 Graphics debugGraphics = debugGraphics();
429
430                 debugGraphics.drawRoundRect(x, y, width, height,
431                                             arcWidth, arcHeight);
432                 debugGraphics.dispose();
433             }
434         } else if (debugFlash()) {
435             Color oldColor = getColor();
436             int i, count = (info.flashCount * 2) - 1;
437
438             for (i = 0; i < count; i++) {
439                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
440                 graphics.drawRoundRect(x, y, width, height,
441                                        arcWidth, arcHeight);
442                 Toolkit.getDefaultToolkit().sync();
443                 sleep(info.flashTime);
444             }
445             graphics.setColor(oldColor);
446         }
447         graphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
448     }
449
450     /**
451      * Overrides <code>Graphics.fillRoundRect</code>.
452      */

453     public void fillRoundRect(int x, int y, int width, int height,
454                               int arcWidth, int arcHeight) {
455         DebugGraphicsInfo JavaDoc info = info();
456
457         if (debugLog()) {
458             info().log(toShortString() +
459                       " Filling round rect: " +
460                       new Rectangle(x, y, width, height) +
461                       " arcWidth: " + arcWidth +
462                       " archHeight: " + arcHeight);
463         }
464         if (isDrawingBuffer()) {
465             if (debugBuffered()) {
466                 Graphics debugGraphics = debugGraphics();
467
468                 debugGraphics.fillRoundRect(x, y, width, height,
469                                             arcWidth, arcHeight);
470                 debugGraphics.dispose();
471             }
472         } else if (debugFlash()) {
473             Color oldColor = getColor();
474             int i, count = (info.flashCount * 2) - 1;
475
476             for (i = 0; i < count; i++) {
477                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
478                 graphics.fillRoundRect(x, y, width, height,
479                                        arcWidth, arcHeight);
480                 Toolkit.getDefaultToolkit().sync();
481                 sleep(info.flashTime);
482             }
483             graphics.setColor(oldColor);
484         }
485         graphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
486     }
487
488     /**
489      * Overrides <code>Graphics.drawLine</code>.
490      */

491     public void drawLine(int x1, int y1, int x2, int y2) {
492         DebugGraphicsInfo JavaDoc info = info();
493
494         if (debugLog()) {
495             info().log(toShortString() +
496                        " Drawing line: from " + pointToString(x1, y1) +
497                        " to " + pointToString(x2, y2));
498         }
499
500         if (isDrawingBuffer()) {
501             if (debugBuffered()) {
502                 Graphics debugGraphics = debugGraphics();
503
504                 debugGraphics.drawLine(x1, y1, x2, y2);
505                 debugGraphics.dispose();
506             }
507         } else if (debugFlash()) {
508             Color oldColor = getColor();
509             int i, count = (info.flashCount * 2) - 1;
510
511             for (i = 0; i < count; i++) {
512                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
513                 graphics.drawLine(x1, y1, x2, y2);
514                 Toolkit.getDefaultToolkit().sync();
515                 sleep(info.flashTime);
516             }
517             graphics.setColor(oldColor);
518         }
519         graphics.drawLine(x1, y1, x2, y2);
520     }
521
522     /**
523      * Overrides <code>Graphics.draw3DRect</code>.
524      */

525     public void draw3DRect(int x, int y, int width, int height,
526                            boolean raised) {
527         DebugGraphicsInfo JavaDoc info = info();
528
529         if (debugLog()) {
530             info().log(toShortString() +
531                        " Drawing 3D rect: " +
532                        new Rectangle(x, y, width, height) +
533                        " Raised bezel: " + raised);
534         }
535         if (isDrawingBuffer()) {
536             if (debugBuffered()) {
537                 Graphics debugGraphics = debugGraphics();
538
539                 debugGraphics.draw3DRect(x, y, width, height, raised);
540                 debugGraphics.dispose();
541             }
542         } else if (debugFlash()) {
543             Color oldColor = getColor();
544             int i, count = (info.flashCount * 2) - 1;
545
546             for (i = 0; i < count; i++) {
547                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
548                 graphics.draw3DRect(x, y, width, height, raised);
549                 Toolkit.getDefaultToolkit().sync();
550                 sleep(info.flashTime);
551             }
552             graphics.setColor(oldColor);
553         }
554         graphics.draw3DRect(x, y, width, height, raised);
555     }
556
557     /**
558      * Overrides <code>Graphics.fill3DRect</code>.
559      */

560     public void fill3DRect(int x, int y, int width, int height,
561                boolean raised) {
562         DebugGraphicsInfo JavaDoc info = info();
563
564         if (debugLog()) {
565             info().log(toShortString() +
566                        " Filling 3D rect: " +
567                        new Rectangle(x, y, width, height) +
568                        " Raised bezel: " + raised);
569         }
570         if (isDrawingBuffer()) {
571             if (debugBuffered()) {
572                 Graphics debugGraphics = debugGraphics();
573
574                 debugGraphics.fill3DRect(x, y, width, height, raised);
575                 debugGraphics.dispose();
576             }
577         } else if (debugFlash()) {
578             Color oldColor = getColor();
579             int i, count = (info.flashCount * 2) - 1;
580
581             for (i = 0; i < count; i++) {
582                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
583                 graphics.fill3DRect(x, y, width, height, raised);
584                 Toolkit.getDefaultToolkit().sync();
585                 sleep(info.flashTime);
586             }
587             graphics.setColor(oldColor);
588         }
589         graphics.fill3DRect(x, y, width, height, raised);
590     }
591
592     /**
593      * Overrides <code>Graphics.drawOval</code>.
594      */

595     public void drawOval(int x, int y, int width, int height) {
596         DebugGraphicsInfo JavaDoc info = info();
597
598         if (debugLog()) {
599             info().log(toShortString() +
600                       " Drawing oval: " +
601                       new Rectangle(x, y, width, height));
602         }
603         if (isDrawingBuffer()) {
604             if (debugBuffered()) {
605                 Graphics debugGraphics = debugGraphics();
606
607                 debugGraphics.drawOval(x, y, width, height);
608                 debugGraphics.dispose();
609             }
610         } else if (debugFlash()) {
611             Color oldColor = getColor();
612             int i, count = (info.flashCount * 2) - 1;
613
614             for (i = 0; i < count; i++) {
615                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
616                 graphics.drawOval(x, y, width, height);
617                 Toolkit.getDefaultToolkit().sync();
618                 sleep(info.flashTime);
619             }
620             graphics.setColor(oldColor);
621         }
622         graphics.drawOval(x, y, width, height);
623     }
624
625     /**
626      * Overrides <code>Graphics.fillOval</code>.
627      */

628     public void fillOval(int x, int y, int width, int height) {
629         DebugGraphicsInfo JavaDoc info = info();
630
631         if (debugLog()) {
632             info().log(toShortString() +
633                       " Filling oval: " +
634                       new Rectangle(x, y, width, height));
635         }
636         if (isDrawingBuffer()) {
637             if (debugBuffered()) {
638                 Graphics debugGraphics = debugGraphics();
639
640                 debugGraphics.fillOval(x, y, width, height);
641                 debugGraphics.dispose();
642             }
643         } else if (debugFlash()) {
644             Color oldColor = getColor();
645             int i, count = (info.flashCount * 2) - 1;
646
647             for (i = 0; i < count; i++) {
648                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
649                 graphics.fillOval(x, y, width, height);
650                 Toolkit.getDefaultToolkit().sync();
651                 sleep(info.flashTime);
652             }
653             graphics.setColor(oldColor);
654         }
655         graphics.fillOval(x, y, width, height);
656     }
657
658     /**
659      * Overrides <code>Graphics.drawArc</code>.
660      */

661     public void drawArc(int x, int y, int width, int height,
662                         int startAngle, int arcAngle) {
663         DebugGraphicsInfo JavaDoc info = info();
664
665         if (debugLog()) {
666             info().log(toShortString() +
667                       " Drawing arc: " +
668                       new Rectangle(x, y, width, height) +
669                       " startAngle: " + startAngle +
670                       " arcAngle: " + arcAngle);
671         }
672         if (isDrawingBuffer()) {
673             if (debugBuffered()) {
674                 Graphics debugGraphics = debugGraphics();
675
676                 debugGraphics.drawArc(x, y, width, height,
677                                       startAngle, arcAngle);
678                 debugGraphics.dispose();
679             }
680         } else if (debugFlash()) {
681             Color oldColor = getColor();
682             int i, count = (info.flashCount * 2) - 1;
683
684             for (i = 0; i < count; i++) {
685                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
686                 graphics.drawArc(x, y, width, height, startAngle, arcAngle);
687                 Toolkit.getDefaultToolkit().sync();
688                 sleep(info.flashTime);
689             }
690             graphics.setColor(oldColor);
691         }
692         graphics.drawArc(x, y, width, height, startAngle, arcAngle);
693     }
694
695     /**
696      * Overrides <code>Graphics.fillArc</code>.
697      */

698     public void fillArc(int x, int y, int width, int height,
699                         int startAngle, int arcAngle) {
700         DebugGraphicsInfo JavaDoc info = info();
701
702         if (debugLog()) {
703             info().log(toShortString() +
704                       " Filling arc: " +
705                       new Rectangle(x, y, width, height) +
706                       " startAngle: " + startAngle +
707                       " arcAngle: " + arcAngle);
708         }
709         if (isDrawingBuffer()) {
710             if (debugBuffered()) {
711                 Graphics debugGraphics = debugGraphics();
712
713                 debugGraphics.fillArc(x, y, width, height,
714                                       startAngle, arcAngle);
715                 debugGraphics.dispose();
716             }
717         } else if (debugFlash()) {
718             Color oldColor = getColor();
719             int i, count = (info.flashCount * 2) - 1;
720
721             for (i = 0; i < count; i++) {
722                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
723                 graphics.fillArc(x, y, width, height, startAngle, arcAngle);
724                 Toolkit.getDefaultToolkit().sync();
725                 sleep(info.flashTime);
726             }
727             graphics.setColor(oldColor);
728         }
729         graphics.fillArc(x, y, width, height, startAngle, arcAngle);
730     }
731
732     /**
733      * Overrides <code>Graphics.drawPolyline</code>.
734      */

735     public void drawPolyline(int xPoints[], int yPoints[], int nPoints) {
736         DebugGraphicsInfo JavaDoc info = info();
737
738         if (debugLog()) {
739             info().log(toShortString() +
740                       " Drawing polyline: " +
741                       " nPoints: " + nPoints +
742                       " X's: " + xPoints +
743                       " Y's: " + yPoints);
744         }
745         if (isDrawingBuffer()) {
746             if (debugBuffered()) {
747                 Graphics debugGraphics = debugGraphics();
748
749                 debugGraphics.drawPolyline(xPoints, yPoints, nPoints);
750                 debugGraphics.dispose();
751             }
752         } else if (debugFlash()) {
753             Color oldColor = getColor();
754             int i, count = (info.flashCount * 2) - 1;
755
756             for (i = 0; i < count; i++) {
757                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
758                 graphics.drawPolyline(xPoints, yPoints, nPoints);
759                 Toolkit.getDefaultToolkit().sync();
760                 sleep(info.flashTime);
761             }
762             graphics.setColor(oldColor);
763         }
764         graphics.drawPolyline(xPoints, yPoints, nPoints);
765     }
766
767     /**
768      * Overrides <code>Graphics.drawPolygon</code>.
769      */

770     public void drawPolygon(int xPoints[], int yPoints[], int nPoints) {
771         DebugGraphicsInfo JavaDoc info = info();
772
773         if (debugLog()) {
774             info().log(toShortString() +
775                       " Drawing polygon: " +
776                       " nPoints: " + nPoints +
777                       " X's: " + xPoints +
778                       " Y's: " + yPoints);
779         }
780         if (isDrawingBuffer()) {
781             if (debugBuffered()) {
782                 Graphics debugGraphics = debugGraphics();
783
784                 debugGraphics.drawPolygon(xPoints, yPoints, nPoints);
785                 debugGraphics.dispose();
786             }
787         } else if (debugFlash()) {
788             Color oldColor = getColor();
789             int i, count = (info.flashCount * 2) - 1;
790
791             for (i = 0; i < count; i++) {
792                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
793                 graphics.drawPolygon(xPoints, yPoints, nPoints);
794                 Toolkit.getDefaultToolkit().sync();
795                 sleep(info.flashTime);
796             }
797             graphics.setColor(oldColor);
798         }
799         graphics.drawPolygon(xPoints, yPoints, nPoints);
800     }
801
802     /**
803      * Overrides <code>Graphics.fillPolygon</code>.
804      */

805     public void fillPolygon(int xPoints[], int yPoints[], int nPoints) {
806         DebugGraphicsInfo JavaDoc info = info();
807
808         if (debugLog()) {
809             info().log(toShortString() +
810                       " Filling polygon: " +
811                       " nPoints: " + nPoints +
812                       " X's: " + xPoints +
813                       " Y's: " + yPoints);
814         }
815         if (isDrawingBuffer()) {
816             if (debugBuffered()) {
817                 Graphics debugGraphics = debugGraphics();
818
819                 debugGraphics.fillPolygon(xPoints, yPoints, nPoints);
820                 debugGraphics.dispose();
821             }
822         } else if (debugFlash()) {
823             Color oldColor = getColor();
824             int i, count = (info.flashCount * 2) - 1;
825
826             for (i = 0; i < count; i++) {
827                 graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
828                 graphics.fillPolygon(xPoints, yPoints, nPoints);
829                 Toolkit.getDefaultToolkit().sync();
830                 sleep(info.flashTime);
831             }
832             graphics.setColor(oldColor);
833         }
834         graphics.fillPolygon(xPoints, yPoints, nPoints);
835     }
836
837     /**
838      * Overrides <code>Graphics.drawString</code>.
839      */

840     public void drawString(String JavaDoc aString, int x, int y) {
841         DebugGraphicsInfo JavaDoc info = info();
842
843         if (debugLog()) {
844             info().log(toShortString() +
845                        " Drawing string: \"" + aString +
846                        "\" at: " + new Point(x, y));
847         }
848
849         if (isDrawingBuffer()) {
850             if (debugBuffered()) {
851                 Graphics debugGraphics = debugGraphics();
852
853                 debugGraphics.drawString(aString, x, y);
854                 debugGraphics.dispose();
855             }
856         } else if (debugFlash()) {
857             Color oldColor = getColor();
858             int i, count = (info.flashCount * 2) - 1;
859
860             for (i = 0; i < count; i++) {
861                 graphics.setColor((i % 2) == 0 ? info.flashColor
862                                   : oldColor);
863                 graphics.drawString(aString, x, y);
864                 Toolkit.getDefaultToolkit().sync();
865                 sleep(info.flashTime);
866             }
867             graphics.setColor(oldColor);
868         }
869         graphics.drawString(aString, x, y);
870     }
871
872     /**
873      * Overrides <code>Graphics.drawString</code>.
874      */

875     public void drawString(AttributedCharacterIterator JavaDoc iterator, int x, int y) {
876         DebugGraphicsInfo JavaDoc info = info();
877
878         if (debugLog()) {
879             info().log(toShortString() +
880                        " Drawing text: \"" + iterator +
881                        "\" at: " + new Point(x, y));
882         }
883
884         if (isDrawingBuffer()) {
885             if (debugBuffered()) {
886                 Graphics debugGraphics = debugGraphics();
887
888                 debugGraphics.drawString(iterator, x, y);
889                 debugGraphics.dispose();
890             }
891         } else if (debugFlash()) {
892             Color oldColor = getColor();
893             int i, count = (info.flashCount * 2) - 1;
894
895             for (i = 0; i < count; i++) {
896                 graphics.setColor((i % 2) == 0 ? info.flashColor
897                                   : oldColor);
898                 graphics.drawString(iterator, x, y);
899                 Toolkit.getDefaultToolkit().sync();
900                 sleep(info.flashTime);
901             }
902             graphics.setColor(oldColor);
903         }
904         graphics.drawString(iterator, x, y);
905     }
906
907     /**
908      * Overrides <code>Graphics.drawBytes</code>.
909      */

910     public void drawBytes(byte data[], int offset, int length, int x, int y) {
911         DebugGraphicsInfo JavaDoc info = info();
912
913         Font font = graphics.getFont();
914
915         if (debugLog()) {
916             info().log(toShortString() +
917                        " Drawing bytes at: " + new Point(x, y));
918         }
919
920         if (isDrawingBuffer()) {
921             if (debugBuffered()) {
922                 Graphics debugGraphics = debugGraphics();
923
924                 debugGraphics.drawBytes(data, offset, length, x, y);
925                 debugGraphics.dispose();
926             }
927         } else if (debugFlash()) {
928             Color oldColor = getColor();
929             int i, count = (info.flashCount * 2) - 1;
930
931             for (i = 0; i < count; i++) {
932                 graphics.setColor((i % 2) == 0 ? info.flashColor
933                                   : oldColor);
934                 graphics.drawBytes(data, offset, length, x, y);
935                 Toolkit.getDefaultToolkit().sync();
936                 sleep(info.flashTime);
937             }
938             graphics.setColor(oldColor);
939         }
940         graphics.drawBytes(data, offset, length, x, y);
941     }
942
943     /**
944      * Overrides <code>Graphics.drawChars</code>.
945      */

946     public void drawChars(char data[], int offset, int length, int x, int y) {
947         DebugGraphicsInfo JavaDoc info = info();
948
949         Font font = graphics.getFont();
950
951         if (debugLog()) {
952             info().log(toShortString() +
953                        " Drawing chars at " + new Point(x, y));
954         }
955
956         if (isDrawingBuffer()) {
957             if (debugBuffered()) {
958                 Graphics debugGraphics = debugGraphics();
959
960                 debugGraphics.drawChars(data, offset, length, x, y);
961                 debugGraphics.dispose();
962             }
963         } else if (debugFlash()) {
964             Color oldColor = getColor();
965             int i, count = (info.flashCount * 2) - 1;
966
967             for (i = 0; i < count; i++) {
968                 graphics.setColor((i % 2) == 0 ? info.flashColor
969                                   : oldColor);
970                 graphics.drawChars(data, offset, length, x, y);
971                 Toolkit.getDefaultToolkit().sync();
972                 sleep(info.flashTime);
973             }
974             graphics.setColor(oldColor);
975         }
976         graphics.drawChars(data, offset, length, x, y);
977     }
978
979     /**
980      * Overrides <code>Graphics.drawImage</code>.
981      */

982     public boolean drawImage(Image img, int x, int y,
983                              ImageObserver observer) {
984         DebugGraphicsInfo JavaDoc info = info();
985
986         if (debugLog()) {
987             info.log(toShortString() +
988              " Drawing image: " + img +
989              " at: " + new Point(x, y));
990         }
991
992         if (isDrawingBuffer()) {
993             if (debugBuffered()) {
994                 Graphics debugGraphics = debugGraphics();
995
996                 debugGraphics.drawImage(img, x, y, observer);
997                 debugGraphics.dispose();
998             }
999         } else if (debugFlash()) {
1000            int i, count = (info.flashCount * 2) - 1;
1001            ImageProducer oldProducer = img.getSource();
1002            ImageProducer newProducer
1003                = new FilteredImageSource(oldProducer,
1004                                new DebugGraphicsFilter JavaDoc(info.flashColor));
1005            Image newImage
1006                = Toolkit.getDefaultToolkit().createImage(newProducer);
1007            DebugGraphicsObserver JavaDoc imageObserver
1008                = new DebugGraphicsObserver JavaDoc();
1009
1010            for (i = 0; i < count; i++) {
1011                graphics.drawImage((i % 2) == 0 ? newImage : img, x, y,
1012                                   imageObserver);
1013                Toolkit.getDefaultToolkit().sync();
1014                while (!imageObserver.allBitsPresent() &&
1015                                       !imageObserver.imageHasProblem()) {
1016                    sleep(10);
1017                }
1018                sleep(info.flashTime);
1019            }
1020        }
1021        return graphics.drawImage(img, x, y, observer);
1022    }
1023
1024    /**
1025     * Overrides <code>Graphics.drawImage</code>.
1026     */

1027    public boolean drawImage(Image img, int x, int y, int width, int height,
1028                             ImageObserver observer) {
1029        DebugGraphicsInfo JavaDoc info = info();
1030
1031        if (debugLog()) {
1032            info.log(toShortString() +
1033             " Drawing image: " + img +
1034             " at: " + new Rectangle(x, y, width, height));
1035        }
1036
1037        if (isDrawingBuffer()) {
1038            if (debugBuffered()) {
1039                Graphics debugGraphics = debugGraphics();
1040
1041                debugGraphics.drawImage(img, x, y, width, height, observer);
1042                debugGraphics.dispose();
1043            }
1044        } else if (debugFlash()) {
1045            int i, count = (info.flashCount * 2) - 1;
1046            ImageProducer oldProducer = img.getSource();
1047            ImageProducer newProducer
1048                = new FilteredImageSource(oldProducer,
1049                                new DebugGraphicsFilter JavaDoc(info.flashColor));
1050            Image newImage
1051                = Toolkit.getDefaultToolkit().createImage(newProducer);
1052            DebugGraphicsObserver JavaDoc imageObserver
1053                = new DebugGraphicsObserver JavaDoc();
1054
1055            for (i = 0; i < count; i++) {
1056                graphics.drawImage((i % 2) == 0 ? newImage : img, x, y,
1057                                   width, height, imageObserver);
1058                Toolkit.getDefaultToolkit().sync();
1059                while (!imageObserver.allBitsPresent() &&
1060                                       !imageObserver.imageHasProblem()) {
1061                    sleep(10);
1062                }
1063                sleep(info.flashTime);
1064            }
1065        }
1066        return graphics.drawImage(img, x, y, width, height, observer);
1067    }
1068
1069    /**
1070     * Overrides <code>Graphics.drawImage</code>.
1071     */

1072    public boolean drawImage(Image img, int x, int y,
1073                             Color bgcolor,
1074                             ImageObserver observer) {
1075        DebugGraphicsInfo JavaDoc info = info();
1076
1077        if (debugLog()) {
1078            info.log(toShortString() +
1079             " Drawing image: " + img +
1080             " at: " + new Point(x, y) +
1081             ", bgcolor: " + bgcolor);
1082        }
1083
1084        if (isDrawingBuffer()) {
1085            if (debugBuffered()) {
1086                Graphics debugGraphics = debugGraphics();
1087
1088                debugGraphics.drawImage(img, x, y, bgcolor, observer);
1089                debugGraphics.dispose();
1090            }
1091        } else if (debugFlash()) {
1092            int i, count = (info.flashCount * 2) - 1;
1093            ImageProducer oldProducer = img.getSource();
1094            ImageProducer newProducer
1095                = new FilteredImageSource(oldProducer,
1096                                new DebugGraphicsFilter JavaDoc(info.flashColor));
1097            Image newImage
1098                = Toolkit.getDefaultToolkit().createImage(newProducer);
1099            DebugGraphicsObserver JavaDoc imageObserver
1100                = new DebugGraphicsObserver JavaDoc();
1101
1102            for (i = 0; i < count; i++) {
1103                graphics.drawImage((i % 2) == 0 ? newImage : img, x, y,
1104                                   bgcolor, imageObserver);
1105                Toolkit.getDefaultToolkit().sync();
1106                while (!imageObserver.allBitsPresent() &&
1107                                       !imageObserver.imageHasProblem()) {
1108                    sleep(10);
1109                }
1110                sleep(info.flashTime);
1111            }
1112        }
1113        return graphics.drawImage(img, x, y, bgcolor, observer);
1114    }
1115
1116    /**
1117     * Overrides <code>Graphics.drawImage</code>.
1118     */

1119    public boolean drawImage(Image img, int x, int y,int width, int height,
1120                             Color bgcolor,
1121                             ImageObserver observer) {
1122        DebugGraphicsInfo JavaDoc info = info();
1123
1124        if (debugLog()) {
1125            info.log(toShortString() +
1126             " Drawing image: " + img +
1127             " at: " + new Rectangle(x, y, width, height) +
1128             ", bgcolor: " + bgcolor);
1129        }
1130
1131        if (isDrawingBuffer()) {
1132            if (debugBuffered()) {
1133                Graphics debugGraphics = debugGraphics();
1134
1135                debugGraphics.drawImage(img, x, y, width, height,
1136                    bgcolor, observer);
1137                debugGraphics.dispose();
1138            }
1139        } else if (debugFlash()) {
1140            int i, count = (info.flashCount * 2) - 1;
1141            ImageProducer oldProducer = img.getSource();
1142            ImageProducer newProducer
1143                = new FilteredImageSource(oldProducer,
1144                                new DebugGraphicsFilter JavaDoc(info.flashColor));
1145            Image newImage
1146                = Toolkit.getDefaultToolkit().createImage(newProducer);
1147            DebugGraphicsObserver JavaDoc imageObserver
1148                = new DebugGraphicsObserver JavaDoc();
1149
1150            for (i = 0; i < count; i++) {
1151                graphics.drawImage((i % 2) == 0 ? newImage : img, x, y,
1152                                   width, height, bgcolor, imageObserver);
1153                Toolkit.getDefaultToolkit().sync();
1154                while (!imageObserver.allBitsPresent() &&
1155                                       !imageObserver.imageHasProblem()) {
1156                    sleep(10);
1157                }
1158                sleep(info.flashTime);
1159            }
1160        }
1161        return graphics.drawImage(img, x, y, width, height, bgcolor, observer);
1162    }
1163
1164    /**
1165     * Overrides <code>Graphics.drawImage</code>.
1166     */

1167    public boolean drawImage(Image img,
1168                             int dx1, int dy1, int dx2, int dy2,
1169                             int sx1, int sy1, int sx2, int sy2,
1170                             ImageObserver observer) {
1171        DebugGraphicsInfo JavaDoc info = info();
1172
1173        if (debugLog()) {
1174            info.log(toShortString() +
1175             " Drawing image: " + img +
1176             " destination: " + new Rectangle(dx1, dy1, dx2, dy2) +
1177             " source: " + new Rectangle(sx1, sy1, sx2, sy2));
1178        }
1179
1180        if (isDrawingBuffer()) {
1181            if (debugBuffered()) {
1182                Graphics debugGraphics = debugGraphics();
1183
1184                debugGraphics.drawImage(img, dx1, dy1, dx2, dy2,
1185                    sx1, sy1, sx2, sy2, observer);
1186                debugGraphics.dispose();
1187            }
1188        } else if (debugFlash()) {
1189            int i, count = (info.flashCount * 2) - 1;
1190            ImageProducer oldProducer = img.getSource();
1191            ImageProducer newProducer
1192                = new FilteredImageSource(oldProducer,
1193                                new DebugGraphicsFilter JavaDoc(info.flashColor));
1194            Image newImage
1195                = Toolkit.getDefaultToolkit().createImage(newProducer);
1196            DebugGraphicsObserver JavaDoc imageObserver
1197                = new DebugGraphicsObserver JavaDoc();
1198
1199            for (i = 0; i < count; i++) {
1200                graphics.drawImage((i % 2) == 0 ? newImage : img,
1201                   dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
1202                                   imageObserver);
1203                Toolkit.getDefaultToolkit().sync();
1204                while (!imageObserver.allBitsPresent() &&
1205                                       !imageObserver.imageHasProblem()) {
1206                    sleep(10);
1207                }
1208                sleep(info.flashTime);
1209            }
1210        }
1211        return graphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
1212                                  observer);
1213    }
1214
1215    /**
1216     * Overrides <code>Graphics.drawImage</code>.
1217     */

1218    public boolean drawImage(Image img,
1219                             int dx1, int dy1, int dx2, int dy2,
1220                             int sx1, int sy1, int sx2, int sy2,
1221                             Color bgcolor,
1222                             ImageObserver observer) {
1223        DebugGraphicsInfo JavaDoc info = info();
1224
1225        if (debugLog()) {
1226            info.log(toShortString() +
1227             " Drawing image: " + img +
1228             " destination: " + new Rectangle(dx1, dy1, dx2, dy2) +
1229             " source: " + new Rectangle(sx1, sy1, sx2, sy2) +
1230             ", bgcolor: " + bgcolor);
1231        }
1232
1233        if (isDrawingBuffer()) {
1234            if (debugBuffered()) {
1235                Graphics debugGraphics = debugGraphics();
1236
1237                debugGraphics.drawImage(img, dx1, dy1, dx2, dy2,
1238                    sx1, sy1, sx2, sy2, bgcolor, observer);
1239                debugGraphics.dispose();
1240            }
1241        } else if (debugFlash()) {
1242            int i, count = (info.flashCount * 2) - 1;
1243            ImageProducer oldProducer = img.getSource();
1244            ImageProducer newProducer
1245                = new FilteredImageSource(oldProducer,
1246                                new DebugGraphicsFilter JavaDoc(info.flashColor));
1247            Image newImage
1248                = Toolkit.getDefaultToolkit().createImage(newProducer);
1249            DebugGraphicsObserver JavaDoc imageObserver
1250                = new DebugGraphicsObserver JavaDoc();
1251
1252            for (i = 0; i < count; i++) {
1253                graphics.drawImage((i % 2) == 0 ? newImage : img,
1254                   dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
1255                                   bgcolor, imageObserver);
1256                Toolkit.getDefaultToolkit().sync();
1257                while (!imageObserver.allBitsPresent() &&
1258                                       !imageObserver.imageHasProblem()) {
1259                    sleep(10);
1260                }
1261                sleep(info.flashTime);
1262            }
1263        }
1264        return graphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
1265                                  bgcolor, observer);
1266    }
1267
1268    /**
1269     * Overrides <code>Graphics.copyArea</code>.
1270     */

1271    public void copyArea(int x, int y, int width, int height,
1272                         int destX, int destY) {
1273        if (debugLog()) {
1274            info().log(toShortString() +
1275                      " Copying area from: " +
1276                      new Rectangle(x, y, width, height) +
1277                      " to: " + new Point(destX, destY));
1278        }
1279        graphics.copyArea(x, y, width, height, destX, destY);
1280    }
1281
1282    final void sleep(int mSecs) {
1283        try {
1284            Thread.sleep(mSecs);
1285        } catch (Exception JavaDoc e) {
1286        }
1287    }
1288
1289    /**
1290     * Overrides <code>Graphics.dispose</code>.
1291     */

1292    public void dispose() {
1293        graphics.dispose();
1294        graphics = null;
1295    }
1296
1297    // ALERT!
1298
/**
1299     * Returns the drawingBuffer value.
1300     *
1301     * @return true if this object is drawing from a Buffer
1302     */

1303    public boolean isDrawingBuffer() {
1304        return buffer != null;
1305    }
1306
1307    String JavaDoc toShortString() {
1308        StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("Graphics" + (isDrawingBuffer() ? "<B>" : "") + "(" + graphicsID + "-" + debugOptions + ")");
1309        return buffer.toString();
1310    }
1311
1312    String JavaDoc pointToString(int x, int y) {
1313        StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("(" + x + ", " + y + ")");
1314        return buffer.toString();
1315    }
1316
1317    /** Enables/disables diagnostic information about every graphics
1318      * operation. The value of <b>options</b> indicates how this information
1319      * should be displayed. LOG_OPTION causes a text message to be printed.
1320      * FLASH_OPTION causes the drawing to flash several times. BUFFERED_OPTION
1321      * creates a new Frame that shows each operation on an
1322      * offscreen buffer. The value of <b>options</b> is bitwise OR'd into
1323      * the current value. To disable debugging use NONE_OPTION.
1324      */

1325    public void setDebugOptions(int options) {
1326        if (options != 0) {
1327            if (options == NONE_OPTION) {
1328                if (debugOptions != 0) {
1329                    System.err.println(toShortString() + " Disabling debug");
1330                    debugOptions = 0;
1331                }
1332            } else {
1333                if (debugOptions != options) {
1334                    debugOptions |= options;
1335                    if (debugLog()) {
1336                        System.err.println(toShortString() + " Enabling debug");
1337                    }
1338                }
1339            }
1340        }
1341    }
1342
1343    /** Returns the current debugging options for this DebugGraphics.
1344      * @see #setDebugOptions
1345      */

1346    public int getDebugOptions() {
1347        return debugOptions;
1348    }
1349
1350    /** Static wrapper method for DebugGraphicsInfo.setDebugOptions(). Stores
1351      * options on a per component basis.
1352      */

1353    static void setDebugOptions(JComponent JavaDoc component, int options) {
1354        info().setDebugOptions(component, options);
1355    }
1356
1357    /** Static wrapper method for DebugGraphicsInfo.getDebugOptions().
1358      */

1359    static int getDebugOptions(JComponent JavaDoc component) {
1360        DebugGraphicsInfo JavaDoc debugGraphicsInfo = info();
1361        if (debugGraphicsInfo == null) {
1362            return 0;
1363        } else {
1364            return debugGraphicsInfo.getDebugOptions(component);
1365        }
1366    }
1367
1368    /** Returns non-zero if <b>component</b> should display with DebugGraphics,
1369      * zero otherwise. Walks the JComponent's parent tree to determine if
1370      * any debugging options have been set.
1371      */

1372    static int shouldComponentDebug(JComponent JavaDoc component) {
1373        DebugGraphicsInfo JavaDoc info = info();
1374        if (info == null) {
1375            return 0;
1376        } else {
1377            Container container = (Container)component;
1378            int debugOptions = 0;
1379
1380            while (container != null && (container instanceof JComponent JavaDoc)) {
1381                debugOptions |= info.getDebugOptions((JComponent JavaDoc)container);
1382                container = container.getParent();
1383            }
1384
1385            return debugOptions;
1386        }
1387    }
1388
1389    /** Returns the number of JComponents that have debugging options turned
1390      * on.
1391      */

1392    static int debugComponentCount() {
1393        DebugGraphicsInfo JavaDoc debugGraphicsInfo = info();
1394        if (debugGraphicsInfo != null &&
1395                    debugGraphicsInfo.componentToDebug != null) {
1396            return debugGraphicsInfo.componentToDebug.size();
1397        } else {
1398            return 0;
1399        }
1400    }
1401
1402    boolean debugLog() {
1403        return (debugOptions & LOG_OPTION) == LOG_OPTION;
1404    }
1405
1406    boolean debugFlash() {
1407        return (debugOptions & FLASH_OPTION) == FLASH_OPTION;
1408    }
1409
1410    boolean debugBuffered() {
1411        return (debugOptions & BUFFERED_OPTION) == BUFFERED_OPTION;
1412    }
1413
1414    /** Returns a DebugGraphics for use in buffering window.
1415      */

1416    private Graphics debugGraphics() {
1417        DebugGraphics JavaDoc debugGraphics;
1418        DebugGraphicsInfo JavaDoc info = info();
1419        JFrame JavaDoc debugFrame;
1420
1421        if (info.debugFrame == null) {
1422            info.debugFrame = new JFrame JavaDoc();
1423            info.debugFrame.setSize(500, 500);
1424        }
1425        debugFrame = info.debugFrame;
1426        debugFrame.show();
1427        debugGraphics = new DebugGraphics JavaDoc(debugFrame.getGraphics());
1428        debugGraphics.setFont(getFont());
1429        debugGraphics.setColor(getColor());
1430        debugGraphics.translate(xOffset, yOffset);
1431        debugGraphics.setClip(getClipBounds());
1432        if (debugFlash()) {
1433            debugGraphics.setDebugOptions(FLASH_OPTION);
1434        }
1435        return debugGraphics;
1436    }
1437
1438    /** Returns DebugGraphicsInfo, or creates one if none exists.
1439      */

1440    static DebugGraphicsInfo JavaDoc info() {
1441        DebugGraphicsInfo JavaDoc debugGraphicsInfo = (DebugGraphicsInfo JavaDoc)
1442            SwingUtilities.appContextGet(debugGraphicsInfoKey);
1443        if (debugGraphicsInfo == null) {
1444            debugGraphicsInfo = new DebugGraphicsInfo JavaDoc();
1445            SwingUtilities.appContextPut(debugGraphicsInfoKey,
1446                                         debugGraphicsInfo);
1447        }
1448        return debugGraphicsInfo;
1449    }
1450    private static final Class JavaDoc debugGraphicsInfoKey = DebugGraphicsInfo JavaDoc.class;
1451
1452
1453}
1454
Popular Tags