diff options
Diffstat (limited to 'libjava/javax/swing/DebugGraphics.java')
-rw-r--r-- | libjava/javax/swing/DebugGraphics.java | 612 |
1 files changed, 355 insertions, 257 deletions
diff --git a/libjava/javax/swing/DebugGraphics.java b/libjava/javax/swing/DebugGraphics.java index 6aa80ad..074d451 100644 --- a/libjava/javax/swing/DebugGraphics.java +++ b/libjava/javax/swing/DebugGraphics.java @@ -1,5 +1,5 @@ /* DebugGraphics.java -- - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -56,6 +56,30 @@ import java.text.AttributedCharacterIterator; */ public class DebugGraphics extends Graphics { + /** + * LOG_OPTION + */ + public static final int LOG_OPTION = 1; + + /** + * FLASH_OPTION + */ + public static final int FLASH_OPTION = 2; + + /** + * BUFFERED_OPTION + */ + public static final int BUFFERED_OPTION = 4; + + /** + * NONE_OPTION + */ + public static final int NONE_OPTION = -1; + + static Color debugFlashColor = Color.RED; + static int debugFlashCount = 10; + static int debugFlashTime = 1000; + static PrintStream debugLogStream = System.out; /** * graphics @@ -63,6 +87,11 @@ public class DebugGraphics extends Graphics Graphics graphics; /** + * color + */ + Color color = Color.BLACK; + + /** * buffer */ Image buffer; @@ -88,26 +117,6 @@ public class DebugGraphics extends Graphics int yOffset; /** - * LOG_OPTION - */ - public static final int LOG_OPTION = 1; - - /** - * FLASH_OPTION - */ - public static final int FLASH_OPTION = 2; - - /** - * BUFFERED_OPTION - */ - public static final int BUFFERED_OPTION = 4; - - /** - * NONE_OPTION - */ - public static final int NONE_OPTION = -1; - - /** * Creates a <code>DebugGraphics</code> object. */ public DebugGraphics() @@ -116,55 +125,62 @@ public class DebugGraphics extends Graphics } /** - * Constructor DebugGraphics - * @param graphics TODO + * Creates a <code>DebugGraphics</code> object. + * + * @param graphics The <code>Graphics</code> object to wrap * @param component TODO */ public DebugGraphics(Graphics graphics, JComponent component) { - // TODO + this.graphics = graphics; + // FIXME: What shall we do with component ? } /** - * Constructor DebugGraphics - * @param graphics TODO + * Creates a <code>DebugGraphics</code> object. + * + * @param graphics The <code>Graphics</code> object to wrap */ public DebugGraphics(Graphics graphics) { - // TODO + this.graphics = graphics; } /** - * setColor - * @param value0 TODO + * Sets the color to draw stuff with. + * + * @param color The color */ public void setColor(Color color) { - // TODO + this.color = color; } /** - * create + * Creates a overrides <code>Graphics.create</code> to create a + * <code>DebugGraphics</code> object. * - * @return Graphics + * @return a new <code>DebugGraphics</code> object. */ public Graphics create() { - return null; // TODO + return new DebugGraphics(graphics.create()); } /** - * create + * Creates a overrides <code>Graphics.create</code> to create a + * <code>DebugGraphics</code> object. * - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - * @returns Graphics + * @param x the x coordinate + * @param y the y coordinate + * @param width the width + * @param height the height + * + * @return a new <code>DebugGraphics</code> object. */ - public Graphics create(int valx, int y, int w, int h) + public Graphics create(int x, int y, int width, int height) { - return null; // TODO + return new DebugGraphics(graphics.create(x, y, width, height)); } /** @@ -174,7 +190,7 @@ public class DebugGraphics extends Graphics */ public static Color flashColor() { - return null; // TODO + return debugFlashColor; } /** @@ -184,7 +200,7 @@ public class DebugGraphics extends Graphics */ public static void setFlashColor(Color color) { - // TODO + debugFlashColor = color; } /** @@ -194,7 +210,7 @@ public class DebugGraphics extends Graphics */ public static int flashTime() { - return 0; // TODO + return debugFlashTime; } /** @@ -204,16 +220,17 @@ public class DebugGraphics extends Graphics */ public static void setFlashTime(int time) { - // TODO + debugFlashTime = time; } /** * flashCount - * @returns int + * + * @return The number of flashes */ public static int flashCount() { - return 0; // TODO + return debugFlashCount; } /** @@ -223,7 +240,7 @@ public class DebugGraphics extends Graphics */ public static void setFlashCount(int count) { - // TODO + debugFlashCount = count; } /** @@ -233,7 +250,7 @@ public class DebugGraphics extends Graphics */ public static PrintStream logStream() { - return null; // TODO + return debugLogStream; } /** @@ -243,16 +260,17 @@ public class DebugGraphics extends Graphics */ public static void setLogStream(PrintStream stream) { - // TODO + debugLogStream = stream; } /** * getFont - * @returns Font + * + * @return The font */ public Font getFont() { - return null; // TODO + return graphics.getFont(); } /** @@ -262,46 +280,50 @@ public class DebugGraphics extends Graphics */ public void setFont(Font font) { - // TODO + graphics.setFont(font); } /** - * getColor - * @returns Color + * Returns the color used for drawing. + * + * @return The color. */ public Color getColor() { - return null; // TODO + return color; } /** - * getFontMetrics - * @returns FontMetrics + * Returns the font metrics of the current font. + * + * @return a <code>FontMetrics</code> object */ public FontMetrics getFontMetrics() { - return null; // TODO + return graphics.getFontMetrics(); } /** - * getFontMetrics - * @param font TODO - * @returns FontMetrics + * Returns the font metrics for a given font. + * + * @param font the font to get the metrics for + * + * @return a <code>FontMetrics</code> object */ public FontMetrics getFontMetrics(Font font) { - return null; // TODO + return graphics.getFontMetrics(font); } /** * translate * - * @param x TODO - * @param y TODO + * @param x the x coordinate + * @param y the y coordinate */ public void translate(int x, int y) { - // TODO + graphics.translate(x, y); } /** @@ -309,237 +331,291 @@ public class DebugGraphics extends Graphics */ public void setPaintMode() { - // TODO + graphics.setPaintMode(); } /** * setXORMode * - * @param color TODO + * @param color the color */ public void setXORMode(Color color) { - // TODO + graphics.setXORMode(color); } /** * getClipBounds - * @returns Rectangle + * + * @return Rectangle */ public Rectangle getClipBounds() { - return null; // TODO + return graphics.getClipBounds(); } /** - * clipRect - * @param value0 TODO - * @param value1 TODO - * @param value2 TODO - * @param value3 TODO + * Intersects the current clip region with the given region. + * + * @param x The x-position of the region + * @param y The y-position of the region + * @param width The width of the region + * @param height The height of the region */ - public void clipRect(int value0, int value1, int value2, int value3) + public void clipRect(int x, int y, int width, int height) { - // TODO + graphics.clipRect(x, y, width, height); } /** - * setClip - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO + * Sets the clipping region. + * + * @param x The x-position of the region + * @param y The y-position of the region + * @param width The width of the region + * @param height The height of the region */ - public void setClip(int x, int y, int w, int h) + public void setClip(int x, int y, int width, int height) { - // TODO + graphics.setClip(x, y, width, height); } /** - * getClip - * @returns Shape + * Returns the current clipping region. + * + * @return Shape */ public Shape getClip() { - return null; // TODO + return graphics.getClip(); } /** - * setClip - * @param shape TODO + * Sets the current clipping region + * + * @param shape The clippin region */ public void setClip(Shape shape) { - // TODO + graphics.setClip(shape); } + private void sleep(int milliseconds) + { + try + { + Thread.sleep(milliseconds); + } + catch (InterruptedException e) + { + // Ignore this. + } + } + /** - * drawRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param valh TODO + * Draws a rectangle. + * + * @param x The x-position of the rectangle + * @param y The y-position of the rectangle + * @param width The width of the rectangle + * @param height The height of the rectangle */ - public void drawRect(int x, int y, int w, int h) + public void drawRect(int x, int y, int width, int height) { - // TODO - } // drawRect() + for (int index = 0; index < (debugFlashCount - 1); ++index) + { + graphics.setColor(color); + graphics.drawRect(x, y, width, height); + sleep(debugFlashTime); + + graphics.setColor(debugFlashColor); + graphics.drawRect(x, y, width, height); + sleep(debugFlashTime); + } + + graphics.setColor(color); + graphics.drawRect(x, y, width, height); + } /** - * fillRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO + * Draws a filled rectangle. + * + * @param x The x-position of the rectangle + * @param y The y-position of the rectangle + * @param width The width of the rectangle + * @param height The height of the rectangle */ - public void fillRect(int x, int y, int w, int h) + public void fillRect(int x, int y, int width, int height) { - // TODO - } // fillRect() + for (int index = 0; index < (debugFlashCount - 1); ++index) + { + graphics.setColor(color); + graphics.fillRect(x, y, width, height); + sleep(debugFlashTime); + + graphics.setColor(debugFlashColor); + graphics.fillRect(x, y, width, height); + sleep(debugFlashTime); + } + + graphics.setColor(color); + graphics.fillRect(x, y, width, height); + } /** * clearRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO + * + * @param x The x-position of the rectangle + * @param y The y-position of the rectangle + * @param width The width of the rectangle + * @param height The height of the rectangle */ - public void clearRect(int x, int y, int w, int h) + public void clearRect(int x, int y, int width, int height) { - // TODO + graphics.clearRect(x, y, width, height); } /** * drawRoundRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO + * + * @param x The x-position of the rectangle + * @param y The y-position of the rectangle + * @param width The width of the rectangle + * @param height The height of the rectangle * @param arcWidth TODO * @param arcHeight TODO */ - public void drawRoundRect(int x, int y, int w, int h, int arcWidth, - int arcHeight) + public void drawRoundRect(int x, int y, int width, int height, + int arcWidth, int arcHeight) { - // TODO + graphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight); } /** * fillRoundRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO + * + * @param x The x-position of the rectangle + * @param y The y-position of the rectangle + * @param width The width of the rectangle + * @param height The height of the rectangle * @param arcWidth TODO * @param arcHeight TODO */ - public void fillRoundRect(int x, int y, int w, int h, int arcWidth, - int arcHeight) + public void fillRoundRect(int x, int y, int width, int height, + int arcWidth, int arcHeight) { - // TODO + graphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight); } /** * drawLine - * @param x1 TODO - * @param y1 TODO - * @param x2 TODO - * @param y2 TODO + * + * @param x1 The x-position of the start + * @param y1 The y-position of the start + * @param x2 The x-position of the end + * @param y2 The y-position of the end */ public void drawLine(int x1, int y1, int x2, int y2) { - // TODO + graphics.drawLine(x1, y1, x2, y2); } /** * draw3DRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO + * + * @param x The x-position of the rectangle + * @param y The y-position of the rectangle + * @param width The width of the rectangle + * @param height The height of the rectangle * @param raised TODO */ - public void draw3DRect(int x, int y, int w, int h, boolean raised) + public void draw3DRect(int x, int y, int width, int height, boolean raised) { - // TODO + graphics.draw3DRect(x, y, width, height, raised); } /** * fill3DRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO + * + * @param x The x-position of the rectangle + * @param y The y-position of the rectangle + * @param width The width of the rectangle + * @param height The height of the rectangle * @param raised TODO */ - public void fill3DRect(int x, int y, int w, int h, boolean raised) + public void fill3DRect(int x, int y, int width, int height, boolean raised) { - // TODO + graphics.fill3DRect(x, y, width, height, raised); } /** * drawOval - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO + * + * @param x the x coordinate + * @param y the y coordiante + * @param width the width + * @param height the height */ - public void drawOval(int x, int y, int w, int h) + public void drawOval(int x, int y, int width, int height) { - // TODO + graphics.drawOval(x, y, width, height); } /** * fillOval - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO + * + * @param x the x coordinate + * @param y the y coordinate + * @param width the width + * @param height the height */ - public void fillOval(int x, int y, int w, int h) + public void fillOval(int x, int y, int width, int height) { - // TODO + graphics.fillOval(x, y, width, height); } /** * drawArc * - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO + * @param x the x coordinate + * @param y the y coordinate + * @param width the width + * @param height the height * @param startAngle TODO * @param arcAngle TODO */ - public void drawArc(int x, int y, int w, int h, int startAngle, int arcAngle) + public void drawArc(int x, int y, int width, int height, + int startAngle, int arcAngle) { - // TODO + graphics.drawArc(x, y, width, height, startAngle, arcAngle); } /** * fillArc * - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO + * @param x the coordinate + * @param y the y coordinate + * @param width the width + * @param height the height * @param startAngle TODO * @param arcAngle TODO */ - public void fillArc(int x, int y, int w, int h, int startAngle, int arcAngle) + public void fillArc(int x, int y, int width, int height, + int startAngle, int arcAngle) { - // TODO + graphics.fillArc(x, y, width, height, startAngle, arcAngle); } /** * drawPolyline + * * @param xpoints TODO * @param ypoints TODO * @param npoints TODO */ public void drawPolyline(int[] xpoints, int[] ypoints, int npoints) { - // TODO + graphics.drawPolyline(xpoints, ypoints, npoints); } /** @@ -551,7 +627,7 @@ public class DebugGraphics extends Graphics */ public void drawPolygon(int[] xpoints, int[] ypoints, int npoints) { - // TODO + graphics.drawPolygon(xpoints, ypoints, npoints); } /** @@ -563,31 +639,32 @@ public class DebugGraphics extends Graphics */ public void fillPolygon(int[] xpoints, int[] ypoints, int npoints) { - // TODO + graphics.fillPolygon(xpoints, ypoints, npoints); } /** * drawString * - * @param string TODO - * @param x TODO - * @param y TODO + * @param string the string + * @param x the x coordinate + * @param y the y coordinate */ - public void drawString(String string, int s, int y) + public void drawString(String string, int x, int y) { - // TODO + graphics.drawString(string, x, y); } /** * drawString * * @param iterator TODO - * @param x TODO - * @param y TODO + * @param x the x coordinate + * @param y the y coordinate */ - public void drawString(AttributedCharacterIterator iterator, int x, int y) + public void drawString(AttributedCharacterIterator iterator, + int x, int y) { - // TODO + graphics.drawString(iterator, x, y); } /** @@ -596,86 +673,111 @@ public class DebugGraphics extends Graphics * @param data TODO * @param offset TODO * @param length TODO - * @param x TODO - * @param y TODO + * @param x the x coordinate + * @param y the y coordinate */ - public void drawBytes(byte[] data, int offset, int length, int x, int y) + public void drawBytes(byte[] data, int offset, int length, + int x, int y) { - // TODO + graphics.drawBytes(data, offset, length, x, y); } /** * drawChars - * @param data TODO - * @param offset TODO - * @param length TODO - * @param value3 TODO - * @param value4 TODO + * + * @param data array of characters to draw + * @param offset offset in array + * @param length number of characters in array to draw + * @param x x-position + * @param y y-position */ - public void drawChars(char[] data, int offset, int value2, int x, int y) + public void drawChars(char[] data, int offset, int length, + int x, int y) { - // TODO - } // drawChars() + for (int index = 0; index < (debugFlashCount - 1); ++index) + { + graphics.setColor(color); + graphics.drawChars(data, offset, length, x, y); + sleep(debugFlashTime); + + graphics.setColor(debugFlashColor); + graphics.drawChars(data, offset, length, x, y); + sleep(debugFlashTime); + } + + graphics.setColor(color); + graphics.drawChars(data, offset, length, x, y); + } /** * drawImage - * @param image TODO - * @param x TODO - * @param y TODO - * @param observer TODO - * @returns boolean + * + * @param image The image to draw + * @param x The x position + * @param y The y position + * @param observer The image observer + * @return boolean */ - public boolean drawImage(Image image, int x, int y, ImageObserver observer) + public boolean drawImage(Image image, int x, int y, + ImageObserver observer) { - return false; // TODO + return graphics.drawImage(image, x, y, observer); } /** * drawImage - * @param image TODO - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - * @param observer TODO - * @returns boolean + * + * @param image The image to draw + * @param x The x position + * @param y The y position + * @param width The width of the area to draw the image + * @param height The height of the area to draw the image + * @param observer The image observer + * + * @return boolean */ - public boolean drawImage(Image image, int x, int y, int w, int h, - ImageObserver observer) + public boolean drawImage(Image image, int x, int y, int width, + int height, ImageObserver observer) { - return false; // TODO + return graphics.drawImage(image, x, y, width, height, observer); } /** * drawImage - * @param image TODO - * @param x TODO - * @param y TODO - * @param background TODO - * @param observer TODO - * @returns boolean + * + * @param image The image to draw + * @param x The x position + * @param y The y position + * @param background The color for the background in the opaque regions + * of the image + * @param observer The image observer + * + * @return boolean */ - public boolean drawImage(Image image, int x, int y, Color background, - ImageObserver observer) + public boolean drawImage(Image image, int x, int y, + Color background, ImageObserver observer) { - return false; // TODO + return graphics.drawImage(image, x, y, background, observer); } /** * drawImage - * @param image TODO - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - * @param background TODO - * @param observer TODO - * @returns boolean - */ - public boolean drawImage(Image image, int x, int y, int w, int h, - Color background, ImageObserver observer) + * + * @param image The image to draw + * @param x The x position + * @param y The y position + * @param width The width of the area to draw the image + * @param height The height of the area to draw the image + * @param background The color for the background in the opaque regions + * of the image + * @param observer The image observer + * + * @return boolean + */ + public boolean drawImage(Image image, int x, int y, int width, int height, + Color background, ImageObserver observer) { - return false; // TODO + return graphics.drawImage(image, x, y, width, height, background, observer); } /** @@ -690,14 +792,15 @@ public class DebugGraphics extends Graphics * @param sy1 TODO * @param sx2 TODO * @param sy2 TODO - * @param observer TODO - * @returns boolean + * @param observer The image observer + * + * @return boolean */ - public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, - int sx1, int sy1, int sx2, int sy2, - ImageObserver observer) + public boolean drawImage(Image image, int dx1, int dy1, + int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, + ImageObserver observer) { - return false; // TODO + return graphics.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer); } /** @@ -712,15 +815,17 @@ public class DebugGraphics extends Graphics * @param sy1 TODO * @param sx2 TODO * @param sy2 TODO - * @param background TODO - * @param observer TODO - * @returns boolean + * @param background The color for the background in the opaque regions + * of the image + * @param observer The image observer + * + * @return boolean */ - public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, - int sx1, int sy1, int sx2, int sy2, - Color background, ImageObserver observer) + public boolean drawImage(Image image, int dx1, int dy1, + int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, + Color background, ImageObserver observer) { - return false; // TODO + return graphics.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, background, observer); } /** @@ -733,9 +838,10 @@ public class DebugGraphics extends Graphics * @param destx The x position of the destination area * @param desty The y posiiton of the destination area */ - public void copyArea(int x, int y, int w, int h, int destx, int desty) + public void copyArea(int x, int y, int width, int height, + int destx, int desty) { - // TODO + graphics.copyArea(x, y, width, height, destx, desty); } /** @@ -743,7 +849,8 @@ public class DebugGraphics extends Graphics */ public void dispose() { - // TODO + graphics.dispose(); + graphics = null; } /** @@ -757,22 +864,13 @@ public class DebugGraphics extends Graphics } /** - * toShortString - * @returns String - */ - String toShortString() - { - return null; // TODO - } // toShortString() - - /** * setDebugOptions * * @param options the debug options */ public void setDebugOptions(int options) { - // TODO + debugOptions = options; } /** @@ -782,6 +880,6 @@ public class DebugGraphics extends Graphics */ public int getDebugOptions() { - return 0; // TODO + return debugOptions; } } |