Module java.desktop
Package javax.swing

Class DebugGraphics

java.lang.Object
java.awt.Graphics
javax.swing.DebugGraphics

public class DebugGraphics
extends Graphics
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:
JComponent.setDebugGraphicsOptions(int), RepaintManager.currentManager(java.awt.Component), RepaintManager.setDoubleBufferingEnabled(boolean)
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static int BUFFERED_OPTION
    Show buffered operations in a separate Frame.
    static int FLASH_OPTION
    Flash graphics operations.
    static int LOG_OPTION
    Log graphics operations.
    static int NONE_OPTION
    Don't debug graphics operations.
  • Constructor Summary

    Constructors 
    Constructor Description
    DebugGraphics()
    Constructs 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 Type Method Description
    void clearRect​(int x, int y, int width, int height)
    Overrides Graphics.clearRect.
    void clipRect​(int x, int y, int width, int height)
    Overrides Graphics.clipRect.
    void copyArea​(int x, int y, int width, int height, int destX, int destY)
    Overrides Graphics.copyArea.
    Graphics create()
    Overrides Graphics.create to return a DebugGraphics object.
    Graphics create​(int x, int y, int width, int height)
    Overrides Graphics.create to return a DebugGraphics object.
    void dispose()
    Overrides Graphics.dispose.
    void draw3DRect​(int x, int y, int width, int height, boolean raised)
    Overrides Graphics.draw3DRect.
    void drawArc​(int x, int y, int width, int height, int startAngle, int arcAngle)
    Overrides Graphics.drawArc.
    void drawBytes​(byte[] data, int offset, int length, int x, int y)
    Overrides Graphics.drawBytes.
    void drawChars​(char[] data, int offset, int length, int x, int y)
    Overrides Graphics.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)
    Overrides Graphics.drawImage.
    boolean drawImage​(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
    Overrides Graphics.drawImage.
    boolean drawImage​(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
    Overrides Graphics.drawImage.
    boolean drawImage​(Image img, int x, int y, int width, int height, ImageObserver observer)
    Overrides Graphics.drawImage.
    boolean drawImage​(Image img, int x, int y, Color bgcolor, ImageObserver observer)
    Overrides Graphics.drawImage.
    boolean drawImage​(Image img, int x, int y, ImageObserver observer)
    Overrides Graphics.drawImage.
    void drawLine​(int x1, int y1, int x2, int y2)
    Overrides Graphics.drawLine.
    void drawOval​(int x, int y, int width, int height)
    Overrides Graphics.drawOval.
    void drawPolygon​(int[] xPoints, int[] yPoints, int nPoints)
    Overrides Graphics.drawPolygon.
    void drawPolyline​(int[] xPoints, int[] yPoints, int nPoints)
    Overrides Graphics.drawPolyline.
    void drawRect​(int x, int y, int width, int height)
    Overrides Graphics.drawRect.
    void drawRoundRect​(int x, int y, int width, int height, int arcWidth, int arcHeight)
    Overrides Graphics.drawRoundRect.
    void drawString​(String aString, int x, int y)
    Overrides Graphics.drawString.
    void drawString​(AttributedCharacterIterator iterator, int x, int y)
    Overrides Graphics.drawString.
    void fill3DRect​(int x, int y, int width, int height, boolean raised)
    Overrides Graphics.fill3DRect.
    void fillArc​(int x, int y, int width, int height, int startAngle, int arcAngle)
    Overrides Graphics.fillArc.
    void fillOval​(int x, int y, int width, int height)
    Overrides Graphics.fillOval.
    void fillPolygon​(int[] xPoints, int[] yPoints, int nPoints)
    Overrides Graphics.fillPolygon.
    void fillRect​(int x, int y, int width, int height)
    Overrides Graphics.fillRect.
    void fillRoundRect​(int x, int y, int width, int height, int arcWidth, int arcHeight)
    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​(Font f)
    Overrides Graphics.getFontMetrics.
    boolean isDrawingBuffer()
    Returns the drawingBuffer value.
    static PrintStream logStream()
    Returns the stream to which the DebugGraphics logs drawing operations.
    void setClip​(int x, int y, int width, int height)
    Overrides Graphics.setClip.
    void setClip​(Shape clip)
    Overrides Graphics.setClip.
    void setColor​(Color aColor)
    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 setFont​(Font aFont)
    Sets the Font used for text drawing operations.
    static void setLogStream​(PrintStream stream)
    Sets the stream to which the DebugGraphics logs drawing operations.
    void setPaintMode()
    Overrides Graphics.setPaintMode.
    void setXORMode​(Color aColor)
    Overrides Graphics.setXORMode.
    void translate​(int x, int y)
    Overrides Graphics.translate.

    Methods declared in class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • DebugGraphics

      public DebugGraphics()
      Constructs a new debug graphics context that supports slowed down drawing.
    • DebugGraphics

      public DebugGraphics​(Graphics graphics, JComponent component)
      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 down
      component - the JComponent to draw slowly
    • DebugGraphics

      public DebugGraphics​(Graphics graphics)
      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