javax.swing

Class DebugGraphics


public class DebugGraphics
extends Graphics

An extension of Graphics that can be used for debugging custom Swing widgets. DebugGraphics has the ability to draw slowly and can log drawing actions.

Field Summary

static int
BUFFERED_OPTION
BUFFERED_OPTION
static int
FLASH_OPTION
FLASH_OPTION
static int
LOG_OPTION
LOG_OPTION
static int
NONE_OPTION
NONE_OPTION

Constructor Summary

DebugGraphics()
Creates a DebugGraphics object.
DebugGraphics(Graphics graphics)
Creates a DebugGraphics object.
DebugGraphics(Graphics graphics, JComponent component)
Creates a DebugGraphics object.

Method Summary

void
clearRect(int x, int y, int width, int height)
clearRect
void
clipRect(int x, int y, int width, int height)
Intersects the current clip region with the given region.
void
copyArea(int x, int y, int width, int height, int destx, int desty)
copyArea
Graphics
create()
Creates a overrides Graphics.create to create a DebugGraphics object.
Graphics
create(int x, int y, int width, int height)
Creates a overrides Graphics.create to create a DebugGraphics object.
void
dispose()
Releases all system resources that this Graphics is using.
void
draw3DRect(int x, int y, int width, int height, boolean raised)
draw3DRect
void
drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
drawArc
void
drawBytes(byte[] data, int offset, int length, int x, int y)
drawBytes
void
drawChars(char[] data, int offset, int length, int x, int y)
drawChars
boolean
drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color background, ImageObserver observer)
drawImage
boolean
drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
drawImage
boolean
drawImage(Image image, int x, int y, int width, int height, Color background, ImageObserver observer)
drawImage
boolean
drawImage(Image image, int x, int y, int width, int height, ImageObserver observer)
drawImage
boolean
drawImage(Image image, int x, int y, Color background, ImageObserver observer)
drawImage
boolean
drawImage(Image image, int x, int y, ImageObserver observer)
drawImage
void
drawLine(int x1, int y1, int x2, int y2)
drawLine
void
drawOval(int x, int y, int width, int height)
drawOval
void
drawPolygon(int[] xpoints, int[] ypoints, int npoints)
drawPolygon
void
drawPolyline(int[] xpoints, int[] ypoints, int npoints)
drawPolyline
void
drawRect(int x, int y, int width, int height)
Draws a rectangle.
void
drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
drawRoundRect
void
drawString(String string, int x, int y)
drawString
void
drawString(AttributedCharacterIterator iterator, int x, int y)
drawString
void
fill3DRect(int x, int y, int width, int height, boolean raised)
fill3DRect
void
fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
fillArc
void
fillOval(int x, int y, int width, int height)
fillOval
void
fillPolygon(int[] xpoints, int[] ypoints, int npoints)
fillPolygon
void
fillRect(int x, int y, int width, int height)
Draws a filled rectangle.
void
fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
fillRoundRect
static Color
flashColor()
flashColor
static int
flashCount()
flashCount
static int
flashTime()
flashTime
Shape
getClip()
Returns the current clipping region.
Rectangle
getClipBounds()
getClipBounds
Color
getColor()
Returns the color used for drawing.
int
getDebugOptions()
getDebugOptions
Font
getFont()
getFont
FontMetrics
getFontMetrics()
Returns the font metrics of the current font.
FontMetrics
getFontMetrics(Font font)
Returns the font metrics for a given font.
boolean
isDrawingBuffer()
isDrawingBuffer
static PrintStream
logStream()
logStream
void
setClip(int x, int y, int width, int height)
Sets the clipping region.
void
setClip(Shape shape)
Sets the current clipping region
void
setColor(Color color)
Sets the color to draw stuff with.
void
setDebugOptions(int options)
setDebugOptions
static void
setFlashColor(Color color)
setFlashColor
static void
setFlashCount(int count)
setFlashCount
static void
setFlashTime(int time)
setFlashTime
void
setFont(Font font)
setFont
static void
setLogStream(PrintStream stream)
setLogStream
void
setPaintMode()
setPaintMode
void
setXORMode(Color color)
setXORMode
void
translate(int x, int y)
translate

Methods inherited from class java.awt.Graphics

