jdk/src/share/classes/javax/swing/DebugGraphics.java
author malenkov
Wed, 30 Apr 2014 19:28:05 +0400
changeset 24544 c0133e7c7162
parent 7668 d4a77089c587
child 25201 4adc75e0c4e5
permissions -rw-r--r--
8041917: unexcepted behavior of LineBorder while using Boolean variable true Reviewed-by: alexsch, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 7014
diff changeset
     2
 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.image.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.text.AttributedCharacterIterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * Graphics subclass supporting graphics debugging. Overrides most methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * from Graphics.  DebugGraphics objects are rarely created by hand.  They
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * are most frequently created automatically when a JComponent's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * debugGraphicsOptions are changed using the setDebugGraphicsOptions()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * NOTE: You must turn off double buffering to use DebugGraphics:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *       RepaintManager repaintManager = RepaintManager.currentManager(component);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *       repaintManager.setDoubleBufferingEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @see JComponent#setDebugGraphicsOptions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @see RepaintManager#currentManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see RepaintManager#setDoubleBufferingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @author Dave Karlton
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
public class DebugGraphics extends Graphics {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    Graphics                    graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    Image                       buffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    int                         debugOptions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    int                         graphicsID = graphicsCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    int                         xOffset, yOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private static int          graphicsCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static ImageIcon    imageLoadingIcon = new ImageIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /** Log graphics operations. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public static final int     LOG_OPTION   = 1 << 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /** Flash graphics operations. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    public static final int     FLASH_OPTION = 1 << 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /** Show buffered operations in a separate <code>Frame</code>. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    public static final int     BUFFERED_OPTION = 1 << 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    /** Don't debug graphics operations. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public static final int     NONE_OPTION = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        JComponent.DEBUG_GRAPHICS_LOADED = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * Constructs a new debug graphics context that supports slowed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * down drawing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public DebugGraphics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        buffer = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        xOffset = yOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * Constructs a debug graphics context from an existing graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * context that slows down drawing for the specified component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @param graphics  the Graphics context to slow down
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @param component the JComponent to draw slowly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public DebugGraphics(Graphics graphics, JComponent component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        this(graphics);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        setDebugOptions(component.shouldDebugGraphics());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * Constructs a debug graphics context from an existing graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * context that supports slowed down drawing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @param graphics  the Graphics context to slow down
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    public DebugGraphics(Graphics graphics) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        this();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        this.graphics = graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Overrides <code>Graphics.create</code> to return a DebugGraphics object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public Graphics create() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        DebugGraphics debugGraphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        debugGraphics = new DebugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        debugGraphics.graphics = graphics.create();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        debugGraphics.debugOptions = debugOptions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        debugGraphics.buffer = buffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        return debugGraphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * Overrides <code>Graphics.create</code> to return a DebugGraphics object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    public Graphics create(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        DebugGraphics debugGraphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        debugGraphics = new DebugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        debugGraphics.graphics = graphics.create(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        debugGraphics.debugOptions = debugOptions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        debugGraphics.buffer = buffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        debugGraphics.xOffset = xOffset + x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        debugGraphics.yOffset = yOffset + y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        return debugGraphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    //------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    //  NEW METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    //------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Sets the Color used to flash drawing operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    public static void setFlashColor(Color flashColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        info().flashColor = flashColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * Returns the Color used to flash drawing operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @see #setFlashColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public static Color flashColor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        return info().flashColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * Sets the time delay of drawing operation flashing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    public static void setFlashTime(int flashTime) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        info().flashTime = flashTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * Returns the time delay of drawing operation flashing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @see #setFlashTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public static int flashTime() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        return info().flashTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * Sets the number of times that drawing operations will flash.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public static void setFlashCount(int flashCount) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        info().flashCount = flashCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    /** Returns the number of times that drawing operations will flash.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
      * @see #setFlashCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public static int flashCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        return info().flashCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /** Sets the stream to which the DebugGraphics logs drawing operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    public static void setLogStream(java.io.PrintStream stream) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        info().stream = stream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    /** Returns the stream to which the DebugGraphics logs drawing operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
      * @see #setLogStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    public static java.io.PrintStream logStream() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        return info().stream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    /** Sets the Font used for text drawing operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    public void setFont(Font aFont) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            info().log(toShortString() + " Setting font: " + aFont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        graphics.setFont(aFont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    /** Returns the Font used for text drawing operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
      * @see #setFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    public Font getFont() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        return graphics.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    /** Sets the color to be used for drawing and filling lines and shapes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    public void setColor(Color aColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            info().log(toShortString() + " Setting color: " + aColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        graphics.setColor(aColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /** Returns the Color used for text drawing operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
      * @see #setColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    public Color getColor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        return graphics.getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    //-----------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    // OVERRIDDEN METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    //------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * Overrides <code>Graphics.getFontMetrics</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    public FontMetrics getFontMetrics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        return graphics.getFontMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * Overrides <code>Graphics.getFontMetrics</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    public FontMetrics getFontMetrics(Font f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        return graphics.getFontMetrics(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * Overrides <code>Graphics.translate</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    public void translate(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                " Translating by: " + new Point(x, y));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        xOffset += x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        yOffset += y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        graphics.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * Overrides <code>Graphics.setPaintMode</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public void setPaintMode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            info().log(toShortString() + " Setting paint mode");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        graphics.setPaintMode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * Overrides <code>Graphics.setXORMode</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    public void setXORMode(Color aColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            info().log(toShortString() + " Setting XOR mode: " + aColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        graphics.setXORMode(aColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * Overrides <code>Graphics.getClipBounds</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    public Rectangle getClipBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        return graphics.getClipBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Overrides <code>Graphics.clipRect</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    public void clipRect(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        graphics.clipRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                " Setting clipRect: " + (new Rectangle(x, y, width, height)) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                " New clipRect: " + graphics.getClip());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * Overrides <code>Graphics.setClip</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    public void setClip(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        graphics.setClip(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                        " Setting new clipRect: " + graphics.getClip());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * Overrides <code>Graphics.getClip</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    public Shape getClip() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        return graphics.getClip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * Overrides <code>Graphics.setClip</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    public void setClip(Shape clip) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        graphics.setClip(clip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                       " Setting new clipRect: " +  graphics.getClip());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * Overrides <code>Graphics.drawRect</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    public void drawRect(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                      " Drawing rect: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                      new Rectangle(x, y, width, height));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                debugGraphics.drawRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                graphics.drawRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        graphics.drawRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * Overrides <code>Graphics.fillRect</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public void fillRect(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                      " Filling rect: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                      new Rectangle(x, y, width, height));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                debugGraphics.fillRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                graphics.fillRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        graphics.fillRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * Overrides <code>Graphics.clearRect</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    public void clearRect(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                      " Clearing rect: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                      new Rectangle(x, y, width, height));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                debugGraphics.clearRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                graphics.clearRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        graphics.clearRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * Overrides <code>Graphics.drawRoundRect</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    public void drawRoundRect(int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                              int arcWidth, int arcHeight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                      " Drawing round rect: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                      new Rectangle(x, y, width, height) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                      " arcWidth: " + arcWidth +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                      " archHeight: " + arcHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                debugGraphics.drawRoundRect(x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                                            arcWidth, arcHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                graphics.drawRoundRect(x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                                       arcWidth, arcHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        graphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * Overrides <code>Graphics.fillRoundRect</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    public void fillRoundRect(int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                              int arcWidth, int arcHeight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                      " Filling round rect: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                      new Rectangle(x, y, width, height) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                      " arcWidth: " + arcWidth +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                      " archHeight: " + arcHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                debugGraphics.fillRoundRect(x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                                            arcWidth, arcHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                graphics.fillRoundRect(x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                                       arcWidth, arcHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        graphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * Overrides <code>Graphics.drawLine</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    public void drawLine(int x1, int y1, int x2, int y2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                       " Drawing line: from " + pointToString(x1, y1) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                       " to " +  pointToString(x2, y2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                debugGraphics.drawLine(x1, y1, x2, y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                graphics.drawLine(x1, y1, x2, y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        graphics.drawLine(x1, y1, x2, y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * Overrides <code>Graphics.draw3DRect</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    public void draw3DRect(int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                           boolean raised) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                       " Drawing 3D rect: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                       new Rectangle(x, y, width, height) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                       " Raised bezel: " + raised);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                debugGraphics.draw3DRect(x, y, width, height, raised);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                graphics.draw3DRect(x, y, width, height, raised);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        graphics.draw3DRect(x, y, width, height, raised);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * Overrides <code>Graphics.fill3DRect</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    public void fill3DRect(int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                           boolean raised) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                       " Filling 3D rect: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                       new Rectangle(x, y, width, height) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                       " Raised bezel: " + raised);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                debugGraphics.fill3DRect(x, y, width, height, raised);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                graphics.fill3DRect(x, y, width, height, raised);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        graphics.fill3DRect(x, y, width, height, raised);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     * Overrides <code>Graphics.drawOval</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    public void drawOval(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                      " Drawing oval: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                      new Rectangle(x, y, width, height));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                debugGraphics.drawOval(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                graphics.drawOval(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        graphics.drawOval(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * Overrides <code>Graphics.fillOval</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    public void fillOval(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                      " Filling oval: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                      new Rectangle(x, y, width, height));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                debugGraphics.fillOval(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                graphics.fillOval(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        graphics.fillOval(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * Overrides <code>Graphics.drawArc</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    public void drawArc(int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                        int startAngle, int arcAngle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                      " Drawing arc: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                      new Rectangle(x, y, width, height) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                      " startAngle: " + startAngle +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                      " arcAngle: " + arcAngle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                debugGraphics.drawArc(x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                                      startAngle, arcAngle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                graphics.drawArc(x, y, width, height, startAngle, arcAngle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        graphics.drawArc(x, y, width, height, startAngle, arcAngle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * Overrides <code>Graphics.fillArc</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    public void fillArc(int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                        int startAngle, int arcAngle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                      " Filling arc: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
                      new Rectangle(x, y, width, height) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                      " startAngle: " + startAngle +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                      " arcAngle: " + arcAngle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                debugGraphics.fillArc(x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                                      startAngle, arcAngle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
                graphics.fillArc(x, y, width, height, startAngle, arcAngle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        graphics.fillArc(x, y, width, height, startAngle, arcAngle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     * Overrides <code>Graphics.drawPolyline</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    public void drawPolyline(int xPoints[], int yPoints[], int nPoints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                      " Drawing polyline: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                      " nPoints: " + nPoints +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                      " X's: " + xPoints +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                      " Y's: " + yPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                debugGraphics.drawPolyline(xPoints, yPoints, nPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                graphics.drawPolyline(xPoints, yPoints, nPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        graphics.drawPolyline(xPoints, yPoints, nPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * Overrides <code>Graphics.drawPolygon</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    public void drawPolygon(int xPoints[], int yPoints[], int nPoints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
                      " Drawing polygon: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
                      " nPoints: " + nPoints +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                      " X's: " + xPoints +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                      " Y's: " + yPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                debugGraphics.drawPolygon(xPoints, yPoints, nPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                graphics.drawPolygon(xPoints, yPoints, nPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        graphics.drawPolygon(xPoints, yPoints, nPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     * Overrides <code>Graphics.fillPolygon</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    public void fillPolygon(int xPoints[], int yPoints[], int nPoints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
                      " Filling polygon: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                      " nPoints: " + nPoints +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                      " X's: " + xPoints +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
                      " Y's: " + yPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                debugGraphics.fillPolygon(xPoints, yPoints, nPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
                graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                graphics.fillPolygon(xPoints, yPoints, nPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        graphics.fillPolygon(xPoints, yPoints, nPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
     * Overrides <code>Graphics.drawString</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    public void drawString(String aString, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                       " Drawing string: \"" + aString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                       "\" at: " + new Point(x, y));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
                debugGraphics.drawString(aString, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
                graphics.setColor((i % 2) == 0 ? info.flashColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
                                  : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                graphics.drawString(aString, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        graphics.drawString(aString, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
     * Overrides <code>Graphics.drawString</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
    public void drawString(AttributedCharacterIterator iterator, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
                       " Drawing text: \"" + iterator +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
                       "\" at: " + new Point(x, y));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                debugGraphics.drawString(iterator, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                graphics.setColor((i % 2) == 0 ? info.flashColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                                  : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                graphics.drawString(iterator, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
        graphics.drawString(iterator, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     * Overrides <code>Graphics.drawBytes</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
    public void drawBytes(byte data[], int offset, int length, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        Font font = graphics.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                       " Drawing bytes at: " + new Point(x, y));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                debugGraphics.drawBytes(data, offset, length, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
                graphics.setColor((i % 2) == 0 ? info.flashColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
                                  : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
                graphics.drawBytes(data, offset, length, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        graphics.drawBytes(data, offset, length, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
     * Overrides <code>Graphics.drawChars</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
    public void drawChars(char data[], int offset, int length, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        Font font = graphics.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                       " Drawing chars at " +  new Point(x, y));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                debugGraphics.drawChars(data, offset, length, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
            Color oldColor = getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                graphics.setColor((i % 2) == 0 ? info.flashColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                                  : oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                graphics.drawChars(data, offset, length, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
            graphics.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
        graphics.drawChars(data, offset, length, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * Overrides <code>Graphics.drawImage</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
    public boolean drawImage(Image img, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
                             ImageObserver observer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
            info.log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
                     " Drawing image: " + img +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                     " at: " + new Point(x, y));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
                debugGraphics.drawImage(img, x, y, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
            ImageProducer oldProducer = img.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
            ImageProducer newProducer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
                = new FilteredImageSource(oldProducer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
                                new DebugGraphicsFilter(info.flashColor));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
            Image newImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
                = Toolkit.getDefaultToolkit().createImage(newProducer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
            DebugGraphicsObserver imageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
                = new DebugGraphicsObserver();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
            Image imageToDraw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
                imageToDraw = (i % 2) == 0 ? newImage : img;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
                loadImage(imageToDraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
                graphics.drawImage(imageToDraw, x, y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
                                   imageObserver);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
        return graphics.drawImage(img, x, y, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     * Overrides <code>Graphics.drawImage</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
    public boolean drawImage(Image img, int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
                             ImageObserver observer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
            info.log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
                     " Drawing image: " + img +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
                     " at: " + new Rectangle(x, y, width, height));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
                debugGraphics.drawImage(img, x, y, width, height, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
            ImageProducer oldProducer = img.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
            ImageProducer newProducer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
                = new FilteredImageSource(oldProducer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
                                new DebugGraphicsFilter(info.flashColor));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
            Image newImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
                = Toolkit.getDefaultToolkit().createImage(newProducer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
            DebugGraphicsObserver imageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
                = new DebugGraphicsObserver();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
            Image imageToDraw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
                imageToDraw = (i % 2) == 0 ? newImage : img;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
                loadImage(imageToDraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                graphics.drawImage(imageToDraw, x, y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                                   width, height, imageObserver);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
        return graphics.drawImage(img, x, y, width, height, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
     * Overrides <code>Graphics.drawImage</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
    public boolean drawImage(Image img, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
                             Color bgcolor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
                             ImageObserver observer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
            info.log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
                     " Drawing image: " + img +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
                     " at: " + new Point(x, y) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
                     ", bgcolor: " + bgcolor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
                debugGraphics.drawImage(img, x, y, bgcolor, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
            ImageProducer oldProducer = img.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
            ImageProducer newProducer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
                = new FilteredImageSource(oldProducer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
                                new DebugGraphicsFilter(info.flashColor));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
            Image newImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
                = Toolkit.getDefaultToolkit().createImage(newProducer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
            DebugGraphicsObserver imageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
                = new DebugGraphicsObserver();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
            Image imageToDraw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
                imageToDraw = (i % 2) == 0 ? newImage : img;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
                loadImage(imageToDraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
                graphics.drawImage(imageToDraw, x, y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
                                   bgcolor, imageObserver);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
        return graphics.drawImage(img, x, y, bgcolor, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
     * Overrides <code>Graphics.drawImage</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
    public boolean drawImage(Image img, int x, int y,int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
                             Color bgcolor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
                             ImageObserver observer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
            info.log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
                     " Drawing image: " + img +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
                     " at: " + new Rectangle(x, y, width, height) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
                     ", bgcolor: " + bgcolor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
                debugGraphics.drawImage(img, x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
                                        bgcolor, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
            ImageProducer oldProducer = img.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
            ImageProducer newProducer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
                = new FilteredImageSource(oldProducer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
                                new DebugGraphicsFilter(info.flashColor));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
            Image newImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
                = Toolkit.getDefaultToolkit().createImage(newProducer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
            DebugGraphicsObserver imageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
                = new DebugGraphicsObserver();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
            Image imageToDraw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
                imageToDraw = (i % 2) == 0 ? newImage : img;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
                loadImage(imageToDraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
                graphics.drawImage(imageToDraw, x, y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
                                   width, height, bgcolor, imageObserver);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
        return graphics.drawImage(img, x, y, width, height, bgcolor, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
     * Overrides <code>Graphics.drawImage</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
    public boolean drawImage(Image img,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
                             int dx1, int dy1, int dx2, int dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
                             int sx1, int sy1, int sx2, int sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
                             ImageObserver observer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
            info.log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
                     " Drawing image: " + img +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
                     " destination: " + new Rectangle(dx1, dy1, dx2, dy2) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
                     " source: " + new Rectangle(sx1, sy1, sx2, sy2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
                debugGraphics.drawImage(img, dx1, dy1, dx2, dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
                                        sx1, sy1, sx2, sy2, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
            ImageProducer oldProducer = img.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
            ImageProducer newProducer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
                = new FilteredImageSource(oldProducer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
                                new DebugGraphicsFilter(info.flashColor));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
            Image newImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
                = Toolkit.getDefaultToolkit().createImage(newProducer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
            DebugGraphicsObserver imageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
                = new DebugGraphicsObserver();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
            Image imageToDraw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
                imageToDraw = (i % 2) == 0 ? newImage : img;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
                loadImage(imageToDraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
                graphics.drawImage(imageToDraw,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
                                   dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
                                   imageObserver);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
        return graphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
                                  observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
     * Overrides <code>Graphics.drawImage</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
    public boolean drawImage(Image img,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
                             int dx1, int dy1, int dx2, int dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
                             int sx1, int sy1, int sx2, int sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
                             Color bgcolor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
                             ImageObserver observer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
            info.log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
                     " Drawing image: " + img +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
                     " destination: " + new Rectangle(dx1, dy1, dx2, dy2) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
                     " source: " + new Rectangle(sx1, sy1, sx2, sy2) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
                     ", bgcolor: " + bgcolor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
        if (isDrawingBuffer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
            if (debugBuffered()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
                Graphics debugGraphics = debugGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
                debugGraphics.drawImage(img, dx1, dy1, dx2, dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
                                        sx1, sy1, sx2, sy2, bgcolor, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
                debugGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
        } else if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
            int i, count = (info.flashCount * 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
            ImageProducer oldProducer = img.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
            ImageProducer newProducer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
                = new FilteredImageSource(oldProducer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
                                new DebugGraphicsFilter(info.flashColor));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
            Image newImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
                = Toolkit.getDefaultToolkit().createImage(newProducer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
            DebugGraphicsObserver imageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
                = new DebugGraphicsObserver();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
            Image imageToDraw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
                imageToDraw = (i % 2) == 0 ? newImage : img;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
                loadImage(imageToDraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
                graphics.drawImage(imageToDraw,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
                                   dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
                                   bgcolor, imageObserver);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
                Toolkit.getDefaultToolkit().sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
                sleep(info.flashTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
        return graphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
                                  bgcolor, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
    static void loadImage(Image img) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
        imageLoadingIcon.loadImage(img);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
     * Overrides <code>Graphics.copyArea</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
    public void copyArea(int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
                         int destX, int destY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
        if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
            info().log(toShortString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
                      " Copying area from: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
                      new Rectangle(x, y, width, height) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
                      " to: " + new Point(destX, destY));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
        graphics.copyArea(x, y, width, height, destX, destY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
    final void sleep(int mSecs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
            Thread.sleep(mSecs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
     * Overrides <code>Graphics.dispose</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
    public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
        graphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
        graphics = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
    // ALERT!
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
     * Returns the drawingBuffer value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
     * @return true if this object is drawing from a Buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
    public boolean isDrawingBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
        return buffer != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
    String toShortString() {
7014
eb4fcf73ee99 6432566: Replace usage of StringBuffer with StringBuilder in Swing
rupashka
parents: 5506
diff changeset
  1325
        return "Graphics" + (isDrawingBuffer() ? "<B>" : "") + "(" + graphicsID + "-" + debugOptions + ")";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
    String pointToString(int x, int y) {
7014
eb4fcf73ee99 6432566: Replace usage of StringBuffer with StringBuilder in Swing
rupashka
parents: 5506
diff changeset
  1329
        return "(" + x + ", " + y + ")";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
    /** Enables/disables diagnostic information about every graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
      * operation. The value of <b>options</b> indicates how this information
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
      * should be displayed. LOG_OPTION causes a text message to be printed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
      * FLASH_OPTION causes the drawing to flash several times. BUFFERED_OPTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
      * creates a new Frame that shows each operation on an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
      * offscreen buffer. The value of <b>options</b> is bitwise OR'd into
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
      * the current value. To disable debugging use NONE_OPTION.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
    public void setDebugOptions(int options) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
        if (options != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
            if (options == NONE_OPTION) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
                if (debugOptions != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
                    System.err.println(toShortString() + " Disabling debug");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
                    debugOptions = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
                if (debugOptions != options) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
                    debugOptions |= options;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
                    if (debugLog()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
                        System.err.println(toShortString() + " Enabling debug");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
    /** Returns the current debugging options for this DebugGraphics.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
      * @see #setDebugOptions
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
    public int getDebugOptions() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
        return debugOptions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
    /** Static wrapper method for DebugGraphicsInfo.setDebugOptions(). Stores
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
      * options on a per component basis.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
    static void setDebugOptions(JComponent component, int options) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
        info().setDebugOptions(component, options);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
    /** Static wrapper method for DebugGraphicsInfo.getDebugOptions().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
    static int getDebugOptions(JComponent component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
        DebugGraphicsInfo debugGraphicsInfo = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
        if (debugGraphicsInfo == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
            return debugGraphicsInfo.getDebugOptions(component);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
    /** Returns non-zero if <b>component</b> should display with DebugGraphics,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
      * zero otherwise. Walks the JComponent's parent tree to determine if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
      * any debugging options have been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
    static int shouldComponentDebug(JComponent component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
        DebugGraphicsInfo info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
        if (info == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
            Container container = (Container)component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
            int debugOptions = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
            while (container != null && (container instanceof JComponent)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
                debugOptions |= info.getDebugOptions((JComponent)container);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
                container = container.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
            return debugOptions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
    /** Returns the number of JComponents that have debugging options turned
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
      * on.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
    static int debugComponentCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
        DebugGraphicsInfo debugGraphicsInfo = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
        if (debugGraphicsInfo != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
                    debugGraphicsInfo.componentToDebug != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
            return debugGraphicsInfo.componentToDebug.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
    boolean debugLog() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
        return (debugOptions & LOG_OPTION) == LOG_OPTION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
    boolean debugFlash() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
        return (debugOptions & FLASH_OPTION) == FLASH_OPTION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
    boolean debugBuffered() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
        return (debugOptions & BUFFERED_OPTION) == BUFFERED_OPTION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
    /** Returns a DebugGraphics for use in buffering window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
    private Graphics debugGraphics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
        DebugGraphics        debugGraphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
        DebugGraphicsInfo    info = info();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
        JFrame               debugFrame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
        if (info.debugFrame == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
            info.debugFrame = new JFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
            info.debugFrame.setSize(500, 500);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
        debugFrame = info.debugFrame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
        debugFrame.show();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
        debugGraphics = new DebugGraphics(debugFrame.getGraphics());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
        debugGraphics.setFont(getFont());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
        debugGraphics.setColor(getColor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
        debugGraphics.translate(xOffset, yOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
        debugGraphics.setClip(getClipBounds());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
        if (debugFlash()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
            debugGraphics.setDebugOptions(FLASH_OPTION);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
        return debugGraphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
    /** Returns DebugGraphicsInfo, or creates one if none exists.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
    static DebugGraphicsInfo info() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
        DebugGraphicsInfo debugGraphicsInfo = (DebugGraphicsInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
            SwingUtilities.appContextGet(debugGraphicsInfoKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
        if (debugGraphicsInfo == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
            debugGraphicsInfo = new DebugGraphicsInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
            SwingUtilities.appContextPut(debugGraphicsInfoKey,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
                                         debugGraphicsInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
        return debugGraphicsInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
    private static final Class debugGraphicsInfoKey = DebugGraphicsInfo.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
}