/[classpath]/classpath/java/awt/Graphics.java
ViewVC logotype

Diff of /classpath/java/awt/Graphics.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10.2.3 by gnu_andrew, Tue Aug 2 20:12:15 2005 UTC revision 1.10.2.4 by gnu_andrew, Wed Nov 2 00:43:30 2005 UTC
# Line 42  import java.awt.image.ImageObserver; Line 42  import java.awt.image.ImageObserver;
42  import java.text.AttributedCharacterIterator;  import java.text.AttributedCharacterIterator;
43    
44  /**  /**
45    * This is the abstract superclass of classes for drawing to graphics   * This is the abstract superclass of classes for drawing to graphics
46    * devices such as the screen or printers.   * devices such as the screen or printers.
47    *   *
48    * @author Aaron M. Renn (arenn@urbanophile.com)   * @author Aaron M. Renn (arenn@urbanophile.com)
49    * @author Warren Levy (warrenl@cygnus.com)   * @author Warren Levy (warrenl@cygnus.com)
   */  
 public abstract class Graphics  
 {  
   
 /*  
  * Instance Variables  
  */  
   
 /*************************************************************************/  
   
 /*  
  * Constructors  
  */  
   
 /**  
   * Default constructor for subclasses.  
   */  
 protected  
 Graphics()  
 {  
 }  
   
 /*************************************************************************/  
   
 /*  
  * Instance Methods  
50   */   */
51    public abstract class Graphics
 /**  
   * Returns a copy of this <code>Graphics</code> object.  
   *  
   * @return A copy of this object.  
   */  
 public abstract Graphics  
 create();  
   
 /*************************************************************************/  
   
 /**  
   * Returns a copy of this <code>Graphics</code> object.  The origin point  
   * will be translated to the point (x, y) and the cliping rectangle set  
   * to the intersection of the clipping rectangle in this object and the  
   * rectangle specified by the parameters to this method.  
   *  
   * @param x The new X coordinate of the clipping region rect.  
   * @param y The new Y coordinate of the clipping region rect.  
   * @param width The width of the clipping region intersect rectangle.  
   * @param height The height of the clipping region intersect rectangle.  
   *  
   * @return A copy of this object, modified as specified.  
   */  
 public Graphics  
 create(int x, int y, int width, int height)  
52  {  {
   Graphics g = create();  
   
   g.translate(x, y);  
   // FIXME: I'm not sure if this will work.  Are the old clip rect bounds  
   // translated above?  
   g.clipRect(0, 0, width, height);  
   
   return(g);  
 }  
53    
54  /*************************************************************************/    /**
55       * Default constructor for subclasses.
56  /**     */
57    * Translates this context so that its new origin point is the point    protected
58    * (x, y).    Graphics()
59    *    {
60    * @param x The new X coordinate of the origin.    }
61    * @param y The new Y coordinate of the origin.  
62    */    /**
63  public abstract void     * Returns a copy of this <code>Graphics</code> object.
64  translate(int x, int y);     *
65       * @return A copy of this object.
66  /*************************************************************************/     */
67      public abstract Graphics create();
68  /**  
69    * Returns the current color for this object.    /**
70    *     * Returns a copy of this <code>Graphics</code> object.  The origin point
71    * @return The color for this object.     * will be translated to the point (x, y) and the cliping rectangle set
72    */     * to the intersection of the clipping rectangle in this object and the
73  public abstract Color     * rectangle specified by the parameters to this method.
74  getColor();     *
75       * @param x The new X coordinate of the clipping region rect.
76  /*************************************************************************/     * @param y The new Y coordinate of the clipping region rect.
77       * @param width The width of the clipping region intersect rectangle.
78  /**     * @param height The height of the clipping region intersect rectangle.
79    * Sets the current color for this object.     *
80    *     * @return A copy of this object, modified as specified.
81    * @param color The new color.     */
82    */    public Graphics create(int x, int y, int width, int height)
83  public abstract void    {
84  setColor(Color color);      Graphics g = create();
85    
86  /*************************************************************************/      g.translate(x, y);
87        // FIXME: I'm not sure if this will work.  Are the old clip rect bounds
88  /**      // translated above?
89    * Sets this context into "paint" mode, where the target pixels are      g.clipRect(0, 0, width, height);
90    * completely overwritten when drawn on.  
91    */      return(g);
92  public abstract void    }
93  setPaintMode();  
94      /**
95  /*************************************************************************/     * Translates this context so that its new origin point is the point
96       * (x, y).
97  /**     *
98    * Sets this context info "XOR" mode, where the targe pixles are     * @param x The new X coordinate of the origin.
99    * XOR-ed when drawn on.     * @param y The new Y coordinate of the origin.
100    *     */
101    * @param color The color to XOR against.    public abstract void translate(int x, int y);
102    */  
103  public abstract void    /**
104  setXORMode(Color color);     * Returns the current color for this object.
105       *
106       * @return The color for this object.
107       */
108      public abstract Color getColor();
109    
110      /**
111       * Sets the current color for this object.
112       *
113       * @param color The new color.
114       */
115      public abstract void setColor(Color color);
116    
117      /**
118       * Sets this context into "paint" mode, where the target pixels are
119       * completely overwritten when drawn on.
120       */
121      public abstract void setPaintMode();
122    
123      /**
124       * Sets this context info "XOR" mode, where the targe pixles are
125       * XOR-ed when drawn on.
126       *
127       * @param color The color to XOR against.
128       */
129      public abstract void setXORMode(Color color);
130        
131  /*************************************************************************/    /**
132       * Returns the current font for this graphics context.
133  /**     *
134    * Returns the current font for this graphics context.     * @return The current font.
135    *     */
136    * @return The current font.    public abstract Font getFont();
137    */  
138  public abstract Font    /**
139  getFont();     * Sets the font for this graphics context to the specified value.
140       *
141  /*************************************************************************/     * @param font The new font.
142       */
143  /**    public abstract void setFont(Font font);
144    * Sets the font for this graphics context to the specified value.  
145    *    /**
146    * @param font The new font.     * Returns the font metrics for the current font.
147    */     *
148  public abstract void     * @return The font metrics for the current font.
149  setFont(Font font);     */
150      public FontMetrics getFontMetrics()
151  /*************************************************************************/    {
152        return getFontMetrics(getFont());
153  /**    }
154    * Returns the font metrics for the current font.  
155    *    /**
156    * @return The font metrics for the current font.     * Returns the font metrics for the specified font.
157    */     *
158  public FontMetrics     * @param font The font to return metrics for.
159  getFontMetrics()     *
160  {     * @return The requested font metrics.
161    return(getFontMetrics(getFont()));     */
162  }    public abstract FontMetrics getFontMetrics(Font font);
163    
164  /*************************************************************************/    /**
165       * Returns the bounding rectangle of the clipping region for this
166  /**     * graphics context.
167    * Returns the font metrics for the specified font.     *
168    *     * @return The bounding rectangle for the clipping region.
169    * @param font The font to return metrics for.     */
170    *    public abstract Rectangle getClipBounds();
171    * @return The requested font metrics.  
172    */    /**
173  public abstract FontMetrics     * Returns the bounding rectangle of the clipping region for this
174  getFontMetrics(Font font);     * graphics context.
175       *
176  /*************************************************************************/     * @return The bounding rectangle for the clipping region.
177       *
178  /**     * @deprecated This method is deprecated in favor of
179    * Returns the bounding rectangle of the clipping region for this     * <code>getClipBounds()</code>.
180    * graphics context.     */
181    *    public Rectangle getClipRect()
182    * @return The bounding rectangle for the clipping region.    {
183    */      return getClipBounds();
184  public abstract Rectangle    }
185  getClipBounds();  
186      /**
187  /*************************************************************************/     * Sets the clipping region to the intersection of the current clipping
188       * region and the rectangle determined by the specified parameters.
189  /**     *
190    * Returns the bounding rectangle of the clipping region for this     * @param x The X coordinate of the upper left corner of the intersect rect.
191    * graphics context.     * @param y The Y coordinate of the upper left corner of the intersect rect.
192    *     * @param width The width of the intersect rect.
193    * @return The bounding rectangle for the clipping region.     * @param height The height of the intersect rect.
194    *     */
195    * @deprecated This method is deprecated in favor of    public abstract void clipRect(int x, int y, int width, int height);
196    * <code>getClipBounds()</code>.  
197    */    /**
198  public Rectangle     * Sets the clipping region to the rectangle determined by the specified
199  getClipRect()     * parameters.
200  {     *
201    return(getClipBounds());     * @param x The X coordinate of the upper left corner of the rect.
202  }     * @param y The Y coordinate of the upper left corner of the rect.
203       * @param width The width of the rect.
204  /*************************************************************************/     * @param height The height of the rect.
205       */
206  /**    public abstract void setClip(int x, int y, int width, int height);
207    * Sets the clipping region to the intersection of the current clipping  
208    * region and the rectangle determined by the specified parameters.    /**
209    *     * Returns the current clipping region as a <code>Shape</code> object.
210    * @param x The X coordinate of the upper left corner of the intersect rect.     *
211    * @param y The Y coordinate of the upper left corner of the intersect rect.     * @return The clipping region as a <code>Shape</code>.
212    * @param width The width of the intersect rect.     */
213    * @param height The height of the intersect rect.    public abstract Shape getClip();
214    */  
215  public abstract void    /**
216  clipRect(int x, int y, int width, int height);     * Sets the clipping region to the specified <code>Shape</code>.
217       *
218  /*************************************************************************/     * @param clip The new clipping region.
219       */
220  /**    public abstract void setClip(Shape clip);
221    * Sets the clipping region to the rectangle determined by the specified  
222    * parameters.    /**
223    *     * Copies the specified rectangle to the specified offset location.
224    * @param x The X coordinate of the upper left corner of the rect.     *
225    * @param y The Y coordinate of the upper left corner of the rect.     * @param x The X coordinate of the upper left corner of the copy rect.
226    * @param width The width of the rect.     * @param y The Y coordinate of the upper left corner of the copy rect.
227    * @param height The height of the rect.     * @param width The width of the copy rect.
228    */     * @param height The height of the copy rect.
229  public abstract void     * @param dx The offset from the X value to start drawing.
230  setClip(int x, int y, int width, int height);     * @param dy The offset from the Y value to start drawing.
231       */
232  /*************************************************************************/    public abstract void copyArea(int x, int y, int width, int height, int dx,
233                                    int dy);
234  /**  
235    * Returns the current clipping region as a <code>Shape</code> object.    /**
236    *     * Draws a line between the two specified points.
237    * @return The clipping region as a <code>Shape</code>.     *
238    */     * @param x1 The X coordinate of the first point.
239  public abstract Shape     * @param y1 The Y coordinate of the first point.
240  getClip();     * @param x2 The X coordinate of the second point.
241       * @param y2 The Y coordinate of the second point.
242  /*************************************************************************/     */
243      public abstract void drawLine(int x1, int y1, int x2, int y2);
244  /**  
245    * Sets the clipping region to the specified <code>Shape</code>.    /**
246    *     * Fills the area bounded by the specified rectangle.
247    * @param clip The new clipping region.     *
248    */     * @param x The X coordinate of the upper left corner of the fill rect.
249  public abstract void     * @param y The Y coordinate of the upper left corner of the fill rect.
250  setClip(Shape clip);     * @param width The width of the fill rect.
251       * @param height The height of the fill rect.
252  /*************************************************************************/     */
253      public abstract void fillRect(int x, int y, int width, int height);
254  /**  
255    * Copies the specified rectangle to the specified offset location.    /**
256    *     * Draws the outline of the specified rectangle.
257    * @param x The X coordinate of the upper left corner of the copy rect.     *
258    * @param y The Y coordinate of the upper left corner of the copy rect.     * @param x The X coordinate of the upper left corner of the draw rect.
259    * @param width The width of the copy rect.     * @param y The Y coordinate of the upper left corner of the draw rect.
260    * @param height The height of the copy rect.     * @param width The width of the draw rect.
261    * @param dx The offset from the X value to start drawing.     * @param height The height of the draw rect.
262    * @param dy The offset from the Y value to start drawing.     */
263    */    public void drawRect(int x, int y, int width, int height)
264  public abstract void    {
265  copyArea(int x, int y, int width, int height, int dx, int dy);      int x1 = x;
266        int y1 = y;
267  /*************************************************************************/      int x2 = x + width;
268        int y2 = y + height;
269  /**      drawLine(x1, y1, x2, y1);
270    * Draws a line between the two specified points.      drawLine(x2, y1, x2, y2);
271    *      drawLine(x2, y2, x1, y2);
272    * @param x1 The X coordinate of the first point.      drawLine(x1, y2, x1, y1);
273    * @param y1 The Y coordinate of the first point.    }
274    * @param x2 The X coordinate of the second point.  
275    * @param y2 The Y coordinate of the second point.    /**
276    */     * Clears the specified rectangle.
277  public abstract void     *
278  drawLine(int x1, int y1, int x2, int y2);     * @param x The X coordinate of the upper left corner of the clear rect.
279       * @param y The Y coordinate of the upper left corner of the clear rect.
280  /*************************************************************************/     * @param width The width of the clear rect.
281       * @param height The height of the clear rect.
282  /**     */
283    * Fills the area bounded by the specified rectangle.    public abstract void clearRect(int x, int y, int width, int height);
284    *  
285    * @param x The X coordinate of the upper left corner of the fill rect.    /**
286    * @param y The Y coordinate of the upper left corner of the fill rect.     * Draws the outline of the specified rectangle with rounded cornders.
287    * @param width The width of the fill rect.     *
288    * @param height The height of the fill rect.     * @param x The X coordinate of the upper left corner of the draw rect.
289    */     * @param y The Y coordinate of the upper left corner of the draw rect.
290  public abstract void     * @param width The width of the draw rect.
291  fillRect(int x, int y, int width, int height);     * @param height The height of the draw rect.
292       * @param arcWidth The width of the corner arcs.
293  /*************************************************************************/     * @param arcHeight The height of the corner arcs.
294       */
295  /**    public abstract void drawRoundRect(int x, int y, int width, int height,
296    * Draws the outline of the specified rectangle.                                       int arcWidth, int arcHeight);
297    *  
298    * @param x The X coordinate of the upper left corner of the draw rect.    /**
299    * @param y The Y coordinate of the upper left corner of the draw rect.     * Fills the specified rectangle with rounded cornders.
300    * @param width The width of the draw rect.     *
301    * @param height The height of the draw rect.     * @param x The X coordinate of the upper left corner of the fill rect.
302    */     * @param y The Y coordinate of the upper left corner of the fill rect.
303  public void     * @param width The width of the fill rect.
304  drawRect(int x, int y, int width, int height)     * @param height The height of the fill rect.
305  {     * @param arcWidth The width of the corner arcs.
306    int x1 = x;     * @param arcHeight The height of the corner arcs.
307    int y1 = y;     */
308    int x2 = x + width;    public abstract void fillRoundRect(int x, int y, int width, int height,
309    int y2 = y + height;                                       int arcWidth, int arcHeight);
310    drawLine(x1, y1, x2, y1);  
311    drawLine(x2, y1, x2, y2);    public void draw3DRect(int x, int y, int width, int height, boolean raised)
312    drawLine(x2, y2, x1, y2);    {
313    drawLine(x1, y2, x1, y1);      Color color = getColor();
314  }      Color tl = color.brighter();
315        Color br = color.darker();
 /*************************************************************************/  
   
 /**  
   * Clears the specified rectangle.  
   *  
   * @param x The X coordinate of the upper left corner of the clear rect.  
   * @param y The Y coordinate of the upper left corner of the clear rect.  
   * @param width The width of the clear rect.  
   * @param height The height of the clear rect.  
   */  
 public abstract void  
 clearRect(int x, int y, int width, int height);  
   
 /*************************************************************************/  
   
 /**  
   * Draws the outline of the specified rectangle with rounded cornders.  
   *  
   * @param x The X coordinate of the upper left corner of the draw rect.  
   * @param y The Y coordinate of the upper left corner of the draw rect.  
   * @param width The width of the draw rect.  
   * @param height The height of the draw rect.  
   * @param arcWidth The width of the corner arcs.  
   * @param arcHeight The height of the corner arcs.  
   */  
 public abstract void  
 drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight);  
   
 /*************************************************************************/  
   
 /**  
   * Fills the specified rectangle with rounded cornders.  
   *  
   * @param x The X coordinate of the upper left corner of the fill rect.  
   * @param y The Y coordinate of the upper left corner of the fill rect.  
   * @param width The width of the fill rect.  
   * @param height The height of the fill rect.  
   * @param arcWidth The width of the corner arcs.  
   * @param arcHeight The height of the corner arcs.  
   */  
 public abstract void  
 fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight);  
   
 /*************************************************************************/  
   
 public void  
 draw3DRect(int x, int y, int width, int height, boolean raised)  
 {  
   Color color = getColor();  
   Color tl = color.brighter();  
   Color br = color.darker();  
316            
317    if (!raised)      if (!raised)
318      {        {
319        Color tmp = tl;          Color tmp = tl;
320        tl = br;          tl = br;
321        br = tmp;          br = tmp;
322      }        }
323            
324    int x1 = x;      int x1 = x;
325    int y1 = y;      int y1 = y;
326    int x2 = x + width;      int x2 = x + width;
327    int y2 = y + height;      int y2 = y + height;
328            
329    setColor(tl);      setColor(tl);
330    drawLine(x1, y1, x2, y1);      drawLine(x1, y1, x2, y1);
331    drawLine(x1, y2, x1, y1);      drawLine(x1, y2, x1, y1);
332    setColor(br);      setColor(br);
333    drawLine(x2, y1, x2, y2);      drawLine(x2, y1, x2, y2);
334    drawLine(x2, y2, x1, y2);      drawLine(x2, y2, x1, y2);
335    setColor(color);      setColor(color);
336  }    }
337    
338  /**    /**
339    * Fills the specified rectangle with a 3D effect     * Fills the specified rectangle with a 3D effect
340    *     *
341    * @param x The X coordinate of the upper left corner of the fill rect.     * @param x The X coordinate of the upper left corner of the fill rect.
342    * @param y The Y coordinate of the upper left corner of the fill rect.     * @param y The Y coordinate of the upper left corner of the fill rect.
343    * @param width The width of the fill rect.     * @param width The width of the fill rect.
344    * @param height The height of the fill rect.     * @param height The height of the fill rect.
345    * @param raised <code>true</code> if the rectangle appears raised,     * @param raised <code>true</code> if the rectangle appears raised,
346    * <code>false</code> if it should appear etched.     * <code>false</code> if it should appear etched.
347    */     */
348  public void    public void fill3DRect(int x, int y, int width, int height, boolean raised)
349  fill3DRect(int x, int y, int width, int height, boolean raised)    {
350  {      fillRect(x, y, width, height);
351    fillRect(x, y, width, height);      draw3DRect(x, y, width-1, height-1, raised);
352    draw3DRect(x, y, width-1, height-1, raised);    }
353  }  
354      /**
355  /*************************************************************************/     * Draws an oval that just fits within the specified rectangle.
356       *
357  /**     * @param x The X coordinate of the upper left corner of the rect.
358    * Draws an oval that just fits within the specified rectangle.     * @param y The Y coordinate of the upper left corner of the rect.
359    *     * @param width The width of the rect.
360    * @param x The X coordinate of the upper left corner of the rect.     * @param height The height of the rect.
361    * @param y The Y coordinate of the upper left corner of the rect.     */
362    * @param width The width of the rect.    public abstract void drawOval(int x, int y, int width, int height);
363    * @param height The height of the rect.  
364    */    /**
365  public abstract void     * Fills an oval that just fits within the specified rectangle.
366  drawOval(int x, int y, int width, int height);     *
367       * @param x The X coordinate of the upper left corner of the rect.
368  /*************************************************************************/     * @param y The Y coordinate of the upper left corner of the rect.
369       * @param width The width of the rect.
370  /**     * @param height The height of the rect.
371    * Fills an oval that just fits within the specified rectangle.     */
372    *    public abstract void fillOval(int x, int y, int width, int height);
373    * @param x The X coordinate of the upper left corner of the rect.  
374    * @param y The Y coordinate of the upper left corner of the rect.    /**
375    * @param width The width of the rect.     * Draws an arc using the specified bounding rectangle and the specified
376    * @param height The height of the rect.     * angle parameter.  The arc is centered at the center of the rectangle.
377    */     * The arc starts at the arcAngle position and extend for arcAngle
378  public abstract void     * degrees.  The degree origin is at the 3 o'clock position.
379  fillOval(int x, int y, int width, int height);     *
380       * @param x The X coordinate of the upper left corner of the rect.
381  /*************************************************************************/     * @param y The Y coordinate of the upper left corner of the rect.
382       * @param width The width of the rect.
383  /**     * @param height The height of the rect.
384    * Draws an arc using the specified bounding rectangle and the specified     * @param arcStart The beginning angle of the arc.
385    * angle parameter.  The arc is centered at the center of the rectangle.     * @param arcAngle The extent of the arc.
386    * The arc starts at the arcAngle position and extend for arcAngle     */
387    * degrees.  The degree origin is at the 3 o'clock position.    public abstract void drawArc(int x, int y, int width, int height,
388    *                                 int arcStart, int arcAngle);
389    * @param x The X coordinate of the upper left corner of the rect.  
390    * @param y The Y coordinate of the upper left corner of the rect.    /**
391    * @param width The width of the rect.     * Fills the arc define by the specified bounding rectangle and the specified
392    * @param height The height of the rect.     * angle parameter.  The arc is centered at the center of the rectangle.
393    * @param arcStart The beginning angle of the arc.     * The arc starts at the arcAngle position and extend for arcAngle
394    * @param arcAngle The extent of the arc.     * degrees.  The degree origin is at the 3 o'clock position.
395    */     *
396  public abstract void     * @param x The X coordinate of the upper left corner of the rect.
397  drawArc(int x, int y, int width, int height, int arcStart, int arcAngle);     * @param y The Y coordinate of the upper left corner of the rect.
398       * @param width The width of the rect.
399  /*************************************************************************/     * @param height The height of the rect.
400       * @param arcStart The beginning angle of the arc.
401  /**     * @param arcAngle The extent of the arc.
402    * Fills the arc define by the specified bounding rectangle and the specified     */
403    * angle parameter.  The arc is centered at the center of the rectangle.    public abstract void fillArc(int x, int y, int width, int height,
404    * The arc starts at the arcAngle position and extend for arcAngle                                 int arcStart, int arcAngle);
405    * degrees.  The degree origin is at the 3 o'clock position.  
406    *    /**
407    * @param x The X coordinate of the upper left corner of the rect.     * Draws a series of interconnected lines determined by the arrays
408    * @param y The Y coordinate of the upper left corner of the rect.     * of corresponding x and y coordinates.
409    * @param width The width of the rect.     *
410    * @param height The height of the rect.     * @param xPoints The X coordinate array.
411    * @param arcStart The beginning angle of the arc.     * @param yPoints The Y coordinate array.
412    * @param arcAngle The extent of the arc.     * @param npoints The number of points to draw.
413    */     */
414  public abstract void    public abstract void drawPolyline(int xPoints[], int yPoints[], int npoints);
415  fillArc(int x, int y, int width, int height, int arcStart, int arcAngle);  
416      /**
417  /*************************************************************************/     * Draws a series of interconnected lines determined by the arrays
418       * of corresponding x and y coordinates.  The figure is closed if necessary
419  /**     * by connecting the first and last points.
420    * Draws a series of interconnected lines determined by the arrays     *
421    * of corresponding x and y coordinates.     * @param xPoints The X coordinate array.
422    *     * @param yPoints The Y coordinate array.
423    * @param xPoints The X coordinate array.     * @param npoints The number of points to draw.
424    * @param yPoints The Y coordinate array.     */
425    * @param npoints The number of points to draw.    public abstract void drawPolygon(int xPoints[], int yPoints[], int npoints);
426    */  
427  public abstract void    /**
428  drawPolyline(int xPoints[], int yPoints[], int npoints);     * Draws the specified polygon.
429       *
430  /*************************************************************************/     * @param polygon The polygon to draw.
431       */
432  /**    public void drawPolygon(Polygon polygon)
433    * Draws a series of interconnected lines determined by the arrays    {
434    * of corresponding x and y coordinates.  The figure is closed if necessary      drawPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
435    * by connecting the first and last points.    }
436    *  
437    * @param xPoints The X coordinate array.    /**
438    * @param yPoints The Y coordinate array.     * Fills the polygon determined by the arrays
439    * @param npoints The number of points to draw.     * of corresponding x and y coordinates.
440    */     *
441  public abstract void     * @param xPoints The X coordinate array.
442  drawPolygon(int xPoints[], int yPoints[], int npoints);     * @param yPoints The Y coordinate array.
443       * @param npoints The number of points to draw.
444  /*************************************************************************/     */
445      public abstract void fillPolygon(int xPoints[], int yPoints[], int npoints);
446  /**  
447    * Draws the specified polygon.    /**
448    *     * Fills the specified polygon
449    * @param polygon The polygon to draw.     *
450    */     * @param polygon The polygon to fill.
451  public void     */
452  drawPolygon(Polygon polygon)    public void fillPolygon(Polygon polygon)
453  {    {
454    drawPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);      fillPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
455  }    }
456    
457  /*************************************************************************/    /**
458       * Draws the specified string starting at the specified point.
459  /**     *
460    * Fills the polygon determined by the arrays     * @param string The string to draw.
461    * of corresponding x and y coordinates.     * @param x The X coordinate of the point to draw at.
462    *     * @param y The Y coordinate of the point to draw at.
463    * @param xPoints The X coordinate array.     */
464    * @param yPoints The Y coordinate array.    public abstract void drawString(String string, int x, int y);
465    * @param npoints The number of points to draw.  
466    */    public abstract void drawString (AttributedCharacterIterator ci, int x,
467  public abstract void                                     int y);
468  fillPolygon(int xPoints[], int yPoints[], int npoints);  
469      /**
470  /*************************************************************************/     * Draws the specified characters starting at the specified point.
471       *
472  /**     * @param data The array of characters to draw.
473    * Fills the specified polygon     * @param offset The offset into the array to start drawing characters from.
474    *     * @param length The number of characters to draw.
475    * @param polygon The polygon to fill.     * @param x The X coordinate of the point to draw at.
476    */     * @param y The Y coordinate of the point to draw at.
477  public void     */
478  fillPolygon(Polygon polygon)    public void drawChars(char data[], int offset, int length, int x, int y)
479  {    {
480    fillPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);      drawString(new String(data, offset, length), x, y);
481  }    }
482    
483  /*************************************************************************/    public void drawBytes(byte[] data, int offset, int length, int x, int y)
484      {
485  /**      String str = new String(data, offset, length);
486    * Draws the specified string starting at the specified point.      drawString(str, x, y);
487    *    }
488    * @param string The string to draw.  
489    * @param x The X coordinate of the point to draw at.    /**
490    * @param y The Y coordinate of the point to draw at.     * Draws all of the image that is available and returns.  If the image
491    */     * is not completely loaded, <code>false</code> is returned and
492  public abstract void     * the specified iamge observer is notified as more data becomes
493  drawString(String string, int x, int y);     * available.
494       *
495  public abstract void drawString (AttributedCharacterIterator ci, int x, int y);     * @param image The image to draw.
496       * @param x The X coordinate of the point to draw at.
497  /*************************************************************************/     * @param y The Y coordinate of the point to draw at.
498       * @param observer The image observer to notify as data becomes available.
499  /**     *
500    * Draws the specified characters starting at the specified point.     * @return <code>true</code> if all the image data is available,
501    *     * <code>false</code> otherwise.
502    * @param data The array of characters to draw.     */
503    * @param offset The offset into the array to start drawing characters from.    public abstract boolean drawImage(Image image, int x, int y,
504    * @param length The number of characters to draw.                                      ImageObserver observer);
   * @param x The X coordinate of the point to draw at.  
   * @param y The Y coordinate of the point to draw at.  
   */  
 public void  
 drawChars(char data[], int offset, int length, int x, int y)  
 {  
   drawString(new String(data, offset, length), x, y);  
 }  
   
 public void  
 drawBytes(byte[] data, int offset, int length, int x, int y)  
 {  
   String str = new String(data, offset, length);  
   drawString(str, x, y);  
 }  
   
 /*************************************************************************/  
   
 /**  
   * Draws all of the image that is available and returns.  If the image  
   * is not completely loaded, <code>false</code> is returned and  
   * the specified iamge observer is notified as more data becomes  
   * available.  
   *  
   * @param image The image to draw.  
   * @param x The X coordinate of the point to draw at.  
   * @param y The Y coordinate of the point to draw at.  
   * @param observer The image observer to notify as data becomes available.  
   *  
   * @return <code>true</code> if all the image data is available,  
   * <code>false</code> otherwise.  
   */  
 public abstract boolean  
 drawImage(Image image, int x, int y, ImageObserver observer);  
505    
506  /*************************************************************************/    /**
507       * Draws all of the image that is available and returns.  The image
508  /**     * is scaled to fit in the specified rectangle.  If the image
509    * Draws all of the image that is available and returns.  The image     * is not completely loaded, <code>false</code> is returned and
510    * is scaled to fit in the specified rectangle.  If the image     * the specified iamge observer is notified as more data becomes
511    * is not completely loaded, <code>false</code> is returned and     * available.
512    * the specified iamge observer is notified as more data becomes     *
513    * available.     * @param image The image to draw.
514    *     * @param x The X coordinate of the point to draw at.
515    * @param image The image to draw.     * @param y The Y coordinate of the point to draw at.
516    * @param x The X coordinate of the point to draw at.     * @param width The width of the rectangle to draw in.
517    * @param y The Y coordinate of the point to draw at.     * @param height The height of the rectangle to draw in.
518    * @param width The width of the rectangle to draw in.     * @param observer The image observer to notify as data becomes available.
519    * @param height The height of the rectangle to draw in.     *
520    * @param observer The image observer to notify as data becomes available.     * @return <code>true</code> if all the image data is available,
521    *     * <code>false</code> otherwise.
522    * @return <code>true</code> if all the image data is available,     */
523    * <code>false</code> otherwise.    public abstract boolean drawImage(Image image, int x, int y, int width,
524    */                                      int height, ImageObserver observer);
 public abstract boolean  
 drawImage(Image image, int x, int y, int width, int height,  
           ImageObserver observer);  
   
 /*************************************************************************/  
   
 /**  
   * Draws all of the image that is available and returns.  If the image  
   * is not completely loaded, <code>false</code> is returned and  
   * the specified iamge observer is notified as more data becomes  
   * available.  
   *  
   * @param image The image to draw.  
   * @param x The X coordinate of the point to draw at.  
   * @param y The Y coordinate of the point to draw at.  
   * @param bgcolor The background color to use for the image.  
   * @param observer The image observer to notify as data becomes available.  
   *  
   * @return <code>true</code> if all the image data is available,  
   * <code>false</code> otherwise.  
   */  
 public abstract boolean  
 drawImage(Image image, int x, int y, Color bgcolor, ImageObserver observer);  
525    
526  /*************************************************************************/    /**
527       * Draws all of the image that is available and returns.  If the image
528  /**     * is not completely loaded, <code>false</code> is returned and
529    * Draws all of the image that is available and returns.  The image     * the specified iamge observer is notified as more data becomes
530    * is scaled to fit in the specified rectangle.  If the image     * available.
531    * is not completely loaded, <code>false</code> is returned and     *
532    * the specified iamge observer is notified as more data becomes     * @param image The image to draw.
533    * available.     * @param x The X coordinate of the point to draw at.
534    *     * @param y The Y coordinate of the point to draw at.
535    * @param image The image to draw.     * @param bgcolor The background color to use for the image.
536    * @param x The X coordinate of the point to draw at.     * @param observer The image observer to notify as data becomes available.
537    * @param y The Y coordinate of the point to draw at.     *
538    * @param width The width of the rectangle to draw in.     * @return <code>true</code> if all the image data is available,
539    * @param height The height of the rectangle to draw in.     * <code>false</code> otherwise.
540    * @param bgcolor The background color to use for the image.     */
541    * @param observer The image observer to notify as data becomes available.    public abstract boolean drawImage(Image image, int x, int y, Color bgcolor,
542    *                                      ImageObserver observer);
   * @return <code>true</code> if all the image data is available,  
   * <code>false</code> otherwise.  
   */  
 public abstract boolean  
 drawImage(Image image, int x, int y, int width, int height, Color bgcolor,  
           ImageObserver observer);  
543    
544  /*************************************************************************/    /**
545       * Draws all of the image that is available and returns.  The image
546  /**     * is scaled to fit in the specified rectangle.  If the image
547    * FIXME: Write Javadocs for this when you understand it.     * is not completely loaded, <code>false</code> is returned and
548    */     * the specified iamge observer is notified as more data becomes
549  public abstract boolean     * available.
550  drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,     *
551            int sx2, int sy2, ImageObserver observer);     * @param image The image to draw.
552       * @param x The X coordinate of the point to draw at.
553  /*************************************************************************/     * @param y The Y coordinate of the point to draw at.
554       * @param width The width of the rectangle to draw in.
555  /**     * @param height The height of the rectangle to draw in.
556    * FIXME: Write Javadocs for this when you understand it.     * @param bgcolor The background color to use for the image.
557    */     * @param observer The image observer to notify as data becomes available.
558  public abstract boolean     *
559  drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,     * @return <code>true</code> if all the image data is available,
560            int sx2, int sy2, Color bgcolor, ImageObserver observer);     * <code>false</code> otherwise.
561       */
562  /*************************************************************************/    public abstract boolean drawImage(Image image, int x, int y, int width,
563                                        int height, Color bgcolor,
564  /**                                      ImageObserver observer);
565    * Free any resources held by this graphics context immediately instead  
566    * of waiting for the object to be garbage collected and finalized.    /**
567    */     * FIXME: Write Javadocs for this when you understand it.
568  public abstract void     */
569  dispose();    public abstract boolean drawImage(Image image, int dx1, int dy1, int dx2,
570                                        int dy2, int sx1, int sy1, int sx2,
571  /*************************************************************************/                                      int sy2, ImageObserver observer);
572    
573  /**    /**
574    * Frees the resources held by this graphics context when it is     * FIXME: Write Javadocs for this when you understand it.
575    * garbage collected.     */
576    */    public abstract boolean drawImage(Image image, int dx1, int dy1, int dx2,
577  public void                                      int dy2, int sx1, int sy1, int sx2,
578  finalize()                                      int sy2, Color bgcolor,
579  {                                      ImageObserver observer);
580    dispose();  
581  }    /**
582       * Free any resources held by this graphics context immediately instead
583  /*************************************************************************/     * of waiting for the object to be garbage collected and finalized.
584       */
585  /**    public abstract void dispose();
586   * Returns a string representation of this object.  
587   *    /**
588   * @return A string representation of this object.     * Frees the resources held by this graphics context when it is
589   */     * garbage collected.
590  public String     */
591  toString()    public void finalize()
592  {    {
593    return getClass ().getName () + "[font=" + getFont () + ",color=" + getColor () + "]";      dispose();
594  }    }
595    
596  public boolean    /**
597  hitClip(int x, int y, int width, int height)     * Returns a string representation of this object.
598  {     *
599    throw new UnsupportedOperationException("not implemented yet");     * @return A string representation of this object.
600  }     */
601      public String toString()
602  public Rectangle    {
603  getClipBounds(Rectangle r)      return getClass ().getName () + "[font=" + getFont () + ",color="
604  {             + getColor () + "]";
605    Rectangle clipBounds = getClipBounds();    }
606    
607      /**
608       * Returns <code>true</code> if the specified rectangle intersects with the
609       * current clip, <code>false</code> otherwise.
610       *
611       * @param x the X coordinate of the upper left corner of the test rectangle
612       * @param y the Y coordinate of the upper left corner of the test rectangle
613       * @param width the width of the upper left corner of the test rectangle
614       * @param height the height of the upper left corner of the test rectangle
615       * @return <code>true</code> if the specified rectangle intersects with the
616       *         current clip, <code>false</code> otherwise
617       */
618      public boolean hitClip(int x, int y, int width, int height)
619      {
620        return getClip().intersects(x, y, width, height);
621      }
622    
623      public Rectangle getClipBounds(Rectangle r)
624      {
625        Rectangle clipBounds = getClipBounds();
626        
627    if (r == null)      if (r == null)
628      return clipBounds;        return clipBounds;
629    
630    r.x      = clipBounds.x;      r.x      = clipBounds.x;
631    r.y      = clipBounds.y;      r.y      = clipBounds.y;
632    r.width  = clipBounds.width;      r.width  = clipBounds.width;
633    r.height = clipBounds.height;      r.height = clipBounds.height;
634    return r;      return r;
635      }
636  }  }
   
 } // class Graphics  
   

Legend:
Removed from v.1.10.2.3  
changed lines
  Added in v.1.10.2.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26