clearRect, clipRect, copyArea, create, create, dispose, draw3DRect, drawArc, drawBytes, drawChars, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolygon, drawPolyline, drawRect, drawRoundRect, drawString, drawString, fill3DRect, fillArc, fillOval, fillPolygon, fillPolygon, fillRect, fillRoundRect, finalize, getClip, getClipBounds, getClipBounds, getClipRect, getColor, getFont, getFontMetrics, getFontMetrics, hitClip, setClip, setClip, setColor, setFont, setPaintMode, setXORMode, toString, translate

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

BUFFERED_OPTION

public static final int BUFFERED_OPTION
BUFFERED_OPTION
Field Value:
4

FLASH_OPTION

public static final int FLASH_OPTION
FLASH_OPTION
Field Value:
2

LOG_OPTION

public static final int LOG_OPTION
LOG_OPTION
Field Value:
1

NONE_OPTION

public static final int NONE_OPTION
NONE_OPTION
Field Value:
-1

Constructor Details

DebugGraphics

public DebugGraphics()
Creates a DebugGraphics object.

DebugGraphics

public DebugGraphics(Graphics graphics)
Creates a DebugGraphics object.
Parameters:
graphics - The Graphics object to wrap

DebugGraphics

public DebugGraphics(Graphics graphics,
                     JComponent component)
Creates a DebugGraphics object.
Parameters:
graphics - The Graphics object to wrap
component - TODO

Method Details

clearRect

public void clearRect(int x,
                      int y,
                      int width,
                      int height)
clearRect
Overrides:
clearRect in interface Graphics
Parameters:
x - The x-position of the rectangle
y - The y-position of the rectangle
width - The width of the rectangle
height - The height of the rectangle

clipRect

public void clipRect(int x,
                     int y,
                     int width,
                     int height)
Intersects the current clip region with the given region.
Overrides:
clipRect in interface Graphics
Parameters:
x - The x-position of the region
y - The y-position of the region
width - The width of the region
height - The height of the region

copyArea

public void copyArea(int x,
                     int y,
                     int width,
                     int height,
                     int destx,
                     int desty)
copyArea
Overrides:
copyArea in interface Graphics
Parameters:
x - The x position of the source area
y - The y position of the source area
width - The width of the area
height - The height of the area
destx - The x position of the destination area
desty - The y posiiton of the destination area

create

public Graphics create()
Creates a overrides Graphics.create to create a DebugGraphics object.
Overrides:
create in interface Graphics
Returns:
a new DebugGraphics object.

create

public Graphics create(int x,
                       int y,
                       int width,
                       int height)
Creates a overrides Graphics.create to create a DebugGraphics object.
Overrides:
create in interface Graphics
Parameters:
x - the x coordinate
y - the y coordinate
width - the width
height - the height
Returns:
a new DebugGraphics object.

dispose

public void dispose()
Releases all system resources that this Graphics is using.
Overrides:
dispose in interface Graphics

draw3DRect

public void draw3DRect(int x,
                       int y,
                       int width,
                       int height,
                       boolean raised)
draw3DRect
Overrides:
draw3DRect in interface Graphics
Parameters:
x - The x-position of the rectangle
y - The y-position of the rectangle
width - The width of the rectangle
height - The height of the rectangle
raised - TODO

drawArc

public void drawArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
drawArc
Overrides:
drawArc in interface Graphics
Parameters:
x - the x coordinate
y - the y coordinate
width - the width
height - the height
startAngle - TODO
arcAngle - TODO

drawBytes

public void drawBytes(byte[] data,
                      int offset,
                      int length,
                      int x,
                      int y)
drawBytes
Overrides:
drawBytes in interface Graphics
Parameters:
data - TODO
offset - TODO
length - TODO
x - the x coordinate
y - the y coordinate

drawChars

public void drawChars(char[] data,
                      int offset,
                      int length,
                      int x,
                      int y)
drawChars
Parameters:
data - array of characters to draw
offset - offset in array
length - number of characters in array to draw
x - x-position
y - y-position

drawImage

public boolean drawImage(Image image,
                         int dx1,
                         int dy1,
                         int dx2,
                         int dy2,
                         int sx1,
                         int sy1,
                         int sx2,
                         int sy2,
                         Color background,
                         ImageObserver observer)
drawImage
Overrides:
drawImage in interface Graphics
Parameters:
image - The image to draw
dx1 - TODO
dy1 - TODO
dx2 - TODO
dy2 - TODO
sx1 - TODO
sy1 - TODO
sx2 - TODO
sy2 - TODO
background - The color for the background in the opaque regions of the image
observer - The image observer
Returns:
boolean

