javax.swing

Class DebugGraphics

public class DebugGraphics extends Graphics

An extension of {@link 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 intBUFFERED_OPTION
BUFFERED_OPTION
static intFLASH_OPTION
FLASH_OPTION
static intLOG_OPTION
LOG_OPTION
static intNONE_OPTION
NONE_OPTION
Constructor Summary
DebugGraphics()
Creates a DebugGraphics object.
DebugGraphics(Graphics graphics, JComponent component)
Creates a DebugGraphics object.
DebugGraphics(Graphics graphics)
Creates a DebugGraphics object.
Method Summary
voidclearRect(int x, int y, int width, int height)
clearRect
voidclipRect(int x, int y, int width, int height)
Intersects the current clip region with the given region.
voidcopyArea(int x, int y, int width, int height, int destx, int desty)
copyArea
Graphicscreate()
Creates a overrides Graphics.create to create a DebugGraphics object.
Graphicscreate(int x, int y, int width, int height)
Creates a overrides Graphics.create to create a DebugGraphics object.
voiddispose()
Releases all system resources that this Graphics is using.
voiddraw3DRect(int x, int y, int width, int height, boolean raised)
draw3DRect
voiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
drawArc
voiddrawBytes(byte[] data, int offset, int length, int x, int y)
drawBytes
voiddrawChars(char[] data, int offset, int length, int x, int y)
drawChars
booleandrawImage(Image image, int x, int y, ImageObserver observer)
drawImage
booleandrawImage(Image image, int x, int y, int width, int height, ImageObserver observer)
drawImage
booleandrawImage(Image image, int x, int y, Color background, ImageObserver observer)
drawImage
booleandrawImage(Image image, int x, int y, int width, int height, Color background, ImageObserver observer)
drawImage
booleandrawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
drawImage
booleandrawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color background, ImageObserver observer)
drawImage
voiddrawLine(int x1, int y1, int x2, int y2)
drawLine
voiddrawOval(int x, int y, int width, int height)
drawOval
voiddrawPolygon(int[] xpoints, int[] ypoints, int npoints)
drawPolygon
voiddrawPolyline(int[] xpoints, int[] ypoints, int npoints)
drawPolyline
voiddrawRect(int x, int y, int width, int height)
Draws a rectangle.
voiddrawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
drawRoundRect
voiddrawString(String string, int x, int y)
drawString
voiddrawString(AttributedCharacterIterator iterator, int x, int y)
drawString
voidfill3DRect(int x, int y, int width, int height, boolean raised)
fill3DRect
voidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
fillArc
voidfillOval(int x, int y, int width, int height)
fillOval
voidfillPolygon(int[] xpoints, int[] ypoints, int npoints)
fillPolygon
voidfillRect(int x, int y, int width, int height)
Draws a filled rectangle.
voidfillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
fillRoundRect
static ColorflashColor()
flashColor
static intflashCount()
flashCount
static intflashTime()
flashTime
ShapegetClip()
Returns the current clipping region.
RectanglegetClipBounds()
getClipBounds
ColorgetColor()
Returns the color used for drawing.
intgetDebugOptions()
getDebugOptions
FontgetFont()
getFont
FontMetricsgetFontMetrics()
Returns the font metrics of the current font.
FontMetricsgetFontMetrics(Font font)
Returns the font metrics for a given font.
booleanisDrawingBuffer()
isDrawingBuffer
static PrintStreamlogStream()
logStream
voidsetClip(int x, int y, int width, int height)
Sets the clipping region.
voidsetClip(Shape shape)
Sets the current clipping region
voidsetColor(Color color)
Sets the color to draw stuff with.
voidsetDebugOptions(int options)
setDebugOptions
static voidsetFlashColor(Color color)
setFlashColor
static voidsetFlashCount(int count)
setFlashCount
static voidsetFlashTime(int time)
setFlashTime
voidsetFont(Font font)
setFont
static voidsetLogStream(PrintStream stream)
setLogStream
voidsetPaintMode()
setPaintMode
voidsetXORMode(Color color)
setXORMode
voidtranslate(int x, int y)
translate

Field Detail

BUFFERED_OPTION

public static final int BUFFERED_OPTION
BUFFERED_OPTION

FLASH_OPTION

public static final int FLASH_OPTION
FLASH_OPTION

LOG_OPTION

public static final int LOG_OPTION
LOG_OPTION

NONE_OPTION

public static final int NONE_OPTION
NONE_OPTION

Constructor Detail

DebugGraphics

public DebugGraphics()
Creates a DebugGraphics object.

DebugGraphics

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

Parameters: graphics The Graphics object to wrap component TODO

DebugGraphics

public DebugGraphics(Graphics graphics)
Creates a DebugGraphics object.

Parameters: graphics The Graphics object to wrap

Method Detail

clearRect

public void clearRect(int x, int y, int width, int height)
clearRect

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.

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

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.

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.

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.

draw3DRect

public void draw3DRect(int x, int y, int width, int height, boolean raised)
draw3DRect

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

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

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 x, int y, ImageObserver observer)
drawImage

Parameters: image The image to draw x The x position y The y position observer The image observer

Returns: boolean

drawImage

public boolean drawImage(Image image, int x, int y, int width, int height, ImageObserver observer)
drawImage

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

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, int width, int height, Color background, ImageObserver observer)
drawImage

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 dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
drawImage

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 dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color background, ImageObserver observer)
drawImage

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

drawLine

public void drawLine(int x1, int y1, int x2, int y2)
drawLine

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

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.

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

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

Parameters: string the string x the x coordinate y the y coordinate

drawString

public void drawString(AttributedCharacterIterator iterator, int x, int y)
drawString

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

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

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

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.

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

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.

Returns: Shape

getClipBounds

public Rectangle getClipBounds()
getClipBounds

Returns: Rectangle

getColor

public Color getColor()
Returns the color used for drawing.

Returns: The color.

getDebugOptions

public int getDebugOptions()
getDebugOptions

Returns: the debug options

getFont

public Font getFont()
getFont

Returns: The font

getFontMetrics

public FontMetrics getFontMetrics()
Returns the font metrics of the current font.

Returns: a FontMetrics object

getFontMetrics

public FontMetrics getFontMetrics(Font font)
Returns the font metrics for a given font.

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.

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

Parameters: shape The clippin region

setColor

public void setColor(Color color)
Sets the color to draw stuff with.

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

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

setXORMode

public void setXORMode(Color color)
setXORMode

Parameters: color the color

translate

public void translate(int x, int y)
translate

Parameters: x the x coordinate y the y coordinate