0001: /*
0002: * @(#)Graphics.java 1.13 06/10/10
0003: *
0004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
0005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
0006: *
0007: * This program is free software; you can redistribute it and/or
0008: * modify it under the terms of the GNU General Public License version
0009: * 2 only, as published by the Free Software Foundation.
0010: *
0011: * This program is distributed in the hope that it will be useful, but
0012: * WITHOUT ANY WARRANTY; without even the implied warranty of
0013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0014: * General Public License version 2 for more details (a copy is
0015: * included at /legal/license.txt).
0016: *
0017: * You should have received a copy of the GNU General Public License
0018: * version 2 along with this work; if not, write to the Free Software
0019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
0020: * 02110-1301 USA
0021: *
0022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
0023: * Clara, CA 95054 or visit www.sun.com if you need additional
0024: * information or have any questions.
0025: *
0026: */
0027: package java.awt;
0028:
0029: import java.io.*;
0030: import java.lang.*;
0031: import java.util.*;
0032: import java.awt.image.ImageObserver;
0033: import java.text.AttributedCharacterIterator;
0034:
0035: /**
0036: * The <code>Graphics</code> class is the abstract base class for
0037: * all graphics contexts that allow an application to draw onto
0038: * components that are realized on various devices, as well as
0039: * onto off-screen images.
0040: * <p>
0041: * A <code>Graphics</code> object encapsulates state information needed
0042: * for the basic rendering operations that Java supports. This
0043: * state information includes the following properties:
0044: * <p>
0045: * <ul>
0046: * <li>The <code>Component</code> object on which to draw.
0047: * <li>A translation origin for rendering and clipping coordinates.
0048: * <li>The current clip.
0049: * <li>The current color.
0050: * <li>The current font.
0051: * <li>The current logical pixel operation function (XOR or Paint).
0052: * <li>The current XOR alternation color
0053: * (see <a href="#setXORMode"><code>setXORMode</code></a>).
0054: * </ul>
0055: * <p>
0056: * Coordinates are infinitely thin and lie between the pixels of the
0057: * output device.
0058: * Operations which draw the outline of a figure operate by traversing
0059: * an infinitely thin path between pixels with a pixel-sized pen that hangs
0060: * down and to the right of the anchor point on the path.
0061: * Operations which fill a figure operate by filling the interior
0062: * of that infinitely thin path.
0063: * Operations which render horizontal text render the ascending
0064: * portion of character glyphs entirely above the baseline coordinate.
0065: * <p>
0066: * The graphics pen hangs down and to the right from the path it traverses.
0067: * This has the following implications:
0068: * <p><ul>
0069: * <li>If you draw a figure that covers a given rectangle, that
0070: * figure occupies one extra row of pixels on the right and bottom edges
0071: * as compared to filling a figure that is bounded by that same rectangle.
0072: * <li>If you draw a horizontal line along the same <i>y</i> coordinate as
0073: * the baseline of a line of text, that line is drawn entirely below
0074: * the text, except for any descenders.
0075: * </ul><p>
0076: * All coordinates which appear as arguments to the methods of this
0077: * <code>Graphics</code> object are considered relative to the
0078: * translation origin of this <code>Graphics</code> object prior to
0079: * the invocation of the method.
0080: * All rendering operations modify only pixels which lie within the
0081: * area bounded by both the current clip of the graphics context
0082: * and the extents of the component used to create the
0083: * <code>Graphics</code> object.
0084: * All drawing or writing is done in the current color,
0085: * using the current paint mode, and in the current font.
0086: * <h3>Compatibility</h3>
0087: * The Graphics class is compatible with the graphics class in
0088: * PersonalJava. It has modified behavior from JDK1.1.8, in that
0089: * its setXorMode may not have any effect.
0090: *
0091: * @version 1.46, 03/12/01
0092: * @author Sami Shaio
0093: * @author Arthur van Hoff
0094: * @see java.awt.Component
0095: * @see java.awt.Graphics#clipRect(int, int, int, int)
0096: * @see java.awt.Graphics#setColor(java.awt.Color)
0097: * @see java.awt.Graphics#setPaintMode()
0098: * @see java.awt.Graphics#setXORMode(java.awt.Color)
0099: * @see java.awt.Graphics#setFont(java.awt.Font)
0100: * @since JDK1.0
0101: */
0102: public abstract class Graphics {
0103:
0104: public abstract void drawString(
0105: AttributedCharacterIterator iterator, int x, int y);
0106:
0107: /**
0108: * Constructs a new <code>Graphics</code> object.
0109: * This constructor is the default contructor for a graphics
0110: * context.
0111: * <p>
0112: * Since <code>Graphics</code> is an abstract class, applications
0113: * cannot call this constructor directly. Graphics contexts are
0114: * obtained from other graphics contexts or are created by calling
0115: * <code>getGraphics</code> on a component.
0116: * @see java.awt.Graphics#create()
0117: * @see java.awt.Component#getGraphics
0118: * @since JDK1.0
0119: */
0120: protected Graphics() {
0121: }
0122:
0123: /**
0124: * Creates a new <code>Graphics</code> object that is
0125: * a copy of this <code>Graphics</code> object.
0126: * @return a new graphics context that is a copy of
0127: * this graphics context.
0128: * @since JDK1.0
0129: */
0130: public abstract Graphics create();
0131:
0132: /**
0133: * Creates a new <code>Graphics</code> object based on this
0134: * <code>Graphics</code> object, but with a new translation and clip area.
0135: * The new <code>Graphics</code> object has its origin
0136: * translated to the specified point (<i>x</i>, <i>y</i>).
0137: * Its clip area is determined by the intersection of the original
0138: * clip area with the specified rectangle. The arguments are all
0139: * interpreted in the coordinate system of the original
0140: * <code>Graphics</code> object. The new graphics context is
0141: * identical to the original, except in two respects:
0142: * <p>
0143: * <ul>
0144: * <li>
0145: * The new graphics context is translated by (<i>x</i>, <i>y</i>).
0146: * That is to say, the point (<code>0</code>, <code>0</code>) in the
0147: * new graphics context is the same as (<i>x</i>, <i>y</i>) in
0148: * the original graphics context.
0149: * <li>
0150: * The new graphics context has an additional clipping rectangle, in
0151: * addition to whatever (translated) clipping rectangle it inherited
0152: * from the original graphics context. The origin of the new clipping
0153: * rectangle is at (<code>0</code>, <code>0</code>), and its size
0154: * is specified by the <code>width</code> and <code>height</code> arguments.
0155: * </ul>
0156: * <p>
0157: * @param x the <i>x</i> coordinate.
0158: * @param y the <i>y</i> coordinate.
0159: * @param width the width of the clipping rectangle.
0160: * @param height the height of the clipping rectangle.
0161: * @return a new graphics context.
0162: * @see java.awt.Graphics#translate
0163: * @see java.awt.Graphics#clipRect
0164: * @since JDK1.0
0165: */
0166: public Graphics create(int x, int y, int width, int height) {
0167: Graphics g = create();
0168: g.translate(x, y);
0169: g.clipRect(0, 0, width, height);
0170: return g;
0171: }
0172:
0173: /**
0174: * Translates the origin of the graphics context to the point
0175: * (<i>x</i>, <i>y</i>) in the current coordinate system.
0176: * Modifies this graphics context so that its new origin corresponds
0177: * to the point (<i>x</i>, <i>y</i>) in this graphics context's
0178: * original coordinate system. All coordinates used in subsequent
0179: * rendering operations on this graphics context will be relative
0180: * to this new origin.
0181: * @param x the <i>x</i> coordinate.
0182: * @param y the <i>y</i> coordinate.
0183: * @since JDK1.0
0184: */
0185: public abstract void translate(int x, int y);
0186:
0187: /**
0188: * Gets this graphics context's current color.
0189: * @return this graphics context's current color.
0190: * @see java.awt.Color
0191: * @see java.awt.Graphics#setColor
0192: * @since JDK1.0
0193: */
0194: public abstract Color getColor();
0195:
0196: /**
0197: * Sets this graphics context's current color to the specified
0198: * color. All subsequent graphics operations using this graphics
0199: * context use this specified color.
0200: * @param c the new rendering color.
0201: * @see java.awt.Color
0202: * @see java.awt.Graphics#getColor
0203: * @since JDK1.0
0204: */
0205: public abstract void setColor(Color c);
0206:
0207: /**
0208: * Sets the paint mode of this graphics context to overwrite the
0209: * destination with this graphics context's current color.
0210: * This sets the logical pixel operation function to the paint or
0211: * overwrite mode. All subsequent rendering operations will
0212: * overwrite the destination with the current color.
0213: * @since JDK1.0
0214: */
0215: public abstract void setPaintMode();
0216:
0217: /**
0218: * This method sets the graphics context to xor paint mode using
0219: * the "exclusive or" color xorcolor.
0220: * This specifies that logical pixel operations are performed in the
0221: * XOR mode, which alternates pixels between the current color and
0222: * a specified XOR color.
0223: * <p>
0224: * When drawing operations are performed, pixels which are the
0225: * current color are changed to the specified color, and vice versa.
0226: * <p>
0227: * Pixels that are of colors other than those two colors are changed
0228: * in an unpredictable but reversible manner; if the same figure is
0229: * drawn twice, then all pixels are restored to their original values.
0230: * <h3>Compatibility</h3>
0231: * Both PersonalJava and Personal Profile implementations are not required
0232: * to support this method.
0233: * <h3>System Properties</h3>
0234: * The System Property <code>java.awt.graphics.SupportsXorMode</code> is set to
0235: * <code>"true"</code> or <code>"false"</code> indicating if the platform supports
0236: * XOR rendering.
0237: * @param c1 the XOR alternation color
0238: * @exception <code>UnsupportedOperationException</code> if the implementation does
0239: * not support an XOR paint mode.
0240: * @since JDK1.0
0241: */
0242: public abstract void setXORMode(Color c1);
0243:
0244: /**
0245: * Gets the current font.
0246: * @return this graphics context's current font.
0247: * @see java.awt.Font
0248: * @see java.awt.Graphics#setFont
0249: * @since JDK1.0
0250: */
0251: public abstract Font getFont();
0252:
0253: /**
0254: * Sets this graphics context's font to the specified font.
0255: * All subsequent text operations using this graphics context
0256: * use this font.
0257: * @param font the font.
0258: * @see java.awt.Graphics#getFont
0259: * @see java.awt.Graphics#drawChars
0260: * @see java.awt.Graphics#drawString
0261: * @see java.awt.Graphics#drawBytes
0262: * @since JDK1.0
0263: */
0264: public abstract void setFont(Font font);
0265:
0266: /**
0267: * Gets the font metrics of the current font.
0268: * @return the font metrics of this graphics
0269: * context's current font.
0270: * @see java.awt.Graphics#getFont
0271: * @see java.awt.FontMetrics
0272: * @see java.awt.Graphics#getFontMetrics(Font)
0273: * @since JDK1.0
0274: */
0275: public FontMetrics getFontMetrics() {
0276: return getFontMetrics(getFont());
0277: }
0278:
0279: /**
0280: * Gets the font metrics for the specified font.
0281: * @return the font metrics for the specified font.
0282: * @param f the specified font
0283: * @see java.awt.Graphics#getFont
0284: * @see java.awt.FontMetrics
0285: * @see java.awt.Graphics#getFontMetrics()
0286: * @since JDK1.0
0287: */
0288: public abstract FontMetrics getFontMetrics(Font f);
0289:
0290: /**
0291: * Returns the bounding rectangle of the current clipping area.
0292: * The coordinates in the rectangle are relative to the coordinate
0293: * system origin of this graphics context.
0294: * @return the bounding rectangle of the current clipping area.
0295: * @see java.awt.Graphics#getClip
0296: * @see java.awt.Graphics#clipRect
0297: * @see java.awt.Graphics#setClip(int, int, int, int)
0298: * @see java.awt.Graphics#setClip(Shape)
0299: * @since JDK1.1
0300: */
0301: public abstract Rectangle getClipBounds();
0302:
0303: /**
0304: * Intersects the current clip with the specified rectangle.
0305: * The resulting clipping area is the intersection of the current
0306: * clipping area and the specified rectangle.
0307: * This method can only be used to make the current clip smaller.
0308: * To set the current clip larger, use any of the setClip methods.
0309: * Rendering operations have no effect outside of the clipping area.
0310: * @param x the x coordinate of the rectangle to intersect the clip with
0311: * @param y the y coordinate of the rectangle to intersect the clip with
0312: * @param width the width of the rectangle to intersect the clip with
0313: * @param height the height of the rectangle to intersect the clip with
0314: * @see #setClip(int, int, int, int)
0315: * @see #setClip(Shape)
0316: */
0317: public abstract void clipRect(int x, int y, int width, int height);
0318:
0319: /**
0320: * Returns true if the specified rectangular area intersects
0321: * the bounding rectangle of the current clipping area.
0322: * The coordinates in the rectangle are relative to the coordinate
0323: * system origin of this graphics context.
0324: *
0325: * @param x the x coordinate of the rectangle to test against the clip
0326: * @param y the y coordinate of the rectangle to test against the clip
0327: * @param width the width of the rectangle to test against the clip
0328: * @param height the height of the rectangle to test against the clip
0329: */
0330: public boolean hitClip(int x, int y, int width, int height) {
0331: return new Rectangle(x, y, width, height)
0332: .intersects(getClipBounds());
0333: }
0334:
0335: /**
0336: * Sets the current clip to the rectangle specified by the given
0337: * coordinates.
0338: * Rendering operations have no effect outside of the clipping area.
0339: * @param x the <i>x</i> coordinate of the new clip rectangle.
0340: * @param y the <i>y</i> coordinate of the new clip rectangle.
0341: * @param width the width of the new clip rectangle.
0342: * @param height the height of the new clip rectangle.
0343: * @see java.awt.Graphics#clipRect
0344: * @see java.awt.Graphics#setClip(Shape)
0345: * @since JDK1.1
0346: */
0347: public abstract void setClip(int x, int y, int width, int height);
0348:
0349: /**
0350: * Gets the current clipping area.
0351: * @return a <code>Shape</code> object representing the
0352: * current clipping area.
0353: * @see java.awt.Graphics#getClipBounds
0354: * @see java.awt.Graphics#clipRect
0355: * @see java.awt.Graphics#setClip(int, int, int, int)
0356: * @see java.awt.Graphics#setClip(Shape)
0357: * @since JDK1.1
0358: */
0359: public abstract Shape getClip();
0360:
0361: /**
0362: * Sets the current clipping area to an arbitrary clip shape.
0363: * Not all objects which implement the <code>Shape</code>
0364: * interface can be used to set the clip. The only
0365: * <code>Shape</code> objects which are guaranteed to be
0366: * supported are <code>Shape</code> objects which are
0367: * obtained via the <code>getClip</code> method and via
0368: * <code>Rectangle</code> objects.
0369: * @see java.awt.Graphics#getClip()
0370: * @see java.awt.Graphics#clipRect
0371: * @see java.awt.Graphics#setClip(int, int, int, int)
0372: * @since JDK1.1
0373: */
0374: public abstract void setClip(Shape clip);
0375:
0376: /**
0377: * Copies an area of the component by a distance specified by
0378: * <code>dx</code> and <code>dy</code>. From the point specified
0379: * by <code>x</code> and <code>y</code>, this method
0380: * copies downwards and to the right. To copy an area of the
0381: * component to the left or upwards, specify a negative value for
0382: * <code>dx</code> or <code>dy</code>.
0383: * If a portion of the source rectangle lies outside the bounds
0384: * of the component, or is obscured by another window or component,
0385: * <code>copyArea</code> will be unable to copy the associated
0386: * pixels. The area that is omitted can be refreshed by calling
0387: * the component's <code>paint</code> method.
0388: * @param x the <i>x</i> coordinate of the source rectangle.
0389: * @param y the <i>y</i> coordinate of the source rectangle.
0390: * @param width the width of the source rectangle.
0391: * @param height the height of the source rectangle.
0392: * @param dx the horizontal distance to copy the pixels.
0393: * @param dy the vertical distance to copy the pixels.
0394: * @since JDK1.0
0395: */
0396: public abstract void copyArea(int x, int y, int width, int height,
0397: int dx, int dy);
0398:
0399: /**
0400: * Draws a line, using the current color, between the points
0401: * <code>(x1, y1)</code> and <code>(x2, y2)</code>
0402: * in this graphics context's coordinate system.
0403: * @param x1 the first point's <i>x</i> coordinate.
0404: * @param y1 the first point's <i>y</i> coordinate.
0405: * @param x2 the second point's <i>x</i> coordinate.
0406: * @param y2 the second point's <i>y</i> coordinate.
0407: * @since JDK1.0
0408: */
0409: public abstract void drawLine(int x1, int y1, int x2, int y2);
0410:
0411: /**
0412: * Fills the specified rectangle.
0413: * The left and right edges of the rectangle are at
0414: * <code>x</code> and <code>x + width - 1</code>.
0415: * The top and bottom edges are at
0416: * <code>y</code> and <code>y + height - 1</code>.
0417: * The resulting rectangle covers an area
0418: * <code>width</code> pixels wide by
0419: * <code>height</code> pixels tall.
0420: * The rectangle is filled using the graphics context's current color.
0421: * @param x the <i>x</i> coordinate
0422: * of the rectangle to be filled.
0423: * @param y the <i>y</i> coordinate
0424: * of the rectangle to be filled.
0425: * @param width the width of the rectangle to be filled.
0426: * @param height the height of the rectangle to be filled.
0427: * @see java.awt.Graphics#fillRect
0428: * @see java.awt.Graphics#clearRect
0429: * @since JDK1.0
0430: */
0431: public abstract void fillRect(int x, int y, int width, int height);
0432:
0433: /**
0434: * Draws the outline of the specified rectangle.
0435: * The left and right edges of the rectangle are at
0436: * <code>x</code> and <code>x + width</code>.
0437: * The top and bottom edges are at
0438: * <code>y</code> and <code>y + height</code>.
0439: * The rectangle is drawn using the graphics context's current color.
0440: * @param x the <i>x</i> coordinate
0441: * of the rectangle to be drawn.
0442: * @param y the <i>y</i> coordinate
0443: * of the rectangle to be drawn.
0444: * @param width the width of the rectangle to be drawn.
0445: * @param height the height of the rectangle to be drawn.
0446: * @see java.awt.Graphics#fillRect
0447: * @see java.awt.Graphics#clearRect
0448: * @since JDK1.0
0449: */
0450: public void drawRect(int x, int y, int width, int height) {
0451: if ((width < 0) || (height < 0)) {
0452: return;
0453: }
0454: if (height == 0 || width == 0) {
0455: drawLine(x, y, x + width, y + height);
0456: } else {
0457: drawLine(x, y, x + width - 1, y);
0458: drawLine(x + width, y, x + width, y + height - 1);
0459: drawLine(x + width, y + height, x + 1, y + height);
0460: drawLine(x, y + height, x, y + 1);
0461: }
0462: }
0463:
0464: /**
0465: * Clears the specified rectangle by filling it with the background
0466: * color of the current drawing surface. This operation does not
0467: * use the current paint mode.
0468: * <p>
0469: * Beginning with Java 1.1, the background color
0470: * of offscreen images may be system dependent. Applications should
0471: * use <code>setColor</code> followed by <code>fillRect</code> to
0472: * ensure that an offscreen image is cleared to a specific color.
0473: * @param x the <i>x</i> coordinate of the rectangle to clear.
0474: * @param y the <i>y</i> coordinate of the rectangle to clear.
0475: * @param width the width of the rectangle to clear.
0476: * @param height the height of the rectangle to clear.
0477: * @see java.awt.Graphics#fillRect(int, int, int, int)
0478: * @see java.awt.Graphics#drawRect
0479: * @see java.awt.Graphics#setColor(java.awt.Color)
0480: * @see java.awt.Graphics#setPaintMode
0481: * @see java.awt.Graphics#setXORMode(java.awt.Color)
0482: * @since JDK1.0
0483: */
0484: public abstract void clearRect(int x, int y, int width, int height);
0485:
0486: /**
0487: * Draws an outlined round-cornered rectangle using this graphics
0488: * context's current color. The left and right edges of the rectangle
0489: * are at <code>x</code> and <code>x + width</code>,
0490: * respectively. The top and bottom edges of the rectangle are at
0491: * <code>y</code> and <code>y + height</code>.
0492: * @param x the <i>x</i> coordinate of the rectangle to be drawn.
0493: * @param y the <i>y</i> coordinate of the rectangle to be drawn.
0494: * @param width the width of the rectangle to be drawn.
0495: * @param height the height of the rectangle to be drawn.
0496: * @param arcWidth the horizontal diameter of the arc
0497: * at the four corners.
0498: * @param arcHeight the vertical diameter of the arc
0499: * at the four corners.
0500: * @see java.awt.Graphics#fillRoundRect
0501: * @since JDK1.0
0502: */
0503: public abstract void drawRoundRect(int x, int y, int width,
0504: int height, int arcWidth, int arcHeight);
0505:
0506: /**
0507: * Fills the specified rounded corner rectangle with the current color.
0508: * The left and right edges of the rectangle
0509: * are at <code>x</code> and <code>x + width - 1</code>,
0510: * respectively. The top and bottom edges of the rectangle are at
0511: * <code>y</code> and <code>y + height - 1</code>.
0512: * @param x the <i>x</i> coordinate of the rectangle to be filled.
0513: * @param y the <i>y</i> coordinate of the rectangle to be filled.
0514: * @param width the width of the rectangle to be filled.
0515: * @param height the height of the rectangle to be filled.
0516: * @param arcWidth the horizontal diameter
0517: * of the arc at the four corners.
0518: * @param arcHeight the vertical diameter
0519: * of the arc at the four corners.
0520: * @see java.awt.Graphics#drawRoundRect
0521: * @since JDK1.0
0522: */
0523: public abstract void fillRoundRect(int x, int y, int width,
0524: int height, int arcWidth, int arcHeight);
0525:
0526: /**
0527: * Draws a 3-D highlighted outline of the specified rectangle.
0528: * The edges of the rectangle are highlighted so that they
0529: * appear to be beveled and lit from the upper left corner.
0530: * <p>
0531: * The colors used for the highlighting effect are determined
0532: * based on the current color.
0533: * The resulting rectangle covers an area that is
0534: * <code>width + 1</code> pixels wide
0535: * by <code>height + 1</code> pixels tall.
0536: * @param x the <i>x</i> coordinate of the rectangle to be drawn.
0537: * @param y the <i>y</i> coordinate of the rectangle to be drawn.
0538: * @param width the width of the rectangle to be drawn.
0539: * @param height the height of the rectangle to be drawn.
0540: * @param raised a boolean that determines whether the rectangle
0541: * appears to be raised above the surface
0542: * or sunk into the surface.
0543: * @see java.awt.Graphics#fill3DRect
0544: * @since JDK1.0
0545: */
0546: public void draw3DRect(int x, int y, int width, int height,
0547: boolean raised) {
0548: Color c = getColor();
0549: Color brighter = c.brighter();
0550: Color darker = c.darker();
0551: setColor(raised ? brighter : darker);
0552: drawLine(x, y, x, y + height);
0553: drawLine(x + 1, y, x + width - 1, y);
0554: setColor(raised ? darker : brighter);
0555: drawLine(x + 1, y + height, x + width, y + height);
0556: drawLine(x + width, y, x + width, y + height - 1);
0557: setColor(c);
0558: }
0559:
0560: /**
0561: * Paints a 3-D highlighted rectangle filled with the current color.
0562: * The edges of the rectangle will be highlighted so that it appears
0563: * as if the edges were beveled and lit from the upper left corner.
0564: * The colors used for the highlighting effect will be determined from
0565: * the current color.
0566: * @param x the <i>x</i> coordinate of the rectangle to be filled.
0567: * @param y the <i>y</i> coordinate of the rectangle to be filled.
0568: * @param width the width of the rectangle to be filled.
0569: * @param height the height of the rectangle to be filled.
0570: * @param raised a boolean value that determines whether the
0571: * rectangle appears to be raised above the surface
0572: * or etched into the surface.
0573: * @see java.awt.Graphics#draw3DRect
0574: * @since JDK1.0
0575: */
0576: public void fill3DRect(int x, int y, int width, int height,
0577: boolean raised) {
0578: Color c = getColor();
0579: Color brighter = c.brighter();
0580: Color darker = c.darker();
0581: if (!raised) {
0582: setColor(darker);
0583: }
0584: fillRect(x + 1, y + 1, width - 2, height - 2);
0585: setColor(raised ? brighter : darker);
0586: drawLine(x, y, x, y + height - 1);
0587: drawLine(x + 1, y, x + width - 2, y);
0588: setColor(raised ? darker : brighter);
0589: drawLine(x + 1, y + height - 1, x + width - 1, y + height - 1);
0590: drawLine(x + width - 1, y, x + width - 1, y + height - 2);
0591: setColor(c);
0592: }
0593:
0594: /**
0595: * Draws the outline of an oval.
0596: * The result is a circle or ellipse that fits within the
0597: * rectangle specified by the <code>x</code>, <code>y</code>,
0598: * <code>width</code>, and <code>height</code> arguments.
0599: * <p>
0600: * The oval covers an area that is
0601: * <code>width + 1</code> pixels wide
0602: * and <code>height + 1<code> pixels tall.
0603: * @param x the <i>x</i> coordinate of the upper left
0604: * corner of the oval to be drawn.
0605: * @param y the <i>y</i> coordinate of the upper left
0606: * corner of the oval to be drawn.
0607: * @param width the width of the oval to be drawn.
0608: * @param height the height of the oval to be drawn.
0609: * @see java.awt.Graphics#fillOval
0610: * @since JDK1.0
0611: */
0612: public abstract void drawOval(int x, int y, int width, int height);
0613:
0614: /**
0615: * Fills an oval bounded by the specified rectangle with the
0616: * current color.
0617: * @param x the <i>x</i> coordinate of the upper left corner
0618: * of the oval to be filled.
0619: * @param y the <i>y</i> coordinate of the upper left corner
0620: * of the oval to be filled.
0621: * @param width the width of the oval to be filled.
0622: * @param height the height of the oval to be filled.
0623: * @see java.awt.Graphics#drawOval
0624: * @since JDK1.0
0625: */
0626: public abstract void fillOval(int x, int y, int width, int height);
0627:
0628: /**
0629: * Draws the outline of a circular or elliptical arc
0630: * covering the specified rectangle.
0631: * <p>
0632: * The resulting arc begins at <code>startAngle</code> and extends
0633: * for <code>arcAngle</code> degrees, using the current color.
0634: * Angles are interpreted such that 0 degrees
0635: * is at the 3 o'clock position.
0636: * A positive value indicates a counter-clockwise rotation
0637: * while a negative value indicates a clockwise rotation.
0638: * <p>
0639: * The center of the arc is the center of the rectangle whose origin
0640: * is (<i>x</i>, <i>y</i>) and whose size is specified by the
0641: * <code>width</code> and <code>height</code> arguments.
0642: * <p>
0643: * The resulting arc covers an area
0644: * <code>width + 1</code> pixels wide
0645: * by <code>height + 1</code> pixels tall.
0646: * @param x the <i>x</i> coordinate of the
0647: * upper-left corner of the arc to be drawn.
0648: * @param y the <i>y</i> coordinate of the
0649: * upper-left corner of the arc to be drawn.
0650: * @param width the width of the arc to be drawn.
0651: * @param height the height of the arc to be drawn.
0652: * @param startAngle the beginning angle.
0653: * @param arcAngle the angular extent of the arc,
0654: * relative to the start angle.
0655: * @see java.awt.Graphics#fillArc
0656: * @since JDK1.0
0657: */
0658: public abstract void drawArc(int x, int y, int width, int height,
0659: int startAngle, int arcAngle);
0660:
0661: /**
0662: * Fills a circular or elliptical arc covering the specified rectangle.
0663: * <p>
0664: * The resulting arc begins at <code>startAngle</code> and extends
0665: * for <code>arcAngle</code> degrees.
0666: * Angles are interpreted such that 0 degrees
0667: * is at the 3 o'clock position.
0668: * A positive value indicates a counter-clockwise rotation
0669: * while a negative value indicates a clockwise rotation.
0670: * <p>
0671: * The center of the arc is the center of the rectangle whose origin
0672: * is (<i>x</i>, <i>y</i>) and whose size is specified by the
0673: * <code>width</code> and <code>height</code> arguments.
0674: * <p>
0675: * The resulting arc covers an area
0676: * <code>width + 1</code> pixels wide
0677: * by <code>height + 1</code> pixels tall.
0678: * @param x the <i>x</i> coordinate of the
0679: * upper-left corner of the arc to be filled.
0680: * @param y the <i>y</i> coordinate of the
0681: * upper-left corner of the arc to be filled.
0682: * @param width the width of the arc to be filled.
0683: * @param height the height of the arc to be filled.
0684: * @param startAngle the beginning angle.
0685: * @param arcAngle the angular extent of the arc,
0686: * relative to the start angle.
0687: * @see java.awt.Graphics#drawArc
0688: * @since JDK1.0
0689: */
0690: public abstract void fillArc(int x, int y, int width, int height,
0691: int startAngle, int arcAngle);
0692:
0693: /**
0694: * Draws a sequence of connected lines defined by
0695: * arrays of <i>x</i> and <i>y</i> coordinates.
0696: * Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.
0697: * The figure is not closed if the first point
0698: * differs from the last point.
0699: * @param xPoints an array of <i>x</i> points
0700: * @param yPoints an array of <i>y</i> points
0701: * @param nPoints the total number of points
0702: * @see java.awt.Graphics#drawPolygon(int[], int[], int)
0703: * @since JDK1.1
0704: */
0705: public abstract void drawPolyline(int xPoints[], int yPoints[],
0706: int nPoints);
0707:
0708: /**
0709: * Draws a closed polygon defined by
0710: * arrays of <i>x</i> and <i>y</i> coordinates.
0711: * Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.
0712: * <p>
0713: * This method draws the polygon defined by <code>nPoint</code> line
0714: * segments, where the first <code>nPoint - 1</code>
0715: * line segments are line segments from
0716: * <code>(xPoints[i - 1], yPoints[i - 1])</code>
0717: * to <code>(xPoints[i], yPoints[i])</code>, for
0718: * 1 ≤ <i>i</i> ≤ <code>nPoints</code>.
0719: * The figure is automatically closed by drawing a line connecting
0720: * the final point to the first point, if those points are different.
0721: * @param xPoints a an array of <code>x</code> coordinates.
0722: * @param yPoints a an array of <code>y</code> coordinates.
0723: * @param nPoints a the total number of points.
0724: * @see java.awt.Graphics#fillPolygon
0725: * @see java.awt.Graphics#drawPolyline
0726: * @since JDK1.0
0727: */
0728: public abstract void drawPolygon(int xPoints[], int yPoints[],
0729: int nPoints);
0730:
0731: /**
0732: * Draws the outline of a polygon defined by the specified
0733: * <code>Polygon</code> object.
0734: * @param p the polygon to draw.
0735: * @see java.awt.Graphics#fillPolygon
0736: * @see java.awt.Graphics#drawPolyline
0737: * @since JDK1.0
0738: */
0739: public void drawPolygon(Polygon p) {
0740: drawPolygon(p.xpoints, p.ypoints, p.npoints);
0741: }
0742:
0743: /**
0744: * Fills a closed polygon defined by
0745: * arrays of <i>x</i> and <i>y</i> coordinates.
0746: * <p>
0747: * This method draws the polygon defined by <code>nPoint</code> line
0748: * segments, where the first <code>nPoint - 1</code>
0749: * line segments are line segments from
0750: * <code>(xPoints[i - 1], yPoints[i - 1])</code>
0751: * to <code>(xPoints[i], yPoints[i])</code>, for
0752: * 1 ≤ <i>i</i> ≤ <code>nPoints</code>.
0753: * The figure is automatically closed by drawing a line connecting
0754: * the final point to the first point, if those points are different.
0755: * <p>
0756: * The area inside the polygon is defined using an
0757: * even-odd fill rule, also known as the alternating rule.
0758: * @param xPoints a an array of <code>x</code> coordinates.
0759: * @param yPoints a an array of <code>y</code> coordinates.
0760: * @param nPoints a the total number of points.
0761: * @see java.awt.Graphics#drawPolygon(int[], int[], int)
0762: * @since JDK1.0
0763: */
0764: public abstract void fillPolygon(int xPoints[], int yPoints[],
0765: int nPoints);
0766:
0767: /**
0768: * Fills the polygon defined by the specified Polygon object with
0769: * the graphics context's current color.
0770: * <p>
0771: * The area inside the polygon is defined using an
0772: * even-odd fill rule, also known as the alternating rule.
0773: * @param p the polygon to fill.
0774: * @see java.awt.Graphics#drawPolygon(int[], int[], int)
0775: * @since JDK1.0
0776: */
0777: public void fillPolygon(Polygon p) {
0778: fillPolygon(p.xpoints, p.ypoints, p.npoints);
0779: }
0780:
0781: /**
0782: * Draws the text given by the specified string, using this
0783: * graphics context's current font and color. The baseline of the
0784: * first character is at position (<i>x</i>, <i>y</i>) in this
0785: * graphics context's coordinate system.
0786: * @param str the string to be drawn.
0787: * @param x the <i>x</i> coordinate.
0788: * @param y the <i>y</i> coordinate.
0789: * @see java.awt.Graphics#drawBytes
0790: * @see java.awt.Graphics#drawChars
0791: * @since JDK1.0
0792: */
0793: public abstract void drawString(String str, int x, int y);
0794:
0795: /**
0796: * Draws the text given by the specified character array, using this
0797: * graphics context's current font and color. The baseline of the
0798: * first character is at position (<i>x</i>, <i>y</i>) in this
0799: * graphics context's coordinate system.
0800: * @param data the array of characters to be drawn
0801: * @param offset the start offset in the data
0802: * @param length the number of characters to be drawn
0803: * @param x the <i>x</i> coordinate of the baseline of the text
0804: * @param y the <i>y</i> coordinate of the baseline of the text
0805: * @see java.awt.Graphics#drawBytes
0806: * @see java.awt.Graphics#drawString
0807: * @since JDK1.0
0808: */
0809: public void drawChars(char data[], int offset, int length, int x,
0810: int y) {
0811: drawString(new String(data, offset, length), x, y);
0812: }
0813:
0814: /**
0815: * Draws the text given by the specified byte array, using this
0816: * graphics context's current font and color. The baseline of the
0817: * first character is at position (<i>x</i>, <i>y</i>) in this
0818: * graphics context's coordinate system.
0819: * @param data the data to be drawn
0820: * @param offset the start offset in the data
0821: * @param length the number of bytes that are drawn
0822: * @param x the <i>x</i> coordinate of the baseline of the text
0823: * @param y the <i>y</i> coordinate of the baseline of the text
0824: * @see java.awt.Graphics#drawChars
0825: * @see java.awt.Graphics#drawString
0826: * @since JDK1.0
0827: */
0828: public void drawBytes(byte data[], int offset, int length, int x,
0829: int y) {
0830: drawString(new String(data, offset, length), x, y);
0831: }
0832:
0833: /**
0834: * Draws as much of the specified image as is currently available.
0835: * The image is drawn with its top-left corner at
0836: * (<i>x</i>, <i>y</i>) in this graphics context's coordinate
0837: * space. Transparent pixels in the image do not affect whatever
0838: * pixels are already there.
0839: * <p>
0840: * This method returns immediately in all cases, even if the
0841: * complete image has not yet been loaded, and it has not been dithered
0842: * and converted for the current output device.
0843: * <p>
0844: * If the image has not yet been completely loaded, then
0845: * <code>drawImage</code> returns <code>false</code>. As more of
0846: * the image becomes available, the process that draws the image notifies
0847: * the specified image observer.
0848: * @param img the specified image to be drawn.
0849: * @param x the <i>x</i> coordinate.
0850: * @param y the <i>y</i> coordinate.
0851: * @param observer object to be notified as more of
0852: * the image is converted.
0853: * @see java.awt.Image
0854: * @see java.awt.image.ImageObserver
0855: * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
0856: * @since JDK1.0
0857: */
0858: public abstract boolean drawImage(Image img, int x, int y,
0859: ImageObserver observer);
0860:
0861: /**
0862: * Draws as much of the specified image as has already been scaled
0863: * to fit inside the specified rectangle.
0864: * <p>
0865: * The image is drawn inside the specified rectangle of this
0866: * graphics context's coordinate space, and is scaled if
0867: * necessary. Transparent pixels do not affect whatever pixels
0868: * are already there.
0869: * <p>
0870: * This method returns immediately in all cases, even if the
0871: * entire image has not yet been scaled, dithered, and converted
0872: * for the current output device.
0873: * If the current output representation is not yet complete, then
0874: * <code>drawImage</code> returns <code>false</code>. As more of
0875: * the image becomes available, the process that draws the image notifies
0876: * the image observer by calling its <code>imageUpdate</code> method.
0877: * <p>
0878: * A scaled version of an image will not necessarily be
0879: * available immediately just because an unscaled version of the
0880: * image has been constructed for this output device. Each size of
0881: * the image may be cached separately and generated from the original
0882: * data in a separate image production sequence.
0883: * @param img the specified image to be drawn.
0884: * @param x the <i>x</i> coordinate.
0885: * @param y the <i>y</i> coordinate.
0886: * @param width the width of the rectangle.
0887: * @param height the height of the rectangle.
0888: * @param observer object to be notified as more of
0889: * the image is converted.
0890: * @see java.awt.Image
0891: * @see java.awt.image.ImageObserver
0892: * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
0893: * @since JDK1.0
0894: */
0895: public abstract boolean drawImage(Image img, int x, int y,
0896: int width, int height, ImageObserver observer);
0897:
0898: /**
0899: * Draws as much of the specified image as is currently available.
0900: * The image is drawn with its top-left corner at
0901: * (<i>x</i>, <i>y</i>) in this graphics context's coordinate
0902: * space. Transparent pixels are drawn in the specified
0903: * background color.
0904: * <p>
0905: * This operation is equivalent to filling a rectangle of the
0906: * width and height of the specified image with the given color and then
0907: * drawing the image on top of it, but possibly more efficient.
0908: * <p>
0909: * This method returns immediately in all cases, even if the
0910: * complete image has not yet been loaded, and it has not been dithered
0911: * and converted for the current output device.
0912: * <p>
0913: * If the image has not yet been completely loaded, then
0914: * <code>drawImage</code> returns <code>false</code>. As more of
0915: * the image becomes available, the process that draws the image notifies
0916: * the specified image observer.
0917: * @param img the specified image to be drawn.
0918: * @param x the <i>x</i> coordinate.
0919: * @param y the <i>y</i> coordinate.
0920: * @param bgcolor the background color to paint under the
0921: * non-opaque portions of the image.
0922: * @param observer object to be notified as more of
0923: * the image is converted.
0924: * @see java.awt.Image
0925: * @see java.awt.image.ImageObserver
0926: * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
0927: * @since JDK1.0
0928: */
0929: public abstract boolean drawImage(Image img, int x, int y,
0930: Color bgcolor, ImageObserver observer);
0931:
0932: /**
0933: * Draws as much of the specified image as has already been scaled
0934: * to fit inside the specified rectangle.
0935: * <p>
0936: * The image is drawn inside the specified rectangle of this
0937: * graphics context's coordinate space, and is scaled if
0938: * necessary. Transparent pixels are drawn in the specified
0939: * background color.
0940: * This operation is equivalent to filling a rectangle of the
0941: * width and height of the specified image with the given color and then
0942: * drawing the image on top of it, but possibly more efficient.
0943: * <p>
0944: * This method returns immediately in all cases, even if the
0945: * entire image has not yet been scaled, dithered, and converted
0946: * for the current output device.
0947: * If the current output representation is not yet complete then
0948: * <code>drawImage</code> returns <code>false</code>. As more of
0949: * the image becomes available, the process that draws the image notifies
0950: * the specified image observer.
0951: * <p>
0952: * A scaled version of an image will not necessarily be
0953: * available immediately just because an unscaled version of the
0954: * image has been constructed for this output device. Each size of
0955: * the image may be cached separately and generated from the original
0956: * data in a separate image production sequence.
0957: * @param img the specified image to be drawn.
0958: * @param x the <i>x</i> coordinate.
0959: * @param y the <i>y</i> coordinate.
0960: * @param width the width of the rectangle.
0961: * @param height the height of the rectangle.
0962: * @param bgcolor the background color to paint under the
0963: * non-opaque portions of the image.
0964: * @param observer object to be notified as more of
0965: * the image is converted.
0966: * @see java.awt.Image
0967: * @see java.awt.image.ImageObserver
0968: * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
0969: * @since JDK1.0
0970: */
0971: public abstract boolean drawImage(Image img, int x, int y,
0972: int width, int height, Color bgcolor, ImageObserver observer);
0973:
0974: /**
0975: * Draws as much of the specified area of the specified image as is
0976: * currently available, scaling it on the fly to fit inside the
0977: * specified area of the destination drawable surface. Transparent pixels
0978: * do not affect whatever pixels are already there.
0979: * <p>
0980: * This method returns immediately in all cases, even if the
0981: * image area to be drawn has not yet been scaled, dithered, and converted
0982: * for the current output device.
0983: * If the current output representation is not yet complete then
0984: * <code>drawImage</code> returns <code>false</code>. As more of
0985: * the image becomes available, the process that draws the image notifies
0986: * the specified image observer.
0987: * <p>
0988: * This method always uses the unscaled version of the image
0989: * to render the scaled rectangle and performs the required
0990: * scaling on the fly. It does not use a cached, scaled version
0991: * of the image for this operation. Scaling of the image from source
0992: * to destination is performed such that the first coordinate
0993: * of the source rectangle is mapped to the first coordinate of
0994: * the destination rectangle, and the second source coordinate is
0995: * mapped to the second destination coordinate. The subimage is
0996: * scaled and flipped as needed to preserve those mappings.
0997: * @param img the specified image to be drawn
0998: * @param dx1 the <i>x</i> coordinate of the first corner of the
0999: * destination rectangle.
1000: * @param dy1 the <i>y</i> coordinate of the first corner of the
1001: * destination rectangle.
1002: * @param dx2 the <i>x</i> coordinate of the second corner of the
1003: * destination rectangle.
1004: * @param dy2 the <i>y</i> coordinate of the second corner of the
1005: * destination rectangle.
1006: * @param sx1 the <i>x</i> coordinate of the first corner of the
1007: * source rectangle.
1008: * @param sy1 the <i>y</i> coordinate of the first corner of the
1009: * source rectangle.
1010: * @param sx2 the <i>x</i> coordinate of the second corner of the
1011: * source rectangle.
1012: * @param sy2 the <i>y</i> coordinate of the second corner of the
1013: * source rectangle.
1014: * @param observer object to be notified as more of the image is
1015: * scaled and converted.
1016: * @see java.awt.Image
1017: * @see java.awt.image.ImageObserver
1018: * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
1019: * @since JDK1.1
1020: */
1021: public abstract boolean drawImage(Image img, int dx1, int dy1,
1022: int dx2, int dy2, int sx1, int sy1, int sx2, int sy2,
1023: ImageObserver observer);
1024:
1025: /**
1026: * Draws as much of the specified area of the specified image as is
1027: * currently available, scaling it on the fly to fit inside the
1028: * specified area of the destination drawable surface.
1029: * <p>
1030: * Transparent pixels are drawn in the specified background color.
1031: * This operation is equivalent to filling a rectangle of the
1032: * width and height of the specified image with the given color and then
1033: * drawing the image on top of it, but possibly more efficient.
1034: * <p>
1035: * This method returns immediately in all cases, even if the
1036: * image area to be drawn has not yet been scaled, dithered, and converted
1037: * for the current output device.
1038: * If the current output representation is not yet complete then
1039: * <code>drawImage</code> returns <code>false</code>. As more of
1040: * the image becomes available, the process that draws the image notifies
1041: * the specified image observer.
1042: * <p>
1043: * This method always uses the unscaled version of the image
1044: * to render the scaled rectangle and performs the required
1045: * scaling on the fly. It does not use a cached, scaled version
1046: * of the image for this operation. Scaling of the image from source
1047: * to destination is performed such that the first coordinate
1048: * of the source rectangle is mapped to the first coordinate of
1049: * the destination rectangle, and the second source coordinate is
1050: * mapped to the second destination coordinate. The subimage is
1051: * scaled and flipped as needed to preserve those mappings.
1052: * @param img the specified image to be drawn
1053: * @param dx1 the <i>x</i> coordinate of the first corner of the
1054: * destination rectangle.
1055: * @param dy1 the <i>y</i> coordinate of the first corner of the
1056: * destination rectangle.
1057: * @param dx2 the <i>x</i> coordinate of the second corner of the
1058: * destination rectangle.
1059: * @param dy2 the <i>y</i> coordinate of the second corner of the
1060: * destination rectangle.
1061: * @param sx1 the <i>x</i> coordinate of the first corner of the
1062: * source rectangle.
1063: * @param sy1 the <i>y</i> coordinate of the first corner of the
1064: * source rectangle.
1065: * @param sx2 the <i>x</i> coordinate of the second corner of the
1066: * source rectangle.
1067: * @param sy2 the <i>y</i> coordinate of the second corner of the
1068: * source rectangle.
1069: * @param bgcolor the background color to paint under the
1070: * non-opaque portions of the image.
1071: * @param observer object to be notified as more of the image is
1072: * scaled and converted.
1073: * @see java.awt.Image
1074: * @see java.awt.image.ImageObserver
1075: * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
1076: * @since JDK1.1
1077: */
1078: public abstract boolean drawImage(Image img, int dx1, int dy1,
1079: int dx2, int dy2, int sx1, int sy1, int sx2, int sy2,
1080: Color bgcolor, ImageObserver observer);
1081:
1082: /**
1083: * Disposes of this graphics context and releases
1084: * any system resources that it is using.
1085: * A <code>Graphics</code> object cannot be used after
1086: * <code>dispose</code>has been called.
1087: * <p>
1088: * When a Java program runs, a large number of <code>Graphics</code>
1089: * objects can be created within a short time frame.
1090: * Although the finalization process of the garbage collector
1091: * also disposes of the same system resources, it is preferable
1092: * to manually free the associated resources by calling this
1093: * method rather than to rely on a finalization process which
1094: * may not run to completion for a long period of time.
1095: * <p>
1096: * Graphics objects which are provided as arguments to the
1097: * <code>paint</code> and <code>update</code> methods
1098: * of components are automatically released by the system when
1099: * those methods return. For efficiency, programmers should
1100: * call <code>dispose</code> when finished using
1101: * a <code>Graphics</code> object only if it was created
1102: * directly from a component or another <code>Graphics</code> object.
1103: * @see java.awt.Graphics#finalize
1104: * @see java.awt.Component#paint
1105: * @see java.awt.Component#update
1106: * @see java.awt.Component#getGraphics
1107: * @see java.awt.Graphics#create
1108: * @since JDK1.0
1109: */
1110: public abstract void dispose();
1111:
1112: /**
1113: * Disposes of this graphics context once it is no longer referenced.
1114: * @see #dispose
1115: * @since JDK1.0
1116: */
1117: public void finalize() {
1118: dispose();
1119: }
1120:
1121: /**
1122: * Returns a <code>String</code> object representing this
1123: * <code>Graphics</code> object's value.
1124: * @return a string representation of this graphics context.
1125: * @since JDK1.0
1126: */
1127: public String toString() {
1128: return getClass().getName() + "[font=" + getFont() + ",color="
1129: + getColor() + "]";
1130: }
1131:
1132: /**
1133: * @deprecated As of JDK version 1.1,
1134: * replaced by <code>getClipBounds()</code>.
1135: */
1136: public Rectangle getClipRect() {
1137: return getClipBounds();
1138: }
1139:
1140: /**
1141: * Returns the bounding rectangle of the current clipping area.
1142: * The coordinates in the rectangle are relative to the coordinate
1143: * system origin of this graphics context. This method differs
1144: * from {@link #getClipBounds() getClipBounds} in that an existing
1145: * rectangle is used instead of allocating a new one.
1146: * This method refers to the user clip, which is independent of the
1147: * clipping associated with device bounds and window visibility.
1148: * If no clip has previously been set, or if the clip has been
1149: * cleared using <code>setClip(null)</code>, this method returns the
1150: * specified <code>Rectangle</code>.
1151: * @param r the rectangle where the current clipping area is
1152: * copied to. Any current values in this rectangle are
1153: * overwritten.
1154: * @return the bounding rectangle of the current clipping area.
1155: */
1156: public Rectangle getClipBounds(Rectangle r) {
1157: Rectangle clipRect = getClipBounds();
1158: if (clipRect == null)
1159: return r;
1160: if (r == null)
1161: return clipRect;
1162: r.x = clipRect.x;
1163: r.y = clipRect.y;
1164: r.width = clipRect.width;
1165: r.height = clipRect.height;
1166: return r;
1167: }
1168: }
|