drawImage

public boolean drawImage(Image image,
                         int dx1,
                         int dy1,
                         int dx2,
                         int dy2,
                         int sx1,
                         int sy1,
                         int sx2,
                         int sy2,
                         ImageObserver observer)
drawImage
Overrides:
drawImage in interface Graphics
Parameters:
image - The image to draw
dx1 - TODO
dy1 - TODO
dx2 - TODO
dy2 - TODO
sx1 - TODO
sy1 - TODO
sx2 - TODO
sy2 - TODO
observer - The image observer
Returns:
boolean

drawImage

public boolean drawImage(Image image,
                         int x,
                         int y,
                         int width,
                         int height,
                         Color background,
                         ImageObserver observer)
drawImage
Overrides:
drawImage in interface Graphics
Parameters:
image - The image to draw
x - The x position
y - The y position
width - The width of the area to draw the image
height - The height of the area to draw the image
background - The color for the background in the opaque regions of the image
observer - The image observer
Returns:
boolean

drawImage

public boolean drawImage(Image image,
                         int x,
                         int y,
                         int width,
                         int height,
                         ImageObserver observer)
drawImage
Overrides:
drawImage in interface Graphics
Parameters:
image - The image to draw
x - The x position
y - The y position
width - The width of the area to draw the image
height - The height of the area to draw the image
observer - The image observer
Returns:
boolean

drawImage

public boolean drawImage(Image image,
                         int x,
                         int y,
                         Color background,
                         ImageObserver observer)
drawImage
Overrides:
drawImage in interface Graphics
Parameters:
image - The image to draw
x - The x position
y - The y position
background - The color for the background in the opaque regions of the image
observer - The image observer
Returns:
boolean

drawImage

public boolean drawImage(Image image,
                         int x,
                         int y,
                         ImageObserver observer)
drawImage
Overrides:
drawImage in interface Graphics
Parameters:
image - The image to draw
x - The x position
y - The y position
observer - The image observer
Returns:
boolean

drawLine

public void drawLine(int x1,
                     int y1,
                     int x2,
                     int y2)
drawLine
Overrides:
drawLine in interface Graphics
Parameters:
x1 - The x-position of the start
y1 - The y-position of the start
x2 - The x-position of the end
y2 - The y-position of the end

drawOval

public void drawOval(int x,
                     int y,
                     int width,
                     int height)
drawOval
Overrides:
drawOval in interface Graphics
Parameters:
x - the x coordinate
y - the y coordiante
width - the width
height - the height

drawPolygon

public void drawPolygon(int[] xpoints,
                        int[] ypoints,
                        int npoints)
drawPolygon
Parameters:
xpoints - TODO
ypoints - TODO
npoints - TODO

drawPolyline

public void drawPolyline(int[] xpoints,
                         int[] ypoints,
                         int npoints)
drawPolyline
Parameters:
xpoints - TODO
ypoints - TODO
npoints - TODO

drawRect

public void drawRect(int x,
                     int y,
                     int width,
                     int height)
Draws a rectangle.
Overrides:
drawRect in interface Graphics
Parameters:
x - The x-position of the rectangle
y - The y-position of the rectangle
width - The width of the rectangle
height - The height of the rectangle

drawRoundRect

public void drawRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
drawRoundRect
Overrides:
drawRoundRect in interface Graphics
Parameters:
x - The x-position of the rectangle
y - The y-position of the rectangle
width - The width of the rectangle
height - The height of the rectangle
arcWidth - TODO
arcHeight - TODO

drawString

public void drawString(String string,
                       int x,
                       int y)
drawString
Overrides:
drawString in interface Graphics
Parameters:
string - the string
x - the x coordinate
y - the y coordinate

drawString

public void drawString(AttributedCharacterIterator iterator,
                       int x,
                       int y)
drawString
Overrides:
drawString in interface Graphics
Parameters:
iterator - TODO
x - the x coordinate
y - the y coordinate

fill3DRect

public void fill3DRect(int x,
                       int y,
                       int width,
                       int height,
                       boolean raised)
fill3DRect
Overrides:
fill3DRect in interface Graphics
Parameters:
x - The x-position of the rectangle
y - The y-position of the rectangle
width - The width of the rectangle
height - The height of the rectangle
raised - TODO

fillArc

