Module java.desktop
Package javax.swing

Class DebugGraphics

    • Field Summary

      Fields 
      Modifier and TypeFieldDescription
      static intBUFFERED_OPTION
      Show buffered operations in a separate Frame.
      static intFLASH_OPTION
      Flash graphics operations.
      static intLOG_OPTION
      Log graphics operations.
      static intNONE_OPTION
      Don't debug graphics operations.
    • Constructor Summary

      Constructors 
      ConstructorDescription
      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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidclearRect​(int x, int y, int width, int height)
      Overrides Graphics.clearRect.
      voidclipRect​(int x, int y, int width, int height)
      Overrides Graphics.clipRect.
      voidcopyArea​(int x, int y, int width, int height, int destX, int destY)
      Overrides Graphics.copyArea.
      Graphicscreate()
      Overrides Graphics.create to return a DebugGraphics object.
      Graphicscreate​(int x, int y, int width, int height)
      Overrides Graphics.create to return a DebugGraphics object.
      voiddispose()
      Overrides Graphics.dispose.
      voiddraw3DRect​(int x, int y, int width, int height, boolean raised)
      Overrides Graphics.draw3DRect.
      voiddrawArc​(int x, int y, int width, int height, int startAngle, int arcAngle)
      Overrides Graphics.drawArc.
      voiddrawBytes​(byte[] data, int offset, int length, int x, int y)
      Overrides Graphics.drawBytes.
      voiddrawChars​(char[] data, int offset, int length, int x, int y)
      Overrides Graphics.drawChars.
      booleandrawImage​(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.
      booleandrawImage​(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
      Overrides Graphics.drawImage.
      booleandrawImage​(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
      Overrides Graphics.drawImage.
      booleandrawImage​(Image img, int x, int y, int width, int height, ImageObserver observer)
      Overrides Graphics.drawImage.
      booleandrawImage​(Image img, int x, int y, Color bgcolor, ImageObserver observer)
      Overrides Graphics.drawImage.
      booleandrawImage​(Image img, int x, int y, ImageObserver observer)
      Overrides Graphics.drawImage.
      voiddrawLine​(int x1, int y1, int x2, int y2)
      Overrides Graphics.drawLine.
      voiddrawOval​(int x, int y, int width, int height)
      Overrides Graphics.drawOval.
      voiddrawPolygon​(int[] xPoints, int[] yPoints, int nPoints)
      Overrides Graphics.drawPolygon.
      voiddrawPolyline​(int[] xPoints, int[] yPoints, int nPoints)
      Overrides Graphics.drawPolyline.
      voiddrawRect​(int x, int y, int width, int height)
      Overrides Graphics.drawRect.
      voiddrawRoundRect​(int x, int y, int width, int height, int arcWidth, int arcHeight)
      Overrides Graphics.drawRoundRect.
      voiddrawString​(String aString, int x, int y)
      Overrides Graphics.drawString.
      voiddrawString​(AttributedCharacterIterator iterator, int x, int y)
      Overrides Graphics.drawString.
      voidfill3DRect​(int x, int y, int width, int height, boolean raised)
      Overrides Graphics.fill3DRect.
      voidfillArc​(int x, int y, int width, int height, int startAngle, int arcAngle)
      Overrides Graphics.fillArc.
      voidfillOval​(int x, int y, int width, int height)
      Overrides Graphics.fillOval.
      voidfillPolygon​(int[] xPoints, int[] yPoints, int nPoints)
      Overrides Graphics.fillPolygon.
      voidfillRect​(int x, int y, int width, int height)
      Overrides Graphics.fillRect.
      voidfillRoundRect​(int x, int y, int width, int height, int arcWidth, int arcHeight)
      Overrides Graphics.fillRoundRect.
      static ColorflashColor()
      Returns the Color used to flash drawing operations.
      static intflashCount()
      Returns the number of times that drawing operations will flash.
      static intflashTime()
      Returns the time delay of drawing operation flashing.
      ShapegetClip()
      Overrides Graphics.getClip.
      RectanglegetClipBounds()
      Overrides Graphics.getClipBounds.
      ColorgetColor()
      Returns the Color used for text drawing operations.
      intgetDebugOptions()
      Returns the current debugging options for this DebugGraphics.
      FontgetFont()
      Returns the Font used for text drawing operations.
      FontMetricsgetFontMetrics()
      Overrides Graphics.getFontMetrics.
      FontMetricsgetFontMetrics​(Font f)
      Overrides Graphics.getFontMetrics.
      booleanisDrawingBuffer()
      Returns the drawingBuffer value.
      static PrintStreamlogStream()
      Returns the stream to which the DebugGraphics logs drawing operations.
      voidsetClip​(int x, int y, int width, int height)
      Overrides Graphics.setClip.
      voidsetClip​(Shape clip)
      Overrides Graphics.setClip.
      voidsetColor​(Color aColor)
      Sets the color to be used for drawing and filling lines and shapes.
      voidsetDebugOptions​(int options)
      Enables/disables diagnostic information about every graphics operation.
      static voidsetFlashColor​(Color flashColor)
      Sets the Color used to flash drawing operations.
      static voidsetFlashCount​(int flashCount)
      Sets the number of times that drawing operations will flash.
      static voidsetFlashTime​(int flashTime)
      Sets the time delay of drawing operation flashing.
      voidsetFont​(Font aFont)
      Sets the Font used for text drawing operations.
      static voidsetLogStream​(PrintStream stream)
      Sets the stream to which the DebugGraphics logs drawing operations.
      voidsetPaintMode()
      Overrides Graphics.setPaintMode.
      voidsetXORMode​(Color aColor)
      Overrides Graphics.setXORMode.
      voidtranslate​(int x, int y)
      Overrides Graphics.translate.
    • Field Detail

      • FLASH_OPTION

        public static final int FLASH_OPTION
        Flash graphics operations.
        See Also:
        Constant Field Values
      • BUFFERED_OPTION

        public static final int BUFFERED_OPTION
        Show buffered operations in a separate Frame.
        See Also:
        Constant Field Values
      • NONE_OPTION

        public static final int NONE_OPTION
        Don't debug graphics operations.
        See Also:
        Constant Field Values
    • Constructor Detail

      • 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 Detail

      • create

        public Graphics create()
        Overrides Graphics.create to return a DebugGraphics object.
        Specified by:
        create in class Graphics
        Returns:
        a new graphics context that is a copy of this graphics context.
      • setFlashColor

        public static void setFlashColor​(Color flashColor)
        Sets the Color used to flash drawing operations.
        Parameters:
        flashColor - the Color used to flash drawing operations
      • flashColor

        public static Color flashColor()
        Returns the Color used to flash drawing operations.
        Returns:
        the Color used to flash drawing operations
        See Also:
        setFlashColor(java.awt.Color)
      • 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:
        setFlashTime(int)
      • 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:
        setFlashCount(int)
      • setLogStream

        public static void setLogStream​(PrintStream stream)
        Sets the stream to which the DebugGraphics logs drawing operations.
        Parameters:
        stream - the stream to which the DebugGraphics logs drawing operations
      • logStream

        public static PrintStream logStream()
        Returns the stream to which the DebugGraphics logs drawing operations.
        Returns:
        the stream to which the DebugGraphics logs drawing operations
        See Also:
        setLogStream(java.io.PrintStream)
      • setColor

        public void setColor​(Color aColor)
        Sets the color to be used for drawing and filling lines and shapes.
        Specified by:
        setColor in class Graphics
        Parameters:
        aColor - the new rendering color.
        See Also:
        Color, Graphics.getColor()
      • translate

        public void translate​(int x,
                              int y)
        Overrides Graphics.translate.
        Specified by:
        translate in class Graphics
        Parameters:
        x - the x coordinate.
        y - the y coordinate.
      • setPaintMode

        public void setPaintMode()
        Overrides Graphics.setPaintMode.
        Specified by:
        setPaintMode in class Graphics
      • setXORMode

        public void setXORMode​(Color aColor)
        Overrides Graphics.setXORMode.
        Specified by:
        setXORMode in class Graphics
        Parameters:
        aColor - the XOR alternation color
      • clipRect

        public void clipRect​(int x,
                             int y,
                             int width,
                             int height)
        Overrides Graphics.clipRect.
        Specified by:
        clipRect in class Graphics
        Parameters:
        x - the x coordinate of the rectangle to intersect the clip with
        y - the y coordinate of the rectangle to intersect the clip with
        width - the width of the rectangle to intersect the clip with
        height - the height of the rectangle to intersect the clip with
        See Also:
        Graphics.setClip(int, int, int, int), Graphics.setClip(Shape)
      • drawRoundRect

        public void drawRoundRect​(int x,
                                  int y,
                                  int width,
                                  int height,
                                  int arcWidth,
                                  int arcHeight)
        Overrides Graphics.drawRoundRect.
        Specified by:
        drawRoundRect in class Graphics
        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:
        Graphics.fillRoundRect(int, int, int, int, int, int)
      • fillRoundRect

        public void fillRoundRect​(int x,
                                  int y,
                                  int width,
                                  int height,
                                  int arcWidth,
                                  int arcHeight)
        Overrides Graphics.fillRoundRect.
        Specified by:
        fillRoundRect in class Graphics
        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:
        Graphics.drawRoundRect(int, int, int, int, int, int)
      • drawLine

        public void drawLine​(int x1,
                             int y1,
                             int x2,
                             int y2)
        Overrides Graphics.drawLine.
        Specified by:
        drawLine in class Graphics
        Parameters:
        x1 - the first point's x coordinate.
        y1 - the first point's y coordinate.
        x2 - the second point's x coordinate.
        y2 - the second point's y coordinate.
      • draw3DRect

        public void draw3DRect​(int x,
                               int y,
                               int width,
                               int height,
                               boolean raised)
        Overrides Graphics.draw3DRect.
        Overrides:
        draw3DRect in class Graphics
        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:
        Graphics.fill3DRect(int, int, int, int, boolean)
      • fill3DRect

        public void fill3DRect​(int x,
                               int y,
                               int width,
                               int height,
                               boolean raised)
        Overrides Graphics.fill3DRect.
        Overrides:
        fill3DRect in class Graphics
        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.
        raised - a boolean value that determines whether the rectangle appears to be raised above the surface or etched into the surface.
        See Also:
        Graphics.draw3DRect(int, int, int, int, boolean)
      • drawOval

        public void drawOval​(int x,
                             int y,
                             int width,
                             int height)
        Overrides Graphics.drawOval.
        Specified by:
        drawOval in class Graphics
        Parameters:
        x - the x coordinate of the upper left corner of the oval to be drawn.
        y - the y coordinate of the upper left corner of the oval to be drawn.
        width - the width of the oval to be drawn.
        height - the height of the oval to be drawn.
        See Also:
        Graphics.fillOval(int, int, int, int)
      • fillOval

        public void fillOval​(int x,
                             int y,
                             int width,
                             int height)
        Overrides Graphics.fillOval.
        Specified by:
        fillOval in class Graphics
        Parameters:
        x - the x coordinate of the upper left corner of the oval to be filled.
        y - the y coordinate of the upper left corner of the oval to be filled.
        width - the width of the oval to be filled.
        height - the height of the oval to be filled.
        See Also:
        Graphics.drawOval(int, int, int, int)
      • drawArc

        public void drawArc​(int x,
                            int y,
                            int width,
                            int height,
                            int startAngle,
                            int arcAngle)
        Overrides Graphics.drawArc.
        Specified by:
        drawArc in class Graphics
        Parameters:
        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.
        See Also:
        Graphics.fillArc(int, int, int, int, int, int)
      • fillArc

        public void fillArc​(int x,
                            int y,
                            int width,
                            int height,
                            int startAngle,
                            int arcAngle)
        Overrides Graphics.fillArc.
        Specified by:
        fillArc in class Graphics
        Parameters:
        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.
        See Also:
        Graphics.drawArc(int, int, int, int, int, int)
      • drawPolyline

        public void drawPolyline​(int[] xPoints,
                                 int[] yPoints,
                                 int nPoints)
        Overrides Graphics.drawPolyline.
        Specified by:
        drawPolyline in class Graphics
        Parameters:
        xPoints - an array of x points
        yPoints - an array of y points
        nPoints - the total number of points
        See Also:
        Graphics.drawPolygon(int[], int[], int)
      • fillPolygon

        public void fillPolygon​(int[] xPoints,
                                int[] yPoints,
                                int nPoints)
        Overrides Graphics.fillPolygon.
        Specified by:
        fillPolygon in class Graphics
        Parameters:
        xPoints - a an array of x coordinates.
        yPoints - a an array of y coordinates.
        nPoints - a the total number of points.
        See Also:
        Graphics.drawPolygon(int[], int[], int)
      • drawImage

        public boolean drawImage​(Image img,
                                 int x,
                                 int y,
                                 int width,
                                 int height,
                                 ImageObserver observer)
        Overrides Graphics.drawImage.
        Specified by:
        drawImage in class Graphics
        Parameters:
        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.
        Returns:
        false if the image pixels are still changing; true otherwise.
        See Also:
        Image, ImageObserver, ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
      • drawImage

        public boolean drawImage​(Image img,
                                 int x,
                                 int y,
                                 Color bgcolor,
                                 ImageObserver observer)
        Overrides Graphics.drawImage.
        Specified by:
        drawImage in class Graphics
        Parameters:
        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.
        Returns:
        false if the image pixels are still changing; true otherwise.
        See Also:
        Image, ImageObserver, ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
      • drawImage

        public boolean drawImage​(Image img,
                                 int x,
                                 int y,
                                 int width,
                                 int height,
                                 Color bgcolor,
                                 ImageObserver observer)
        Overrides Graphics.drawImage.
        Specified by:
        drawImage in class Graphics
        Parameters:
        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.
        Returns:
        false if the image pixels are still changing; true otherwise.
        See Also:
        Image, ImageObserver, ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
      • drawImage

        public 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.
        Specified by:
        drawImage in class Graphics
        Parameters:
        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.
        Returns:
        false if the image pixels are still changing; true otherwise.
        See Also:
        Image, ImageObserver, ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
      • 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)
        Overrides Graphics.drawImage.
        Specified by:
        drawImage in class Graphics
        Parameters:
        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.
        Returns:
        false if the image pixels are still changing; true otherwise.
        See Also:
        Image, ImageObserver, ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
      • copyArea

        public void copyArea​(int x,
                             int y,
                             int width,
                             int height,
                             int destX,
                             int destY)
        Overrides Graphics.copyArea.
        Specified by:
        copyArea in class Graphics
        Parameters:
        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.
      • isDrawingBuffer

        public boolean isDrawingBuffer()
        Returns the drawingBuffer value.
        Returns:
        true if this object is drawing from a Buffer
      • setDebugOptions

        public void setDebugOptions​(int options)
        Enables/disables diagnostic information about every graphics operation. The value of options indicates how this information should be displayed. LOG_OPTION causes a text message to be printed. FLASH_OPTION causes the drawing to flash several times. BUFFERED_OPTION creates a new Frame that shows each operation on an offscreen buffer. The value of options is bitwise OR'd into the current value. To disable debugging use NONE_OPTION.
        Parameters:
        options - indicates how diagnostic information should be displayed
      • getDebugOptions

        public int getDebugOptions()
        Returns the current debugging options for this DebugGraphics.
        Returns:
        the current debugging options for this DebugGraphics
        See Also:
        setDebugOptions(int)

微信小程序

微信扫一扫体验

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部