1. /*
  2. * @(#)Graphics2D.java 1.70 00/02/02
  3. *
  4. * Copyright 1996-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.awt.RenderingHints.Key;
  12. import java.awt.geom.AffineTransform;
  13. import java.awt.image.ImageObserver;
  14. import java.awt.image.BufferedImageOp;
  15. import java.awt.image.BufferedImage;
  16. import java.awt.image.RenderedImage;
  17. import java.awt.image.renderable.RenderableImage;
  18. import java.awt.font.GlyphVector;
  19. import java.awt.font.FontRenderContext;
  20. import java.text.AttributedCharacterIterator;
  21. import java.util.Map;
  22. /**
  23. * This <code>Graphics2D</code> class extends the
  24. * {@link Graphics} class to provide more sophisticated
  25. * control over geometry, coordinate transformations, color management,
  26. * and text layout. This is the fundamental class for rendering
  27. * 2-dimensional shapes, text and images on the Java(tm) platform.
  28. * <p>
  29. * <h2>Coordinate Spaces</h2>
  30. * All coordinates passed to a <code>Graphics2D</code> object are specified
  31. * in a device-independent coordinate system called User Space, which is
  32. * used by applications. The <code>Graphics2D</code> object contains
  33. * an {@link AffineTransform} object as part of its rendering state
  34. * that defines how to convert coordinates from user space to
  35. * device-dependent coordinates in Device Space.
  36. * <p>
  37. * Coordinates in device space usually refer to individual device pixels
  38. * and are aligned on the infinitely thin gaps between these pixels.
  39. * Some <code>Graphics2D</code> objects can be used to capture rendering
  40. * operations for storage into a graphics metafile for playback on a
  41. * concrete device of unknown physical resolution at a later time. Since
  42. * the resolution might not be known when the rendering operations are
  43. * captured, the <code>Graphics2D</code> <code>Transform</code> is set up
  44. * to transform user coordinates to a virtual device space that
  45. * approximates the expected resolution of the target device. Further
  46. * transformations might need to be applied at playback time if the
  47. * estimate is incorrect.
  48. * <p>
  49. * Some of the operations performed by the rendering attribute objects
  50. * occur in the device space, but all <code>Graphics2D</code> methods take
  51. * user space coordinates.
  52. * <p>
  53. * Every <code>Graphics2D</code> object is associated with a target that
  54. * defines where rendering takes place. A
  55. * {@link GraphicsConfiguration} object defines the characteristics
  56. * of the rendering target, such as pixel format and resolution.
  57. * The same rendering target is used throughout the life of a
  58. * <code>Graphics2D</code> object.
  59. * <p>
  60. * When creating a <code>Graphics2D</code> object, the
  61. * <code>GraphicsConfiguration</code>
  62. * specifies the <a name="#deftransform">default transform</a> for
  63. * the target of the <code>Graphics2D</code> (a
  64. * {@link Component} or {@link Image}). This default transform maps the
  65. * user space coordinate system to screen and printer device coordinates
  66. * such that the origin maps to the upper left hand corner of the
  67. * target region of the device with increasing X coordinates extending
  68. * to the right and increasing Y coordinates extending downward.
  69. * The scaling of the default transform is set to identity for those devices
  70. * that are close to 72 dpi, such as screen devices.
  71. * The scaling of the default transform is set to approximately 72 user
  72. * space coordinates per square inch for high resolution devices, such as
  73. * printers. For image buffers, the default transform is the
  74. * <code>Identity</code> transform.
  75. *
  76. * <h2>Rendering Process</h2>
  77. * The Rendering Process can be broken down into four phases that are
  78. * controlled by the <code>Graphics2D</code> rendering attributes.
  79. * The renderer can optimize many of these steps, either by caching the
  80. * results for future calls, by collapsing multiple virtual steps into
  81. * a single operation, or by recognizing various attributes as common
  82. * simple cases that can be eliminated by modifying other parts of the
  83. * operation.
  84. * <p>
  85. * The steps in the rendering process are:
  86. * <ol>
  87. * <li>
  88. * Determine what to render.
  89. * <li>
  90. * Constrain the rendering operation to the current <code>Clip</code>.
  91. * The <code>Clip</code> is specified by a {@link Shape} in user
  92. * space and is controlled by the program using the various clip
  93. * manipulation methods of <code>Graphics</code> and
  94. * <code>Graphics2D</code>. This <i>user clip</i>
  95. * is transformed into device space by the current
  96. * <code>Transform</code> and combined with the
  97. * <i>device clip</i>, which is defined by the visibility of windows and
  98. * device extents. The combination of the user clip and device clip
  99. * defines the <i>composite clip</i>, which determines the final clipping
  100. * region. The user clip is not modified by the rendering
  101. * system to reflect the resulting composite clip.
  102. * <li>
  103. * Determine what colors to render.
  104. * <li>
  105. * Apply the colors to the destination drawing surface using the current
  106. * {@link Composite} attribute in the <code>Graphics2D</code> context.
  107. * </ol>
  108. * <br>
  109. * The three types of rendering operations, along with details of each
  110. * of their particular rendering processes are:
  111. * <ol>
  112. * <li>
  113. * <b><a name="rendershape"><code>Shape</code> operations</a></b>
  114. * <ol>
  115. * <li>
  116. * If the operation is a <code>draw(Shape)</code> operation, then
  117. * the {@link Stroke#createStrokedShape(Shape) createStrokedShape}
  118. * method on the current {@link Stroke} attribute in the
  119. * <code>Graphics2D</code> context is used to construct a new
  120. * <code>Shape</code> object that contains the outline of the specified
  121. * <code>Shape</code>.
  122. * <li>
  123. * The <code>Shape</code> is transformed from user space to device space
  124. * using the current <code>Transform</code>
  125. * in the <code>Graphics2D</code> context.
  126. * <li>
  127. * The outline of the <code>Shape</code> is extracted using the
  128. * {@link Shape#getPathIterator(AffineTransform) getPathIterator} method of
  129. * <code>Shape</code>, which returns a
  130. * {@link java.awt.geom.PathIterator PathIterator}
  131. * object that iterates along the boundary of the <code>Shape</code>.
  132. * <li>
  133. * If the <code>Graphics2D</code> object cannot handle the curved segments
  134. * that the <code>PathIterator</code> object returns then it can call the
  135. * alternate
  136. * {@link Shape#getPathIterator(AffineTransform, double) getPathIterator}
  137. * method of <code>Shape</code>, which flattens the <code>Shape</code>.
  138. * <li>
  139. * The current {@link Paint} in the <code>Graphics2D</code> context
  140. * is queried for a {@link PaintContext}, which specifies the
  141. * colors to render in device space.
  142. * </ol>
  143. * <li>
  144. * <b><a name=rendertext>Text operations</a></b>
  145. * <ol>
  146. * <li>
  147. * The following steps are used to determine the set of glyphs required
  148. * to render the indicated <code>String</code>:
  149. * <ol>
  150. * <li>
  151. * If the argument is a <code>String</code>, then the current
  152. * <code>Font</code> in the <code>Graphics2D</code> context is asked to
  153. * convert the Unicode characters in the <code>String</code> into a set of
  154. * glyphs for presentation with whatever basic layout and shaping
  155. * algorithms the font implements.
  156. * <li>
  157. * If the argument is an
  158. * {@link AttributedCharacterIterator},
  159. * the iterator is asked to convert itself to a
  160. * {@link java.awt.font.TextLayout TextLayout}
  161. * using its embedded font attributes. The <code>TextLayout</code>
  162. * implements more sophisticated glyph layout algorithms that
  163. * perform Unicode bi-directional layout adjustments automatically
  164. * for multiple fonts of differing writing directions.
  165. * <li>
  166. * If the argument is a
  167. * {@link GlyphVector}, then the
  168. * <code>GlyphVector</code> object already contains the appropriate
  169. * font-specific glyph codes with explicit coordinates for the position of
  170. * each glyph.
  171. * </ol>
  172. * <li>
  173. * The current <code>Font</code> is queried to obtain outlines for the
  174. * indicated glyphs. These outlines are treated as shapes in user space
  175. * relative to the position of each glyph that was determined in step 1.
  176. * <li>
  177. * The character outlines are filled as indicated above
  178. * under <a href="#rendershape"><code>Shape</code> operations</a>.
  179. * <li>
  180. * The current <code>Paint</code> is queried for a
  181. * <code>PaintContext</code>, which specifies
  182. * the colors to render in device space.
  183. * </ol>
  184. * <li>
  185. * <b><a name= renderingimage><code>Image</code> Operations</a></b>
  186. * <ol>
  187. * <li>
  188. * The region of interest is defined by the bounding box of the source
  189. * <code>Image</code>.
  190. * This bounding box is specified in Image Space, which is the
  191. * <code>Image</code> object's local coordinate system.
  192. * <li>
  193. * If an <code>AffineTransform</code> is passed to
  194. * {@link #drawImage(java.awt.Image, java.awt.geom.AffineTransform, java.awt.image.ImageObserver) drawImage(Image, AffineTransform, ImageObserver)},
  195. * the <code>AffineTransform</code> is used to transform the bounding
  196. * box from image space to user space. If no <code>AffineTransform</code>
  197. * is supplied, the bounding box is treated as if it is already in user space.
  198. * <li>
  199. * The bounding box of the source <code>Image</code> is transformed from user
  200. * space into device space using the current <code>Transform</code>.
  201. * Note that the result of transforming the bounding box does not
  202. * necessarily result in a rectangular region in device space.
  203. * <li>
  204. * The <code>Image</code> object determines what colors to render,
  205. * sampled according to the source to destination
  206. * coordinate mapping specified by the current <code>Transform</code> and the
  207. * optional image transform.
  208. * </ol>
  209. * </ol>
  210. *
  211. * <h2>Default Rendering Attributes</h2>
  212. * The default values for the <code>Graphics2D</code> rendering attributes are:
  213. * <dl compact>
  214. * <dt><i><code>Paint</code></i>
  215. * <dd>The color of the <code>Component</code>.
  216. * <dt><i><code>Font</code></i>
  217. * <dd>The <code>Font</code> of the <code>Component</code>.
  218. * <dt><i><code>Stroke</code></i>
  219. * <dd>A square pen with a linewidth of 1, no dashing, miter segment joins
  220. * and square end caps.
  221. * <dt><i><code>Transform</code></i>
  222. * <dd>The
  223. * {@link GraphicsConfiguration#getDefaultTransform() getDefaultTransform}
  224. * for the <code>GraphicsConfiguration</code> of the <code>Component</code>.
  225. * <dt><i><code>Composite</code></i>
  226. * <dd>The {@link AlphaComposite#SRC_OVER} rule.
  227. * <dt><i><code>Clip</code></i>
  228. * <dd>No rendering <code>Clip</code>, the output is clipped to the
  229. * <code>Component</code>.
  230. * </dl>
  231. *
  232. * <h2>Rendering Compatibility Issues</h2>
  233. * The JDK(tm) 1.1 rendering model is based on a pixelization model
  234. * that specifies that coordinates
  235. * are infinitely thin, lying between the pixels. Drawing operations are
  236. * performed using a one-pixel wide pen that fills the
  237. * pixel below and to the right of the anchor point on the path.
  238. * The JDK 1.1 rendering model is consistent with the
  239. * capabilities of most of the existing class of platform
  240. * renderers that need to resolve integer coordinates to a
  241. * discrete pen that must fall completely on a specified number of pixels.
  242. * <p>
  243. * The Java 2D(tm) (Java(tm) 2 platform) API supports antialiasing renderers.
  244. * A pen with a width of one pixel does not need to fall
  245. * completely on pixel N as opposed to pixel N+1. The pen can fall
  246. * partially on both pixels. It is not necessary to choose a bias
  247. * direction for a wide pen since the blending that occurs along the
  248. * pen traversal edges makes the sub-pixel position of the pen
  249. * visible to the user. On the other hand, when antialiasing is
  250. * turned off by setting the
  251. * {@link RenderingHints#KEY_ANTIALIASING KEY_ANTIALIASING} hint key
  252. * to the
  253. * {@link RenderingHints#VALUE_ANTIALIAS_OFF VALUE_ANTIALIAS_OFF}
  254. * hint value, the renderer might need
  255. * to apply a bias to determine which pixel to modify when the pen
  256. * is straddling a pixel boundary, such as when it is drawn
  257. * along an integer coordinate in device space. While the capabilities
  258. * of an antialiasing renderer make it no longer necessary for the
  259. * rendering model to specify a bias for the pen, it is desirable for the
  260. * antialiasing and non-antialiasing renderers to perform similarly for
  261. * the common cases of drawing one-pixel wide horizontal and vertical
  262. * lines on the screen. To ensure that turning on antialiasing by
  263. * setting the
  264. * {@link RenderingHints#KEY_ANTIALIASING KEY_ANTIALIASING} hint
  265. * key to
  266. * {@link RenderingHints#VALUE_ANTIALIAS_ON VALUE_ANTIALIAS_ON}
  267. * does not cause such lines to suddenly become twice as wide and half
  268. * as opaque, it is desirable to have the model specify a path for such
  269. * lines so that they completely cover a particular set of pixels to help
  270. * increase their crispness.
  271. * <p>
  272. * Java 2D API maintains compatibility with JDK 1.1 rendering
  273. * behavior, such that legacy operations and existing renderer
  274. * behavior is unchanged under Java 2D API. Legacy
  275. * methods that map onto general <code>draw</code> and
  276. * <code>fill</code> methods are defined, which clearly indicates
  277. * how <code>Graphics2D</code> extends <code>Graphics</code> based
  278. * on settings of <code>Stroke</code> and <code>Transform</code>
  279. * attributes and rendering hints. The definition
  280. * performs identically under default attribute settings.
  281. * For example, the default <code>Stroke</code> is a
  282. * <code>BasicStroke</code> with a width of 1 and no dashing and the
  283. * default Transform for screen drawing is an Identity transform.
  284. * <p>
  285. * The following two rules provide predictable rendering behavior whether
  286. * aliasing or antialiasing is being used.
  287. * <ul>
  288. * <li> Device coordinates are defined to be between device pixels which
  289. * avoids any inconsistent results between aliased and antaliased
  290. * rendering. If coordinates were defined to be at a pixel's center, some
  291. * of the pixels covered by a shape, such as a rectangle, would only be
  292. * half covered.
  293. * With aliased rendering, the half covered pixels would either be
  294. * rendered inside the shape or outside the shape. With anti-aliased
  295. * rendering, the pixels on the entire edge of the shape would be half
  296. * covered. On the other hand, since coordinates are defined to be
  297. * between pixels, a shape like a rectangle would have no half covered
  298. * pixels, whether or not it is rendered using antialiasing.
  299. * <li> Lines and paths stroked using the <code>BasicStroke</code>
  300. * object may be "normalized" to provide consistent rendering of the
  301. * outlines when positioned at various points on the drawable and
  302. * whether drawn with aliased or antialiased rendering. This
  303. * normalization process is controlled by the
  304. * {@link RenderingHints#KEY_STROKE_CONTROL KEY_STROKE_CONTROL} hint.
  305. * The exact normalization algorithm is not specified, but the goals
  306. * of this normalization are to ensure that lines are rendered with
  307. * consistent visual appearance regardless of how they fall on the
  308. * pixel grid and to promote more solid horizontal and vertical
  309. * lines in antialiased mode so that they resemble their non-antialiased
  310. * counterparts more closely. A typical normalization step might
  311. * promote antialiased line endpoints to pixel centers to reduce the
  312. * amount of blending or adjust the subpixel positioning of
  313. * non-antialiased lines so that the floating point line widths
  314. * round to even or odd pixel counts with equal likelihood. This
  315. * process can move endpoints by up to half a pixel (usually towards
  316. * positive infinity along both axes) to promote these consistent
  317. * results.
  318. * </ul>
  319. * <p>
  320. * The following definitions of general legacy methods
  321. * perform identically to previously specified behavior under default
  322. * attribute settings:
  323. * <ul>
  324. * <li>
  325. * For <code>fill</code> operations, including <code>fillRect</code>,
  326. * <code>fillRoundRect</code>, <code>fillOval</code>,
  327. * <code>fillArc</code>, <code>fillPolygon</code>, and
  328. * <code>clearRect</code>, {@link #fill(Shape) fill} can now be called
  329. * with the desired <code>Shape</code>. For example, when filling a
  330. * rectangle:
  331. * <pre>
  332. * fill(new Rectangle(x, y, w, h));
  333. * </pre>
  334. * is called.
  335. * <p>
  336. * <li>
  337. * Similarly, for draw operations, including <code>drawLine</code>,
  338. * <code>drawRect</code>, <code>drawRoundRect</code>,
  339. * <code>drawOval</code>, <code>drawArc</code>, <code>drawPolyline</code>,
  340. * and <code>drawPolygon</code>, {@link #draw(Shape) draw} can now be
  341. * called with the desired <code>Shape</code>. For example, when drawing a
  342. * rectangle:
  343. * <pre>
  344. * draw(new Rectangle(x, y, w, h));
  345. * </pre>
  346. * is called.
  347. * <p>
  348. * <li>
  349. * The <code>draw3DRect</code> and <code>fill3DRect</code> methods were
  350. * implemented in terms of the <code>drawLine</code> and
  351. * <code>fillRect</code> methods in the <code>Graphics</code> class which
  352. * would predicate their behavior upon the current <code>Stroke</code>
  353. * and <code>Paint</code> objects in a <code>Graphics2D</code> context.
  354. * This class overrides those implementations with versions that use
  355. * the current <code>Color</code> exclusively, overriding the current
  356. * <code>Paint</code> and which uses <code>fillRect</code> to describe
  357. * the exact same behavior as the preexisting methods regardless of the
  358. * setting of the current <code>Stroke</code>.
  359. * </ul>
  360. * The <code>Graphics</code> class defines only the <code>setColor</code>
  361. * method to control the color to be painted. Since the Java 2D API extends
  362. * the <code>Color</code> object to implement the new <code>Paint</code>
  363. * interface, the existing
  364. * <code>setColor</code> method is now a convenience method for setting the
  365. * current <code>Paint</code> attribute to a <code>Color</code> object.
  366. * <code>setColor(c)</code> is equivalent to <code>setPaint(c)</code>.
  367. * <p>
  368. * The <code>Graphics</code> class defines two methods for controlling
  369. * how colors are applied to the destination.
  370. * <ol>
  371. * <li>
  372. * The <code>setPaintMode</code> method is implemented as a convenience
  373. * method to set the default <code>Composite</code>, equivalent to
  374. * <code>setComposite(new AlphaComposite.SrcOver)</code>.
  375. * <li>
  376. * The <code>setXORMode(Color xorcolor)</code> method is implemented
  377. * as a convenience method to set a special <code>Composite</code> object that
  378. * ignores the <code>Alpha</code> components of source colors and sets the
  379. * destination color to the value:
  380. * <pre>
  381. * dstpixel = (PixelOf(srccolor) ^ PixelOf(xorcolor) ^ dstpixel);
  382. * </pre>
  383. * </ol>
  384. *
  385. * @version 1.70, 02/02/00
  386. * @author Jim Graham
  387. * @see java.awt.RenderingHints
  388. */
  389. public abstract class Graphics2D extends Graphics {
  390. /**
  391. * Constructs a new <code>Graphics2D</code> object. Since
  392. * <code>Graphics2D</code> is an abstract class, and since it must be
  393. * customized by subclasses for different output devices,
  394. * <code>Graphics2D</code> objects cannot be created directly.
  395. * Instead, <code>Graphics2D</code> objects must be obtained from another
  396. * <code>Graphics2D</code> object, created by a
  397. * <code>Component</code>, or obtained from images such as
  398. * {@link BufferedImage} objects.
  399. * @see java.awt.Component#getGraphics
  400. * @see java.awt.Graphics#create
  401. */
  402. protected Graphics2D() {
  403. }
  404. /**
  405. * Draws a 3-D highlighted outline of the specified rectangle.
  406. * The edges of the rectangle are highlighted so that they
  407. * appear to be beveled and lit from the upper left corner.
  408. * <p>
  409. * The colors used for the highlighting effect are determined
  410. * based on the current color.
  411. * The resulting rectangle covers an area that is
  412. * <code>width + 1</code> pixels wide
  413. * by <code>height + 1</code> pixels tall. This method
  414. * uses the current <code>Color</code> exclusively and ignores
  415. * the current <code>Paint</code>.
  416. * @param x, y the coordinates of the rectangle to be drawn.
  417. * @param width the width of the rectangle to be drawn.
  418. * @param height the height of the rectangle to be drawn.
  419. * @param raised a boolean that determines whether the rectangle
  420. * appears to be raised above the surface
  421. * or sunk into the surface.
  422. * @see java.awt.Graphics#fill3DRect
  423. */
  424. public void draw3DRect(int x, int y, int width, int height,
  425. boolean raised) {
  426. Paint p = getPaint();
  427. Color c = getColor();
  428. Color brighter = c.brighter();
  429. Color darker = c.darker();
  430. setColor(raised ? brighter : darker);
  431. //drawLine(x, y, x, y + height);
  432. fillRect(x, y, 1, height + 1);
  433. //drawLine(x + 1, y, x + width - 1, y);
  434. fillRect(x + 1, y, width - 1, 1);
  435. setColor(raised ? darker : brighter);
  436. //drawLine(x + 1, y + height, x + width, y + height);
  437. fillRect(x + 1, y + height, width, 1);
  438. //drawLine(x + width, y, x + width, y + height - 1);
  439. fillRect(x + width, y, 1, height);
  440. setPaint(p);
  441. }
  442. /**
  443. * Paints a 3-D highlighted rectangle filled with the current color.
  444. * The edges of the rectangle are highlighted so that it appears
  445. * as if the edges were beveled and lit from the upper left corner.
  446. * The colors used for the highlighting effect and for filling are
  447. * determined from the current <code>Color</code>. This method uses
  448. * the current <code>Color</code> exclusively and ignores the current
  449. * <code>Paint</code>.
  450. * @param x, y the coordinates of the rectangle to be filled.
  451. * @param width the width of the rectangle to be filled.
  452. * @param height the height of the rectangle to be filled.
  453. * @param raised a boolean value that determines whether the
  454. * rectangle appears to be raised above the surface
  455. * or etched into the surface.
  456. * @see java.awt.Graphics#draw3DRect
  457. */
  458. public void fill3DRect(int x, int y, int width, int height,
  459. boolean raised) {
  460. Paint p = getPaint();
  461. Color c = getColor();
  462. Color brighter = c.brighter();
  463. Color darker = c.darker();
  464. if (!raised) {
  465. setColor(darker);
  466. } else if (p != c) {
  467. setColor(c);
  468. }
  469. fillRect(x+1, y+1, width-2, height-2);
  470. setColor(raised ? brighter : darker);
  471. //drawLine(x, y, x, y + height - 1);
  472. fillRect(x, y, 1, height);
  473. //drawLine(x + 1, y, x + width - 2, y);
  474. fillRect(x + 1, y, width - 2, 1);
  475. setColor(raised ? darker : brighter);
  476. //drawLine(x + 1, y + height - 1, x + width - 1, y + height - 1);
  477. fillRect(x + 1, y + height - 1, width - 1, 1);
  478. //drawLine(x + width - 1, y, x + width - 1, y + height - 2);
  479. fillRect(x + width - 1, y, 1, height - 1);
  480. setPaint(p);
  481. }
  482. /**
  483. * Strokes the outline of a <code>Shape</code> using the settings of the
  484. * current <code>Graphics2D</code> context. The rendering attributes
  485. * applied include the <code>Clip</code>, <code>Transform</code>,
  486. * <code>Paint</code>, <code>Composite</code> and
  487. * <code>Stroke</code> attributes.
  488. * @param s the <code>Shape</code> to be rendered
  489. * @see #setStroke
  490. * @see #setPaint
  491. * @see java.awt.Graphics#setColor
  492. * @see #transform
  493. * @see #setTransform
  494. * @see #clip
  495. * @see #setClip
  496. * @see #setComposite
  497. */
  498. public abstract void draw(Shape s);
  499. /**
  500. * Renders an image, applying a transform from image space into user space
  501. * before drawing.
  502. * The transformation from user space into device space is done with
  503. * the current <code>Transform</code> in the <code>Graphics2D</code>.
  504. * The specified transformation is applied to the image before the
  505. * transform attribute in the <code>Graphics2D</code> context is applied.
  506. * The rendering attributes applied include the <code>Clip</code>,
  507. * <code>Transform</code>, and <code>Composite</code> attributes.
  508. * Note that no rendering is done if the specified transform is
  509. * noninvertible.
  510. * @param img the <code>Image</code> to be rendered
  511. * @param xform the transformation from image space into user space
  512. * @param obs the {@link ImageObserver}
  513. * to be notified as more of the <code>Image</code>
  514. * is converted
  515. * @return <code>true</code> if the <code>Image</code> is
  516. * fully loaded and completely rendered;
  517. * <code>false</code> if the <code>Image</code> is still being loaded.
  518. * @see #transform
  519. * @see #setTransform
  520. * @see #setComposite
  521. * @see #clip
  522. * @see #setClip
  523. */
  524. public abstract boolean drawImage(Image img,
  525. AffineTransform xform,
  526. ImageObserver obs);
  527. /**
  528. * Renders a <code>BufferedImage</code> that is
  529. * filtered with a
  530. * {@link BufferedImageOp}.
  531. * The rendering attributes applied include the <code>Clip</code>,
  532. * <code>Transform</code>
  533. * and <code>Composite</code> attributes. This is equivalent to:
  534. * <pre>
  535. * img1 = op.filter(img, null);
  536. * drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);
  537. * </pre>
  538. * @param op the filter to be applied to the image before rendering
  539. * @param img the <code>BufferedImage</code> to be rendered
  540. * @param x, y the location in user space where the upper left
  541. * corner of the
  542. * image is rendered
  543. * @see #transform
  544. * @see #setTransform
  545. * @see #setComposite
  546. * @see #clip
  547. * @see #setClip
  548. */
  549. public abstract void drawImage(BufferedImage img,
  550. BufferedImageOp op,
  551. int x,
  552. int y);
  553. /**
  554. * Renders a {@link RenderedImage},
  555. * applying a transform from image
  556. * space into user space before drawing.
  557. * The transformation from user space into device space is done with
  558. * the current <code>Transform</code> in the <code>Graphics2D</code>.
  559. * The specified transformation is applied to the image before the
  560. * transform attribute in the <code>Graphics2D</code> context is applied.
  561. * The rendering attributes applied include the <code>Clip</code>,
  562. * <code>Transform</code>, and <code>Composite</code> attributes. Note
  563. * that no rendering is done if the specified transform is
  564. * noninvertible.
  565. * @param img the image to be rendered
  566. * @param xform the transformation from image space into user space
  567. * @see #transform
  568. * @see #setTransform
  569. * @see #setComposite
  570. * @see #clip
  571. * @see #setClip
  572. */
  573. public abstract void drawRenderedImage(RenderedImage img,
  574. AffineTransform xform);
  575. /**
  576. * Renders a
  577. * {@link RenderableImage},
  578. * applying a transform from image space into user space before drawing.
  579. * The transformation from user space into device space is done with
  580. * the current <code>Transform</code> in the <code>Graphics2D</code>.
  581. * The specified transformation is applied to the image before the
  582. * transform attribute in the <code>Graphics2D</code> context is applied.
  583. * The rendering attributes applied include the <code>Clip</code>,
  584. * <code>Transform</code>, and <code>Composite</code> attributes. Note
  585. * that no rendering is done if the specified transform is
  586. * noninvertible.
  587. *<p>
  588. * Rendering hints set on the <code>Graphics2D</code> object might
  589. * be used in rendering the <code>RenderableImage</code>.
  590. * If explicit control is required over specific hints recognized by a
  591. * specific <code>RenderableImage</code>, or if knowledge of which hints
  592. * are used is required, then a <code>RenderedImage</code> should be
  593. * obtained directly from the <code>RenderableImage</code>
  594. * and rendered using
  595. *{@link #drawRenderedImage(RenderedImage, AffineTransform) drawRenderedImage}.
  596. * @param img the image to be rendered
  597. * @param xform the transformation from image space into user space
  598. * @see #transform
  599. * @see #setTransform
  600. * @see #setComposite
  601. * @see #clip
  602. * @see #setClip
  603. * @see #drawRenderedImage
  604. */
  605. public abstract void drawRenderableImage(RenderableImage img,
  606. AffineTransform xform);
  607. /**
  608. * Renders the text of the specified <code>String</code>, using the
  609. * current <code>Font</code> and <code>Paint</code> attributes in the
  610. * <code>Graphics2D</code> context.
  611. * The baseline of the
  612. * first character is at position (<i>x</i>, <i>y</i>) in
  613. * the User Space.
  614. * The rendering attributes applied include the <code>Clip</code>,
  615. * <code>Transform</code>, <code>Paint</code>, <code>Font</code> and
  616. * <code>Composite</code> attributes. For characters in script
  617. * systems such as Hebrew and Arabic, the glyphs can be rendered from
  618. * right to left, in which case the coordinate supplied is the
  619. * location of the leftmost character on the baseline.
  620. * @param str the string to be rendered
  621. * @param x, y the coordinates where the <code>String</code>
  622. * should be rendered
  623. * @throws NullPointerException if <code>str</code> is
  624. * <code>null</code>
  625. * @see java.awt.Graphics#drawBytes
  626. * @see java.awt.Graphics#drawChars
  627. * @since JDK1.0
  628. */
  629. public abstract void drawString(String str, int x, int y);
  630. /**
  631. * Renders the text specified by the specified <code>String</code>,
  632. * using the current <code>Font</code> and <code>Paint</code> attributes
  633. * in the <code>Graphics2D</code> context.
  634. * The baseline of the first character is at position
  635. * (<i>x</i>, <i>y</i>) in the User Space.
  636. * The rendering attributes applied include the <code>Clip</code>,
  637. * <code>Transform</code>, <code>Paint</code>, <code>Font</code> and
  638. * <code>Composite</code> attributes. For characters in script systems
  639. * such as Hebrew and Arabic, the glyphs can be rendered from right to
  640. * left, in which case the coordinate supplied is the location of the
  641. * leftmost character on the baseline.
  642. * @param s the <code>String</code> to be rendered
  643. * @param x, y the coordinates where the <code>String</code>
  644. * should be rendered
  645. * @throws NullPointerException if <code>str</code> is
  646. * <code>null</code>
  647. * @see #setPaint
  648. * @see java.awt.Graphics#setColor
  649. * @see java.awt.Graphics#setFont
  650. * @see #setTransform
  651. * @see #setComposite
  652. * @see #setClip
  653. */
  654. public abstract void drawString(String s, float x, float y);
  655. /**
  656. * Renders the text of the specified iterator, using the
  657. * <code>Graphics2D</code> context's current <code>Paint</code>. The
  658. * iterator has to specify a font
  659. * for each character. The baseline of the
  660. * first character is at position (<i>x</i>, <i>y</i>) in the
  661. * User Space.
  662. * The rendering attributes applied include the <code>Clip</code>,
  663. * <code>Transform</code>, <code>Paint</code>, and
  664. * <code>Composite</code> attributes.
  665. * For characters in script systems such as Hebrew and Arabic,
  666. * the glyphs can be rendered from right to left, in which case the
  667. * coordinate supplied is the location of the leftmost character
  668. * on the baseline.
  669. * @param iterator the iterator whose text is to be rendered
  670. * @param x, y the coordinates where the iterator's text is to be
  671. * rendered
  672. * @see #setPaint
  673. * @see java.awt.Graphics#setColor
  674. * @see #setTransform
  675. * @see #setComposite
  676. * @see #setClip
  677. */
  678. public abstract void drawString(AttributedCharacterIterator iterator,
  679. int x, int y);
  680. /**
  681. * Renders the text of the specified iterator, using the
  682. * <code>Graphics2D</code> context's current <code>Paint</code>. The
  683. * iterator must specify a font
  684. * for each character. The baseline of the
  685. * first character is at position (<i>x</i>, <i>y</i>) in the
  686. * User Space.
  687. * The rendering attributes applied include the <code>Clip</code>,
  688. * <code>Transform</code>, <code>Paint</code>, and
  689. * <code>Composite</code> attributes.
  690. * For characters in script systems such as Hebrew and Arabic,
  691. * the glyphs can be rendered from right to left, in which case the
  692. * coordinate supplied is the location of the leftmost character
  693. * on the baseline.
  694. * @param iterator the iterator whose text is to be rendered
  695. * @param x, y the coordinates where the iterator's text is to be
  696. * rendered
  697. * @see #setPaint
  698. * @see java.awt.Graphics#setColor
  699. * @see #setTransform
  700. * @see #setComposite
  701. * @see #setClip
  702. */
  703. public abstract void drawString(AttributedCharacterIterator iterator,
  704. float x, float y);
  705. /**
  706. * Renders the text of the specified
  707. * {@link GlyphVector} using
  708. * the <code>Graphics2D</code> context's rendering attributes.
  709. * The rendering attributes applied include the <code>Clip</code>,
  710. * <code>Transform</code>, <code>Paint</code>, and
  711. * <code>Composite</code> attributes. The <code>GlyphVector</code>
  712. * specifies individual glyphs from a {@link Font}.
  713. * The <code>GlyphVector</code> can also contain the glyph positions.
  714. * This is the fastest way to render a set of characters to the
  715. * screen.
  716. * @param g the <code>GlyphVector</code> to be rendered
  717. * @param x, y the position in User Space where the glyphs should
  718. * be rendered
  719. *
  720. * @see java.awt.font#createGlyphVector
  721. * @see java.awt.font.GlyphVector
  722. * @see #setPaint
  723. * @see java.awt.Graphics#setColor
  724. * @see #setTransform
  725. * @see #setComposite
  726. * @see #setClip
  727. */
  728. public abstract void drawGlyphVector(GlyphVector g, float x, float y);
  729. /**
  730. * Fills the interior of a <code>Shape</code> using the settings of the
  731. * <code>Graphics2D</code> context. The rendering attributes applied
  732. * include the <code>Clip</code>, <code>Transform</code>,
  733. * <code>Paint</code>, and <code>Composite</code>.
  734. * @param s the <code>Shape</code> to be filled
  735. * @see #setPaint
  736. * @see java.awt.Graphics#setColor
  737. * @see #transform
  738. * @see #setTransform
  739. * @see #setComposite
  740. * @see #clip
  741. * @see #setClip
  742. */
  743. public abstract void fill(Shape s);
  744. /**
  745. * Checks whether or not the specified <code>Shape</code> intersects
  746. * the specified {@link Rectangle}, which is in device
  747. * space. If <code>onStroke</code> is false, this method checks
  748. * whether or not the interior of the specified <code>Shape</code>
  749. * intersects the specified <code>Rectangle</code>. If
  750. * <code>onStroke</code> is <code>true</code>, this method checks
  751. * whether or not the <code>Stroke</code> of the specified
  752. * <code>Shape</code> outline intersects the specified
  753. * <code>Rectangle</code>.
  754. * The rendering attributes taken into account include the
  755. * <code>Clip</code>, <code>Transform</code>, and <code>Stroke</code>
  756. * attributes.
  757. * @param rect the area in device space to check for a hit
  758. * @param s the <code>Shape</code> to check for a hit
  759. * @param onStroke flag used to choose between testing the
  760. * stroked or the filled shape. If the flag is <code>true</code>, the
  761. * <code>Stroke</code> oultine is tested. If the flag is
  762. * <code>false</code>, the filled <code>Shape</code> is tested.
  763. * @return <code>true</code> if there is a hit; <code>false</code>
  764. * otherwise.
  765. * @see #setStroke
  766. * @see #fill
  767. * @see #draw
  768. * @see #transform
  769. * @see #setTransform
  770. * @see #clip
  771. * @see #setClip
  772. */
  773. public abstract boolean hit(Rectangle rect,
  774. Shape s,
  775. boolean onStroke);
  776. /**
  777. * Returns the device configuration associated with this
  778. * <code>Graphics2D</code>.
  779. */
  780. public abstract GraphicsConfiguration getDeviceConfiguration();
  781. /**
  782. * Sets the <code>Composite</code> for the <code>Graphics2D</code> context.
  783. * The <code>Composite</code> is used in all drawing methods such as
  784. * <code>drawImage</code>, <code>drawString</code>, <code>draw</code>,
  785. * and <code>fill</code>. It specifies how new pixels are to be combined
  786. * with the existing pixels on the graphics device during the rendering
  787. * process.
  788. * <p>If this <code>Graphics2D</code> context is drawing to a
  789. * <code>Component</code> on the display screen and the
  790. * <code>Composite</code> is a custom object rather than an
  791. * instance of the <code>AlphaComposite</code> class, and if
  792. * there is a security manager, its <code>checkPermission</code>
  793. * method is called with an <code>AWTPermission("readDisplayPixels")</code>
  794. * permission.
  795. * @throws SecurityException
  796. * if a custom <code>Composite</code> object is being
  797. * used to render to the screen and a security manager
  798. * is set and its <code>checkPermission</code> method
  799. * does not allow the operation.
  800. * @param comp the <code>Composite</code> object to be used for rendering
  801. * @see java.awt.Graphics#setXORMode
  802. * @see java.awt.Graphics#setPaintMode
  803. * @see AlphaComposite
  804. * @see SecurityManager#checkPermission
  805. * @see java.awt.AWTPermission
  806. */
  807. public abstract void setComposite(Composite comp);
  808. /**
  809. * Sets the <code>Paint</code> attribute for the
  810. * <code>Graphics2D</code> context. Calling this method
  811. * with a <code>null</code> <code>Paint</code> object does
  812. * not have any effect on the current <code>Paint</code> attribute
  813. * of this <code>Graphics2D</code>.
  814. * @param paint the <code>Paint</code> object to be used to generate
  815. * color during the rendering process, or <code>null</code>
  816. * @see java.awt.Graphics#setColor
  817. * @see GradientPaint
  818. * @see TexturePaint
  819. */
  820. public abstract void setPaint( Paint paint );
  821. /**
  822. * Sets the <code>Stroke</code> for the <code>Graphics2D</code> context.
  823. * @param s the <code>Stroke</code> object to be used to stroke a
  824. * <code>Shape</code> during the rendering process
  825. * @see BasicStroke
  826. */
  827. public abstract void setStroke(Stroke s);
  828. /**
  829. * Sets the value of a single preference for the rendering algorithms.
  830. * Hint categories include controls for rendering quality and overall
  831. * time/quality trade-off in the rendering process. Refer to the
  832. * <code>RenderingHints</code> class for definitions of some common
  833. * keys and values.
  834. * @param hintKey the key of the hint to be set.
  835. * @param hintValue the value indicating preferences for the specified
  836. * hint category.
  837. * @see RenderingHints
  838. */
  839. public abstract void setRenderingHint(Key hintKey, Object hintValue);
  840. /**
  841. * Returns the value of a single preference for the rendering algorithms.
  842. * Hint categories include controls for rendering quality and overall
  843. * time/quality trade-off in the rendering process. Refer to the
  844. * <code>RenderingHints</code> class for definitions of some common
  845. * keys and values.
  846. * @param hintKey the key corresponding to the hint to get.
  847. * @return an object representing the value for the specified hint key.
  848. * Some of the keys and their associated values are defined in the
  849. * <code>RenderingHints</code> class.
  850. * @see RenderingHints
  851. */
  852. public abstract Object getRenderingHint(Key hintKey);
  853. /**
  854. * Replaces the values of all preferences for the rendering
  855. * algorithms with the specified <code>hints</code>.
  856. * The existing values for all rendering hints are discarded and
  857. * the new set of known hints and values are initialized from the
  858. * specified {@link Map} object.
  859. * Hint categories include controls for rendering quality and
  860. * overall time/quality trade-off in the rendering process.
  861. * Refer to the <code>RenderingHints</code> class for definitions of
  862. * some common keys and values.
  863. * @param hints the rendering hints to be set
  864. * @see RenderingHints
  865. */
  866. public abstract void setRenderingHints(Map hints);
  867. /**
  868. * Sets the values of an arbitrary number of preferences for the
  869. * rendering algorithms.
  870. * Only values for the rendering hints that are present in the
  871. * specified <code>Map</code> object are modified.
  872. * All other preferences not present in the specified
  873. * object are left unmodified.
  874. * Hint categories include controls for rendering quality and
  875. * overall time/quality trade-off in the rendering process.
  876. * Refer to the <code>RenderingHints</code> class for definitions of
  877. * some common keys and values.
  878. * @param hints the rendering hints to be set
  879. * @see RenderingHints
  880. */
  881. public abstract void addRenderingHints(Map hints);
  882. /**
  883. * Gets the preferences for the rendering algorithms. Hint categories
  884. * include controls for rendering quality and overall time/quality
  885. * trade-off in the rendering process.
  886. * Returns all of the hint key/value pairs that were ever specified in
  887. * one operation. Refer to the
  888. * <code>RenderingHints</code> class for definitions of some common
  889. * keys and values.
  890. * @return a reference to an instance of <code>RenderingHints</code>
  891. * that contains the current preferences.
  892. * @see RenderingHints
  893. */
  894. public abstract RenderingHints getRenderingHints();
  895. /**
  896. * Translates the origin of the <code>Graphics2D</code> context to the
  897. * point (<i>x</i>, <i>y</i>) in the current coordinate system.
  898. * Modifies the <code>Graphics2D</code> context so that its new origin
  899. * corresponds to the point (<i>x</i>, <i>y</i>) in the
  900. * <code>Graphics2D</code> context's former coordinate system. All
  901. * coordinates used in subsequent rendering operations on this graphics
  902. * context are relative to this new origin.
  903. * @param x, y the specified coordinates
  904. * @since JDK1.0
  905. */
  906. public abstract void translate(int x, int y);
  907. /**
  908. * Concatenates the current
  909. * <code>Graphics2D</code> <code>Transform</code>
  910. * with a translation transform.
  911. * Subsequent rendering is translated by the specified
  912. * distance relative to the previous position.
  913. * This is equivalent to calling transform(T), where T is an
  914. * <code>AffineTransform</code> represented by the following matrix:
  915. * <pre>
  916. * [ 1 0 tx ]
  917. * [ 0 1 ty ]
  918. * [ 0 0 1 ]
  919. * </pre>
  920. * @param tx the distance to translate along the x-axis
  921. * @param ty the distance to translate along the y-axis
  922. */
  923. public abstract void translate(double tx, double ty);
  924. /**
  925. * Concatenates the current <code>Graphics2D</code>
  926. * <code>Transform</code> with a rotation transform.
  927. * Subsequent rendering is rotated by the specified radians relative
  928. * to the previous origin.
  929. * This is equivalent to calling <code>transform(R)</code>, where R is an
  930. * <code>AffineTransform</code> represented by the following matrix:
  931. * <pre>
  932. * [ cos(theta) -sin(theta) 0 ]
  933. * [ sin(theta) cos(theta) 0 ]
  934. * [ 0 0 1 ]
  935. * </pre>
  936. * Rotating with a positive angle theta rotates points on the positive
  937. * x axis toward the positive y axis.
  938. * @param theta the angle of rotation in radians
  939. */
  940. public abstract void rotate(double theta);
  941. /**
  942. * Concatenates the current <code>Graphics2D</code>
  943. * <code>Transform</code> with a translated rotation
  944. * transform. Subsequent rendering is transformed by a transform
  945. * which is constructed by translating to the specified location,
  946. * rotating by the specified radians, and translating back by the same
  947. * amount as the original translation. This is equivalent to the
  948. * following sequence of calls:
  949. * <pre>
  950. * translate(x, y);
  951. * rotate(theta);
  952. * translate(-x, -y);
  953. * </pre>
  954. * Rotating with a positive angle theta rotates points on the positive
  955. * x axis toward the positive y axis.
  956. * @param theta the angle of rotation in radians
  957. * @param x, y coordinates of the origin of the rotation
  958. */
  959. public abstract void rotate(double theta, double x, double y);
  960. /**
  961. * Concatenates the current <code>Graphics2D</code>
  962. * <code>Transform</code> with a scaling transformation
  963. * Subsequent rendering is resized according to the specified scaling
  964. * factors relative to the previous scaling.
  965. * This is equivalent to calling <code>transform(S)</code>, where S is an
  966. * <code>AffineTransform</code> represented by the following matrix:
  967. * <pre>
  968. * [ sx 0 0 ]
  969. * [ 0 sy 0 ]
  970. * [ 0 0 1 ]
  971. * </pre>
  972. * @param sx the amount by which X coordinates in subsequent
  973. * rendering operations are multiplied relative to previous
  974. * rendering operations.
  975. * @param sy the amount by which Y coordinates in subsequent
  976. * rendering operations are multiplied relative to previous
  977. * rendering operations.
  978. */
  979. public abstract void scale(double sx, double sy);
  980. /**
  981. * Concatenates the current <code>Graphics2D</code>
  982. * <code>Transform</code> with a shearing transform.
  983. * Subsequent renderings are sheared by the specified
  984. * multiplier relative to the previous position.
  985. * This is equivalent to calling <code>transform(SH)</code>, where SH
  986. * is an <code>AffineTransform</code> represented by the following
  987. * matrix:
  988. * <pre>
  989. * [ 1 shx 0 ]
  990. * [ shy 1 0 ]
  991. * [ 0 0 1 ]
  992. * </pre>
  993. * @param shx the multiplier by which coordinates are shifted in
  994. * the positive X axis direction as a function of their Y coordinate
  995. * @param shy the multiplier by which coordinates are shifted in
  996. * the positive Y axis direction as a function of their X coordinate
  997. */
  998. public abstract void shear(double shx, double shy);
  999. /**
  1000. * Composes an <code>AffineTransform</code> object with the
  1001. * <code>Transform</code> in this <code>Graphics2D</code> according
  1002. * to the rule last-specified-first-applied. If the current
  1003. * <code>Transform</code> is Cx, the result of composition
  1004. * with Tx is a new <code>Transform</code> Cx'. Cx' becomes the
  1005. * current <code>Transform</code> for this <code>Graphics2D</code>.
  1006. * Transforming a point p by the updated <code>Transform</code> Cx' is
  1007. * equivalent to first transforming p by Tx and then transforming
  1008. * the result by the original <code>Transform</code> Cx. In other
  1009. * words, Cx'(p) = Cx(Tx(p)). A copy of the Tx is made, if necessary,
  1010. * so further modifications to Tx do not affect rendering.
  1011. * @param Tx the <code>AffineTransform</code> object to be composed with
  1012. * the current <code>Transform</code>
  1013. * @see #setTransform
  1014. * @see AffineTransform
  1015. */
  1016. public abstract void transform(AffineTransform Tx);
  1017. /**
  1018. * Sets the <code>Transform</code> in the <code>Graphics2D</code>
  1019. * context.
  1020. * @param Tx the <code>AffineTransform</code> object to be used in the
  1021. * rendering process
  1022. * @see #transform
  1023. * @see AffineTransform
  1024. */
  1025. public abstract void setTransform(AffineTransform Tx);
  1026. /**
  1027. * Returns a copy of the current <code>Transform</code> in the
  1028. * <code>Graphics2D</code> context.
  1029. * @return the current <code>AffineTransform</code> in the
  1030. * <code>Graphics2D</code> context.
  1031. * @see #transform
  1032. * @see #setTransform
  1033. */
  1034. public abstract AffineTransform getTransform();
  1035. /**
  1036. * Returns the current <code>Paint</code> of the
  1037. * <code>Graphics2D</code> context.
  1038. * @return the current <code>Graphics2D</code> <code>Paint</code>,
  1039. * which defines a color or pattern.
  1040. * @see #setPaint
  1041. * @see java.awt.Graphics#setColor
  1042. */
  1043. public abstract Paint getPaint();
  1044. /**
  1045. * Returns the current <code>Composite</code> in the
  1046. * <code>Graphics2D</code> context.
  1047. * @return the current <code>Graphics2D</code> <code>Composite</code>,
  1048. * which defines a compositing style.
  1049. * @see #setComposite
  1050. */
  1051. public abstract Composite getComposite();
  1052. /**
  1053. * Sets the background color for the <code>Graphics2D</code> context.
  1054. * The background color is used for clearing a region.
  1055. * When a <code>Graphics2D</code> is constructed for a
  1056. * <code>Component</code>, the background color is
  1057. * inherited from the <code>Component</code>. Setting the background color
  1058. * in the <code>Graphics2D</code> context only affects the subsequent
  1059. * <code>clearRect</code> calls and not the background color of the
  1060. * <code>Component</code>. To change the background
  1061. * of the <code>Component</code>, use appropriate methods of
  1062. * the <code>Component</code>.
  1063. * @param color the background color that isused in
  1064. * subsequent calls to <code>clearRect</code>
  1065. * @see #getBackground
  1066. * @see java.awt.Graphics#clearRect
  1067. */
  1068. public abstract void setBackground(Color color);
  1069. /**
  1070. * Returns the background color used for clearing a region.
  1071. * @return the current <code>Graphics2D</code> <code>Color</code>,
  1072. * which defines the background color.
  1073. * @see #setBackground
  1074. */
  1075. public abstract Color getBackground();
  1076. /**
  1077. * Returns the current <code>Stroke</code> in the
  1078. * <code>Graphics2D</code> context.
  1079. * @return the current <code>Graphics2D</code> <code>Stroke</code>,
  1080. * which defines the line style.
  1081. * @see #setStroke
  1082. */
  1083. public abstract Stroke getStroke();
  1084. /**
  1085. * Intersects the current <code>Clip</code> with the interior of the
  1086. * specified <code>Shape</code> and sets the <code>Clip</code> to the
  1087. * resulting intersection. The specified <code>Shape</code> is
  1088. * transformed with the current <code>Graphics2D</code>
  1089. * <code>Transform</code> before being intersected with the current
  1090. * <code>Clip</code>. This method is used to make the current
  1091. * <code>Clip</code> smaller.
  1092. * To make the <code>Clip</code> larger, use <code>setClip</code>.
  1093. * The <i>user clip</i> modified by this method is independent of the
  1094. * clipping associated with device bounds and visibility. If no clip has
  1095. * previously been set, or if the clip has been cleared using
  1096. * {@link Graphics#setClip(Shape) setClip} with a <code>null</code>
  1097. * argument, the specified <code>Shape</code> becomes the new
  1098. * user clip.
  1099. * @param s the <code>Shape</code> to be intersected with the current
  1100. * <code>Clip</code>. If <code>s</code> is <code>null</code>,
  1101. * this method clears the current <code>Clip</code>.
  1102. */
  1103. public abstract void clip(Shape s);
  1104. /**
  1105. * Get the rendering context of the <code>Font</code> within this
  1106. * <code>Graphics2D</code> context.
  1107. * The {@link FontRenderContext}
  1108. * encapsulates application hints such as anti-aliasing and
  1109. * fractional metrics, as well as target device specific information
  1110. * such as dots-per-inch. This information should be provided by the
  1111. * application when using objects that perform typographical
  1112. * formatting, such as <code>Font</code> and
  1113. * <code>TextLayout</code>. This information should also be provided
  1114. * by applications that perform their own layout and need accurate
  1115. * measurements of various characteristics of glyphs such as advance
  1116. * and line height when various rendering hints have been applied to
  1117. * the text rendering.
  1118. *
  1119. * @return a reference to an instance of FontRenderContext.
  1120. * @see java.awt.font.FontRenderContext
  1121. * @see java.awt.Font#createGlyphVector
  1122. * @see java.awt.font.TextLayout
  1123. * @since 1.2
  1124. */
  1125. public abstract FontRenderContext getFontRenderContext();
  1126. }