java.lang.Object
java.awt.Graphics
javax.swing.DebugGraphics
支持图形调试的图形子类。重写 Graphics 中的大多数方法。 DebugGraphics 对象很少是手动创建的。当使用 setDebugGraphicsOptions() 方法更改 JComponent 的 debugGraphicsOptions 时,它们最常自动创建。
注意:您必须关闭双缓冲才能使用 DebugGraphics: RepaintManager repaintManager = RepaintManager.currentManager(component); repaintManager.setDoubleBufferingEnabled(false);
- 自从:
- 1.2
- 参见:
-
字段摘要
字段修饰符和类型Field描述static final int在单独的Frame中显示缓冲操作。static final intFlash图形操作。static final int记录图形操作。static final int不要调试图形操作。 -
构造方法总结
构造方法构造方法描述构造一个新的调试图形上下文,它支持减慢绘图速度。DebugGraphics(Graphics graphics) 从支持减慢绘图的现有图形上下文构造调试图形上下文。DebugGraphics(Graphics graphics, JComponent component) 从现有图形上下文构造调试图形上下文,这会减慢指定组件的绘制速度。 -
方法总结
修饰符和类型方法描述voidclearRect(int x, int y, int width, int height) 重写Graphics.clearRectvoidclipRect(int x, int y, int width, int height) 重写Graphics.clipRectvoidcopyArea(int x, int y, int width, int height, int destX, int destY) 重写Graphics.copyAreacreate()覆盖Graphics.create以返回 DebugGraphics 对象。create(int x, int y, int width, int height) 覆盖Graphics.create以返回 DebugGraphics 对象。voiddispose()重写Graphics.disposevoiddraw3DRect(int x, int y, int width, int height, boolean raised) 重写Graphics.draw3DRectvoiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle) 重写Graphics.drawArcvoiddrawBytes(byte[] data, int offset, int length, int x, int y) 重写Graphics.drawBytesvoiddrawChars(char[] data, int offset, int length, int x, int y) 重写Graphics.drawCharsbooleandrawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) 重写Graphics.drawImagebooleandrawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) 重写Graphics.drawImagebooleandrawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) 重写Graphics.drawImagebooleandrawImage(Image img, int x, int y, int width, int height, ImageObserver observer) 重写Graphics.drawImagebooleandrawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) 重写Graphics.drawImagebooleandrawImage(Image img, int x, int y, ImageObserver observer) 重写Graphics.drawImagevoiddrawLine(int x1, int y1, int x2, int y2) 重写Graphics.drawLinevoiddrawOval(int x, int y, int width, int height) 重写Graphics.drawOvalvoiddrawPolygon(int[] xPoints, int[] yPoints, int nPoints) 重写Graphics.drawPolygonvoiddrawPolyline(int[] xPoints, int[] yPoints, int nPoints) 重写Graphics.drawPolylinevoiddrawRect(int x, int y, int width, int height) 重写Graphics.drawRectvoiddrawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) 重写Graphics.drawRoundRectvoiddrawString(String aString, int x, int y) 重写Graphics.drawStringvoiddrawString(AttributedCharacterIterator iterator, int x, int y) 重写Graphics.drawStringvoidfill3DRect(int x, int y, int width, int height, boolean raised) 重写Graphics.fill3DRectvoidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle) 重写Graphics.fillArcvoidfillOval(int x, int y, int width, int height) 重写Graphics.fillOvalvoidfillPolygon(int[] xPoints, int[] yPoints, int nPoints) 重写Graphics.fillPolygonvoidfillRect(int x, int y, int width, int height) 重写Graphics.fillRectvoidfillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) 重写Graphics.fillRoundRectstatic Color返回用于闪烁绘图操作的颜色。static int返回绘图操作闪烁的次数。static int返回绘图操作闪烁的时间延迟。getClip()重写Graphics.getClip重写Graphics.getClipBoundsgetColor()返回用于文本绘制操作的颜色。int返回此 DebugGraphics 的当前调试选项。getFont()返回用于文本绘制操作的字体。重写Graphics.getFontMetrics重写Graphics.getFontMetricsboolean返回绘图缓冲区值。static PrintStream返回 DebugGraphics 记录绘图操作的流。voidsetClip(int x, int y, int width, int height) 重写Graphics.setClipvoid重写Graphics.setClipvoid设置用于绘制和填充线条和形状的颜色。voidsetDebugOptions(int options) 启用/禁用有关每个图形操作的诊断信息。static voidsetFlashColor(Color flashColor) 设置用于闪烁绘图操作的颜色。static voidsetFlashCount(int flashCount) 设置绘图操作闪烁的次数。static voidsetFlashTime(int flashTime) 设置绘图操作闪烁的时间延迟。void设置用于文本绘制操作的字体。static voidsetLogStream(PrintStream stream) 设置 DebugGraphics 记录绘图操作的流。void重写Graphics.setPaintModevoidsetXORMode(Color aColor) 重写Graphics.setXORModevoidtranslate(int x, int y) 重写Graphics.translate在类 java.awt.Graphics 中声明的方法
drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, hitClip, toString
-
字段详细信息
-
LOG_OPTION
public static final int LOG_OPTION记录图形操作。- 参见:
-
FLASH_OPTION
public static final int FLASH_OPTIONFlash图形操作。- 参见:
-
BUFFERED_OPTION
public static final int BUFFERED_OPTION在单独的Frame中显示缓冲操作。- 参见:
-
NONE_OPTION
public static final int NONE_OPTION不要调试图形操作。- 参见:
-
-
构造方法详细信息
-
DebugGraphics
public DebugGraphics()构造一个新的调试图形上下文,它支持减慢绘图速度。注意:此构造函数不应由应用程序调用,它仅供内部使用。当直接调用时,它将创建一个无法使用的实例。
-
DebugGraphics
从现有图形上下文构造调试图形上下文,这会减慢指定组件的绘制速度。- 参数:
graphics- 要减慢的图形上下文component- 缓慢绘制的 JComponent
-
DebugGraphics
从支持减慢绘图的现有图形上下文构造调试图形上下文。- 参数:
graphics- 要减慢的图形上下文
-
-
方法详情
-
create
覆盖Graphics.create以返回 DebugGraphics 对象。 -
create
覆盖Graphics.create以返回 DebugGraphics 对象。 -
setFlashColor
设置用于闪烁绘图操作的颜色。- 参数:
flashColor- 用于闪烁绘图操作的颜色
-
flashColor
返回用于闪烁绘图操作的颜色。- 返回:
- 用于闪烁绘图操作的颜色
- 参见:
-
setFlashTime
public static void setFlashTime(int flashTime) 设置绘图操作闪烁的时间延迟。- 参数:
flashTime- 绘图操作闪烁的延时
-
flashTime
public static int flashTime()返回绘图操作闪烁的时间延迟。- 返回:
- 绘图操作闪烁的延时
- 参见:
-
setFlashCount
public static void setFlashCount(int flashCount) 设置绘图操作闪烁的次数。- 参数:
flashCount- 绘图操作闪烁的次数
-
flashCount
public static int flashCount()返回绘图操作闪烁的次数。- 返回:
- 绘图操作闪烁的次数
- 参见:
-
setLogStream
设置 DebugGraphics 记录绘图操作的流。- 参数:
stream- DebugGraphics 记录绘图操作的流
-
logStream
返回 DebugGraphics 记录绘图操作的流。- 返回:
- DebugGraphics 记录绘图操作的流
- 参见:
-
setFont
设置用于文本绘制操作的字体。 -
getFont
返回用于文本绘制操作的字体。 -
setColor
设置用于绘制和填充线条和形状的颜色。 -
getColor
返回用于文本绘制操作的颜色。 -
getFontMetrics
重写Graphics.getFontMetrics- 重写:
getFontMetrics在类Graphics中- 返回:
- 此图形上下文的当前字体的字体规格。
- 参见:
-
getFontMetrics
重写Graphics.getFontMetrics- 指定者:
getFontMetrics在类Graphics中- 参数:
f- 指定字体- 返回:
- 指定字体的字体规格。
- 参见:
-
translate
public void translate(int x, int y) 重写Graphics.translate -
setPaintMode
public void setPaintMode()重写Graphics.setPaintMode- 指定者:
setPaintMode在类Graphics中
-
setXORMode
重写Graphics.setXORMode- 指定者:
setXORMode在类Graphics中- 参数:
aColor- 异或交替颜色
-
getClipBounds
重写Graphics.getClipBounds- 指定者:
getClipBounds在类Graphics中- 返回:
-
当前剪辑区域的边界矩形,如果没有设置剪辑,则为
null。 - 参见:
-
clipRect
public void clipRect(int x, int y, int width, int height) 重写Graphics.clipRect -
setClip
public void setClip(int x, int y, int width, int height) 重写Graphics.setClip -
getClip
重写Graphics.getClip -
setClip
重写Graphics.setClip -
drawRect
public void drawRect(int x, int y, int width, int height) 重写Graphics.drawRect -
fillRect
public void fillRect(int x, int y, int width, int height) 重写Graphics.fillRect -
clearRect
public void clearRect(int x, int y, int width, int height) 重写Graphics.clearRect -
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) 重写Graphics.drawRoundRect- 指定者:
drawRoundRect在类Graphics中- 参数:
x- 的x要绘制的矩形的坐标。y- 的y要绘制的矩形的坐标。width- 要绘制的矩形的宽度。height- 要绘制的矩形的高度。arcWidth- 四个角处圆弧的水平直径。arcHeight- 四个角处圆弧的垂直直径。- 参见:
-
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) 重写Graphics.fillRoundRect- 指定者:
fillRoundRect在类Graphics中- 参数:
x- 的x要填充的矩形的坐标。y- 的y要填充的矩形的坐标。width- 要填充的矩形的宽度。height- 要填充的矩形的高度。arcWidth- 四个角处圆弧的水平直径。arcHeight- 四个角处圆弧的垂直直径。- 参见:
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2) 重写Graphics.drawLine -
draw3DRect
public void draw3DRect(int x, int y, int width, int height, boolean raised) 重写Graphics.draw3DRect- 重写:
draw3DRect在类Graphics中- 参数:
x- 的x要绘制的矩形的坐标。y- 的y要绘制的矩形的坐标。width- 要绘制的矩形的宽度。height- 要绘制的矩形的高度。raised- 一个boolean,用于确定矩形是凸出表面还是凹入表面。- 参见:
-
fill3DRect
public void fill3DRect(int x, int y, int width, int height, boolean raised) 重写Graphics.fill3DRect- 重写:
fill3DRect在类Graphics中- 参数:
x- 的x要填充的矩形的坐标。y- 的y要填充的矩形的坐标。width- 要填充的矩形的宽度。height- 要填充的矩形的高度。raised- 一个boolean,用于确定矩形是凸出表面还是蚀刻到表面中。- 参见:
-
drawOval
public void drawOval(int x, int y, int width, int height) 重写Graphics.drawOval -
fillOval
public void fillOval(int x, int y, int width, int height) 重写Graphics.fillOval -
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) 重写Graphics.drawArc -
fillArc
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) 重写Graphics.fillArc -
drawPolyline
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) 重写Graphics.drawPolyline- 指定者:
drawPolyline在类Graphics中- 参数:
xPoints- 数组x积分yPoints- 数组y积分nPoints- 总点数- 参见:
-
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) 重写Graphics.drawPolygon- 指定者:
drawPolygon在类Graphics中- 参数:
xPoints-x坐标数组。yPoints-y坐标数组。nPoints- 总点数。- 参见:
-
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) 重写Graphics.fillPolygon- 指定者:
fillPolygon在类Graphics中- 参数:
xPoints-x坐标数组。yPoints-y坐标数组。nPoints- 总点数。- 参见:
-
drawString
重写Graphics.drawString- 指定者:
drawString在类Graphics中- 参数:
aString- 要绘制的字符串。x- 的x协调。y- 的y协调。- 参见:
-
drawString
重写Graphics.drawString- 指定者:
drawString在类Graphics中- 参数:
iterator- 要绘制其文本的迭代器x- 的x协调。y- 的y协调。- 参见:
-
drawBytes
public void drawBytes(byte[] data, int offset, int length, int x, int y) 重写Graphics.drawBytes -
drawChars
public void drawChars(char[] data, int offset, int length, int x, int y) 重写Graphics.drawChars -
drawImage
重写Graphics.drawImage -
drawImage
重写Graphics.drawImage -
drawImage
重写Graphics.drawImage -
drawImage
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) 重写Graphics.drawImage -
drawImage
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
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在类Graphics中- 参数:
img- 要绘制的指定图像。如果img为空,则此方法不执行任何操作。dx1- 的x目标矩形第一个角的坐标。dy1- 的y目标矩形第一个角的坐标。dx2- 的x目标矩形第二个角的坐标。dy2- 的y目标矩形第二个角的坐标。sx1- 的x源矩形第一个角的坐标。sy1- 的y源矩形第一个角的坐标。sx2- 的x源矩形第二个角的坐标。sy2- 的y源矩形第二个角的坐标。bgcolor- 在图像的非不透明部分下绘制的背景颜色。observer- 在缩放和转换更多图像时要通知的对象。- 返回:
false如果图像像素仍在变化;true否则。- 参见:
-
copyArea
public void copyArea(int x, int y, int width, int height, int destX, int destY) 重写Graphics.copyArea -
dispose
public void dispose()重写Graphics.dispose -
isDrawingBuffer
public boolean isDrawingBuffer()返回绘图缓冲区值。- 返回:
- 如果此对象是从 Buffer 绘制的,则为 true
-
setDebugOptions
public void setDebugOptions(int options) 启用/禁用有关每个图形操作的诊断信息。的值选项指示应如何显示此信息。 LOG_OPTION 导致打印一条文本消息。 FLASH_OPTION 使图形闪烁几次。 BUFFERED_OPTION 创建一个新的 Frame 来显示屏幕外缓冲区上的每个操作。的值选项与当前值按位或运算。要禁用调试,请使用 NONE_OPTION。- 参数:
options- 指示应如何显示诊断信息
-
getDebugOptions
public int getDebugOptions()返回此 DebugGraphics 的当前调试选项。- 返回:
- 此 DebugGraphics 的当前调试选项
- 参见:
-