javax.swing

接口
类
异常
java.lang.Object
  继承者 java.awt.Graphics
      继承者 javax.swing.DebugGraphics

public class DebugGraphics
     
extends Graphics

支持图形调试的图形子类。重写 Graphics 中的大多数方法。DebugGraphics 对象很少通过手工创建。它们通常在 JComponent 的 debugGraphicsOptions 因使用 setDebugGraphicsOptions() 方法而发生更改时自动创建。

注:必须关闭双缓冲来使用 DebugGraphics:RepaintManager repaintManager = RepaintManager.currentManager(component); repaintManager.setDoubleBufferingEnabled(false);

另请参见:
JComponent.setDebugGraphicsOptions(int), RepaintManager.currentManager(java.awt.Component), RepaintManager.setDoubleBufferingEnabled(boolean)

字段摘要
static int BUFFERED_OPTION
          在一个单独的 Frame 中显示已缓冲的操作。
static int FLASH_OPTION
          Flash 图形操作。
static int LOG_OPTION
          记录图形操作。
static int NONE_OPTION
          不要调试图形操作。
 
构造方法摘要
DebugGraphics()
          构造一个支持减速绘制的新调试图形上下文。
DebugGraphics(Graphics graphics)
          根据现有图形上下文构造一个调试图形上下文,该上下文支持减慢绘制。
DebugGraphics(Graphics graphics, JComponent component)
          根据现有图形上下文构造一个调试图形上下文,该上下文可以减慢指定组件的绘制。
 
方法摘要
 void clearRect(int x, int y, int width, int height)
          重写 Graphics.clearRect。
 void clipRect(int x, int y, int width, int height)
          重写 Graphics.clipRect。
 void copyArea(int x, int y, int width, int height, int destX, int destY)
          重写 Graphics.copyArea。
 Graphics create()
          重写 Graphics.create 来返回一个 DebugGraphics 对象。
 Graphics create(int x, int y, int width, int height)
          重写 Graphics.create 来返回一个 DebugGraphics 对象。
 void dispose()
          重写 Graphics.dispose。
 void draw3DRect(int x, int y, int width, int height, boolean raised)
          重写 Graphics.draw3DRect。
 void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
          重写 Graphics.drawArc。
 void drawBytes(byte[] data, int offset, int length, int x, int y)
          重写 Graphics.drawBytes。
 void drawChars(char[] data, int offset, int length, int x, int y)
          重写 Graphics.drawChars。
 boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
          重写 Graphics.drawImage。
 boolean drawImage(Image img, int x, int y, ImageObserver observer)
          重写 Graphics.drawImage。
 boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
          重写 Graphics.drawImage。
 boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
          重写 Graphics.drawImage。
 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。
 boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
          重写 Graphics.drawImage。
 void drawLine(int x1, int y1, int x2, int y2)
          重写 Graphics.drawLine。
 void drawOval(int x, int y, int width, int height)
          重写 Graphics.drawOval。
 void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
          重写 Graphics.drawPolygon。
 void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
          重写 Graphics.drawPolyline。
 void drawRect(int x, int y, int width, int height)
          重写 Graphics.drawRect。
 void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
          重写 Graphics.drawRoundRect。
 void drawString(AttributedCharacterIterator iterator, int x, int y)
          重写 Graphics.drawString。
 void drawString(String aString, int x, int y)
          重写 Graphics.drawString。
 void fill3DRect(int x, int y, int width, int height, boolean raised)
          重写 Graphics.fill3DRect。
 void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
          重写 Graphics.fillArc。
 void fillOval(int x, int y, int width, int height)
          重写 Graphics.fillOval。
 void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
          重写 Graphics.fillPolygon。
 void fillRect(int x, int y, int width, int height)
          重写 Graphics.fillRect。
 void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
          重写 Graphics.fillRoundRect。
static Color flashColor()
          返回用于 flash 绘制操作的 Color。
static int flashCount()
          绘制操作将要 flash 的次数。
static int flashTime()
          返回绘制操作 flash 的时间延迟。
 Shape getClip()
          重写 Graphics.getClip。
 Rectangle getClipBounds()
          重写 Graphics.getClipBounds。
 Color getColor()
          返回用于文本绘制操作的 Color。
 int getDebugOptions()
          返回此 DebugGraphics 的当前调试选项。
 Font getFont()
          返回用于文本绘制操作的 Font。
 FontMetrics getFontMetrics()
          重写 Graphics.getFontMetrics。
 FontMetrics getFontMetrics(Font f)
          重写 Graphics.getFontMetrics。
 boolean isDrawingBuffer()
          返回 drawingBuffer 值。
