/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Graphics subclass supporting graphics debugging. Overrides most methods
* from Graphics. DebugGraphics objects are rarely created by hand. They
* are most frequently created automatically when a JComponent's
* debugGraphicsOptions are changed using the setDebugGraphicsOptions()
* method.
* <p>
* NOTE: You must turn off double buffering to use DebugGraphics:
* RepaintManager repaintManager = RepaintManager.currentManager(component);
* repaintManager.setDoubleBufferingEnabled(false);
*
* @see JComponent#setDebugGraphicsOptions
* @see RepaintManager#currentManager
* @see RepaintManager#setDoubleBufferingEnabled
*
* @author Dave Karlton
*/
int debugOptions;
/** Log graphics operations. */
/** Flash graphics operations. */
/** Show buffered operations in a separate <code>Frame</code>. */
/** Don't debug graphics operations. */
static {
JComponent.DEBUG_GRAPHICS_LOADED = true;
}
/**
* Constructs a new debug graphics context that supports slowed
* down drawing.
*/
public DebugGraphics() {
super();
}
/**
* Constructs a debug graphics context from an existing graphics
* context that slows down drawing for the specified component.
*
* @param graphics the Graphics context to slow down
* @param component the JComponent to draw slowly
*/
this(graphics);
}
/**
* Constructs a debug graphics context from an existing graphics
* context that supports slowed down drawing.
*
* @param graphics the Graphics context to slow down
*/
this();
}
/**
* Overrides <code>Graphics.create</code> to return a DebugGraphics object.
*/
debugGraphics = new DebugGraphics();
return debugGraphics;
}
/**
* Overrides <code>Graphics.create</code> to return a DebugGraphics object.
*/
debugGraphics = new DebugGraphics();
return debugGraphics;
}
//------------------------------------------------
// NEW METHODS
//------------------------------------------------
/**
* Sets the Color used to flash drawing operations.
*/
}
/**
* Returns the Color used to flash drawing operations.
* @see #setFlashColor
*/
return info().flashColor;
}
/**
* Sets the time delay of drawing operation flashing.
*/
}
/**
* Returns the time delay of drawing operation flashing.
* @see #setFlashTime
*/
public static int flashTime() {
}
/**
* Sets the number of times that drawing operations will flash.
*/
}
/** Returns the number of times that drawing operations will flash.
* @see #setFlashCount
*/
public static int flashCount() {
return info().flashCount;
}
/** Sets the stream to which the DebugGraphics logs drawing operations.
*/
}
/** Returns the stream to which the DebugGraphics logs drawing operations.
* @see #setLogStream
*/
}
/** Sets the Font used for text drawing operations.
*/
if (debugLog()) {
}
}
/** Returns the Font used for text drawing operations.
* @see #setFont
*/
}
/** Sets the color to be used for drawing and filling lines and shapes.
*/
if (debugLog()) {
}
}
/** Returns the Color used for text drawing operations.
* @see #setColor
*/
}
//-----------------------------------------------
// OVERRIDDEN METHODS
//------------------------------------------------
/**
* Overrides <code>Graphics.getFontMetrics</code>.
*/
return graphics.getFontMetrics();
}
/**
* Overrides <code>Graphics.getFontMetrics</code>.
*/
return graphics.getFontMetrics(f);
}
/**
* Overrides <code>Graphics.translate</code>.
*/
public void translate(int x, int y) {
if (debugLog()) {
" Translating by: " + new Point(x, y));
}
xOffset += x;
yOffset += y;
}
/**
* Overrides <code>Graphics.setPaintMode</code>.
*/
public void setPaintMode() {
if (debugLog()) {
}
}
/**
* Overrides <code>Graphics.setXORMode</code>.
*/
if (debugLog()) {
}
}
/**
* Overrides <code>Graphics.getClipBounds</code>.
*/
return graphics.getClipBounds();
}
/**
* Overrides <code>Graphics.clipRect</code>.
*/
if (debugLog()) {
}
}
/**
* Overrides <code>Graphics.setClip</code>.
*/
if (debugLog()) {
}
}
/**
* Overrides <code>Graphics.getClip</code>.
*/
}
/**
* Overrides <code>Graphics.setClip</code>.
*/
if (debugLog()) {
}
}
/**
* Overrides <code>Graphics.drawRect</code>.
*/
if (debugLog()) {
" Drawing rect: " +
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.fillRect</code>.
*/
if (debugLog()) {
" Filling rect: " +
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.clearRect</code>.
*/
if (debugLog()) {
" Clearing rect: " +
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.drawRoundRect</code>.
*/
if (debugLog()) {
" Drawing round rect: " +
" arcWidth: " + arcWidth +
" archHeight: " + arcHeight);
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.fillRoundRect</code>.
*/
if (debugLog()) {
" Filling round rect: " +
" arcWidth: " + arcWidth +
" archHeight: " + arcHeight);
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.drawLine</code>.
*/
if (debugLog()) {
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.draw3DRect</code>.
*/
boolean raised) {
if (debugLog()) {
" Drawing 3D rect: " +
" Raised bezel: " + raised);
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.fill3DRect</code>.
*/
boolean raised) {
if (debugLog()) {
" Filling 3D rect: " +
" Raised bezel: " + raised);
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.drawOval</code>.
*/
if (debugLog()) {
" Drawing oval: " +
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.fillOval</code>.
*/
if (debugLog()) {
" Filling oval: " +
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.drawArc</code>.
*/
int startAngle, int arcAngle) {
if (debugLog()) {
" Drawing arc: " +
" startAngle: " + startAngle +
" arcAngle: " + arcAngle);
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.fillArc</code>.
*/
int startAngle, int arcAngle) {
if (debugLog()) {
" Filling arc: " +
" startAngle: " + startAngle +
" arcAngle: " + arcAngle);
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.drawPolyline</code>.
*/
if (debugLog()) {
" Drawing polyline: " +
" nPoints: " + nPoints +
" X's: " + xPoints +
" Y's: " + yPoints);
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.drawPolygon</code>.
*/
if (debugLog()) {
" Drawing polygon: " +
" nPoints: " + nPoints +
" X's: " + xPoints +
" Y's: " + yPoints);
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.fillPolygon</code>.
*/
if (debugLog()) {
" Filling polygon: " +
" nPoints: " + nPoints +
" X's: " + xPoints +
" Y's: " + yPoints);
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.drawString</code>.
*/
if (debugLog()) {
" Drawing string: \"" + aString +
"\" at: " + new Point(x, y));
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
: oldColor);
}
}
}
/**
* Overrides <code>Graphics.drawString</code>.
*/
if (debugLog()) {
" Drawing text: \"" + iterator +
"\" at: " + new Point(x, y));
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
: oldColor);
}
}
}
/**
* Overrides <code>Graphics.drawBytes</code>.
*/
if (debugLog()) {
" Drawing bytes at: " + new Point(x, y));
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
: oldColor);
}
}
}
/**
* Overrides <code>Graphics.drawChars</code>.
*/
if (debugLog()) {
" Drawing chars at " + new Point(x, y));
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
for (i = 0; i < count; i++) {
: oldColor);
}
}
}
/**
* Overrides <code>Graphics.drawImage</code>.
*/
if (debugLog()) {
" Drawing image: " + img +
" at: " + new Point(x, y));
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
= new FilteredImageSource(oldProducer,
= new DebugGraphicsObserver();
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.drawImage</code>.
*/
if (debugLog()) {
" Drawing image: " + img +
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
= new FilteredImageSource(oldProducer,
= new DebugGraphicsObserver();
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.drawImage</code>.
*/
if (debugLog()) {
" Drawing image: " + img +
" at: " + new Point(x, y) +
", bgcolor: " + bgcolor);
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
= new FilteredImageSource(oldProducer,
= new DebugGraphicsObserver();
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.drawImage</code>.
*/
if (debugLog()) {
" Drawing image: " + img +
", bgcolor: " + bgcolor);
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
= new FilteredImageSource(oldProducer,
= new DebugGraphicsObserver();
for (i = 0; i < count; i++) {
}
}
}
/**
* Overrides <code>Graphics.drawImage</code>.
*/
if (debugLog()) {
" Drawing image: " + img +
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
= new FilteredImageSource(oldProducer,
= new DebugGraphicsObserver();
for (i = 0; i < count; i++) {
}
}
observer);
}
/**
* Overrides <code>Graphics.drawImage</code>.
*/
if (debugLog()) {
" Drawing image: " + img +
", bgcolor: " + bgcolor);
}
if (isDrawingBuffer()) {
if (debugBuffered()) {
}
} else if (debugFlash()) {
= new FilteredImageSource(oldProducer,
= new DebugGraphicsObserver();
for (i = 0; i < count; i++) {
}
}
}
}
/**
* Overrides <code>Graphics.copyArea</code>.
*/
if (debugLog()) {
" Copying area from: " +
}
}
try {
} catch (Exception e) {
}
}
/**
* Overrides <code>Graphics.dispose</code>.
*/
public void dispose() {
}
// ALERT!
/**
* Returns the drawingBuffer value.
*
* @return true if this object is drawing from a Buffer
*/
public boolean isDrawingBuffer() {
}
}
return "(" + x + ", " + y + ")";
}
* operation. The value of <b>options</b> indicates how this information
* should be displayed. LOG_OPTION causes a text message to be printed.
* FLASH_OPTION causes the drawing to flash several times. BUFFERED_OPTION
* creates a new Frame that shows each operation on an
* offscreen buffer. The value of <b>options</b> is bitwise OR'd into
* the current value. To disable debugging use NONE_OPTION.
*/
if (options != 0) {
if (options == NONE_OPTION) {
if (debugOptions != 0) {
debugOptions = 0;
}
} else {
if (debugOptions != options) {
debugOptions |= options;
if (debugLog()) {
}
}
}
}
}
/** Returns the current debugging options for this DebugGraphics.
* @see #setDebugOptions
*/
public int getDebugOptions() {
return debugOptions;
}
/** Static wrapper method for DebugGraphicsInfo.setDebugOptions(). Stores
* options on a per component basis.
*/
}
/** Static wrapper method for DebugGraphicsInfo.getDebugOptions().
*/
if (debugGraphicsInfo == null) {
return 0;
} else {
}
}
/** Returns non-zero if <b>component</b> should display with DebugGraphics,
* zero otherwise. Walks the JComponent's parent tree to determine if
* any debugging options have been set.
*/
return 0;
} else {
int debugOptions = 0;
}
return debugOptions;
}
}
/** Returns the number of JComponents that have debugging options turned
* on.
*/
static int debugComponentCount() {
if (debugGraphicsInfo != null &&
} else {
return 0;
}
}
boolean debugLog() {
}
boolean debugFlash() {
}
boolean debugBuffered() {
}
/** Returns a DebugGraphics for use in buffering window.
*/
}
debugFrame.show();
if (debugFlash()) {
}
return debugGraphics;
}
/** Returns DebugGraphicsInfo, or creates one if none exists.
*/
if (debugGraphicsInfo == null) {
debugGraphicsInfo = new DebugGraphicsInfo();
}
return debugGraphicsInfo;
}
}