Class DebugGraphics
java.lang.Object
java.awt.Graphics
javax.swing.DebugGraphics
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.
NOTE: You must turn off double buffering to use DebugGraphics: RepaintManager repaintManager = RepaintManager.currentManager(component); repaintManager.setDoubleBufferingEnabled(false);
- Since:
- 1.2
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Show buffered operations in a separateFrame
.static final int
Flash graphics operations.static final int
Log graphics operations.static final int
Don't debug graphics operations. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new debug graphics context that supports slowed down drawing.DebugGraphics
(Graphics graphics) Constructs a debug graphics context from an existing graphics context that supports slowed down drawing.DebugGraphics
(Graphics graphics, JComponent component) Constructs a debug graphics context from an existing graphics context that slows down drawing for the specified component. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clearRect
(int x, int y, int width, int height) OverridesGraphics.clearRect
.void
clipRect
(int x, int y, int width, int height) OverridesGraphics.clipRect
.void
copyArea
(int x, int y, int width, int height, int destX, int destY) OverridesGraphics.copyArea
.create()
OverridesGraphics.create
to return a DebugGraphics object.create
(int x, int y, int width, int height) OverridesGraphics.create
to return a DebugGraphics object.void
dispose()
OverridesGraphics.dispose
.void
draw3DRect
(int x, int y, int width, int height, boolean raised) OverridesGraphics.draw3DRect
.void
drawArc
(int x, int y, int width, int height, int startAngle, int arcAngle) OverridesGraphics.drawArc
.void
drawBytes
(byte[] data, int offset, int length, int x, int y) OverridesGraphics.drawBytes
.void
drawChars
(char[] data, int offset, int length, int x, int y) OverridesGraphics.drawChars
.boolean
drawImage
(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) OverridesGraphics.drawImage
.boolean
drawImage
(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) OverridesGraphics.drawImage
.boolean
drawImage
(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) OverridesGraphics.drawImage
.boolean
drawImage
(Image img, int x, int y, int width, int height, ImageObserver observer) OverridesGraphics.drawImage
.boolean
drawImage
(Image img, int x, int y, Color bgcolor, ImageObserver observer) OverridesGraphics.drawImage
.boolean
drawImage
(Image img, int x, int y, ImageObserver observer) OverridesGraphics.drawImage
.void
drawLine
(int x1, int y1, int x2, int y2) OverridesGraphics.drawLine
.void
drawOval
(int x, int y, int width, int height) OverridesGraphics.drawOval
.void
drawPolygon
(int[] xPoints, int[] yPoints, int nPoints) OverridesGraphics.drawPolygon
.void
drawPolyline
(int[] xPoints, int[] yPoints, int nPoints) OverridesGraphics.drawPolyline
.void
drawRect
(int x, int y, int width, int height) OverridesGraphics.drawRect
.void
drawRoundRect
(int x, int y, int width, int height, int arcWidth, int arcHeight) OverridesGraphics.drawRoundRect
.void
drawString
(String aString, int x, int y) OverridesGraphics.drawString
.void
drawString
(AttributedCharacterIterator iterator, int x, int y) OverridesGraphics.drawString
.void
fill3DRect
(int x, int y, int width, int height, boolean raised) OverridesGraphics.fill3DRect
.void
fillArc
(int x, int y, int width, int height, int startAngle, int arcAngle) OverridesGraphics.fillArc
.void
fillOval
(int x, int y, int width, int height) OverridesGraphics.fillOval
.void
fillPolygon
(int[] xPoints, int[] yPoints, int nPoints) OverridesGraphics.fillPolygon
.void
fillRect
(int x, int y, int width, int height) OverridesGraphics.fillRect
.void
fillRoundRect
(int x, int y, int width, int height, int arcWidth, int arcHeight) OverridesGraphics.fillRoundRect
.static Color
Returns the Color used to flash drawing operations.static int
Returns the number of times that drawing operations will flash.static int
Returns the time delay of drawing operation flashing.getClip()
OverridesGraphics.getClip
.OverridesGraphics.getClipBounds
.getColor()
Returns the Color used for text drawing operations.int
Returns the current debugging options for this DebugGraphics.getFont()
Returns the Font used for text drawing operations.OverridesGraphics.getFontMetrics
.OverridesGraphics.getFontMetrics
.boolean
Returns the drawingBuffer value.static PrintStream
Returns the stream to which the DebugGraphics logs drawing operations.void
setClip
(int x, int y, int width, int height) OverridesGraphics.setClip
.void
OverridesGraphics.setClip
.void
Sets the color to be used for drawing and filling lines and shapes.void
setDebugOptions
(int options) Enables/disables diagnostic information about every graphics operation.static void
setFlashColor
(Color flashColor) Sets the Color used to flash drawing operations.static void
setFlashCount
(int flashCount) Sets the number of times that drawing operations will flash.static void
setFlashTime
(int flashTime) Sets the time delay of drawing operation flashing.void
Sets the Font used for text drawing operations.static void
setLogStream
(PrintStream stream) Sets the stream to which the DebugGraphics logs drawing operations.void
OverridesGraphics.setPaintMode
.void
setXORMode
(Color aColor) OverridesGraphics.setXORMode
.void
translate
(int x, int y) OverridesGraphics.translate
.Methods declared in class java.awt.Graphics
drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, hitClip, toString
-
Field Details
-
LOG_OPTION
public static final int LOG_OPTIONLog graphics operations.- See Also:
-
FLASH_OPTION
public static final int FLASH_OPTIONFlash graphics operations.- See Also:
-
BUFFERED_OPTION
public static final int BUFFERED_OPTIONShow buffered operations in a separateFrame
.- See Also:
-
NONE_OPTION
public static final int NONE_OPTIONDon't debug graphics operations.- See Also:
-
-
Constructor Details
-
DebugGraphics
public DebugGraphics()Constructs a new debug graphics context that supports slowed down drawing.NOTE: This constructor should not be called by applications, it is for internal use only. When called directly it will create an un-usable instance.
-
DebugGraphics
Constructs a debug graphics context from an existing graphics context that slows down drawing for the specified component.- Parameters:
graphics
- the Graphics context to slow downcomponent
- the JComponent to draw slowly
-
DebugGraphics
Constructs a debug graphics context from an existing graphics context that supports slowed down drawing.- Parameters:
graphics
- the Graphics context to slow down
-
-
Method Details
-
create
-
create
OverridesGraphics.create
to return a DebugGraphics object. -
setFlashColor
Sets the Color used to flash drawing operations.- Parameters:
flashColor
- the Color used to flash drawing operations
-
flashColor
Returns the Color used to flash drawing operations.- Returns:
- the Color used to flash drawing operations
- See Also:
-
setFlashTime
public static void setFlashTime(int flashTime) Sets the time delay of drawing operation flashing.- Parameters:
flashTime
- the time delay of drawing operation flashing
-
flashTime
public static int flashTime()Returns the time delay of drawing operation flashing.- Returns:
- the time delay of drawing operation flashing
- See Also:
-
setFlashCount
public static void setFlashCount(int flashCount) Sets the number of times that drawing operations will flash.- Parameters:
flashCount
- number of times that drawing operations will flash
-
flashCount
public static int flashCount()Returns the number of times that drawing operations will flash.- Returns:
- the number of times that drawing operations will flash
- See Also:
-
setLogStream
Sets the stream to which the DebugGraphics logs drawing operations.- Parameters:
stream
- the stream to which the DebugGraphics logs drawing operations
-
logStream
Returns the stream to which the DebugGraphics logs drawing operations.- Returns:
- the stream to which the DebugGraphics logs drawing operations
- See Also:
-
setFont
-
getFont
-
setColor
-
getColor
-
getFontMetrics
OverridesGraphics.getFontMetrics
.- Overrides:
getFontMetrics
in classGraphics
- Returns:
- the font metrics of this graphics context's current font.
- See Also:
-
getFontMetrics
OverridesGraphics.getFontMetrics
.- Specified by:
getFontMetrics
in classGraphics
- Parameters:
f
- the specified font- Returns:
- the font metrics for the specified font.
- See Also:
-
translate
-
setPaintMode
public void setPaintMode()OverridesGraphics.setPaintMode
.- Specified by:
setPaintMode
in classGraphics
-
setXORMode
OverridesGraphics.setXORMode
.- Specified by:
setXORMode
in classGraphics
- Parameters:
aColor
- the XOR alternation color
-
getClipBounds
OverridesGraphics.getClipBounds
.- Specified by:
getClipBounds
in classGraphics
- Returns:
- the bounding rectangle of the current clipping area,
or
null
if no clip is set. - See Also:
-
clipRect
public void clipRect(int x, int y, int width, int height) OverridesGraphics.clipRect
.- Specified by:
clipRect
in classGraphics
- Parameters:
x
- the x coordinate of the rectangle to intersect the clip withy
- the y coordinate of the rectangle to intersect the clip withwidth
- the width of the rectangle to intersect the clip withheight
- the height of the rectangle to intersect the clip with- See Also:
-
setClip
public void setClip(int x, int y, int width, int height) OverridesGraphics.setClip
. -
getClip
-
setClip
-
drawRect
public void drawRect(int x, int y, int width, int height) OverridesGraphics.drawRect
. -
fillRect
public void fillRect(int x, int y, int width, int height) OverridesGraphics.fillRect
. -
clearRect
public void clearRect(int x, int y, int width, int height) OverridesGraphics.clearRect
. -
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) OverridesGraphics.drawRoundRect
.- Specified by:
drawRoundRect
in classGraphics
- Parameters:
x
- the x coordinate of the rectangle to be drawn.y
- the y coordinate of the rectangle to be drawn.width
- the width of the rectangle to be drawn.height
- the height of the rectangle to be drawn.arcWidth
- the horizontal diameter of the arc at the four corners.arcHeight
- the vertical diameter of the arc at the four corners.- See Also:
-
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) OverridesGraphics.fillRoundRect
.- Specified by:
fillRoundRect
in classGraphics
- Parameters:
x
- the x coordinate of the rectangle to be filled.y
- the y coordinate of the rectangle to be filled.width
- the width of the rectangle to be filled.height
- the height of the rectangle to be filled.arcWidth
- the horizontal diameter of the arc at the four corners.arcHeight
- the vertical diameter of the arc at the four corners.- See Also:
-
drawLine
-
draw3DRect
public void draw3DRect(int x, int y, int width, int height, boolean raised) OverridesGraphics.draw3DRect
.- Overrides:
draw3DRect
in classGraphics
- Parameters:
x
- the x coordinate of the rectangle to be drawn.y
- the y coordinate of the rectangle to be drawn.width
- the width of the rectangle to be drawn.height
- the height of the rectangle to be drawn.raised
- a boolean that determines whether the rectangle appears to be raised above the surface or sunk into the surface.- See Also:
-