static PrintStream logStream()
          返回 DebugGraphics 在其中记录绘制操作的流。
 void setClip(int x, int y, int width, int height)
          重写 Graphics.setClip。
 void setClip(Shape clip)
          重写 Graphics.setClip。
 void setColor(Color aColor)
          设置用于绘制和填充线条和图形的颜色。
 void setDebugOptions(int options)
          启用/禁用有关每个图形操作的诊断信息。
static void setFlashColor(Color flashColor)
          设置用于 flash 绘制操作的 Color。
static void setFlashCount(int flashCount)
          设置绘制操作将要 flash 的次数。
static void setFlashTime(int flashTime)
          设置绘制操作 flash 的时间延迟。
 void setFont(Font aFont)
          设置用于文本绘制操作的 Font。
static void setLogStream(PrintStream stream)
          设置 DebugGraphics 在其中记录绘制操作的流。
 void setPaintMode()
          重写 Graphics.setPaintMode。
 void setXORMode(Color aColor)
          重写 Graphics.setXORMode。
 void translate(int x, int y)
          重写 Graphics.translate。
 
从类 java.awt.Graphics 继承的方法
drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, hitClip, toString
 
从类 java.lang.Object 继承的方法
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

LOG_OPTION

public static final int LOG_OPTION
记录图形操作。

另请参见:
常量字段值

FLASH_OPTION

public static final int FLASH_OPTION
Flash 图形操作。

另请参见:
常量字段值

BUFFERED_OPTION

public static final int BUFFERED_OPTION
在一个单独的 Frame 中显示已缓冲的操作。

另请参见:
常量字段值

NONE_OPTION

public static final int NONE_OPTION
不要调试图形操作。

另请参见:
常量字段值
构造方法详细信息

DebugGraphics

public DebugGraphics()
构造一个支持减速绘制的新调试图形上下文。


DebugGraphics

public DebugGraphics(Graphics graphics,
                     JComponent component)
根据现有图形上下文构造一个调试图形上下文,该上下文可以减慢指定组件的绘制。

参数:
graphics - 要减慢的 Graphics 上下文
component - 要缓慢绘制的 JComponent

DebugGraphics

public DebugGraphics(Graphics graphics)
根据现有图形上下文构造一个调试图形上下文,该上下文支持减慢绘制。

参数:
graphics - 要减慢的 Graphics 上下文
方法详细信息

create

public Graphics create()
重写 Graphics.create 来返回一个 DebugGraphics 对象。

指定者:
类 Graphics 中的 create
返回:
新的图形上下文,它是此图形上下文的副本。

create

public Graphics create(int x,
                       int y,
                       int width,
                       int height)
重写 Graphics.create 来返回一个 DebugGraphics 对象。

覆盖:
类 Graphics 中的 create
参数:
x - x 坐标。
y - y 坐标。
width - 剪贴矩形的宽度。
height - 剪贴矩形的高度。
返回:
新的图形上下文。
另请参见:
Graphics.translate(int, int), Graphics.clipRect(int, int, int, int)

setFlashColor

public static void setFlashColor(Color flashColor)
设置用于 flash 绘制操作的 Color。


flashColor

public static Color flashColor()
返回用于 flash 绘制操作的 Color。

另请参见:
setFlashColor(java.awt.Color)

setFlashTime

public static void setFlashTime(int flashTime)
设置绘制操作 flash 的时间延迟。


flashTime

public static int flashTime()
返回绘制操作 flash 的时间延迟。

另请参见:
setFlashTime(int)

setFlashCount

public static void setFlashCount(int flashCount)
设置绘制操作将要 flash 的次数。


flashCount

public static int flashCount()
绘制操作将要 flash 的次数。

另请参见:
setFlashCount(int)

setLogStream

public static void setLogStream(PrintStream stream)
设置 DebugGraphics 在其中记录绘制操作的流。


logStream

public static PrintStream logStream()
返回 DebugGraphics 在其中记录绘制操作的流。

另请参见:
setLogStream(java.io.PrintStream)

setFont

public void setFont(Font aFont)
设置用于文本绘制操作的 Font。

指定者:
类 Graphics 中的 setFont
参数:
aFont - 字体。
另请参见:
Graphics.getFont(), Graphics.drawString(java.lang.String, int, int), Graphics.drawBytes(byte[], int, int, int, int), Graphics.drawChars(char[], int, int, int, int)

getFont

public Font getFont()
返回用于文本绘制操作的 Font。

指定者:
类 Graphics 中的 getFont
返回:
此图形上下文的当前字体。
另请参见:
setFont(java.awt.Font)

setColor

public void setColor(Color aColor)
设置用于绘制和填充线条和图形的颜色。

指定者:
类 Graphics 中的 setColor
参数:
aColor - 新的呈现颜色。
另请参见:
Color, Graphics.getColor()

getColor

public Color getColor()
返回用于文本绘制操作的 Color。

指定者:
类 Graphics 中的 getColor
返回:
此图形上下文的当前颜色。
另请参见:
setColor(java.awt.Color)

