Graphics.java 24 KB

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