public class DebugGraphics extends Graphics
NOTE: You must turn off double buffering to use DebugGraphics: RepaintManager repaintManager = RepaintManager.currentManager(component); repaintManager.setDoubleBufferingEnabled(false);
Modifier and Type | Field | Description |
---|---|---|
static final int |
BUFFERED_OPTION |
Show buffered operations in a separate Frame . |
static final int |
FLASH_OPTION |
Flash graphics operations. |
static final int |
LOG_OPTION |
Log graphics operations. |
static final int |
NONE_OPTION |
Don't debug graphics operations. |
Constructor | Description |
---|---|
DebugGraphics() |
Constructs a new debug graphics context that supports slowed down drawing. |
DebugGraphics |
Constructs a debug graphics context from an existing graphics context that supports slowed down drawing. |
DebugGraphics |
Constructs a debug graphics context from an existing graphics context that slows down drawing for the specified component. |
Modifier and Type | Method | Description |
---|---|---|
void |
clearRect |
Overrides Graphics.clearRect . |
void |
clipRect |
Overrides Graphics.clipRect . |
void |
copyArea |
Overrides Graphics.copyArea . |
Graphics |
create() |
Overrides Graphics.create to return a DebugGraphics object. |
Graphics |
create |
Overrides Graphics.create to return a DebugGraphics object. |
void |
dispose() |
Overrides Graphics.dispose . |
void |
draw3DRect |
Overrides Graphics.draw3DRect . |
void |
drawArc |
Overrides Graphics.drawArc . |
void |
drawBytes |
Overrides Graphics.drawBytes . |
void |
drawChars |
Overrides Graphics.drawChars . |
boolean |
drawImage |
Overrides Graphics.drawImage . |
boolean |
drawImage |
Overrides Graphics.drawImage . |
boolean |
drawImage |
Overrides Graphics.drawImage . |
boolean |
drawImage |
Overrides Graphics.drawImage . |
boolean |
drawImage |
Overrides Graphics.drawImage . |
boolean |
drawImage |
Overrides Graphics.drawImage . |
void |
drawLine |
Overrides Graphics.drawLine . |
void |
drawOval |
Overrides Graphics.drawOval . |
void |
drawPolygon |
Overrides Graphics.drawPolygon . |
void |
drawPolyline |
Overrides Graphics.drawPolyline . |
void |
drawRect |
Overrides Graphics.drawRect . |
void |
drawRoundRect |
Overrides Graphics.drawRoundRect . |
void |
drawString |
Overrides Graphics.drawString . |
void |
drawString |
Overrides Graphics.drawString . |
void |
fill3DRect |
Overrides Graphics.fill3DRect . |
void |
fillArc |
Overrides Graphics.fillArc . |
void |
fillOval |
Overrides Graphics.fillOval . |
void |
fillPolygon |
Overrides Graphics.fillPolygon . |
void |
fillRect |
Overrides Graphics.fillRect . |
void |
fillRoundRect |
Overrides Graphics.fillRoundRect . |
static Color |
flashColor() |
Returns the Color used to flash drawing operations. |
static int |
flashCount() |
Returns the number of times that drawing operations will flash. |
static int |
flashTime() |
Returns the time delay of drawing operation flashing. |
Shape |
getClip() |
Overrides Graphics.getClip . |
Rectangle |
getClipBounds() |
Overrides Graphics.getClipBounds . |
Color |
getColor() |
Returns the Color used for text drawing operations. |
int |
getDebugOptions() |
Returns the current debugging options for this DebugGraphics. |
Font |
getFont() |
Returns the Font used for text drawing operations. |
FontMetrics |
getFontMetrics() |
Overrides Graphics.getFontMetrics . |
FontMetrics |
getFontMetrics |
Overrides Graphics.getFontMetrics . |
boolean |
isDrawingBuffer() |
Returns the drawingBuffer value. |
static PrintStream |
logStream() |
Returns the stream to which the DebugGraphics logs drawing operations. |
void |
setClip |
Overrides Graphics.setClip . |
void |
setClip |
Overrides Graphics.setClip . |
void |
setColor |
Sets the color to be used for drawing and filling lines and shapes. |
void |
setDebugOptions |
Enables/disables diagnostic information about every graphics operation. |
static void |
setFlashColor |
Sets the Color used to flash drawing operations. |
static void |
setFlashCount |
Sets the number of times that drawing operations will flash. |
static void |
setFlashTime |
Sets the time delay of drawing operation flashing. |
void |
setFont |
Sets the Font used for text drawing operations. |
static void |
setLogStream |
Sets the stream to which the DebugGraphics logs drawing operations. |
void |
setPaintMode() |
Overrides Graphics.setPaintMode . |
void |
setXORMode |
Overrides Graphics.setXORMode . |
void |
translate |
Overrides Graphics.translate . |
drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, hitClip, toString
public static final int LOG_OPTION
public static final int FLASH_OPTION
public static final int BUFFERED_OPTION
Frame
.public static final int NONE_OPTION
public DebugGraphics()
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.
public DebugGraphics(Graphics graphics, JComponent component)
graphics
- the Graphics context to slow downcomponent
- the JComponent to draw slowlypublic DebugGraphics(Graphics graphics)
graphics
- the Graphics context to slow downpublic Graphics create()
Graphics.create
to return a DebugGraphics object.public Graphics create(int x, int y, int width, int height)
Graphics.create
to return a DebugGraphics object.public static void setFlashColor(Color flashColor)
flashColor
- the Color used to flash drawing operationspublic static Color flashColor()
public static void setFlashTime(int flashTime)
flashTime
- the time delay of drawing operation flashingpublic static int flashTime()
public static void setFlashCount(int flashCount)
flashCount
- number of times that drawing operations will flashpublic static int flashCount()
public static void setLogStream(PrintStream stream)
stream
- the stream to which the DebugGraphics logs drawing operationspublic static PrintStream logStream()
public void setFont(Font aFont)
public Font getFont()
public void setColor(Color aColor)
public Color getColor()
public FontMetrics getFontMetrics()
Graphics.getFontMetrics
.getFontMetrics
in class Graphics
public FontMetrics getFontMetrics(Font f)
Graphics.getFontMetrics
.getFontMetrics
in class Graphics
f
- the specified fontpublic void translate(int x, int y)
Graphics.translate
.public void setPaintMode()
Graphics.setPaintMode
.setPaintMode
in class Graphics
public void setXORMode(Color aColor)
Graphics.setXORMode
.setXORMode
in class Graphics
aColor
- the XOR alternation colorpublic Rectangle getClipBounds()
Graphics.getClipBounds
.getClipBounds
in class Graphics
null
if no clip is set.public void clipRect(int x, int y, int width, int height)
Graphics.clipRect
.clipRect
in class Graphics
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 withpublic void setClip(int x, int y, int width, int height)
Graphics.setClip
.public Shape getClip()
Graphics.getClip
.public void setClip(Shape clip)
Graphics.setClip
.public void drawRect(int x, int y, int width, int height)
Graphics.drawRect
.public void fillRect(int x, int y, int width, int height)
Graphics.fillRect
.public void clearRect(int x, int y, int width, int height)
Graphics.clearRect
.public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
Graphics.drawRoundRect
.drawRoundRect
in class Graphics
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.public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
Graphics.fillRoundRect
.fillRoundRect
in class Graphics
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.public void drawLine(int x1, int y1, int x2, int y2)
Graphics.drawLine
.public void draw3DRect(int x, int y, int width, int height, boolean raised)
Graphics.draw3DRect
.draw3DRect
in class Graphics
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.public void fill3DRect(int x, int y, int width, int height, boolean raised)
Graphics.fill3DRect
.fill3DRect
in class Graphics
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.raised
- a boolean value that determines whether the rectangle appears to be raised above the surface or etched into the surface.public void drawOval(int x, int y, int width, int height)
Graphics.drawOval
.public void fillOval(int x, int y, int width, int height)
Graphics.fillOval
.public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Graphics.drawArc
.drawArc
in class Graphics
x
- the x coordinate of the upper-left corner of the arc to be drawn.y
- the y coordinate of the upper-left corner of the arc to be drawn.width
- the width of the arc to be drawn.height
- the height of the arc to be drawn.startAngle
- the beginning angle.arcAngle
- the angular extent of the arc, relative to the start angle.public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Graphics.fillArc
.fillArc
in class Graphics
x
- the x coordinate of the upper-left corner of the arc to be filled.y
- the y coordinate of the upper-left corner of the arc to be filled.width
- the width of the arc to be filled.height
- the height of the arc to be filled.startAngle
- the beginning angle.arcAngle
- the angular extent of the arc, relative to the start angle.public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
Graphics.drawPolyline
.drawPolyline
in class Graphics
xPoints
- an array of x pointsyPoints
- an array of y pointsnPoints
- the total number of pointspublic void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
Graphics.drawPolygon
.drawPolygon
in class Graphics
xPoints
- an array of x
coordinates.yPoints
- an array of y
coordinates.nPoints
- the total number of points.public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
Graphics.fillPolygon
.fillPolygon
in class Graphics
xPoints
- an array of x
coordinates.yPoints
- an array of y
coordinates.nPoints
- the total number of points.public void drawString(String aString, int x, int y)
Graphics.drawString
.drawString
in class Graphics
aString
- the string to be drawn.x
- the x coordinate.y
- the y coordinate.public void drawString(AttributedCharacterIterator iterator, int x, int y)
Graphics.drawString
.drawString
in class Graphics
iterator
- the iterator whose text is to be drawnx
- the x coordinate.y
- the y coordinate.public void drawBytes(byte[] data, int offset, int length, int x, int y)
Graphics.drawBytes
.public void drawChars(char[] data, int offset, int length, int x, int y)
Graphics.drawChars
.public boolean drawImage(Image img, int x, int y, ImageObserver observer)
Graphics.drawImage
.drawImage
in class Graphics
img
- the specified image to be drawn. This method does nothing if img
is null.x
- the x coordinate.y
- the y coordinate.observer
- object to be notified as more of the image is converted.false
if the image pixels are still changing; true
otherwise.public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
Graphics.drawImage
.drawImage
in class Graphics
img
- the specified image to be drawn. This method does nothing if img
is null.x
- the x coordinate.y
- the y coordinate.width
- the width of the rectangle.height
- the height of the rectangle.observer
- object to be notified as more of the image is converted.false
if the image pixels are still changing; true
otherwise.public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
Graphics.drawImage
.drawImage
in class Graphics
img
- the specified image to be drawn. This method does nothing if img
is null.x
- the x coordinate.y
- the y coordinate.bgcolor
- the background color to paint under the non-opaque portions of the image.observer
- object to be notified as more of the image is converted.false
if the image pixels are still changing; true
otherwise.public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
Graphics.drawImage
.drawImage
in class Graphics
img
- the specified image to be drawn. This method does nothing if img
is null.x
- the x coordinate.y
- the y coordinate.width
- the width of the rectangle.height
- the height of the rectangle.bgcolor
- the background color to paint under the non-opaque portions of the image.observer
- object to be notified as more of the image is converted.false
if the image pixels are still changing; true
otherwise.public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
Graphics.drawImage
.drawImage
in class Graphics
img
- the specified image to be drawn. This method does nothing if img
is null.dx1
- the x coordinate of the first corner of the destination rectangle.dy1
- the y coordinate of the first corner of the destination rectangle.dx2
- the x coordinate of the second corner of the destination rectangle.dy2
- the y coordinate of the second corner of the destination rectangle.sx1
- the x coordinate of the first corner of the source rectangle.sy1
- the y coordinate of the first corner of the source rectangle.sx2
- the x coordinate of the second corner of the source rectangle.sy2
- the y coordinate of the second corner of the source rectangle.observer
- object to be notified as more of the image is scaled and converted.false
if the image pixels are still changing; true
otherwise.public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)
Graphics.drawImage
.drawImage
in class Graphics
img
- the specified image to be drawn. This method does nothing if img
is null.dx1
- the x coordinate of the first corner of the destination rectangle.dy1
- the y coordinate of the first corner of the destination rectangle.dx2
- the x coordinate of the second corner of the destination rectangle.dy2
- the y coordinate of the second corner of the destination rectangle.sx1
- the x coordinate of the first corner of the source rectangle.sy1
- the y coordinate of the first corner of the source rectangle.sx2
- the x coordinate of the second corner of the source rectangle.sy2
- the y coordinate of the second corner of the source rectangle.bgcolor
- the background color to paint under the non-opaque portions of the image.observer
- object to be notified as more of the image is scaled and converted.false
if the image pixels are still changing; true
otherwise.public void copyArea(int x, int y, int width, int height, int destX, int destY)
Graphics.copyArea
.copyArea
in class Graphics
x
- the x coordinate of the source rectangle.y
- the y coordinate of the source rectangle.width
- the width of the source rectangle.height
- the height of the source rectangle.destX
- the horizontal distance to copy the pixels.destY
- the vertical distance to copy the pixels.public void dispose()
Graphics.dispose
.public boolean isDrawingBuffer()
public void setDebugOptions(int options)
options
- indicates how diagnostic information should be displayedpublic int getDebugOptions()
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/DebugGraphics.html