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