public void fillArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
fillArc
Overrides:
fillArc in interface Graphics
Parameters:
x - the coordinate
y - the y coordinate
width - the width
height - the height
startAngle - TODO
arcAngle - TODO

fillOval

public void fillOval(int x,
                     int y,
                     int width,
                     int height)
fillOval
Overrides:
fillOval in interface Graphics
Parameters:
x - the x coordinate
y - the y coordinate
width - the width
height - the height

fillPolygon

public void fillPolygon(int[] xpoints,
                        int[] ypoints,
                        int npoints)
fillPolygon
Parameters:
xpoints - TODO
ypoints - TODO
npoints - TODO

fillRect

public void fillRect(int x,
                     int y,
                     int width,
                     int height)
Draws a filled rectangle.
Overrides:
fillRect in interface Graphics
Parameters:
x - The x-position of the rectangle
y - The y-position of the rectangle
width - The width of the rectangle
height - The height of the rectangle

fillRoundRect

public void fillRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
fillRoundRect
Overrides:
fillRoundRect in interface Graphics
Parameters:
x - The x-position of the rectangle
y - The y-position of the rectangle
width - The width of the rectangle
height - The height of the rectangle
arcWidth - TODO
arcHeight - TODO

flashColor

public static Color flashColor()
flashColor
Returns:
Color

flashCount

public static int flashCount()
flashCount
Returns:
The number of flashes

flashTime

public static int flashTime()
flashTime
Returns:
The time in milliseconds

getClip

public Shape getClip()
Returns the current clipping region.
Overrides:
getClip in interface Graphics
Returns:
Shape

getClipBounds

public Rectangle getClipBounds()
getClipBounds
Overrides:
getClipBounds in interface Graphics
Returns:
Rectangle

getColor

public Color getColor()
Returns the color used for drawing.
Overrides:
getColor in interface Graphics
Returns:
The color.

getDebugOptions

public int getDebugOptions()
getDebugOptions
Returns:
the debug options

getFont

public Font getFont()
getFont
Overrides:
getFont in interface Graphics
Returns:
The font

getFontMetrics

public FontMetrics getFontMetrics()
Returns the font metrics of the current font.
Overrides:
getFontMetrics in interface Graphics
Returns:
a FontMetrics object

getFontMetrics

public FontMetrics getFontMetrics(Font font)
Returns the font metrics for a given font.
Overrides:
getFontMetrics in interface Graphics
Parameters:
font - the font to get the metrics for
Returns:
a FontMetrics object

isDrawingBuffer

public boolean isDrawingBuffer()
isDrawingBuffer
Returns:
boolean

logStream

public static PrintStream logStream()
logStream
Returns:
The PrintStream to write logging messages to

setClip

public void setClip(int x,
                    int y,
                    int width,
                    int height)
Sets the clipping region.
Overrides:
setClip in interface Graphics
Parameters:
x - The x-position of the region
y - The y-position of the region
width - The width of the region
height - The height of the region

setClip

public void setClip(Shape shape)
Sets the current clipping region
Overrides:
setClip in interface Graphics
Parameters:
shape - The clippin region

setColor

public void setColor(Color color)
Sets the color to draw stuff with.
Overrides:
setColor in interface Graphics
Parameters:
color - The color

setDebugOptions

public void setDebugOptions(int options)
setDebugOptions
Parameters:
options - the debug options

setFlashColor

public static void setFlashColor(Color color)
setFlashColor
Parameters:
color - the color to use for flashing

setFlashCount

public static void setFlashCount(int count)
setFlashCount
Parameters:
count - The number of flashes

setFlashTime

public static void setFlashTime(int time)
setFlashTime
Parameters:
time - The time in milliseconds

setFont

public void setFont(Font font)
setFont
Overrides:
setFont in interface Graphics
Parameters:
font - The font to use for drawing text

setLogStream

public static void setLogStream(PrintStream stream)
setLogStream
Parameters:
stream - The currently set PrintStream.

setPaintMode

public void setPaintMode()
setPaintMode
Overrides:
setPaintMode in interface Graphics

setXORMode

public void setXORMode(Color color)
setXORMode
Overrides:
setXORMode in interface Graphics
Parameters:
color - the color

translate

public void translate(int x,
                      int y)
translate
Overrides:
translate in interface Graphics
Parameters:
x - the x coordinate
y - the y coordinate

DebugGraphics.java -- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath 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 for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.