getFontMetrics

public FontMetrics getFontMetrics()
重写 Graphics.getFontMetrics。

覆盖:
类 Graphics 中的 getFontMetrics
返回:
此图形上下文当前字体的字体规格。
另请参见:
Graphics.getFont(), FontMetrics, Graphics.getFontMetrics(Font)

getFontMetrics

public FontMetrics getFontMetrics(Font f)
重写 Graphics.getFontMetrics。

指定者:
类 Graphics 中的 getFontMetrics
参数:
f - 指定的字体
返回:
指定字体的字体规格。
另请参见:
Graphics.getFont(), FontMetrics, Graphics.getFontMetrics()

translate

public void translate(int x,
                      int y)
重写 Graphics.translate。

指定者:
类 Graphics 中的 translate
参数:
x - x 坐标。
y - y 坐标。

setPaintMode

public void setPaintMode()
重写 Graphics.setPaintMode。

指定者:
类 Graphics 中的 setPaintMode

setXORMode

public void setXORMode(Color aColor)
重写 Graphics.setXORMode。

指定者:
类 Graphics 中的 setXORMode
参数:
aColor - XOR 交替颜色

getClipBounds

public Rectangle getClipBounds()
重写 Graphics.getClipBounds。

指定者:
类 Graphics 中的 getClipBounds
返回:
当前剪贴区域的边界矩形;如果未设置剪贴区,则返回 null。
另请参见:
Graphics.getClip(), Graphics.clipRect(int, int, int, int), Graphics.setClip(int, int, int, int), Graphics.setClip(Shape)

clipRect

public void clipRect(int x,
                     int y,
                     int width,
                     int height)
重写 Graphics.clipRect。

指定者:
类 Graphics 中的 clipRect
参数:
x - 要与剪贴区相交的矩形的 x 坐标
y - 要与剪贴区相交的矩形的 y 坐标
width - 要与剪贴区相交的矩形的宽度
height - 要与剪贴区相交的矩形的高度
另请参见:
Graphics.setClip(int, int, int, int), Graphics.setClip(Shape)

setClip

public void setClip(int x,
                    int y,
                    int width,
                    int height)
重写 Graphics.setClip。

指定者:
类 Graphics 中的 setClip
参数:
x - 新剪贴区矩形的 x 坐标。
y - 新剪贴区矩形的 y 坐标。
width - 新剪贴区矩形的宽度。
height - 新剪贴区矩形的高度。
另请参见:
Graphics.clipRect(int, int, int, int), Graphics.setClip(Shape), Graphics.getClip()

getClip

public Shape getClip()
重写 Graphics.getClip。

指定者:
类 Graphics 中的 getClip
返回:
表示当前剪贴区域的 Shape 对象;如果未设置剪贴区,则返回 null。
另请参见:
Graphics.getClipBounds(), Graphics.clipRect(int, int, int, int), Graphics.setClip(int, int, int, int), Graphics.setClip(Shape)

setClip

public void setClip(Shape clip)
重写 Graphics.setClip。

指定者:
类 Graphics 中的 setClip
参数:
clip - 用来设置剪贴形状的 Shape
另请参见:
Graphics.getClip(), Graphics.clipRect(int, int, int, int), Graphics.setClip(int, int, int, int)

drawRect

public void drawRect(int x,
                     int y,
                     int width,
                     int height)
重写 Graphics.drawRect。

覆盖:
类 Graphics 中的 drawRect
参数:
x - 要绘制矩形的 x 坐标。
y - 要绘制矩形的 y 坐标。
width - 要绘制矩形的宽度。
height - 要绘制矩形的高度。
另请参见:
Graphics.fillRect(int, int, int, int), Graphics.clearRect(int, int, int, int)

fillRect

public void fillRect(int x,
                     int y,
                     int width,
                     int height)
重写 Graphics.fillRect。

指定者:
类 Graphics 中的 fillRect
参数:
x - 要填充矩形的 x 坐标。
y - 要填充矩形的 y 坐标。
width - 要填充矩形的宽度。
height - 要填充矩形的高度。
另请参见:
Graphics.clearRect(int, int, int, int), Graphics.drawRect(int, int, int, int)

clearRect

public void clearRect(int x,
                      int y,
                      int width,
                      int height)
重写 Graphics.clearRect。

指定者:
类 Graphics 中的 clearRect
参数:
x - 要清除矩形的 x 坐标。
y - 要清除矩形的 y 坐标。
width - 要清除矩形的宽度。
height - 要清除矩形的高度。
另请参见:
Graphics.fillRect(int, int, int, int), Graphics.drawRect(int, int, int, int), Graphics.setColor(java.awt.Color), Graphics.setPaintMode(), Graphics.setXORMode(java.awt.Color)

drawRoundRect

public void drawRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
重写 Graphics.drawRoundRect。

指定