javax.swing
Class DebugGraphics

java.lang.Object
  extended by java.awt.Graphics
      extended by javax.swing.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 x, int y, Color background, ImageObserver observer)
          drawImage
 boolean drawImage(Image image, int x, int y, 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 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
 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(AttributedCharacterIterator iterator, int x, int y)
          drawString
 void drawString(String string, 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
drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, hitClip, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG_OPTION

public static final int LOG_OPTION
LOG_OPTION

See Also:
Constant Field Values

FLASH_OPTION

public static final int FLASH_OPTION
FLASH_OPTION

See Also:
Constant Field Values

BUFFERED_OPTION

public static final int BUFFERED_OPTION
BUFFERED_OPTION

See Also:
Constant Field Values

NONE_OPTION

public static final int NONE_OPTION
NONE_OPTION

See Also:
Constant Field Values
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

setColor

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

Specified by:
setColor in class Graphics
Parameters:
color - The color

create

public Graphics create()
Creates a overrides Graphics.create to create a DebugGraphics object.

Specified by:
create in class 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 class Graphics
Parameters:
x - the x coordinate
y - the y coordinate
width - the width
height - the height
Returns:
a new DebugGraphics object.

flashColor

public static Color flashColor()
flashColor

Returns:
Color

setFlashColor

public static void setFlashColor(Color color)
setFlashColor

Parameters:
color - the color to use for flashing

flashTime

public static int flashTime()
flashTime

Returns:
The time in milliseconds

setFlashTime

public static void setFlashTime(int time)
setFlashTime

Parameters:
time - The time in milliseconds

flashCount

public static int flashCount()
flashCount

Returns:
The number of flashes

setFlashCount

public static void setFlashCount(int count)
setFlashCount

Parameters:
count - The number of flashes

logStream

public static PrintStream logStream()
logStream

Returns:
The PrintStream to write logging messages to

setLogStream

public static void setLogStream(PrintStream stream)
setLogStream

Parameters:
stream - The currently set PrintStream.

getFont

public Font getFont()
getFont

Specified by:
getFont in class Graphics
Returns:
The font

setFont

public void setFont(Font font)
setFont

Specified by:
setFont in class Graphics
Parameters:
font - The font to use for drawing text

getColor

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

Specified by:
getColor in class Graphics
Returns:
The color.

getFontMetrics

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

Overrides:
getFontMetrics in class Graphics
Returns:
a FontMetrics object

getFontMetrics

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

Specified by:
getFontMetrics in class Graphics
Parameters:
font - the font to get the metrics for
Returns:
a FontMetrics object

translate

public void translate(int x,
                      int y)
translate

Specified by:
translate in class Graphics
Parameters:
x - the x coordinate
y - the y coordinate

setPaintMode

public void setPaintMode()
setPaintMode

Specified by:
setPaintMode in class Graphics

setXORMode

public void setXORMode(Color color)
setXORMode

Specified by:
setXORMode in class Graphics
Parameters:
color - the color

getClipBounds

public Rectangle getClipBounds()
getClipBounds

Specified by:
getClipBounds in class Graphics
Returns:
Rectangle

clipRect

public void clipRect(int x,
                     int y,
                     int width,
                     int height)
Intersects the current clip region with the given region.

Specified by:
clipRect in class 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(int x,
                    int y,
                    int width,
                    int height)
Sets the clipping region.

Specified by:
setClip in class 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

getClip

public Shape getClip()
Returns the current clipping region.

Specified by:
getClip in class Graphics
Returns:
Shape

setClip

public void setClip(Shape shape)
Sets the current clipping region

Specified by:
setClip in class Graphics
Parameters:
shape - The clippin region

drawRect

public void drawRect(int x,
                     int y,
                     int width,
                     int height)
Draws a rectangle.

Overrides:
drawRect in class 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

fillRect

public void fillRect(int x,
                     int y,
                     int width,
                     int height)
Draws a filled rectangle.

Specified by:
fillRect in class 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

clearRect

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

Specified by:
clearRect in class 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

Specified by:
drawRoundRect in class 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

fillRoundRect

public void fillRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
fillRoundRect

Specified by:
fillRoundRect in class 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

drawLine

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

Specified by:
drawLine in class 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

draw3DRect

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

Overrides:
draw3DRect in class 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

fill3DRect

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

Overrides:
fill3DRect in class 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

drawOval

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

Specified by:
drawOval in class Graphics
Parameters:
x - the x coordinate
y - the y coordiante
width - the width
height - the height

fillOval

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

Specified by:
fillOval in class Graphics
Parameters:
x - the x coordinate
y - the y coordinate
width - the width
height - the height

drawArc

public void drawArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
drawArc

Specified by:
drawArc in class Graphics
Parameters:
x - the x coordinate
y - the y coordinate
width - the width
height - the height
startAngle - TODO
arcAngle - TODO

fillArc

public void fillArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
fillArc

Specified by:
fillArc in class Graphics
Parameters:
x - the coordinate
y - the y coordinate
width - the width
height - the height
startAngle - TODO
arcAngle - TODO

drawPolyline

public void drawPolyline(int[] xpoints,
                         int[] ypoints,
                         int npoints)
drawPolyline

Specified by:
drawPolyline in class Graphics
Parameters:
xpoints - TODO
ypoints - TODO
npoints - TODO

drawPolygon

public void drawPolygon(int[] xpoints,
                        int[] ypoints,
                        int npoints)
drawPolygon

Specified by:
drawPolygon in class Graphics
Parameters:
xpoints - TODO
ypoints - TODO
npoints - TODO

fillPolygon

public void fillPolygon(int[] xpoints,
                        int[] ypoints,
                        int npoints)
fillPolygon

Specified by:
fillPolygon in class Graphics
Parameters:
xpoints - TODO
ypoints - TODO
npoints - TODO

drawString

public void drawString(String string,
                       int x,
                       int y)
drawString

Specified by:
drawString in class Graphics
Parameters:
string - the string
x - the x coordinate
y - the y coordinate

drawString

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

Specified by:
drawString in class Graphics
Parameters:
iterator - TODO
x - the x coordinate
y - the y coordinate

drawBytes

public void drawBytes(byte[] data,
                      int offset,
                      int length,
                      int x,
                      int y)
drawBytes

Overrides:
drawBytes in class 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

Overrides:
drawChars in class Graphics
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

Specified by:
drawImage in class Graphics
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

Specified by:
drawImage in class 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

Specified by:
drawImage in class 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,
                         int width,
                         int height,
                         Color background,
                         ImageObserver observer)
drawImage

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

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

Specified by:
drawImage in class 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

copyArea

public void copyArea(int x,
                     int y,
                     int width,
                     int height,
                     int destx,
                     int desty)
copyArea

Specified by:
copyArea in class 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

dispose

public void dispose()
Releases all system resources that this Graphics is using.

Specified by:
dispose in class Graphics

isDrawingBuffer

public boolean isDrawingBuffer()
isDrawingBuffer

Returns:
boolean

setDebugOptions

public void setDebugOptions(int options)
setDebugOptions

Parameters:
options - the debug options

getDebugOptions

public int getDebugOptions()
getDebugOptions

Returns:
the debug options