home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / Graphics.java < prev    next >
Text File  |  1997-10-01  |  52KB  |  1,110 lines

  1. /*
  2.  * @(#)Graphics.java    1.39 97/06/13
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22. package java.awt;
  23.  
  24. import java.io.*;
  25. import java.lang.*;
  26. import java.util.*;
  27. import java.awt.image.ImageObserver;
  28.  
  29. /**
  30.  * The <code>Graphics</code> class is the abstract base class for 
  31.  * all graphics contexts that allow an application to draw onto 
  32.  * components that are realized on various devices, as well as 
  33.  * onto off-screen images.
  34.  * <p>
  35.  * A <code>Graphics</code> object encapsulates state information needed
  36.  * for the basic rendering operations that Java supports.  This
  37.  * state information includes the following properties:
  38.  * <p>
  39.  * <ul>
  40.  * <li>The <code>Component</code> object on which to draw.
  41.  * <li>A translation origin for rendering and clipping coordinates.
  42.  * <li>The current clip.
  43.  * <li>The current color.
  44.  * <li>The current font.
  45.  * <li>The current logical pixel operation function (XOR or Paint).
  46.  * <li>The current XOR alternation color 
  47.  *     (see <a href="#setXORMode"><code>setXORMode</code></a>).
  48.  * </ul>
  49.  * <p>
  50.  * Coordinates are infinitely thin and lie between the pixels of the
  51.  * output device.
  52.  * Operations which draw the outline of a figure operate by traversing
  53.  * an infinitely thin path between pixels with a pixel-sized pen that hangs
  54.  * down and to the right of the anchor point on the path.
  55.  * Operations which fill a figure operate by filling the interior
  56.  * of that infinitely thin path.
  57.  * Operations which render horizontal text render the ascending
  58.  * portion of character glyphs entirely above the baseline coordinate.
  59.  * <p>
  60.  * The graphics pen hangs down and to the right from the path it traverses. 
  61.  * This has the following implications:
  62.  * <p><ul>
  63.  * <li>If you draw a figure that covers a given rectangle, that 
  64.  * figure occupies one extra row of pixels on the right and bottom edges 
  65.  * as compared to filling a figure that is bounded by that same rectangle.
  66.  * <li>If you draw a horizontal line along the same <i>y</i> coordinate as
  67.  * the baseline of a line of text, that line is drawn entirely below
  68.  * the text, except for any descenders.
  69.  * </ul><p>
  70.  * All coordinates which appear as arguments to the methods of this
  71.  * <code>Graphics</code> object are considered relative to the 
  72.  * translation origin of this <code>Graphics</code> object prior to 
  73.  * the invocation of the method.
  74.  * All rendering operations modify only pixels which lie within the
  75.  * area bounded by both the current clip of the graphics context
  76.  * and the extents of the component used to create the 
  77.  * <code>Graphics</code> object.
  78.  * All drawing or writing is done in the current color, 
  79.  * using the current paint mode, and in the current font. 
  80.  * 
  81.  * @version     1.39, 06/13/97
  82.  * @author     Sami Shaio
  83.  * @author     Arthur van Hoff
  84.  * @see     java.awt.Component
  85.  * @see     java.awt.Graphics#clipRect(int, int, int, int)
  86.  * @see     java.awt.Graphics#setColor(java.awt.Color)
  87.  * @see     java.awt.Graphics#setPaintMode()
  88.  * @see     java.awt.Graphics#setXORMode(java.awt.Color)
  89.  * @see     java.awt.Graphics#setFont(java.awt.Font)
  90.  * @since       JDK1.0
  91.  */
  92. public abstract class Graphics {
  93.  
  94.     /**
  95.      * Constructs a new <code>Graphics</code> object.  
  96.      * This constructor is the default contructor for a graphics 
  97.      * context. 
  98.      * <p>
  99.      * Since <code>Graphics</code> is an abstract class, applications 
  100.      * cannot call this constructor directly. Graphics contexts are 
  101.      * obtained from other graphics contexts or are created by calling 
  102.      * <code>getGraphics</code> on a component. 
  103.      * @see        java.awt.Graphics#create()
  104.      * @see        java.awt.Component#getGraphics
  105.      * @since      JDK1.0
  106.      */
  107.     protected Graphics() {
  108.     }
  109.  
  110.     /**
  111.      * Creates a new <code>Graphics</code> object that is 
  112.      * a copy of this <code>Graphics</code> object.
  113.      * @return     a new graphics context that is a copy of 
  114.      *                       this graphics context.
  115.      * @since      JDK1.0
  116.      */
  117.     public abstract Graphics create();
  118.  
  119.     /**
  120.      * Creates a new <code>Graphics</code> object based on this 
  121.      * <code>Graphics</code> object, but with a new translation and clip area.
  122.      * The new <code>Graphics</code> object has its origin 
  123.      * translated to the specified point (<i>x</i>, <i>y</i>). 
  124.      * Its clip area is determined by the intersection of the original
  125.      * clip area with the specified rectangle.  The arguments are all
  126.      * interpreted in the coordinate system of the original 
  127.      * <code>Graphics</code> object. The new graphics context is 
  128.      * identical to the original, except in two respects: 
  129.      * <p>
  130.      * <ul>
  131.      * <li>
  132.      * The new graphics context is translated by (<i>x</i>, <i>y</i>).  
  133.      * That is to say, the point (<code>0</code>, <code>0</code>) in the 
  134.      * new graphics context is the same as (<i>x</i>, <i>y</i>) in 
  135.      * the original graphics context. 
  136.      * <li>
  137.      * The new graphics context has an additional clipping rectangle, in 
  138.      * addition to whatever (translated) clipping rectangle it inherited 
  139.      * from the original graphics context. The origin of the new clipping 
  140.      * rectangle is at (<code>0</code>, <code>0</code>), and its size  
  141.      * is specified by the <code>width</code> and <code>height</code> arguments.
  142.      * </ul>
  143.      * <p>
  144.      * @param      x   the <i>x</i> coordinate.
  145.      * @param      y   the <i>y</i> coordinate.
  146.      * @param      width   the width of the clipping rectangle.
  147.      * @param      height   the height of the clipping rectangle.
  148.      * @return     a new graphics context.
  149.      * @see        java.awt.Graphics#translate
  150.      * @see        java.awt.Graphics#clipRect
  151.      * @since      JDK1.0
  152.      */
  153.     public Graphics create(int x, int y, int width, int height) {
  154.     Graphics g = create();
  155.     g.translate(x, y);
  156.     g.clipRect(0, 0, width, height);
  157.     return g;
  158.     }
  159.  
  160.     /**
  161.      * Translates the origin of the graphics context to the point
  162.      * (<i>x</i>, <i>y</i>) in the current coordinate system. 
  163.      * Modifies this graphics context so that its new origin corresponds 
  164.      * to the point (<i>x</i>, <i>y</i>) in this graphics context's 
  165.      * original coordinate system.  All coordinates used in subsequent 
  166.      * rendering operations on this graphics context will be relative 
  167.      * to this new origin.
  168.      * @param  x   the <i>x</i> coordinate.
  169.      * @param  y   the <i>y</i> coordinate.
  170.      * @since   JDK1.0
  171.      */
  172.     public abstract void translate(int x, int y);
  173.  
  174.     /**
  175.      * Gets this graphics context's current color.
  176.      * @return    this graphics context's current color.
  177.      * @see       java.awt.Color
  178.      * @see       java.awt.Graphics#setColor
  179.      * @since     JDK1.0
  180.      */
  181.     public abstract Color getColor();
  182.  
  183.     /**
  184.      * Sets this graphics context's current color to the specified 
  185.      * color. All subsequent graphics operations using this graphics 
  186.      * context use this specified color. 
  187.      * @param     c   the new rendering color.
  188.      * @see       java.awt.Color
  189.      * @see       java.awt.Graphics#getColor
  190.      * @since     JDK1.0
  191.      */
  192.     public abstract void setColor(Color c);
  193.  
  194.     /**
  195.      * Sets the paint mode of this graphics context to overwrite the 
  196.      * destination with this graphics context's current color. 
  197.      * This sets the logical pixel operation function to the paint or
  198.      * overwrite mode.  All subsequent rendering operations will
  199.      * overwrite the destination with the current color. 
  200.      * @since   JDK1.0
  201.      */
  202.     public abstract void setPaintMode();
  203.  
  204.     /**
  205.      * Sets the paint mode of this graphics context to alternate between 
  206.      * this graphics context's current color and the new specified color. 
  207.      * This specifies that logical pixel operations are performed in the 
  208.      * XOR mode, which alternates pixels between the current color and 
  209.      * a specified XOR color. 
  210.      * <p>
  211.      * When drawing operations are performed, pixels which are the 
  212.      * current color are changed to the specified color, and vice versa. 
  213.      * <p>
  214.      * Pixels that are of colors other than those two colors are changed 
  215.      * in an unpredictable but reversible manner; if the same figure is 
  216.      * drawn twice, then all pixels are restored to their original values. 
  217.      * @param     c1 the XOR alternation color
  218.      * @since     JDK1.0
  219.      */
  220.     public abstract void setXORMode(Color c1);
  221.  
  222.     /**
  223.      * Gets the current font.
  224.      * @return    this graphics context's current font.
  225.      * @see       java.awt.Font
  226.      * @see       java.awt.Graphics#setFont
  227.      * @since     JDK1.0
  228.      */
  229.     public abstract Font getFont();
  230.  
  231.     /**
  232.      * Sets this graphics context's font to the specified font. 
  233.      * All subsequent text operations using this graphics context 
  234.      * use this font. 
  235.      * @param  font   the font.
  236.      * @see     java.awt.Graphics#getFont
  237.      * @see     java.awt.Graphics#drawChars(java.lang.String, int, int)
  238.      * @see     java.awt.Graphics#drawString(byte[], int, int, int, int)
  239.      * @see     java.awt.Graphics#drawBytes(char[], int, int, int, int)
  240.      * @since   JDK1.0
  241.     */
  242.     public abstract void setFont(Font font);
  243.  
  244.     /**
  245.      * Gets the font metrics of the current font.
  246.      * @return    the font metrics of this graphics 
  247.      *                    context's current font.
  248.      * @see       java.awt.Graphics#getFont
  249.      * @see       java.awt.FontMetrics
  250.      * @see       java.awt.Graphics#getFontMetrics(Font)
  251.      * @since     JDK1.0
  252.      */
  253.     public FontMetrics getFontMetrics() {
  254.     return getFontMetrics(getFont());
  255.     }
  256.  
  257.     /**
  258.      * Gets the font metrics for the specified font.
  259.      * @return    the font metrics for the specified font.
  260.      * @param     f the specified font
  261.      * @see       java.awt.Graphics#getFont
  262.      * @see       java.awt.FontMetrics
  263.      * @see       java.awt.Graphics#getFontMetrics()
  264.      * @since     JDK1.0
  265.      */
  266.     public abstract FontMetrics getFontMetrics(Font f);
  267.  
  268.  
  269.     /**
  270.      * Returns the bounding rectangle of the current clipping area.
  271.      * The coordinates in the rectangle are relative to the coordinate
  272.      * system origin of this graphics context.
  273.      * @return      the bounding rectangle of the current clipping area.
  274.      * @see         java.awt.Graphics#getClip
  275.      * @see         java.awt.Graphics#clipRect
  276.      * @see         java.awt.Graphics#setClip(int, int, int, int)
  277.      * @see         java.awt.Graphics#setClip(Shape)
  278.      * @since       JDK1.1
  279.      */
  280.     public abstract Rectangle getClipBounds();
  281.  
  282.     /** 
  283.      * Intersects the current clip with the specified rectangle.
  284.      * The resulting clipping area is the intersection of the current
  285.      * clipping area and the specified rectangle.
  286.      * This method can only be used to make the current clip smaller.
  287.      * To set the current clip larger, use any of the setClip methods.
  288.      * Rendering operations have no effect outside of the clipping area.
  289.      * @param x the x coordinate of the rectangle to intersect the clip with
  290.      * @param y the y coordinate of the rectangle to intersect the clip with
  291.      * @param width the width of the rectangle to intersect the clip with
  292.      * @param height the height of the rectangle to intersect the clip with
  293.      * @see #setClip(int, int, int, int)
  294.      * @see #setClip(Shape)
  295.      */
  296.     public abstract void clipRect(int x, int y, int width, int height);
  297.  
  298.     /**
  299.      * Sets the current clip to the rectangle specified by the given
  300.      * coordinates.
  301.      * Rendering operations have no effect outside of the clipping area.
  302.      * @param       x the <i>x</i> coordinate of the new clip rectangle.
  303.      * @param       y the <i>y</i> coordinate of the new clip rectangle.
  304.      * @param       width the width of the new clip rectangle.
  305.      * @param       height the height of the new clip rectangle.
  306.      * @see         java.awt.Graphics#clipRect
  307.      * @see         java.awt.Graphics#setClip(Shape)
  308.      * @since       JDK1.1
  309.      */
  310.     public abstract void setClip(int x, int y, int width, int height);
  311.  
  312.     /**
  313.      * Gets the current clipping area.
  314.      * @return      a <code>Shape</code> object representing the 
  315.      *                      current clipping area.
  316.      * @see         java.awt.Graphics#getClipBounds
  317.      * @see         java.awt.Graphics#clipRect
  318.      * @see         java.awt.Graphics#setClip(int, int, int, int)
  319.      * @see         java.awt.Graphics#setClip(Shape)
  320.      * @since       JDK1.1
  321.      */
  322.     public abstract Shape getClip();
  323.  
  324.     /**
  325.      * Sets the current clipping area to an arbitrary clip shape.
  326.      * Not all objects which implement the <code>Shape</code> 
  327.      * interface can be used to set the clip.  The only 
  328.      * <code>Shape</code> objects which are guaranteed to be 
  329.      * supported are <code>Shape</code> objects which are
  330.      * obtained via the <code>getClip</code> method and via 
  331.      * <code>Rectangle</code> objects.
  332.      * @see         java.awt.Graphics#getClip()
  333.      * @see         java.awt.Graphics#clipRect
  334.      * @see         java.awt.Graphics#setClip(int, int, int, int)
  335.      * @since       JDK1.1
  336.      */
  337.     public abstract void setClip(Shape clip);
  338.  
  339.     /**
  340.      * Copies an area of the component by a distance specified by 
  341.      * <code>dx</code> and <code>dy</code>. From the point specified
  342.      * by <code>x</code> and <code>y</code>, this method
  343.      * copies downwards and to the right.  To copy an area of the 
  344.      * component to the left or upwards, specify a negative value for 
  345.      * <code>dx</code> or <code>dy</code>.
  346.      * If a portion of the source rectangle lies outside the bounds 
  347.      * of the component, or is obscured by another window or component, 
  348.      * <code>copyArea</code> will be unable to copy the associated
  349.      * pixels. The area that is omitted can be refreshed by calling 
  350.      * the component's <code>paint</code> method.
  351.      * @param       x the <i>x</i> coordinate of the source rectangle.
  352.      * @param       y the <i>y</i> coordinate of the source rectangle.
  353.      * @param       width the width of the source rectangle.
  354.      * @param       height the height of the source rectangle.
  355.      * @param       dx the horizontal distance to copy the pixels.
  356.      * @param       dy the vertical distance to copy the pixels.
  357.      * @since       JDK1.0
  358.      */
  359.     public abstract void copyArea(int x, int y, int width, int height,
  360.                   int dx, int dy);
  361.  
  362.     /** 
  363.      * Draws a line, using the current color, between the points 
  364.      * <code>(x1, y1)</code> and <code>(x2, y2)</code> 
  365.      * in this graphics context's coordinate system. 
  366.      * @param   x1  the first point's <i>x</i> coordinate.
  367.      * @param   y1  the first point's <i>y</i> coordinate.
  368.      * @param   x2  the second point's <i>x</i> coordinate.
  369.      * @param   y2  the second point's <i>y</i> coordinate.
  370.      * @since   JDK1.0
  371.      */
  372.     public abstract void drawLine(int x1, int y1, int x2, int y2);
  373.  
  374.     /** 
  375.      * Fills the specified rectangle. 
  376.      * The left and right edges of the rectangle are at 
  377.      * <code>x</code> and <code>x + width - 1</code>. 
  378.      * The top and bottom edges are at 
  379.      * <code>y</code> and <code>y + height - 1</code>. 
  380.      * The resulting rectangle covers an area 
  381.      * <code>width</code> pixels wide by 
  382.      * <code>height</code> pixels tall.
  383.      * The rectangle is filled using the graphics context's current color. 
  384.      * @param         x   the <i>x</i> coordinate 
  385.      *                         of the rectangle to be filled.
  386.      * @param         y   the <i>y</i> coordinate 
  387.      *                         of the rectangle to be filled.
  388.      * @param         width   the width of the rectangle to be filled.
  389.      * @param         height   the height of the rectangle to be filled.
  390.      * @see           java.awt.Graphics#fillRect
  391.      * @see           java.awt.Graphics#clearRect
  392.      * @since         JDK1.0
  393.      */
  394.     public abstract void fillRect(int x, int y, int width, int height);
  395.  
  396.     /** 
  397.      * Draws the outline of the specified rectangle. 
  398.      * The left and right edges of the rectangle are at 
  399.      * <code>x</code> and <code>x + width</code>. 
  400.      * The top and bottom edges are at 
  401.      * <code>y</code> and <code>y + height</code>. 
  402.      * The rectangle is drawn using the graphics context's current color.
  403.      * @param         x   the <i>x</i> coordinate 
  404.      *                         of the rectangle to be drawn.
  405.      * @param         y   the <i>y</i> coordinate 
  406.      *                         of the rectangle to be drawn.
  407.      * @param         width   the width of the rectangle to be drawn.
  408.      * @param         height   the height of the rectangle to be drawn.
  409.      * @see          java.awt.Graphics#fillRect
  410.      * @see          java.awt.Graphics#clearRect
  411.      * @since        JDK1.0
  412.      */
  413.     public void drawRect(int x, int y, int width, int height) {
  414.     if ((width < 0) || (height < 0)) {
  415.         return;
  416.     }
  417.  
  418.     if (height == 0 || width == 0) {
  419.         drawLine(x, y, x + width, y + height);
  420.     } else {
  421.         drawLine(x, y, x + width - 1, y);
  422.         drawLine(x + width, y, x + width, y + height - 1);
  423.         drawLine(x + width, y + height, x + 1, y + height);
  424.         drawLine(x, y + height, x, y + 1);
  425.     }
  426.     }
  427.     
  428.     /** 
  429.      * Clears the specified rectangle by filling it with the background
  430.      * color of the current drawing surface. This operation does not 
  431.      * use the current paint mode. 
  432.      * <p>
  433.      * Beginning with Java 1.1, the background color 
  434.      * of offscreen images may be system dependent. Applications should 
  435.      * use <code>setColor</code> followed by <code>fillRect</code> to 
  436.      * ensure that an offscreen image is cleared to a specific color. 
  437.      * @param       x the <i>x</i> coordinate of the rectangle to clear.
  438.      * @param       y the <i>y</i> coordinate of the rectangle to clear.
  439.      * @param       width the width of the rectangle to clear.
  440.      * @param       height the height of the rectangle to clear.
  441.      * @see         java.awt.Graphics#fillRect(int, int, int, int)
  442.      * @see         java.awt.Graphics#drawRect
  443.      * @see         java.awt.Graphics#setColor(java.awt.Color)
  444.      * @see         java.awt.Graphics#setPaintMode
  445.      * @see         java.awt.Graphics#setXORMode(java.awt.Color)
  446.      * @since       JDK1.0
  447.      */
  448.     public abstract void clearRect(int x, int y, int width, int height);
  449.  
  450.     /** 
  451.      * Draws an outlined round-cornered rectangle using this graphics 
  452.      * context's current color. The left and right edges of the rectangle 
  453.      * are at <code>x</code> and <code>x + width</code>, 
  454.      * respectively. The top and bottom edges of the rectangle are at 
  455.      * <code>y</code> and <code>y + height</code>. 
  456.      * @param      x the <i>x</i> coordinate of the rectangle to be drawn.
  457.      * @param      y the <i>y</i> coordinate of the rectangle to be drawn.
  458.      * @param      width the width of the rectangle to be drawn.
  459.      * @param      height the height of the rectangle to be drawn.
  460.      * @param      arcWidth the horizontal diameter of the arc 
  461.      *                    at the four corners.
  462.      * @param      arcHeight the vertical diameter of the arc 
  463.      *                    at the four corners.
  464.      * @see        java.awt.Graphics#fillRoundRect
  465.      * @since      JDK1.0
  466.      */
  467.     public abstract void drawRoundRect(int x, int y, int width, int height,
  468.                        int arcWidth, int arcHeight);
  469.  
  470.     /** 
  471.      * Fills the specified rounded corner rectangle with the current color.
  472.      * The left and right edges of the rectangle 
  473.      * are at <code>x</code> and <code>x + width - 1</code>, 
  474.      * respectively. The top and bottom edges of the rectangle are at 
  475.      * <code>y</code> and <code>y + height - 1</code>. 
  476.      * @param       x the <i>x</i> coordinate of the rectangle to be filled.
  477.      * @param       y the <i>y</i> coordinate of the rectangle to be filled.
  478.      * @param       width the width of the rectangle to be filled.
  479.      * @param       height the height of the rectangle to be filled.
  480.      * @param       arcWidth the horizontal diameter 
  481.      *                     of the arc at the four corners.
  482.      * @param       arcHeight the vertical diameter 
  483.      *                     of the arc at the four corners.
  484.      * @see         java.awt.Graphics#drawRoundRect
  485.      * @since       JDK1.0
  486.      */
  487.     public abstract void fillRoundRect(int x, int y, int width, int height,
  488.                        int arcWidth, int arcHeight);
  489.  
  490.     /**
  491.      * Draws a 3-D highlighted outline of the specified rectangle.
  492.      * The edges of the rectangle are highlighted so that they
  493.      * appear to be beveled and lit from the upper left corner.
  494.      * <p>
  495.      * The colors used for the highlighting effect are determined 
  496.      * based on the current color.
  497.      * The resulting rectangle covers an area that is 
  498.      * <code>width + 1</code> pixels wide
  499.      * by <code>height + 1<code> pixels tall.
  500.      * @param       x the <i>x</i> coordinate of the rectangle to be drawn.
  501.      * @param       y the <i>y</i> coordinate of the rectangle to be drawn.
  502.      * @param       width the width of the rectangle to be drawn.
  503.      * @param       height the height of the rectangle to be drawn.
  504.      * @param       raised a boolean that determines whether the rectangle
  505.      *                      appears to be raised above the surface 
  506.      *                      or sunk into the surface.
  507.      * @see         java.awt.Graphics#fill3DRect
  508.      * @since       JDK1.0
  509.      */
  510.     public void draw3DRect(int x, int y, int width, int height,
  511.                boolean raised) {
  512.     Color c = getColor();
  513.     Color brighter = c.brighter();
  514.     Color darker = c.darker();
  515.  
  516.     setColor(raised ? brighter : darker);
  517.     drawLine(x, y, x, y + height);
  518.     drawLine(x + 1, y, x + width - 1, y);
  519.     setColor(raised ? darker : brighter);
  520.     drawLine(x + 1, y + height, x + width, y + height);
  521.     drawLine(x + width, y, x + width, y + height - 1);
  522.     setColor(c);
  523.     }    
  524.  
  525.     /**
  526.      * Paints a 3-D highlighted rectangle filled with the current color.
  527.      * The edges of the rectangle will be highlighted so that it appears
  528.      * as if the edges were beveled and lit from the upper left corner.
  529.      * The colors used for the highlighting effect will be determined from
  530.      * the current color.
  531.      * @param       x the <i>x</i> coordinate of the rectangle to be filled.
  532.      * @param       y the <i>y</i> coordinate of the rectangle to be filled.
  533.      * @param       width the width of the rectangle to be filled.
  534.      * @param       height the height of the rectangle to be filled.
  535.      * @param       raised a boolean value that determines whether the 
  536.      *                      rectangle appears to be raised above the surface 
  537.      *                      or etched into the surface.
  538.      * @see         java.awt.Graphics#draw3DRect
  539.      * @since       JDK1.0
  540.      */
  541.     public void fill3DRect(int x, int y, int width, int height,
  542.                boolean raised) {
  543.     Color c = getColor();
  544.     Color brighter = c.brighter();
  545.     Color darker = c.darker();
  546.  
  547.     if (!raised) {
  548.         setColor(darker);
  549.     }
  550.     fillRect(x+1, y+1, width-2, height-2);
  551.     setColor(raised ? brighter : darker);
  552.     drawLine(x, y, x, y + height - 1);
  553.     drawLine(x + 1, y, x + width - 2, y);
  554.     setColor(raised ? darker : brighter);
  555.     drawLine(x + 1, y + height - 1, x + width - 1, y + height - 1);
  556.     drawLine(x + width - 1, y, x + width - 1, y + height - 2);
  557.     setColor(c);
  558.     }    
  559.  
  560.     /** 
  561.      * Draws the outline of an oval.
  562.      * The result is a circle or ellipse that fits within the 
  563.      * rectangle specified by the <code>x</code>, <code>y</code>, 
  564.      * <code>width</code>, and <code>height</code> arguments. 
  565.      * <p> 
  566.      * The oval covers an area that is 
  567.      * <code>width + 1</code> pixels wide 
  568.      * and <code>height + 1<code> pixels tall. 
  569.      * @param       x the <i>x</i> coordinate of the upper left 
  570.      *                     corner of the oval to be drawn.
  571.      * @param       y the <i>y</i> coordinate of the upper left 
  572.      *                     corner of the oval to be drawn.
  573.      * @param       width the width of the oval to be drawn.
  574.      * @param       height the height of the oval to be drawn.
  575.      * @see         java.awt.Graphics#fillOval
  576.      * @since       JDK1.0
  577.      */
  578.     public abstract void drawOval(int x, int y, int width, int height);
  579.  
  580.     /** 
  581.      * Fills an oval bounded by the specified rectangle with the
  582.      * current color.
  583.      * @param       x the <i>x</i> coordinate of the upper left corner 
  584.      *                     of the oval to be filled.
  585.      * @param       y the <i>y</i> coordinate of the upper left corner 
  586.      *                     of the oval to be filled.
  587.      * @param       width the width of the oval to be filled.
  588.      * @param       height the height of the oval to be filled.
  589.      * @see         java.awt.Graphics#drawOval
  590.      * @since       JDK1.0
  591.      */
  592.     public abstract void fillOval(int x, int y, int width, int height);
  593.  
  594.     /**
  595.      * Draws the outline of a circular or elliptical arc 
  596.      * covering the specified rectangle.
  597.      * <p>
  598.      * The resulting arc begins at <code>startAngle</code> and extends  
  599.      * for <code>arcAngle</code> degrees, using the current color.
  600.      * Angles are interpreted such that 0 degrees 
  601.      * is at the 3 o'clock position. 
  602.      * A positive value indicates a counter-clockwise rotation
  603.      * while a negative value indicates a clockwise rotation.
  604.      * <p>
  605.      * The center of the arc is the center of the rectangle whose origin 
  606.      * is (<i>x</i>, <i>y</i>) and whose size is specified by the 
  607.      * <code>width</code> and <code>height</code> arguments. 
  608.      * <p>
  609.      * The resulting arc covers an area 
  610.      * <code>width + 1</code> pixels wide
  611.      * by <code>height + 1</code> pixels tall.
  612.      * @param        x the <i>x</i> coordinate of the 
  613.      *                    upper-left corner of the arc to be drawn.
  614.      * @param        y the <i>y</i>  coordinate of the 
  615.      *                    upper-left corner of the arc to be drawn.
  616.      * @param        width the width of the arc to be drawn.
  617.      * @param        height the height of the arc to be drawn.
  618.      * @param        startAngle the beginning angle.
  619.      * @param        arcAngle the angular extent of the arc, 
  620.      *                    relative to the start angle.
  621.      * @see         java.awt.Graphics#fillArc
  622.      * @since       JDK1.0
  623.      */
  624.     public abstract void drawArc(int x, int y, int width, int height,
  625.                  int startAngle, int arcAngle);
  626.  
  627.     /** 
  628.      * Fills a circular or elliptical arc covering the specified rectangle.
  629.      * <p>
  630.      * The resulting arc begins at <code>startAngle</code> and extends  
  631.      * for <code>arcAngle</code> degrees.
  632.      * Angles are interpreted such that 0 degrees 
  633.      * is at the 3 o'clock position. 
  634.      * A positive value indicates a counter-clockwise rotation
  635.      * while a negative value indicates a clockwise rotation.
  636.      * <p>
  637.      * The center of the arc is the center of the rectangle whose origin 
  638.      * is (<i>x</i>, <i>y</i>) and whose size is specified by the 
  639.      * <code>width</code> and <code>height</code> arguments. 
  640.      * <p>
  641.      * The resulting arc covers an area 
  642.      * <code>width + 1</code> pixels wide
  643.      * by <code>height + 1</code> pixels tall.
  644.      * @param        x the <i>x</i> coordinate of the 
  645.      *                    upper-left corner of the arc to be filled.
  646.      * @param        y the <i>y</i>  coordinate of the 
  647.      *                    upper-left corner of the arc to be filled.
  648.      * @param        width the width of the arc to be filled.
  649.      * @param        height the height of the arc to be filled.
  650.      * @param        startAngle the beginning angle.
  651.      * @param        arcAngle the angular extent of the arc, 
  652.      *                    relative to the start angle.
  653.      * @see         java.awt.Graphics#drawArc
  654.      * @since       JDK1.0
  655.      */
  656.     public abstract void fillArc(int x, int y, int width, int height,
  657.                  int startAngle, int arcAngle);
  658.  
  659.     /** 
  660.      * Draws a sequence of connected lines defined by 
  661.      * arrays of <i>x</i> and <i>y</i> coordinates. 
  662.      * Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.
  663.      * The figure is not closed if the first point 
  664.      * differs from the last point.
  665.      * @param       xPoints an array of <i>x</i> points
  666.      * @param       yPoints an array of <i>y</i> points
  667.      * @param       nPoints the total number of points
  668.      * @see         java.awt.Graphics#drawPolygon(int[], int[], int)
  669.      * @since       JDK1.1
  670.      */
  671.     public abstract void drawPolyline(int xPoints[], int yPoints[],
  672.                       int nPoints);
  673.  
  674.     /** 
  675.      * Draws a closed polygon defined by 
  676.      * arrays of <i>x</i> and <i>y</i> coordinates. 
  677.      * Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.
  678.      * <p>
  679.      * This method draws the polygon defined by <code>nPoint</code> line 
  680.      * segments, where the first <code>nPoint - 1</code> 
  681.      * line segments are line segments from 
  682.      * <code>(xPoints[i - 1], yPoints[i - 1])</code> 
  683.      * to <code>(xPoints[i], yPoints[i])</code>, for 
  684.      * 1 ≤ <i>i</i> ≤ <code>nPoints</code>.  
  685.      * The figure is automatically closed by drawing a line connecting
  686.      * the final point to the first point, if those points are different.
  687.      * @param        xPoints   a an array of <code>x</code> coordinates.
  688.      * @param        yPoints   a an array of <code>y</code> coordinates.
  689.      * @param        nPoints   a the total number of points.
  690.      * @see          java.awt.Graphics#fillPolygon
  691.      * @see          java.awt.Graphics#drawPolyline
  692.      * @since        JDK1.0
  693.      */
  694.     public abstract void drawPolygon(int xPoints[], int yPoints[],
  695.                      int nPoints);
  696.  
  697.     /** 
  698.      * Draws the outline of a polygon defined by the specified 
  699.      * <code>Polygon</code> object. 
  700.      * @param        p the polygon to draw.
  701.      * @see          java.awt.Graphics#fillPolygon
  702.      * @see          java.awt.Graphics#drawPolyline
  703.      * @since        JDK1.0
  704.      */
  705.     public void drawPolygon(Polygon p) {
  706.     drawPolygon(p.xpoints, p.ypoints, p.npoints);
  707.     }
  708.  
  709.     /** 
  710.      * Fills a closed polygon defined by 
  711.      * arrays of <i>x</i> and <i>y</i> coordinates. 
  712.      * <p>
  713.      * This method draws the polygon defined by <code>nPoint</code> line 
  714.      * segments, where the first <code>nPoint - 1</code> 
  715.      * line segments are line segments from 
  716.      * <code>(xPoints[i - 1], yPoints[i - 1])</code> 
  717.      * to <code>(xPoints[i], yPoints[i])</code>, for 
  718.      * 1 ≤ <i>i</i> ≤ <code>nPoints</code>.  
  719.      * The figure is automatically closed by drawing a line connecting
  720.      * the final point to the first point, if those points are different.
  721.      * <p>
  722.      * The area inside the polygon is defined using an 
  723.      * even-odd fill rule, also known as the alternating rule.
  724.      * @param        xPoints   a an array of <code>x</code> coordinates.
  725.      * @param        yPoints   a an array of <code>y</code> coordinates.
  726.      * @param        nPoints   a the total number of points.
  727.      * @see          java.awt.Graphics#drawPolygon(int[], int[], int)
  728.      * @since        JDK1.0
  729.      */
  730.     public abstract void fillPolygon(int xPoints[], int yPoints[],
  731.                      int nPoints);
  732.  
  733.     /** 
  734.      * Fills the polygon defined by the specified Polygon object with
  735.      * the graphics context's current color. 
  736.      * <p>
  737.      * The area inside the polygon is defined using an 
  738.      * even-odd fill rule, also known as the alternating rule.
  739.      * @param        p the polygon to fill.
  740.      * @see          java.awt.Graphics#drawPolygon(int[], int[], int)
  741.      * @since        JDK1.0
  742.      */
  743.     public void fillPolygon(Polygon p) {
  744.     fillPolygon(p.xpoints, p.ypoints, p.npoints);
  745.     }
  746.  
  747.     /** 
  748.      * Draws the text given by the specified string, using this 
  749.      * graphics context's current font and color. The baseline of the 
  750.      * first character is at position (<i>x</i>, <i>y</i>) in this 
  751.      * graphics context's coordinate system. 
  752.      * @param       str      the string to be drawn.
  753.      * @param       x        the <i>x</i> coordinate.
  754.      * @param       y        the <i>y</i> coordinate.
  755.      * @see         java.awt.Graphics#drawBytes
  756.      * @see         java.awt.Graphics#drawChars
  757.      * @since       JDK1.0
  758.      */
  759.     public abstract void drawString(String str, int x, int y);
  760.  
  761.     /** 
  762.      * Draws the text given by the specified character array, using this 
  763.      * graphics context's current font and color. The baseline of the 
  764.      * first character is at position (<i>x</i>, <i>y</i>) in this 
  765.      * graphics context's coordinate system. 
  766.      * @param data the array of characters to be drawn
  767.      * @param offset the start offset in the data
  768.      * @param length the number of characters to be drawn
  769.      * @param x the <i>x</i> coordinate of the baseline of the text
  770.      * @param y the <i>y</i> coordinate of the baseline of the text
  771.      * @see         java.awt.Graphics#drawBytes
  772.      * @see         java.awt.Graphics#drawString
  773.      * @since       JDK1.0
  774.      */
  775.     public void drawChars(char data[], int offset, int length, int x, int y) {
  776.     drawString(new String(data, offset, length), x, y);
  777.     }
  778.  
  779.     /** 
  780.      * Draws the text given by the specified byte array, using this 
  781.      * graphics context's current font and color. The baseline of the 
  782.      * first character is at position (<i>x</i>, <i>y</i>) in this 
  783.      * graphics context's coordinate system.
  784.      * @param data the data to be drawn
  785.      * @param offset the start offset in the data
  786.      * @param length the number of bytes that are drawn
  787.      * @param x the <i>x</i> coordinate of the baseline of the text
  788.      * @param y the <i>y</i> coordinate of the baseline of the text
  789.      * @see         java.awt.Graphics#drawChars
  790.      * @see         java.awt.Graphics#drawString
  791.      * @since       JDK1.0
  792.      */
  793.     public void drawBytes(byte data[], int offset, int length, int x, int y) {
  794.     drawString(new String(data, 0, offset, length), x, y);
  795.     }
  796.  
  797.     /** 
  798.      * Draws as much of the specified image as is currently available.
  799.      * The image is drawn with its top-left corner at 
  800.      * (<i>x</i>, <i>y</i>) in this graphics context's coordinate 
  801.      * space. Transparent pixels in the image do not affect whatever 
  802.      * pixels are already there. 
  803.      * <p>
  804.      * This method returns immediately in all cases, even if the
  805.      * complete image has not yet been loaded, and it has not been dithered 
  806.      * and converted for the current output device.
  807.      * <p>
  808.      * If the image has not yet been completely loaded, then
  809.      * <code>drawImage</code> returns <code>false</code>. As more of
  810.      * the image becomes available, the process that draws the image notifies 
  811.      * the specified image observer.
  812.      * @param    img the specified image to be drawn.
  813.      * @param    x   the <i>x</i> coordinate.
  814.      * @param    y   the <i>y</i> coordinate.
  815.      * @param    observer    object to be notified as more of 
  816.      *                          the image is converted.
  817.      * @see      java.awt.Image
  818.      * @see      java.awt.image.ImageObserver
  819.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  820.      * @since    JDK1.0
  821.      */
  822.     public abstract boolean drawImage(Image img, int x, int y, 
  823.                       ImageObserver observer);
  824.  
  825.     /**
  826.      * Draws as much of the specified image as has already been scaled
  827.      * to fit inside the specified rectangle.
  828.      * <p>
  829.      * The image is drawn inside the specified rectangle of this 
  830.      * graphics context's coordinate space, and is scaled if 
  831.      * necessary. Transparent pixels do not affect whatever pixels
  832.      * are already there. 
  833.      * <p>
  834.      * This method returns immediately in all cases, even if the
  835.      * entire image has not yet been scaled, dithered, and converted
  836.      * for the current output device.
  837.      * If the current output representation is not yet complete, then
  838.      * <code>drawImage</code> returns <code>false</code>. As more of
  839.      * the image becomes available, the process that draws the image notifies 
  840.      * the image observer by calling its <code>imageUpdate</code> method.
  841.      * <p>
  842.      * A scaled version of an image will not necessarily be
  843.      * available immediately just because an unscaled version of the
  844.      * image has been constructed for this output device.  Each size of
  845.      * the image may be cached separately and generated from the original
  846.      * data in a separate image production sequence.
  847.      * @param    img    the specified image to be drawn.
  848.      * @param    x      the <i>x</i> coordinate.
  849.      * @param    y      the <i>y</i> coordinate.
  850.      * @param    width  the width of the rectangle.
  851.      * @param    height the height of the rectangle.
  852.      * @param    observer    object to be notified as more of 
  853.      *                          the image is converted.
  854.      * @see      java.awt.Image
  855.      * @see      java.awt.image.ImageObserver
  856.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  857.      * @since    JDK1.0
  858.      */
  859.     public abstract boolean drawImage(Image img, int x, int y,
  860.                       int width, int height, 
  861.                       ImageObserver observer);
  862.     
  863.     /** 
  864.      * Draws as much of the specified image as is currently available.
  865.      * The image is drawn with its top-left corner at 
  866.      * (<i>x</i>, <i>y</i>) in this graphics context's coordinate 
  867.      * space.  Transparent pixels are drawn in the specified
  868.      * background color.
  869.      * <p> 
  870.      * This operation is equivalent to filling a rectangle of the
  871.      * width and height of the specified image with the given color and then
  872.      * drawing the image on top of it, but possibly more efficient.
  873.      * <p>
  874.      * This method returns immediately in all cases, even if the
  875.      * complete image has not yet been loaded, and it has not been dithered 
  876.      * and converted for the current output device.
  877.      * <p>
  878.      * If the image has not yet been completely loaded, then
  879.      * <code>drawImage</code> returns <code>false</code>. As more of
  880.      * the image becomes available, the process that draws the image notifies 
  881.      * the specified image observer.
  882.      * @param    img    the specified image to be drawn.
  883.      * @param    x      the <i>x</i> coordinate.
  884.      * @param    y      the <i>y</i> coordinate.
  885.      * @param    bgcolor the background color to paint under the
  886.      *                         non-opaque portions of the image.
  887.      * @param    observer    object to be notified as more of 
  888.      *                          the image is converted.
  889.      * @see      java.awt.Image
  890.      * @see      java.awt.image.ImageObserver
  891.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  892.      * @since    JDK1.0
  893.      */
  894.     public abstract boolean drawImage(Image img, int x, int y, 
  895.                       Color bgcolor,
  896.                       ImageObserver observer);
  897.  
  898.     /**
  899.      * Draws as much of the specified image as has already been scaled
  900.      * to fit inside the specified rectangle.
  901.      * <p>
  902.      * The image is drawn inside the specified rectangle of this 
  903.      * graphics context's coordinate space, and is scaled if 
  904.      * necessary. Transparent pixels are drawn in the specified
  905.      * background color. 
  906.      * This operation is equivalent to filling a rectangle of the
  907.      * width and height of the specified image with the given color and then
  908.      * drawing the image on top of it, but possibly more efficient.
  909.      * <p>
  910.      * This method returns immediately in all cases, even if the
  911.      * entire image has not yet been scaled, dithered, and converted
  912.      * for the current output device.
  913.      * If the current output representation is not yet complete then
  914.      * <code>drawImage</code> returns <code>false</code>. As more of
  915.      * the image becomes available, the process that draws the image notifies 
  916.      * the specified image observer.
  917.      * <p>
  918.      * A scaled version of an image will not necessarily be
  919.      * available immediately just because an unscaled version of the
  920.      * image has been constructed for this output device.  Each size of
  921.      * the image may be cached separately and generated from the original
  922.      * data in a separate image production sequence.
  923.      * @param    img       the specified image to be drawn.
  924.      * @param    x         the <i>x</i> coordinate.
  925.      * @param    y         the <i>y</i> coordinate.
  926.      * @param    width     the width of the rectangle.
  927.      * @param    height    the height of the rectangle.
  928.      * @param    bgcolor   the background color to paint under the
  929.      *                         non-opaque portions of the image.
  930.      * @param    observer    object to be notified as more of 
  931.      *                          the image is converted.
  932.      * @see      java.awt.Image
  933.      * @see      java.awt.image.ImageObserver
  934.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  935.      * @since    JDK1.0
  936.      */
  937.     public abstract boolean drawImage(Image img, int x, int y,
  938.                       int width, int height, 
  939.                       Color bgcolor,
  940.                       ImageObserver observer);
  941.     
  942.     /**
  943.      * Draws as much of the specified area of the specified image as is
  944.      * currently available, scaling it on the fly to fit inside the
  945.      * specified area of the destination drawable surface. Transparent pixels 
  946.      * do not affect whatever pixels are already there.
  947.      * <p>
  948.      * This method returns immediately in all cases, even if the
  949.      * image area to be drawn has not yet been scaled, dithered, and converted
  950.      * for the current output device.
  951.      * If the current output representation is not yet complete then
  952.      * <code>drawImage</code> returns <code>false</code>. As more of
  953.      * the image becomes available, the process that draws the image notifies 
  954.      * the specified image observer.
  955.      * <p>
  956.      * This method always uses the unscaled version of the image
  957.      * to render the scaled rectangle and performs the required
  958.      * scaling on the fly. It does not use a cached, scaled version
  959.      * of the image for this operation. Scaling of the image from source
  960.      * to destination is performed such that the first coordinate
  961.      * of the source rectangle is mapped to the first coordinate of
  962.      * the destination rectangle, and the second source coordinate is
  963.      * mapped to the second destination coordinate. The subimage is
  964.      * scaled and flipped as needed to preserve those mappings.
  965.      * @param       img the specified image to be drawn
  966.      * @param       dx1 the <i>x</i> coordinate of the first corner of the
  967.      *                    destination rectangle.
  968.      * @param       dy1 the <i>y</i> coordinate of the first corner of the
  969.      *                    destination rectangle.
  970.      * @param       dx2 the <i>x</i> coordinate of the second corner of the
  971.      *                    destination rectangle.
  972.      * @param       dy2 the <i>y</i> coordinate of the second corner of the
  973.      *                    destination rectangle.
  974.      * @param       sx1 the <i>x</i> coordinate of the first corner of the
  975.      *                    source rectangle.
  976.      * @param       sy1 the <i>y</i> coordinate of the first corner of the
  977.      *                    source rectangle.
  978.      * @param       sx2 the <i>x</i> coordinate of the second corner of the
  979.      *                    source rectangle.
  980.      * @param       sy2 the <i>y</i> coordinate of the second corner of the
  981.      *                    source rectangle.
  982.      * @param       observer object to be notified as more of the image is
  983.      *                    scaled and converted.
  984.      * @see         java.awt.Image
  985.      * @see         java.awt.image.ImageObserver
  986.      * @see         java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  987.      * @since       JDK1.1
  988.      */
  989.     public abstract boolean drawImage(Image img,
  990.                       int dx1, int dy1, int dx2, int dy2,
  991.                       int sx1, int sy1, int sx2, int sy2,
  992.                       ImageObserver observer);
  993.  
  994.     /**
  995.      * Draws as much of the specified area of the specified image as is
  996.      * currently available, scaling it on the fly to fit inside the
  997.      * specified area of the destination drawable surface. 
  998.      * <p>
  999.      * Transparent pixels are drawn in the specified background color. 
  1000.      * This operation is equivalent to filling a rectangle of the
  1001.      * width and height of the specified image with the given color and then
  1002.      * drawing the image on top of it, but possibly more efficient.
  1003.      * <p>
  1004.      * This method returns immediately in all cases, even if the
  1005.      * image area to be drawn has not yet been scaled, dithered, and converted
  1006.      * for the current output device.
  1007.      * If the current output representation is not yet complete then
  1008.      * <code>drawImage</code> returns <code>false</code>. As more of
  1009.      * the image becomes available, the process that draws the image notifies 
  1010.      * the specified image observer.
  1011.      * <p>
  1012.      * This method always uses the unscaled version of the image
  1013.      * to render the scaled rectangle and performs the required
  1014.      * scaling on the fly. It does not use a cached, scaled version
  1015.      * of the image for this operation. Scaling of the image from source
  1016.      * to destination is performed such that the first coordinate
  1017.      * of the source rectangle is mapped to the first coordinate of
  1018.      * the destination rectangle, and the second source coordinate is
  1019.      * mapped to the second destination coordinate. The subimage is
  1020.      * scaled and flipped as needed to preserve those mappings.
  1021.      * @param       img the specified image to be drawn
  1022.      * @param       dx1 the <i>x</i> coordinate of the first corner of the
  1023.      *                    destination rectangle.
  1024.      * @param       dy1 the <i>y</i> coordinate of the first corner of the
  1025.      *                    destination rectangle.
  1026.      * @param       dx2 the <i>x</i> coordinate of the second corner of the
  1027.      *                    destination rectangle.
  1028.      * @param       dy2 the <i>y</i> coordinate of the second corner of the
  1029.      *                    destination rectangle.
  1030.      * @param       sx1 the <i>x</i> coordinate of the first corner of the
  1031.      *                    source rectangle.
  1032.      * @param       sy1 the <i>y</i> coordinate of the first corner of the
  1033.      *                    source rectangle.
  1034.      * @param       sx2 the <i>x</i> coordinate of the second corner of the
  1035.      *                    source rectangle.
  1036.      * @param       sy2 the <i>y</i> coordinate of the second corner of the
  1037.      *                    source rectangle.
  1038.      * @param       bgcolor the background color to paint under the
  1039.      *                    non-opaque portions of the image.
  1040.      * @param       observer object to be notified as more of the image is
  1041.      *                    scaled and converted.
  1042.      * @see         java.awt.Image
  1043.      * @see         java.awt.image.ImageObserver
  1044.      * @see         java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  1045.      * @since       JDK1.1
  1046.      */
  1047.     public abstract boolean drawImage(Image img,
  1048.                       int dx1, int dy1, int dx2, int dy2,
  1049.                       int sx1, int sy1, int sx2, int sy2,
  1050.                       Color bgcolor,
  1051.                       ImageObserver observer);
  1052.  
  1053.     /**
  1054.      * Disposes of this graphics context and releases 
  1055.      * any system resources that it is using. 
  1056.      * A <code>Graphics</code> object cannot be used after 
  1057.      * <code>dispose</code>has been called.
  1058.      * <p>
  1059.      * When a Java program runs, a large number of <code>Graphics</code>
  1060.      * objects can be created within a short time frame.
  1061.      * Although the finalization process of the garbage collector 
  1062.      * also disposes of the same system resources, it is preferable 
  1063.      * to manually free the associated resources by calling this
  1064.      * method rather than to rely on a finalization process which 
  1065.      * may not run to completion for a long period of time.
  1066.      * <p>
  1067.      * Graphics objects which are provided as arguments to the 
  1068.      * <code>paint</code> and <code>update</code> methods 
  1069.      * of components are automatically released by the system when 
  1070.      * those methods return. For efficiency, programmers should
  1071.      * call <code>dispose</code> when finished using
  1072.      * a <code>Graphics</code> object only if it was created 
  1073.      * directly from a component or another <code>Graphics</code> object.
  1074.      * @see         java.awt.Graphics#finalize
  1075.      * @see         java.awt.Component#paint
  1076.      * @see         java.awt.Component#update
  1077.      * @see         java.awt.Component#getGraphics
  1078.      * @see         java.awt.Graphics#create
  1079.      * @since       JDK1.0
  1080.      */
  1081.     public abstract void dispose();
  1082.  
  1083.     /**
  1084.      * Disposes of this graphics context once it is no longer referenced.
  1085.      * @see #dispose
  1086.      * @since JDK1.0
  1087.      */
  1088.     public void finalize() {
  1089.     dispose();
  1090.     }
  1091.  
  1092.     /**
  1093.      * Returns a <code>String</code> object representing this 
  1094.      *                        <code>Graphics</code> object's value.
  1095.      * @return       a string representation of this graphics context.
  1096.      * @since        JDK1.0
  1097.      */
  1098.     public String toString() {    
  1099.     return getClass().getName() + "[font=" + getFont() + ",color=" + getColor() + "]";
  1100.     }
  1101.  
  1102.     /**
  1103.      * @deprecated As of JDK version 1.1,
  1104.      * replaced by <code>getClipBounds()</code>.
  1105.      */
  1106.     public Rectangle getClipRect() {
  1107.     return getClipBounds();
  1108.     }
  1109. }
  1110.