diff options
author | Tom Tromey <tromey@redhat.com> | 2002-01-16 04:21:35 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2002-01-16 04:21:35 +0000 |
commit | 3bd483f2a189ed92cefd9ad0cfa5f15fabdf1592 (patch) | |
tree | a0f126a62903beed11548538a3c963a7e0a7f669 /libjava/java/awt/Graphics.java | |
parent | c342f12677626f2f683eb9ce43f1d3905105f231 (diff) | |
download | gcc-3bd483f2a189ed92cefd9ad0cfa5f15fabdf1592.zip gcc-3bd483f2a189ed92cefd9ad0cfa5f15fabdf1592.tar.gz gcc-3bd483f2a189ed92cefd9ad0cfa5f15fabdf1592.tar.bz2 |
Start of AWT merge with Classpath:
* Makefile.in: Rebuilt.
* Makefile.am (awt_java_source_files): Reference files in
gnu/java/awt, not gnu/gcj/awt.
* java/awt/image/BufferedImage.java: Updated copyright.
* java/awt/image/ComponentColorModel.java: Updated copyright.
* java/awt/image/ComponentSampleModel.java: Updated copyright.
* java/awt/image/DataBuffer.java: Updated copyright.
* java/awt/image/DataBufferByte.java: Updated copyright.
* java/awt/image/DataBufferInt.java: Updated copyright.
* java/awt/image/DataBufferUShort.java: Updated copyright.
* java/awt/image/IndexColorModel.java: Updated copyright.
* java/awt/image/PackedColorModel.java: Updated copyright.
* java/awt/image/Raster.java: Updated copyright.
* java/awt/image/RasterOp.java: Updated copyright.
* java/awt/image/SampleModel.java: Updated copyright.
* java/awt/image/SinglePixelPackedSampleModel.java: Updated copyright.
* java/awt/image/WritableRaster.java: Updated copyright.
* java/awt/color/ColorSpace.java: Updated copyright.
* java/awt/color/ICC_ColorSpace.java: Updated copyright
* java/awt/color/ICC_Profile.java: Updated copyright.
* java/awt/event/HierarchyBoundsAdapter.java: Updated copyright.
* java/awt/event/HierarchyBoundsListener.java: Updated copyright.
* java/awt/event/HierarchyEvent.java: Updated copyright.
* java/awt/event/HierarchyListener.java: Updated copyright.
* java/awt/geom/AffineTransform.java: Updated copyright.
* java/awt/geom/Dimension2D.java: Updated copyright.
* java/awt/geom/Ellipse2D.java: Updated copyright.
* java/awt/geom/IllegalPathStateException.java: Updated copyright.
* java/awt/geom/Line2D.java: Updated copyright.
* java/awt/geom/NoninvertibleTransformException.java: Updated
copyright.
* java/awt/geom/PathIterator.java: Updated copyright.
* java/awt/geom/Point2D.java: Updated copyright.
* java/awt/geom/Rectangle2D.java: Updated copyright.
* java/awt/geom/RectangularShape.java: Updated copyright.
* java/awt/geom/RoundRectangle2D.java: Updated copyright.
* java/awt/Toolkit.java: Updated import for file moves.
* java/awt/Rectangle.java: Updated copyright; added javadoc from
Classpath.
(hashCode): New method from Classpath.
* java/awt/Graphics2D.java: Updated copyright.
* java/awt/Transparency.java: Updated copyright.
* java/awt/Paint.java: Updated copyright.
* java/awt/Graphics.java: New version from Classpath.
* java/awt/EventDispatchThread.java: Updated copyright.
* java/awt/CardLayout.java (layoutContainer): Don't skip invisible
children.
(gotoComponent): Wrap around on next/previous.
* gnu/gcj/awt/BitMaskExtent.java: Removed.
* gnu/gcj/awt/Buffers.java: Removed.
* gnu/gcj/awt/ComponentDataBlitOp.java: Removed.
* gnu/gcj/awt/GLightweightPeer.java: Removed.
* gnu/java/awt/BitMaskExtent.java: Added.
* gnu/java/awt/Buffers.java: Added.
* gnu/java/awt/ComponentDataBlitOp.java: Added.
* gnu/java/awt/GLightweightPeer.java: Added.
* java/awt/geom/Line2D.java (clone): Ignore
CloneNotSupportedException.
* gnu/gcj/awt/GLightweightPeer.java (getColorModel): New method.
* java/awt/Frame.java: Merged with Classpath.
* java/awt/RenderingHints.java: Copyright update.
* java/awt/Paint.java: Copyright update.
* java/awt/image/DirectColorModel.java: Merged with Classpath.
* java/awt/image/ColorModel.java: Merged with Classpath.
* java/awt/Window.java (show): New Implementation from Classpath.
(isShowing): Use super.isShowing().
* java/awt/EventQueue.java: Merged with Classpath.
* java/awt/AWTEventMulticaster.java (save): Throw
RuntimeException.
(saveInternal): Likewise.
* java/awt/AWTEvent.java: Now implements Serializable.
* java/awt/Event.java: Copyright update.
* java/awt/peer/ComponentPeer.java: Merged with Classpath.
* java/awt/image/BufferedImage.java: Copyright update.
* java/awt/GraphicsConfiguration.java: Copyright update.
* java/awt/Component.java: (addNotify): Don't call
addNotifyContainerChildren().
(addNotifyContainerChildren): Removed.
(setPeer): New method from Classpath.
(setTreeLock): Likewise.
(setVisible): Rewrote.
(show): Use it.
(hide): Likewise.
(validate): Set `valid'.
(checkImage(Image,ImageObserver)): Implementation from Classpath.
(createImage(ImageProducer)): Likewise.
(prepareImage): Likewise.
* java/awt/Container.java (addImpl): Handle case where constraint
is not a String. Post event via system event queue.
(remove): Post event via system event queue.
(validateTree): Only validate child if it is invalid.
(getAlignmentX): Call super method as default.
(getAlignmentY): Likewise.
(addContainerListener): Now synchronized.
(removeContainerListener): Likewise.
(addNotifyContainerChildren): Now private.
* java/awt/ComponentOrientation.java: Updated copyright. Added
@author.
* java/awt/FlowLayout.java (serialVersionUID): New field.
(setAlignment): Better exception message.
(layoutContainer): Don't compute component's preferred size unless
we're going to use it.
* java/awt/BorderLayout.java (AFTER_LAST_LINE, AFTER_LINE_ENDS,
BEFORE_FIRST_LINE, BEFORE_LINE_BEGINS): New constants.
(firstLine, lastLine, firstItem, lastItem): New fields.
(addLayoutComponent): Handle case where constraints is null.
Also, handle relative locations.
(removeLayoutComponent): Handle relative locations.
(MIN, MAX, PREF): New constants.
(calcCompSize): New method.
(calcSize): New method.
(minimumLayoutSize): Use it.
(preferredLayoutSize): Likewise.
(maximumLayoutSize): Likewise.
(toString): Include more information.
(setBounds): New method.
(layoutContainer): Use libgcj implementation; extended to handle
relative locations.
From-SVN: r48896
Diffstat (limited to 'libjava/java/awt/Graphics.java')
-rw-r--r-- | libjava/java/awt/Graphics.java | 928 |
1 files changed, 743 insertions, 185 deletions
diff --git a/libjava/java/awt/Graphics.java b/libjava/java/awt/Graphics.java index 56c732f..bd785be 100644 --- a/libjava/java/awt/Graphics.java +++ b/libjava/java/awt/Graphics.java @@ -1,235 +1,793 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Graphics.java -- Abstract Java drawing class + Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.awt; import java.awt.image.ImageObserver; /** - * @author Warren Levy <warrenl@cygnus.com> - * @date March 15, 2000. + * This is the abstract superclass of classes for drawing to graphics + * devices such as the screen or printers. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Warren Levy <warrenl@cygnus.com> + */ +public abstract class Graphics +{ + +/* + * Instance Variables + */ + +/*************************************************************************/ + +/* + * Constructors */ /** - * Written using on-line Java Platform 1.2 API Specification, as well - * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). - * Status: Almost complete + * Default constructor for subclasses. + */ +protected +Graphics() +{ +} + +/*************************************************************************/ + +/* + * Instance Methods */ -public abstract class Graphics +/** + * Returns a copy of this <code>Graphics</code> object. + * + * @return A copy of this object. + */ +public abstract Graphics +create(); + +/*************************************************************************/ + +/** + * Returns a copy of this <code>Graphics</code> object. The origin point + * will be translated to the point (x, y) and the cliping rectangle set + * to the intersection of the clipping rectangle in this object and the + * rectangle specified by the parameters to this method. + * + * @param x The new X coordinate of the clipping region rect. + * @param y The new Y coordinate of the clipping region rect. + * @param width The width of the clipping region intersect rectangle. + * @param height The height of the clipping region intersect rectangle. + * + * @return A copy of this object, modified as specified. + */ +public Graphics +create(int x, int y, int width, int height) { - protected Graphics() {} + Graphics g = create(); + + g.translate(x, y); + // FIXME: I'm not sure if this will work. Are the old clip rect bounds + // translated above? + g.clipRect(0, 0, width, height); + + return(g); +} + +/*************************************************************************/ + +/** + * Translates this context so that its new origin point is the point + * (x, y). + * + * @param x The new X coordinate of the origin. + * @param y The new Y coordinate of the origin. + */ +public abstract void +translate(int x, int y); + +/*************************************************************************/ + +/** + * Returns the current color for this object. + * + * @return The color for this object. + */ +public abstract Color +getColor(); + +/*************************************************************************/ + +/** + * Sets the current color for this object. + * + * @param color The new color. + */ +public abstract void +setColor(Color color); + +/*************************************************************************/ + +/** + * Sets this context into "paint" mode, where the target pixels are + * completely overwritten when drawn on. + */ +public abstract void +setPaintMode(); + +/*************************************************************************/ + +/** + * Sets this context info "XOR" mode, where the targe pixles are + * XOR-ed when drawn on. + * + * @param color The color to XOR against. + */ +public abstract void +setXORMode(Color color); - public abstract Graphics create(); +/*************************************************************************/ - public Graphics create(int x, int y, int width, int height) - { - Graphics gfx = create(); - gfx.translate(x, y); - gfx.setClip(0, y, width, height); - return gfx; - } +/** + * Returns the current font for this graphics context. + * + * @return The current font. + */ +public abstract Font +getFont(); - public abstract void translate(int x, int y); +/*************************************************************************/ - public abstract Color getColor(); +/** + * Sets the font for this graphics context to the specified value. + * + * @param font The new font. + */ +public abstract void +setFont(Font font); - public abstract void setColor(Color color); +/*************************************************************************/ - public abstract void setPaintMode(); +/** + * Returns the font metrics for the current font. + * + * @return The font metrics for the current font. + */ +public FontMetrics +getFontMetrics() +{ + return(getFontMetrics(getFont())); +} - public abstract void setXORMode(Color altColor); +/*************************************************************************/ - public abstract Font getFont(); +/** + * Returns the font metrics for the specified font. + * + * @param font The font to return metrics for. + * + * @return The requested font metrics. + */ +public abstract FontMetrics +getFontMetrics(Font font); - public abstract void setFont(Font font); +/*************************************************************************/ - public FontMetrics getFontMetrics() - { - return getFontMetrics(getFont()); - } +/** + * Returns the bounding rectangle of the clipping region for this + * graphics context. + * + * @return The bounding rectangle for the clipping region. + */ +public abstract Rectangle +getClipBounds(); - public abstract FontMetrics getFontMetrics(Font font); +/*************************************************************************/ - public abstract Rectangle getClipBounds(); +/** + * Returns the bounding rectangle of the clipping region for this + * graphics context. + * + * @return The bounding rectangle for the clipping region. + * + * @deprecated This method is deprecated in favor of + * <code>getClipBounds()</code>. + */ +public Rectangle +getClipRect() +{ + return(getClipBounds()); +} - public abstract void clipRect(int x, int y, int width, int height); +/*************************************************************************/ - public abstract void setClip(int x, int y, int width, int height); +/** + * Sets the clipping region to the intersection of the current clipping + * region and the rectangle determined by the specified parameters. + * + * @param x The X coordinate of the upper left corner of the intersect rect. + * @param Y The Y coordinate of the upper left corner of the intersect rect. + * @param width The width of the intersect rect. + * @param height The height of the intersect rect. + */ +public abstract void +clipRect(int x, int y, int width, int height); - public abstract Shape getClip(); +/*************************************************************************/ - public abstract void setClip(Shape clip); +/** + * Sets the clipping region to the rectangle determined by the specified + * parameters. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + */ +public abstract void +setClip(int x, int y, int width, int height); - public abstract void copyArea(int x, int y, int width, int height, - int dx, int dy); +/*************************************************************************/ - public abstract void drawLine(int x1, int y1, int x2, int y2); - - public abstract void fillRect(int x, int y, int width, int height); - - public void drawRect(int x, int y, int width, int height) - { - int x1 = x; - int y1 = y; - int x2 = x + width; - int y2 = y + height; - drawLine(x1, y1, x2, y1); - drawLine(x2, y1, x2, y2); - drawLine(x2, y2, x1, y2); - drawLine(x1, y2, x1, y1); - } - - public abstract void clearRect(int x, int y, int width, int height); - - public abstract void drawRoundRect(int x, int y, int width, int height, - int arcWidth, int arcHeight); - - public abstract void fillRoundRect(int x, int y, int width, int height, - int arcWidth, int arcHeight); - - public void draw3DRect(int x, int y, int width, int height, - boolean raised) - { - Color color = getColor(); - Color tl = color.brighter(); - Color br = color.darker(); +/** + * Returns the current clipping region as a <code>Shape</code> object. + * + * @return The clipping region as a <code>Shape</code>. + */ +public abstract Shape +getClip(); + +/*************************************************************************/ + +/** + * Sets the clipping region to the specified <code>Shape</code>. + * + * @param shape The new clipping region. + */ +public abstract void +setClip(Shape clip); + +/*************************************************************************/ + +/** + * Copies the specified rectangle to the specified offset location. + * + * @param x The X coordinate of the upper left corner of the copy rect. + * @param y The Y coordinate of the upper left corner of the copy rect. + * @param width The width of the copy rect. + * @param height The height of the copy rect. + * @param dx The offset from the X value to start drawing. + * @param dy The offset from the Y value to start drawing. + */ +public abstract void +copyArea(int x, int y, int width, int height, int dx, int dy); + +/*************************************************************************/ + +/** + * Draws a line between the two specified points. + * + * @param x1 The X coordinate of the first point. + * @param y1 The Y coordinate of the first point. + * @param x2 The X coordinate of the second point. + * @param y2 The Y coordinate of the second point. + */ +public abstract void +drawLine(int x1, int y1, int x2, int y2); + +/*************************************************************************/ + +/** + * Fills the area bounded by the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the fill rect. + * @param y The Y coordinate of the upper left corner of the fill rect. + * @param width The width of the fill rect. + * @param height The height of the fill rect. + */ +public abstract void +fillRect(int x, int y, int width, int height); + +/*************************************************************************/ + +/** + * Draws the outline of the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the draw rect. + * @param y The Y coordinate of the upper left corner of the draw rect. + * @param width The width of the draw rect. + * @param height The height of the draw rect. + */ +public void +drawRect(int x, int y, int width, int height) +{ + int x1 = x; + int y1 = y; + int x2 = x + width; + int y2 = y + height; + drawLine(x1, y1, x2, y1); + drawLine(x2, y1, x2, y2); + drawLine(x2, y2, x1, y2); + drawLine(x1, y2, x1, y1); +} + +/*************************************************************************/ + +/** + * Clears the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the clear rect. + * @param y The Y coordinate of the upper left corner of the clear rect. + * @param width The width of the clear rect. + * @param height The height of the clear rect. + */ +public abstract void +clearRect(int x, int y, int width, int height); + +/*************************************************************************/ + +/** + * Draws the outline of the specified rectangle with rounded cornders. + * + * @param x The X coordinate of the upper left corner of the draw rect. + * @param y The Y coordinate of the upper left corner of the draw rect. + * @param width The width of the draw rect. + * @param height The height of the draw rect. + * @param arcWidth The width of the corner arcs. + * @param arcHeigth The height of the corner arcs. + */ +public abstract void +drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight); + +/*************************************************************************/ + +/** + * Fills the specified rectangle with rounded cornders. + * + * @param x The X coordinate of the upper left corner of the fill rect. + * @param y The Y coordinate of the upper left corner of the fill rect. + * @param width The width of the fill rect. + * @param height The height of the fill rect. + * @param arcWidth The width of the corner arcs. + * @param arcHeigth The height of the corner arcs. + */ +public abstract void +fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight); + +/*************************************************************************/ + +public void +draw3DRect(int x, int y, int width, int height, boolean raised) +{ + Color color = getColor(); + Color tl = color.brighter(); + Color br = color.darker(); - if (!raised) - { - Color tmp = tl; - tl = br; - br = tmp; - } + if (!raised) + { + Color tmp = tl; + tl = br; + br = tmp; + } - int x1 = x; - int y1 = y; - int x2 = x + width; - int y2 = y + height; + int x1 = x; + int y1 = y; + int x2 = x + width; + int y2 = y + height; - setColor(tl); - drawLine(x1, y1, x2, y1); - drawLine(x1, y2, x1, y1); - setColor(br); - drawLine(x2, y1, x2, y2); - drawLine(x2, y1, x1, y2); - setColor(color); - } - - public void fill3DRect(int x, int y, int width, int height, - boolean raised) - { - fillRect(x, y, width, height); - draw3DRect(x, y, width-1, height-1, raised); - } - - public abstract void drawOval(int x, int y, int width, int height); - - public abstract void fillOval(int x, int y, int width, int height); - - public abstract void drawArc(int x, int y, int width, int height, - int startAngle, int arcAngle); - - public abstract void fillArc(int x, int y, int width, int height, - int startAngle, int arcAngle); - - public abstract void drawPolyline(int[] xPoints, int[] yPoints, - int nPoints); - - public abstract void drawPolygon(int[] xPoints, int[] yPoints, - int nPoints); - - //public void drawPolygon(Polygon p); - - public abstract void fillPolygon(int[] xPoints, int[] yPoints, - int nPoints); + setColor(tl); + drawLine(x1, y1, x2, y1); + drawLine(x1, y2, x1, y1); + setColor(br); + drawLine(x2, y1, x2, y2); + drawLine(x2, y1, x1, y2); + setColor(color); +} + +/** + * Fills the specified rectangle with a 3D effect + * + * @param x The X coordinate of the upper left corner of the fill rect. + * @param y The Y coordinate of the upper left corner of the fill rect. + * @param width The width of the fill rect. + * @param height The height of the fill rect. + * @param raised <code>true</code> if the rectangle appears raised, + * <code>false</code> if it should appear etched. + */ +public void +fill3DRect(int x, int y, int width, int height, boolean raised) +{ + fillRect(x, y, width, height); + draw3DRect(x, y, width-1, height-1, raised); +} + +/*************************************************************************/ + +/** + * Draws the outline of the specified rectangle with a 3D effect + * + * @param x The X coordinate of the upper left corner of the draw rect. + * @param y The Y coordinate of the upper left corner of the draw rect. + * @param width The width of the draw rect. + * @param height The height of the draw rect. + * @param raised <code>true</code> if the rectangle appears raised, + * <code>false</code> if it should appear etched. + */ +public void +drawRoundRect(int x, int y, int width, int height, boolean raised) +{ + // FIXME: ??? +} + +/*************************************************************************/ + +/** + * Draws an oval that just fits within the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + */ +public abstract void +drawOval(int x, int y, int width, int height); + +/*************************************************************************/ + +/** + * Fills an oval that just fits within the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + */ +public abstract void +fillOval(int x, int y, int width, int height); + +/*************************************************************************/ + +/** + * Draws an arc using the specified bounding rectangle and the specified + * angle parameter. The arc is centered at the center of the rectangle. + * The arc starts at the arcAngle position and extend for arcAngle + * degrees. The degree origin is at the 3 o'clock position. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + * @param arcStart The beginning angle of the arc. + * @param arcAngle The extent of the arc. + */ +public abstract void +drawArc(int x, int y, int width, int height, int startAngle, int arcAngle); + +/*************************************************************************/ + +/** + * Fills the arc define by the specified bounding rectangle and the specified + * angle parameter. The arc is centered at the center of the rectangle. + * The arc starts at the arcAngle position and extend for arcAngle + * degrees. The degree origin is at the 3 o'clock position. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + * @param arcStart The beginning angle of the arc. + * @param arcAngle The extent of the arc. + */ +public abstract void +fillArc(int x, int y, int width, int height, int startAngle, int arcAngle); + +/*************************************************************************/ + +/** + * Draws a series of interconnected lines determined by the arrays + * of corresponding x and y coordinates. + * + * @param xPoints The X coordinate array. + * @param yPoints The Y coordinate array. + * @param npoints The number of points to draw. + */ +public abstract void +drawPolyline(int xPoints[], int yPoints[], int npoints); + +/*************************************************************************/ + +/** + * Draws a series of interconnected lines determined by the arrays + * of corresponding x and y coordinates. The figure is closed if necessary + * by connecting the first and last points. + * + * @param xPoints The X coordinate array. + * @param yPoints The Y coordinate array. + * @param npoints The number of points to draw. + */ +public abstract void +drawPolygon(int xPoints[], int yPoints[], int npoints); + +/*************************************************************************/ + +/** + * Draws the specified polygon. + * + * @param polygon The polygon to draw. + */ +public void +drawPolygon(Polygon polygon) +{ + drawPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints); +} + +/*************************************************************************/ + +/** + * Fills the polygon determined by the arrays + * of corresponding x and y coordinates. + * + * @param xPoints The X coordinate array. + * @param yPoints The Y coordinate array. + * @param npoints The number of points to draw. + */ +public abstract void +fillPolygon(int xPoints[], int yPoints[], int npoints); + +/*************************************************************************/ + +/** + * Fills the specified polygon + * + * @param polygon The polygon to fill. + */ +public void +fillPolygon(Polygon polygon) +{ + fillPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints); +} + +/*************************************************************************/ + +/** + * Draws the specified string starting at the specified point. + * + * @param string The string to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + */ +public abstract void +drawString(String string, int x, int y); + +/*************************************************************************/ - //public void fillPolygon(Polygon p); +/** + * Draws the specified characters starting at the specified point. + * + * @param data The array of characters to draw. + * @param offset The offset into the array to start drawing characters from. + * @param length The number of characters to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + */ +public void +drawChars(char data[], int offset, int length, int x, int y) +{ + drawString(new String(data, offset, length), x, y); +} - public abstract void drawString(String str, int x, int y); +/*************************************************************************/ + +/** + * Draws the specified bytes as text starting at the specified point. + * + * @param data The array of bytes to draw. + * @param offset The offset into the array to start drawing bytes from. + * @param length The number of bytes to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + */ +public void +drawChars(byte data[], int offset, int length, int x, int y) +{ + drawString(new String(data, offset, length), x, y); +} - /* - public abstract void drawString(AttributedCharacterIterator iterator, +/* +public abstract void drawString(AttributedCharacterIterator iterator, int x, int y) +*/ + +public void +drawBytes(byte[] data, int offset, int length, int x, int y) +{ + String str = new String(data, offset, length); + drawString(str, x, y); +} + +/*************************************************************************/ + +/** + * Draws all of the image that is available and returns. If the image + * is not completely loaded, <code>false</code> is returned and + * the specified iamge observer is notified as more data becomes + * available. + * + * @param image The image to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + * @param observer The image observer to notify as data becomes available. + * + * @return <code>true</code> if all the image data is available, + * <code>false</code> otherwise. */ +public abstract boolean +drawImage(Image image, int x, int y, ImageObserver observer); + +/*************************************************************************/ - public void drawChars(char[] data, int offset, int length, - int x, int y) - { - String str = new String(data, offset, length); - drawString(str, x, y); - } +/** + * Draws all of the image that is available and returns. The image + * is scaled to fit in the specified rectangle. If the image + * is not completely loaded, <code>false</code> is returned and + * the specified iamge observer is notified as more data becomes + * available. + * + * @param image The image to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + * @param width The width of the rectangle to draw in. + * @param height The height of the rectangle to draw in. + * @param observer The image observer to notify as data becomes available. + * + * @return <code>true</code> if all the image data is available, + * <code>false</code> otherwise. + */ +public abstract boolean +drawImage(Image image, int x, int y, int width, int height, + ImageObserver observer); + +/*************************************************************************/ - public void drawBytes(byte[] data, int offset, int length, - int x, int y) - { - String str = new String(data, offset, length); - drawString(str, x, y); - } +/** + * Draws all of the image that is available and returns. If the image + * is not completely loaded, <code>false</code> is returned and + * the specified iamge observer is notified as more data becomes + * available. + * + * @param image The image to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + * @param bgcolor The background color to use for the image. + * @param observer The image observer to notify as data becomes available. + * + * @return <code>true</code> if all the image data is available, + * <code>false</code> otherwise. + */ +public abstract boolean +drawImage(Image image, int x, int y, Color bgcolor, ImageObserver observer); + +/*************************************************************************/ - public abstract boolean drawImage(Image img, int x, int y, - ImageObserver observer); +/** + * Draws all of the image that is available and returns. The image + * is scaled to fit in the specified rectangle. If the image + * is not completely loaded, <code>false</code> is returned and + * the specified iamge observer is notified as more data becomes + * available. + * + * @param image The image to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + * @param width The width of the rectangle to draw in. + * @param height The height of the rectangle to draw in. + * @param bgcolor The background color to use for the image. + * @param observer The image observer to notify as data becomes available. + * + * @return <code>true</code> if all the image data is available, + * <code>false</code> otherwise. + */ +public abstract boolean +drawImage(Image image, int x, int y, int width, int height, Color bgcolor, + ImageObserver observer); + +/*************************************************************************/ - public abstract boolean drawImage(Image img, int x, int y, - int width, int height, - ImageObserver observer); +/** + * FIXME: Write Javadocs for this when you understand it. + */ +public abstract boolean +drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, + int sx2, int sy2, ImageObserver observer); - public abstract boolean drawImage(Image img, int x, int y, Color bgcolor, - ImageObserver observer); - - public abstract boolean drawImage(Image img, int x, int y, - int width, int height, Color bgcolor, - ImageObserver observer); +/*************************************************************************/ + +/** + * FIXME: Write Javadocs for this when you understand it. + */ +public abstract boolean +drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, + int sx2, int sy2, Color bgcolor, ImageObserver observer); + +/*************************************************************************/ - public abstract boolean drawImage(Image img, - int dx1, int dy1, int dx2, int dy2, - int sx1, int sy1, int sx2, int sy2, - ImageObserver observer); +/** + * Free any resources held by this graphics context immediately instead + * of waiting for the object to be garbage collected and finalized. + */ +public abstract void +dispose(); - public abstract boolean drawImage(Image img, - int dx1, int dy1, int dx2, int dy2, - int sx1, int sy1, int sx2, int sy2, - Color bgcolor, ImageObserver observer); +/*************************************************************************/ + +/** + * Frees the resources held by this graphics context when it is + * garbage collected. + */ +public void +finalize() +{ + dispose(); +} - public abstract void dispose(); +/*************************************************************************/ + +/** + * Returns a string representation of this object. + * + * @param A string representation of this object. + */ +public String +toString() +{ + return(super.toString()); +} + +public boolean +hitClip(int x, int y, int width, int height) +{ + throw new UnsupportedOperationException("not implemented yet"); +} + +public Rectangle +getClipBounds(Rectangle r) +{ + Rectangle clipBounds = getClipBounds(); - public void finalize() - { - dispose(); - } - - public String toString() - { - return super.toString(); // FIXME - } - - /** @deprecated */ - public Rectangle getClipRect() - { - return getClipBounds(null); - } - - public boolean hitClip(int x, int y, int width, int height) - { - throw new UnsupportedOperationException("not implemented yet"); - } - - public Rectangle getClipBounds(Rectangle r) - { - Rectangle clipBounds = getClipBounds(); - - if (r == null) - return clipBounds; - - r.x = clipBounds.x; - r.y = clipBounds.y; - r.width = clipBounds.width; - r.height = clipBounds.height; - return r; - } + if (r == null) + return clipBounds; + + r.x = clipBounds.x; + r.y = clipBounds.y; + r.width = clipBounds.width; + r.height = clipBounds.height; + return r; } + +} // class Graphics + |