1. /*
  2. * @(#)Arc2D.java 1.22 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt.geom;
  8. /**
  9. * <CODE>Arc2D</CODE> is the abstract superclass for all objects that
  10. * store a 2D arc defined by a bounding rectangle,
  11. * start angle, angular extent (length of the arc), and a closure type
  12. * (<CODE>OPEN</CODE>, <CODE>CHORD</CODE>, or <CODE>PIE</CODE>).
  13. * <p>
  14. * The bounding rectangle defines the outer boundary of the full ellipse
  15. * of which this arc is a partial section.
  16. * The angles are specified relative to the non-square extents of the
  17. * bounding rectangle such that 45 degrees always falls on the line from
  18. * the center of the ellipse to the upper right corner of the bounding
  19. * rectangle.
  20. * As a result, if the bounding rectangle is noticeably longer along one
  21. * axis than the other, the angles to the start and end of the arc segment
  22. * will be skewed farther along the longer axis of the bounds.
  23. * <p>
  24. * The actual storage representation of the coordinates is left to
  25. * the subclass.
  26. *
  27. * @version 10 Feb 1997
  28. * @author Jim Graham
  29. */
  30. public abstract class Arc2D extends RectangularShape {
  31. /**
  32. * The closure type for an open arc with no path segments
  33. * connecting the two ends of the arc segment.
  34. */
  35. public final static int OPEN = 0;
  36. /**
  37. * The closure type for an arc closed by drawing a straight
  38. * line segment from the start of the arc segment to the end of the
  39. * arc segment.
  40. */
  41. public final static int CHORD = 1;
  42. /**
  43. * The closure type for an arc closed by drawing straight line
  44. * segments from the start of the arc segment to the center
  45. * of the full ellipse and from that point to the end of the arc segment.
  46. */
  47. public final static int PIE = 2;
  48. /**
  49. * This class defines an arc specified in float precision.
  50. */
  51. public static class Float extends Arc2D {
  52. /**
  53. * The x coordinate of the upper left corner of the arc.
  54. */
  55. public float x;
  56. /**
  57. * The y coordinate of the upper left corner of the arc.
  58. */
  59. public float y;
  60. /**
  61. * The overall width of the full ellipse of which this arc is
  62. * a partial section (not considering the
  63. * angular extents).
  64. */
  65. public float width;
  66. /**
  67. * The overall height of the full ellipse of which this arc is
  68. * a partial section (not considering the
  69. * angular extents).
  70. */
  71. public float height;
  72. /**
  73. * The starting angle of the arc in degrees.
  74. */
  75. public float start;
  76. /**
  77. * The angular extent of the arc in degrees.
  78. */
  79. public float extent;
  80. /**
  81. * Constructs a new OPEN arc, initialized to location (0, 0),
  82. * size (0, 0), angular extents (start = 0, extent = 0).
  83. */
  84. public Float() {
  85. super(OPEN);
  86. }
  87. /**
  88. * Constructs a new arc, initialized to location (0, 0),
  89. * size (0, 0), angular extents (start = 0, extent = 0), and
  90. * the specified closure type.
  91. *
  92. * @param type The closure type for the arc:
  93. * {@link #OPEN OPEN}, {@link #CHORD CHORD}, or {@link #PIE PIE}.
  94. */
  95. public Float(int type) {
  96. super(type);
  97. }
  98. /**
  99. * Constructs a new arc, initialized to the specified location,
  100. * size, angular extents, and closure type.
  101. *
  102. * @param x, y The coordinates of the upper left corner of
  103. * the arc. (Specified in float precision.)
  104. * @param w The overall width of the full ellipse of which
  105. * this arc is a partial section. (Specified in float precision.)
  106. * @param h The overall height of the full ellipse of which this
  107. * arc is a partial section. (Specified in float precision.)
  108. * @param start The starting angle of the arc in degrees.
  109. * (Specified in float precision.)
  110. * @param extent The angular extent of the arc in degrees.
  111. * (Specified in float precision.)
  112. * @param type The closure type for the arc:
  113. * {@link #OPEN OPEN}, {@link #CHORD CHORD}, or {@link #PIE PIE}.
  114. */
  115. public Float(float x, float y, float w, float h,
  116. float start, float extent, int type) {
  117. super(type);
  118. this.x = x;
  119. this.y = y;
  120. this.width = w;
  121. this.height = h;
  122. this.start = start;
  123. this.extent = extent;
  124. }
  125. /**
  126. * Constructs a new arc, initialized to the specified location,
  127. * size, angular extents, and closure type.
  128. *
  129. * @param ellipseBounds The bounding rectangle that defines the
  130. * outer boundary of the full ellipse of which this arc is a
  131. * partial section.
  132. * @param start The starting angle of the arc in degrees.
  133. * (Specified in float precision.)
  134. * @param extent The angular extent of the arc in degrees.
  135. * (Specified in float precision.)
  136. * @param type The closure type for the arc:
  137. * {@link #OPEN OPEN}, {@link #CHORD CHORD}, or {@link #PIE PIE}.
  138. */
  139. public Float(Rectangle2D ellipseBounds,
  140. float start, float extent, int type) {
  141. super(type);
  142. this.x = (float) ellipseBounds.getX();
  143. this.y = (float) ellipseBounds.getY();
  144. this.width = (float) ellipseBounds.getWidth();
  145. this.height = (float) ellipseBounds.getHeight();
  146. this.start = start;
  147. this.extent = extent;
  148. }
  149. /**
  150. * Returns the x coordinate of the upper left corner of the arc.
  151. *
  152. * @return The x coordinate of arc's upper left coordinate in
  153. * double precision.
  154. */
  155. public double getX() {
  156. return (double) x;
  157. }
  158. /**
  159. * Returns the y coordinate of the upper left corner of the arc.
  160. *
  161. * @return The y coordinate of arc's upper left coordinate in
  162. * double precision.
  163. */
  164. public double getY() {
  165. return (double) y;
  166. }
  167. /**
  168. * Returns the width of the ellipse of which this arc is
  169. * a partial section.
  170. *
  171. * @return A double value that represents the width of the full
  172. * ellipse of which this arc is a partial section.
  173. */
  174. public double getWidth() {
  175. return (double) width;
  176. }
  177. /**
  178. * Returns the height of the ellipse of which this arc is
  179. * a partial section.
  180. *
  181. * @return A double value that represents the height of the full
  182. * ellipse of which this arc is a partial section.
  183. */
  184. public double getHeight() {
  185. return (double) height;
  186. }
  187. /**
  188. * Returns the starting angle of the arc.
  189. *
  190. * @return A double value that represents the starting angle of
  191. * the arc in degrees.
  192. * @see #setAngleStart
  193. */
  194. public double getAngleStart() {
  195. return (double) start;
  196. }
  197. /**
  198. * Returns the angular extent of the arc.
  199. *
  200. * @return A double value that represents the angular extent of
  201. * the arc in degrees.
  202. * @see #setAngleExtent
  203. */
  204. public double getAngleExtent() {
  205. return (double) extent;
  206. }
  207. /**
  208. * Determines whether the arc is empty.
  209. *
  210. * @return <CODE>true</CODE> if the arc is empty, <CODE>false</CODE>
  211. * if it is not.
  212. */
  213. public boolean isEmpty() {
  214. return (width <= 0.0 || height <= 0.0);
  215. }
  216. /**
  217. * Sets the location, size, angular extents, and closure type of
  218. * this arc to the specified double values.
  219. *
  220. * @param x, y The coordinates of the upper left corner of
  221. * the arc.
  222. * @param w The overall width of the full ellipse of which this
  223. * arc is a partial section.
  224. * @param h The overall height of the full ellipse of which this
  225. * arc is a partial section.
  226. * @param angSt The starting angle of the arc in degrees.
  227. * @param angExt The angular extent of the arc in degrees.
  228. * @param closure The closure type for the arc:
  229. * {@link #OPEN OPEN}, {@link #CHORD CHORD}, or {@link #PIE PIE}.
  230. */
  231. public void setArc(double x, double y, double w, double h,
  232. double angSt, double angExt, int closure) {
  233. this.setArcType(closure);
  234. this.x = (float) x;
  235. this.y = (float) y;
  236. this.width = (float) w;
  237. this.height = (float) h;
  238. this.start = (float) angSt;
  239. this.extent = (float) angExt;
  240. }
  241. /**
  242. * Sets the starting angle of this arc to the specified double
  243. * value.
  244. *
  245. * @param angSt The starting angle of the arc in degrees.
  246. * @see #getAngleStart
  247. */
  248. public void setAngleStart(double angSt) {
  249. this.start = (float) angSt;
  250. }
  251. /**
  252. * Sets the angular extent of this arc to the specified double
  253. * value.
  254. *
  255. * @param angExt The angular extent of the arc in degrees.
  256. * @see #getAngleExtent
  257. */
  258. public void setAngleExtent(double angExt) {
  259. this.extent = (float) angExt;
  260. }
  261. /**
  262. * Return the high-precision bounding box of the arc.
  263. *
  264. * @param x, y The coordinates of the upper left corner
  265. * of the arc.
  266. * @param w The overall width of the full ellipse of which
  267. * this arc is a partial section.
  268. * @param h The overall height of the full ellipse of which
  269. * this arc is a partial section.
  270. *
  271. * @return The bounding box as a <CODE>Rectangle2D</CODE> object.
  272. */
  273. protected Rectangle2D makeBounds(double x, double y,
  274. double w, double h) {
  275. return new Rectangle2D.Float((float) x, (float) y,
  276. (float) w, (float) h);
  277. }
  278. }
  279. /**
  280. * This class defines an arc specified in double precision.
  281. */
  282. public static class Double extends Arc2D {
  283. /**
  284. * The x coordinate of the upper left corner of the arc.
  285. */
  286. public double x;
  287. /**
  288. * The y coordinate of the upper left corner of the arc.
  289. */
  290. public double y;
  291. /**
  292. * The overall width of the full ellipse (not considering the
  293. * angular extents).
  294. */
  295. public double width;
  296. /**
  297. * The overall height of the full ellipse (not considering the
  298. * angular extents).
  299. */
  300. public double height;
  301. /**
  302. * The starting angle of the arc in degrees.
  303. */
  304. public double start;
  305. /**
  306. * The angular extent of the arc in degrees.
  307. */
  308. public double extent;
  309. /**
  310. * Constructs a new OPEN arc, initialized to location (0, 0),
  311. * size (0, 0), angular extents (start = 0, extent = 0).
  312. */
  313. public Double() {
  314. super(OPEN);
  315. }
  316. /**
  317. * Constructs a new arc, initialized to location (0, 0),
  318. * size (0, 0), angular extents (start = 0, extent = 0), and
  319. * the specified closure type.
  320. *
  321. * @param type The closure type for the arc:
  322. * {@link #OPEN OPEN}, {@link #CHORD CHORD}, or {@link #PIE PIE}.
  323. */
  324. public Double(int type) {
  325. super(type);
  326. }
  327. /**
  328. * Constructs a new arc, initialized to the specified location,
  329. * size, angular extents, and closure type.
  330. *
  331. * @param x, y The coordinates of the upper left corner
  332. * of the arc. (Specified in double precision.)
  333. * @param w The overall width of the full ellipse of which this
  334. * arc is a partial section. (Specified in double precision.)
  335. * @param h The overall height of the full ellipse of which this
  336. * arc is a partial section. (Specified in double precision.)
  337. * @param start The starting angle of the arc in degrees.
  338. * (Specified in double precision.)
  339. * @param extent The angular extent of the arc in degrees.
  340. * (Specified in double precision.)
  341. * @param type The closure type for the arc:
  342. * {@link #OPEN OPEN}, {@link #CHORD CHORD}, or {@link #PIE PIE}.
  343. */
  344. public Double(double x, double y, double w, double h,
  345. double start, double extent, int type) {
  346. super(type);
  347. this.x = x;
  348. this.y = y;
  349. this.width = w;
  350. this.height = h;
  351. this.start = start;
  352. this.extent = extent;
  353. }
  354. /**
  355. * Constructs a new arc, initialized to the specified location,
  356. * size, angular extents, and closure type.
  357. *
  358. * @param ellipseBounds The bounding rectangle that defines the
  359. * outer boundary of the full ellipse of which this arc is a
  360. * partial section.
  361. * @param start The starting angle of the arc in degrees.
  362. * (Specified in double precision.)
  363. * @param extent The angular extent of the arc in degrees.
  364. * (Specified in double precision.)
  365. * @param type The closure type for the arc:
  366. * {@link #OPEN OPEN}, {@link #CHORD CHORD}, or {@link #PIE PIE}.
  367. */
  368. public Double(Rectangle2D ellipseBounds,
  369. double start, double extent, int type) {
  370. super(type);
  371. this.x = ellipseBounds.getX();
  372. this.y = ellipseBounds.getY();
  373. this.width = ellipseBounds.getWidth();
  374. this.height = ellipseBounds.getHeight();
  375. this.start = start;
  376. this.extent = extent;
  377. }
  378. /**
  379. * Returns the x coordinate of the upper left corner of the arc.
  380. *
  381. * @return The x coordinate of arc's upper left coordinate in
  382. * double precision.
  383. */
  384. public double getX() {
  385. return x;
  386. }
  387. /**
  388. * Returns the y coordinate of the upper left corner of the arc.
  389. *
  390. * @return The y coordinate of arc's upper left coordinate in
  391. * double precision.
  392. */
  393. public double getY() {
  394. return y;
  395. }
  396. /**
  397. * Returns the width of the ellipse of which this arc is
  398. * a partial section.
  399. *
  400. * @return A double value that represents the width of the full
  401. * ellipse of which this arc is a partial section.
  402. */
  403. public double getWidth() {
  404. return width;
  405. }
  406. /**
  407. * Returns the height of the ellipse of which this arc is
  408. * a partial section.
  409. *
  410. * @return A double value that represents the height of the full
  411. * ellipse of which this arc is a partial section.
  412. */
  413. public double getHeight() {
  414. return height;
  415. }
  416. /**
  417. * Returns the starting angle of the arc.
  418. *
  419. * @return a double value that represents the starting angle
  420. * of the arc in degrees.
  421. * @see #setAngleStart
  422. */
  423. public double getAngleStart() {
  424. return start;
  425. }
  426. /**
  427. * Returns the angular extent of the arc.
  428. *
  429. * @return A double value that represents the angular extent of
  430. * the arc in degrees.
  431. * @see #setAngleExtent
  432. */
  433. public double getAngleExtent() {
  434. return extent;
  435. }
  436. /**
  437. * Determines whether the arc is empty.
  438. *
  439. * @return <CODE>true</CODE> if the arc is empty, <CODE>false</CODE>
  440. * if it not.
  441. */
  442. public boolean isEmpty() {
  443. return (width <= 0.0 || height <= 0.0);
  444. }
  445. /**
  446. * Sets the location, size, angular extents, and closure type of
  447. * this arc to the specified double values.
  448. *
  449. * @param x, y The coordinates of the upper left corner
  450. * of the arc.
  451. * @param w The overall width of the full ellipse of which
  452. * this arc is a partial section.
  453. * @param h The overall height of the full ellipse of which
  454. * this arc is a partial section.
  455. * @param angSt The starting angle of the arc in degrees.
  456. * @param angExt The angular extent of the arc in degrees.
  457. * @param closure The closure type for the arc:
  458. * {@link #OPEN OPEN}, {@link #CHORD CHORD}, or {@link #PIE PIE}.
  459. */
  460. public void setArc(double x, double y, double w, double h,
  461. double angSt, double angExt, int closure) {
  462. this.setArcType(closure);
  463. this.x = x;
  464. this.y = y;
  465. this.width = w;
  466. this.height = h;
  467. this.start = angSt;
  468. this.extent = angExt;
  469. }
  470. /**
  471. * Sets the starting angle of this arc to the specified double
  472. * value.
  473. *
  474. * @param angSt The starting angle of the arc in degrees.
  475. * @see #getAngleStart
  476. */
  477. public void setAngleStart(double angSt) {
  478. this.start = angSt;
  479. }
  480. /**
  481. * Sets the angular extent of this arc to the specified double
  482. * value.
  483. *
  484. * @param angExt The angular extent of the arc in degrees.
  485. * @see #getAngleExtent
  486. */
  487. public void setAngleExtent(double angExt) {
  488. this.extent = angExt;
  489. }
  490. /**
  491. * Returns the high-precision bounding box of the arc.
  492. *
  493. * @param x, y The coordinates of the upper left corner
  494. * of the arc.
  495. * @param w The overall width of the full ellipse of which
  496. * this arc is a partial section.
  497. * @param h The overall height of the full ellipse of which
  498. * this arc is a partial section.
  499. *
  500. * @return The bounding box as a <CODE>Rectangle2D</CODE> object.
  501. */
  502. protected Rectangle2D makeBounds(double x, double y,
  503. double w, double h) {
  504. return new Rectangle2D.Double(x, y, w, h);
  505. }
  506. }
  507. private int type;
  508. /**
  509. * This is an abstract class that cannot be instantiated directly.
  510. * Type-specific implementation subclasses are available for
  511. * instantiation and provide a number of formats for storing
  512. * the information necessary to satisfy the various accessor
  513. * methods below.
  514. *
  515. * @param type The closure type of this arc:
  516. * {@link #OPEN OPEN}, {@link #CHORD CHORD}, or {@link #PIE PIE}.
  517. * @see java.awt.geom.Arc2D.Float
  518. * @see java.awt.geom.Arc2D.Double
  519. */
  520. protected Arc2D(int type) {
  521. setArcType(type);
  522. }
  523. /**
  524. * Returns the starting angle of the arc.
  525. *
  526. * @return A double value that represents the starting angle
  527. * of the arc in degrees.
  528. * @see #setAngleStart
  529. */
  530. public abstract double getAngleStart();
  531. /**
  532. * Returns the angular extent of the arc.
  533. *
  534. * @return A double value that represents the angular extent
  535. * of the arc in degrees.
  536. * @see #setAngleExtent
  537. */
  538. public abstract double getAngleExtent();
  539. /**
  540. * Returns the arc closure type of the arc: {@link #OPEN OPEN},
  541. * {@link #CHORD CHORD}, or {@link #PIE PIE}.
  542. * @return One of the integer constant closure types defined
  543. * in this class.
  544. * @see #setArcType
  545. */
  546. public int getArcType() {
  547. return type;
  548. }
  549. /**
  550. * Returns the starting point of the arc. This point is the
  551. * intersection of the ray from the center defined by the
  552. * starting angle and the elliptical boundary of the arc.
  553. *
  554. * @return A <CODE>Point2D</CODE> object representing the
  555. * x,y coordinates of the starting point of the arc.
  556. */
  557. public Point2D getStartPoint() {
  558. double angle = Math.toRadians(-getAngleStart());
  559. double x = getX() + (Math.cos(angle) * 0.5 + 0.5) * getWidth();
  560. double y = getY() + (Math.sin(angle) * 0.5 + 0.5) * getHeight();
  561. return new Point2D.Double(x, y);
  562. }
  563. /**
  564. * Returns the ending point of the arc. This point is the
  565. * intersection of the ray from the center defined by the
  566. * starting angle plus the angular extent of the arc and the
  567. * elliptical boundary of the arc.
  568. *
  569. * @return A <CODE>Point2D</CODE> object representing the
  570. * x,y coordinates of the ending point of the arc.
  571. */
  572. public Point2D getEndPoint() {
  573. double angle = Math.toRadians(-getAngleStart() - getAngleExtent());
  574. double x = getX() + (Math.cos(angle) * 0.5 + 0.5) * getWidth();
  575. double y = getY() + (Math.sin(angle) * 0.5 + 0.5) * getHeight();
  576. return new Point2D.Double(x, y);
  577. }
  578. /**
  579. * Sets the location, size, angular extents, and closure type of
  580. * this arc to the specified double values.
  581. *
  582. * @param x, y The coordinates of the upper left corner of
  583. * the arc.
  584. * @param w The overall width of the full ellipse of which
  585. * this arc is a partial section.
  586. * @param h The overall height of the full ellipse of which
  587. * this arc is a partial section.
  588. * @param angSt The starting angle of the arc in degrees.
  589. * @param angExt The angular extent of the arc in degrees.
  590. * @param closure The closure type for the arc:
  591. * {@link #OPEN OPEN}, {@link #CHORD CHORD}, or {@link #PIE PIE}.
  592. */
  593. public abstract void setArc(double x, double y, double w, double h,
  594. double angSt, double angExt, int closure);
  595. /**
  596. * Sets the location, size, angular extents, and closure type of
  597. * this arc to the specified values.
  598. *
  599. * @param loc The <CODE>Point2D</CODE> representing the coordinates of
  600. * the upper left corner of the arc.
  601. * @param size The <CODE>Dimension2D</CODE> representing the width
  602. * and height of the full ellipse of which this arc is
  603. * a partial section.
  604. * @param angSt The starting angle of the arc in degrees.
  605. * (Specified in double precision.)
  606. * @param angExt The angular extent of the arc in degrees.
  607. * (Specified in double precision.)
  608. * @param closure The closure type for the arc:
  609. * {@link #OPEN OPEN}, {@link #CHORD CHORD}, or {@link #PIE PIE}.
  610. */
  611. public void setArc(Point2D loc, Dimension2D size,
  612. double angSt, double angExt, int closure) {
  613. setArc(loc.getX(), loc.getY(), size.getWidth(), size.getHeight(),
  614. angSt, angExt, closure);
  615. }
  616. /**
  617. * Sets the location, size, angular extents, and closure type of
  618. * this arc to the specified values.
  619. *
  620. * @param rect The bounding rectangle that defines the
  621. * outer boundary of the full ellipse of which this arc is a
  622. * partial section.
  623. * @param angSt The starting angle of the arc in degrees.
  624. * (Specified in double precision.)
  625. * @param angExt The angular extent of the arc in degrees.
  626. * (Specified in double precision.)
  627. * @param closure The closure type for the arc:
  628. * {@link #OPEN OPEN}, {@link #CHORD CHORD}, or {@link #PIE PIE}.
  629. */
  630. public void setArc(Rectangle2D rect, double angSt, double angExt,
  631. int closure) {
  632. setArc(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight(),
  633. angSt, angExt, closure);
  634. }
  635. /**
  636. * Sets this arc to be the same as the specified arc.
  637. *
  638. * @param a The <CODE>Arc2D</CODE> to use to set the arc's values.
  639. */
  640. public void setArc(Arc2D a) {
  641. setArc(a.getX(), a.getY(), a.getWidth(), a.getHeight(),
  642. a.getAngleStart(), a.getAngleExtent(), a.type);
  643. }
  644. /**
  645. * Sets the position, bounds, angular extents, and closure type of
  646. * this arc to the specified values. The arc is defined by a center
  647. * point and a radius rather than a bounding box for the full ellipse.
  648. *
  649. * @param x, y The coordinates of the center of the arc.
  650. * (Specified in double precision.)
  651. * @param radius The radius of the arc. (Specified in double precision.)
  652. * @param angSt The starting angle of the arc in degrees.
  653. * (Specified in double precision.)
  654. * @param angExt The angular extent of the arc in degrees.
  655. * (Specified in double precision.)
  656. * @param closure The closure type for the arc:
  657. * {@link #OPEN OPEN}, {@link #CHORD CHORD}, or {@link #PIE PIE}.
  658. */
  659. public void setArcByCenter(double x, double y, double radius,
  660. double angSt, double angExt, int closure) {
  661. setArc(x - radius, y - radius, radius * 2.0, radius * 2.0,
  662. angSt, angExt, closure);
  663. }
  664. /**
  665. * Sets the position, bounds, and angular extents of this arc to the
  666. * specified value. The starting angle of the arc is tangent to the
  667. * line specified by points (p1, p2), the ending angle is tangent to
  668. * the line specified by points (p2, p3), and the arc has the
  669. * specified radius.
  670. *
  671. * @param p1 The first point that defines the arc. The starting
  672. * angle of the arc is tangent to the line specified by points (p1, p2).
  673. * @param p2 The second point that defines the arc. The starting
  674. * angle of the arc is tangent to the line specified by points (p1, p2).
  675. * The ending angle of the arc is tangent to the line specified by
  676. * points (p2, p3).
  677. * @param p3 The third point that defines the arc. The ending angle
  678. * of the arc is tangent to the line specified by points (p2, p3).
  679. * @param radius The radius of the arc. (Specified in double precision.)
  680. */
  681. public void setArcByTangent(Point2D p1, Point2D p2, Point2D p3,
  682. double radius) {
  683. double ang1 = Math.atan2(p1.getY() - p2.getY(),
  684. p1.getX() - p2.getX());
  685. double ang2 = Math.atan2(p3.getY() - p2.getY(),
  686. p3.getX() - p2.getX());
  687. double diff = ang2 - ang1;
  688. if (diff > Math.PI) {
  689. ang2 -= Math.PI * 2.0;
  690. } else if (diff < -Math.PI) {
  691. ang2 += Math.PI * 2.0;
  692. }
  693. double bisect = (ang1 + ang2) / 2.0;
  694. double theta = Math.abs(ang2 - bisect);
  695. double dist = radius / Math.sin(theta);
  696. double x = p2.getX() + dist * Math.cos(bisect);
  697. double y = p2.getY() + dist * Math.sin(bisect);
  698. // REMIND: This needs some work...
  699. if (ang1 < ang2) {
  700. ang1 -= Math.PI / 2.0;
  701. ang2 += Math.PI / 2.0;
  702. } else {
  703. ang1 += Math.PI / 2.0;
  704. ang2 -= Math.PI / 2.0;
  705. }
  706. ang1 = Math.toDegrees(-ang1);
  707. ang2 = Math.toDegrees(-ang2);
  708. diff = ang2 - ang1;
  709. if (diff < 0) {
  710. diff += 360;
  711. } else {
  712. diff -= 360;
  713. }
  714. setArcByCenter(x, y, radius, ang1, diff, type);
  715. }
  716. /**
  717. * Sets the starting angle of this arc to the specified double
  718. * value.
  719. *
  720. * @param angSt The starting angle of the arc in degrees.
  721. * @see #getAngleStart
  722. */
  723. public abstract void setAngleStart(double angSt);
  724. /**
  725. * Sets the angular extent of this arc to the specified double
  726. * value.
  727. *
  728. * @param angExt The angular extent of the arc in degrees.
  729. * @see #getAngleExtent
  730. */
  731. public abstract void setAngleExtent(double angExt);
  732. /**
  733. * Sets the starting angle of this arc to the angle that the
  734. * specified point defines relative to the center of this arc.
  735. * The angular extent of the arc will remain the same.
  736. *
  737. * @param p The <CODE>Point2D</CODE> that defines the starting angle.
  738. * @see #getAngleStart
  739. */
  740. public void setAngleStart(Point2D p) {
  741. setAngleStart(-Math.toDegrees(Math.atan2(p.getY() - getCenterY(),
  742. p.getX() - getCenterX())));
  743. }
  744. /**
  745. * Sets the starting angle and angular extent of this arc using two
  746. * sets of coordinates. The first set of coordinates is used to
  747. * determine the angle of the starting point relative to the arc's
  748. * center. The second set of coordinates is used to determine the
  749. * angle of the end point relative to the arc's center.
  750. * The arc will always be non-empty and extend counterclockwise
  751. * from the first point around to the second point.
  752. *
  753. * @param x1, y1 The coordinates of the arc's starting point.
  754. * @param x2, y2 The coordinates of the arc's ending point.
  755. */
  756. public void setAngles(double x1, double y1, double x2, double y2) {
  757. double x = getCenterX();
  758. double y = getCenterY();
  759. // Note: reversing the Y equations negates the angle to adjust
  760. // for the upside down coordinate system.
  761. double ang1 = Math.atan2(y - y1, x1 - x);
  762. double ang2 = Math.atan2(y - y2, x2 - x);
  763. ang2 -= ang1;
  764. if (ang2 <= 0.0) {
  765. ang2 += Math.PI * 2.0;
  766. }
  767. setAngleStart(Math.toDegrees(ang1));
  768. setAngleExtent(Math.toDegrees(ang2));
  769. }
  770. /**
  771. * Sets the starting angle and angular extent of this arc using
  772. * two points. The first point is used to determine the angle of
  773. * the starting point relative to the arc's center.
  774. * The second point is used to determine the angle of the end point
  775. * relative to the arc's center.
  776. * The arc will always be non-empty and extend counterclockwise
  777. * from the first point around to the second point.
  778. *
  779. * @param p1 The <CODE>Point2D</CODE> that defines the arc's
  780. * starting point.
  781. * @param p2 The <CODE>Point2D</CODE> that defines the arc's
  782. * ending point.
  783. */
  784. public void setAngles(Point2D p1, Point2D p2) {
  785. setAngles(p1.getX(), p1.getY(), p2.getX(), p2.getY());
  786. }
  787. /**
  788. * Sets the closure type of this arc to the specified value:
  789. * <CODE>OPEN</CODE>, <CODE>CHORD</CODE>, or <CODE>PIE</CODE>.
  790. *
  791. * @param type The integer constant that represents the closure
  792. * type of this arc: {@link #OPEN}, {@link #CHORD}, or
  793. * {@link #PIE}.
  794. *
  795. * @throws IllegalArgumentException if <code>type</code> is not
  796. * 0, 1, or 2.+
  797. * @see #getArcType
  798. */
  799. public void setArcType(int type) {
  800. if (type < OPEN || type > PIE) {
  801. throw new IllegalArgumentException("invalid type for Arc: "+type);
  802. }
  803. this.type = type;
  804. }
  805. /**
  806. * Sets the location and size of the outer bounds of this arc
  807. * to the specified values.
  808. *
  809. * @param x, y The coordinates of the upper left corner of the
  810. * arc's bounding box. (Specified in double precision.)
  811. * @param w The width of the arc's bounding box. (Specified in
  812. * double precision.)
  813. * @param h The height of the arc's bounding box. (Specified in
  814. * double precision.)
  815. */
  816. public void setFrame(double x, double y, double w, double h) {
  817. setArc(x, y, w, h, getAngleStart(), getAngleExtent(), type);
  818. }
  819. /**
  820. * Returns the high-precision bounding box of the arc. The bounding
  821. * box contains only the part of this <code>Arc2D</code> that is
  822. * in between the starting and ending angles and contains the pie
  823. * wedge, if this <code>Arc2D</code> has a <code>PIE</code> closure type.
  824. * <p>
  825. * This method differs from the
  826. * {@link RectangularShape#getBounds() getBounds} in that the
  827. * <code>getBounds</code> method only returns the bounds of the
  828. * enclosing ellipse of this <code>Arc2D</code> without considering
  829. * the starting and ending angles of this <code>Arc2D</code>.
  830. *
  831. * @return the <CODE>Rectangle2D</CODE> that represents the arc's
  832. * bounding box.
  833. */
  834. public Rectangle2D getBounds2D() {
  835. if (isEmpty()) {
  836. return makeBounds(getX(), getY(), getWidth(), getHeight());
  837. }
  838. double x1, y1, x2, y2;
  839. if (getArcType() == PIE) {
  840. x1 = y1 = x2 = y2 = 0.0;
  841. } else {
  842. x1 = y1 = 1.0;
  843. x2 = y2 = -1.0;
  844. }
  845. double angle = 0.0;
  846. for (int i = 0; i < 6; i++) {
  847. if (i < 4) {
  848. // 0-3 are the four quadrants
  849. angle += 90.0;
  850. if (!containsAngle(angle)) {
  851. continue;
  852. }
  853. } else if (i == 4) {
  854. // 4 is start angle
  855. angle = getAngleStart();
  856. } else {
  857. // 5 is end angle
  858. angle += getAngleExtent();
  859. }
  860. double rads = Math.toRadians(-angle);
  861. double xe = Math.cos(rads);
  862. double ye = Math.sin(rads);
  863. x1 = Math.min(x1, xe);
  864. y1 = Math.min(y1, ye);
  865. x2 = Math.max(x2, xe);
  866. y2 = Math.max(y2, ye);
  867. }
  868. double w = getWidth();
  869. double h = getHeight();
  870. x2 = (x2 - x1) * 0.5 * w;
  871. y2 = (y2 - y1) * 0.5 * h;
  872. x1 = getX() + (x1 * 0.5 + 0.5) * w;
  873. y1 = getY() + (y1 * 0.5 + 0.5) * h;
  874. return makeBounds(x1, y1, x2, y2);
  875. }
  876. /**
  877. * Constructs a <code>Rectangle2D</code> of the appropriate precision
  878. * to hold the parameters calculated to be the bounding box
  879. * of this arc.
  880. *
  881. * @param x, y The coordinates of the upper left corner of the
  882. * bounding box. (Specified in double precision.)
  883. * @param w The width of the bounding box. (Specified in
  884. * double precision.)
  885. * @param h The height of the bounding box. (Specified in
  886. * double precision.)
  887. * @return a <code>Rectangle2D</code> that is the bounding box
  888. * of this arc.
  889. */
  890. protected abstract Rectangle2D makeBounds(double x, double y,
  891. double w, double h);
  892. /*
  893. * Normalizes the specified angle into the range -180 to 180.
  894. */
  895. static double normalizeDegrees(double angle) {
  896. if (angle > 180.0) {
  897. if (angle <= (180.0 + 360.0)) {
  898. angle = angle - 360.0;
  899. } else {
  900. angle = Math.IEEEremainder(angle, 360.0);
  901. // IEEEremainder can return -180 here for some input values...
  902. if (angle == -180.0) {
  903. angle = 180.0;
  904. }
  905. }
  906. } else if (angle <= -180.0) {
  907. if (angle > (-180.0 - 360.0)) {
  908. angle = angle + 360.0;
  909. } else {
  910. angle = Math.IEEEremainder(angle, 360.0);
  911. // IEEEremainder can return -180 here for some input values...
  912. if (angle == -180.0) {
  913. angle = 180.0;
  914. }
  915. }
  916. }
  917. return angle;
  918. }
  919. /**
  920. * Determines whether or not the specified angle is within the
  921. * angular extents of the arc.
  922. *
  923. * @param angle The angle to test. (Specified in double precision.)
  924. *
  925. * @return <CODE>true</CODE> if the arc contains the angle,
  926. * <CODE>false</CODE> if the arc doesn't contain the angle.
  927. */
  928. public boolean containsAngle(double angle) {
  929. double angExt = getAngleExtent();
  930. boolean backwards = (angExt < 0.0);
  931. if (backwards) {
  932. angExt = -angExt;
  933. }
  934. if (angExt >= 360.0) {
  935. return true;
  936. }
  937. angle = normalizeDegrees(angle) - normalizeDegrees(getAngleStart());
  938. if (backwards) {
  939. angle = -angle;
  940. }
  941. if (angle < 0.0) {
  942. angle += 360.0;
  943. }
  944. return (angle >= 0.0) && (angle < angExt);
  945. }
  946. /**
  947. * Determines whether or not the specified point is inside the boundary
  948. * of the arc.
  949. *
  950. * @param x, y The coordinates of the point to test. (Specified in
  951. * double precision.)
  952. *
  953. * @return <CODE>true</CODE> if the point lies within the bound of
  954. * the arc, <CODE>false</CODE> if the point lies outside of the
  955. * arc's bounds.
  956. */
  957. public boolean contains(double x, double y) {
  958. // Normalize the coordinates compared to the ellipse
  959. // having a center at 0,0 and a radius of 0.5.
  960. double ellw = getWidth();
  961. if (ellw <= 0.0) {
  962. return false;
  963. }
  964. double normx = (x - getX()) / ellw - 0.5;
  965. double ellh = getHeight();
  966. if (ellh <= 0.0) {
  967. return false;
  968. }
  969. double normy = (y - getY()) / ellh - 0.5;
  970. double distSq = (normx * normx + normy * normy);
  971. if (distSq >= 0.25) {
  972. return false;
  973. }
  974. double angExt = Math.abs(getAngleExtent());
  975. if (angExt >= 360.0) {
  976. return true;
  977. }
  978. boolean inarc = containsAngle(-Math.toDegrees(Math.atan2(normy,
  979. normx)));
  980. if (type == PIE) {
  981. return inarc;
  982. }
  983. // CHORD and OPEN behave the same way
  984. if (inarc) {
  985. if (angExt >= 180.0) {
  986. return true;
  987. }
  988. // point must be outside the "pie triangle"
  989. } else {
  990. if (angExt <= 180.0) {
  991. return false;
  992. }
  993. // point must be inside the "pie triangle"
  994. }
  995. // The point is inside the pie triangle iff it is on the same
  996. // side of the line connecting the ends of the arc as the center.
  997. double angle = Math.toRadians(-getAngleStart());
  998. double x1 = Math.cos(angle);
  999. double y1 = Math.sin(angle);
  1000. angle += Math.toRadians(-getAngleExtent());
  1001. double x2 = Math.cos(angle);
  1002. double y2 = Math.sin(angle);
  1003. boolean inside = (Line2D.relativeCCW(x1, y1, x2, y2, x, y) *
  1004. Line2D.relativeCCW(x1, y1, x2, y2, 0, 0) >= 0);
  1005. return inarc ? !inside : inside;
  1006. }
  1007. /**
  1008. * Determines whether or not the interior of the arc intersects
  1009. * the interior of the specified rectangle.
  1010. *
  1011. * @param x, y The coordinates of the rectangle's upper left corner.
  1012. * (Specified in double precision.)
  1013. * @param w The width of the rectangle. (Specified in double precision.)
  1014. * @param h The height of the rectangle. (Specified in double precision.)
  1015. *
  1016. * @return <CODE>true</CODE> if the arc intersects the rectangle,
  1017. * <CODE>false</CODE> if the arc doesn't intersect the rectangle.
  1018. */
  1019. public boolean intersects(double x, double y, double w, double h) {
  1020. /*
  1021. * REMIND: Verify correct handling of "upside down angles".
  1022. */
  1023. /*
  1024. Change around so that is really works this time
  1025. We check each of the four line segments for intersection with an
  1026. ellipse of the same radius as the imaginary arc.
  1027. We then compute the angle of the intersections and call included
  1028. angle to find out if the intersection is within the arc itself
  1029. - Aaron Muderick
  1030. */
  1031. double intersect_angle;
  1032. double yint, xint;
  1033. //if there are any points of the rect in the arc then return true;
  1034. if (contains(x, y) || contains(x + w, y) ||
  1035. contains(x, y + h) || contains(x + w, y + h)) return true;
  1036. //we need to translate the arc and the rect so that we can do
  1037. //quadrant checking
  1038. x = x - (getX() + (getWidth()/2));
  1039. y = (y - (getY() + (getHeight()/2))) * (-1);
  1040. //find out the squash ratio
  1041. double squash = getWidth()/getHeight();
  1042. if (((x*x)/((getWidth()/2)*(getWidth()/2)) < 1)) {
  1043. if ((x == 0) && ((((getHeight()/2) >= (y-h)) && ((getHeight()/2) <= y))
  1044. || ((((-1) * (getHeight()/2)) >= (y-h)) && (((-1)
  1045. * (getHeight()/2) <= y))))) {
  1046. if (containsAngle(Math.PI2)) {
  1047. return true;
  1048. }
  1049. if (containsAngle(Math.PI*(3/2))) {
  1050. return true;
  1051. }
  1052. }
  1053. yint = Math.abs(Math.sqrt((1-((x*x)/((getWidth()/2)*(getWidth()/2))))
  1054. *((getHeight()/2)*(getHeight()/2))));
  1055. intersect_angle = Math.abs(Math.atan((yint*squash)/x));
  1056. if ((x > 0) && (((yint >= (y-h)) && (yint <= y))
  1057. || ((((-1) * yint) >= (y-h))
  1058. && (((-1) * yint) <= y)))) {
  1059. if (containsAngle(intersect_angleMath.PI * 180)) {
  1060. return true;
  1061. }
  1062. if (containsAngle((((2*Math.PI) - intersect_angle)/Math.PI)
  1063. * 180)) {
  1064. return true;
  1065. }
  1066. }
  1067. if ((x < 0) && (((yint >= (y-h)) && (yint <= y))
  1068. || ((((-1) * yint) >= (y-h))
  1069. && (((-1) * yint) <= y)))){
  1070. if (containsAngle((((Math.PI) - intersect_angle)/Math.PI) * 180)) {
  1071. return true;
  1072. }
  1073. if (containsAngle(((Math.PI + intersect_angle)/Math.PI) * 180)) {
  1074. return true;
  1075. }
  1076. }
  1077. }
  1078. if ((((x+w)*(x+w))/((getWidth()/2)*(getWidth()/2)) < 1)) {
  1079. if (((x+w) == 0) && ((((getHeight()/2) >= (y-h))
  1080. && ((getHeight()/2) <= y))
  1081. || ((((-1) * (getHeight()/2)) >= (y-h))
  1082. && (((-1) * (getHeight()/2) <= y))))) {
  1083. if (containsAngle(Math.PI2)) {
  1084. return true;
  1085. }
  1086. if (containsAngle(Math.PI*(3/2))) {
  1087. return true;
  1088. }
  1089. }
  1090. yint = Math.abs(Math.sqrt((1-(((x+w)*(x+w))
  1091. /((getWidth()/2)*(getWidth()/2))))
  1092. *((getHeight()/2)*(getHeight()/2))));
  1093. intersect_angle = Math.abs(Math.atan((yint*squash)/(x+w)));
  1094. if (((x+w) > 0) && (((yint >= (y-h)) && (yint <= y))
  1095. || ((((-1) * yint) >= (y-h))
  1096. && (((-1) * yint) <= y)))) {
  1097. if (containsAngle((intersect_angleMath.PI) * 180)) {
  1098. return true;
  1099. }
  1100. if (containsAngle((((2*Math.PI) - intersect_angle)/Math.PI) * 180)) {
  1101. return true;
  1102. }
  1103. }
  1104. if (((x+w) < 0) && (((yint >= (y-h)) && (yint <= y))
  1105. || ((((-1) * yint) >= (y-h))
  1106. && (((-1) * yint) <= y)))) {
  1107. if (containsAngle((((Math.PI) - intersect_angle)/Math.PI) * 180)) {
  1108. return true;
  1109. }
  1110. if (containsAngle(((Math.PI + intersect_angle)/Math.PI) * 180)) {
  1111. return true;
  1112. }
  1113. }
  1114. }
  1115. if (((y*y)/((getHeight()/2)*(getHeight()/2)) < 1)) {
  1116. if ((y == 0) && ((((getWidth()/2) >= x) && ((getWidth()/2) <= (x+w)))
  1117. || ((((-1) * (getWidth()/2)) >= x)
  1118. && (((-1) * (getWidth()/2)) <= (x+w))))) {
  1119. if (containsAngle(Math.PI)) {
  1120. return true;
  1121. }
  1122. if (containsAngle(Math.PI*2)) {
  1123. return true;
  1124. }
  1125. }
  1126. xint = Math.abs(Math.sqrt((1-((y*y)
  1127. /((getHeight()/2)
  1128. *(getHeight()/2))))
  1129. *((getWidth()/2)*(getWidth()/2))));
  1130. intersect_angle = Math.abs(Math.atan(y(xintsquash)));
  1131. if ((y > 0) && (((xint >= x) && (xint <= (x+w)))
  1132. || ((((-1) * xint) >= x)
  1133. && (((-1) * xint) <= (x+w))))) {
  1134. if (containsAngle((intersect_angle)/Math.PI * 180)) {
  1135. return true;
  1136. }
  1137. if (containsAngle(((Math.PI) - intersect_angle)/Math.PI * 180)) {
  1138. return true;
  1139. }
  1140. }
  1141. if ((y < 0) && (((xint >= x) && (xint <= (x+w)))
  1142. || ((((-1) * xint) >= x)
  1143. && (((-1) * xint) <= (x+w))))) {
  1144. if (containsAngle(((Math.PI*2) - intersect_angle)/Math.PI * 180)) {
  1145. return true;
  1146. }
  1147. if (containsAngle((Math.PI + intersect_angle)/Math.PI * 180)) {
  1148. return true;
  1149. }
  1150. }
  1151. }
  1152. if ((((y-h)*(y-h))/((getHeight()/2)*(getHeight()/2)) < 1)) {
  1153. if (((y-h) == 0) && ((((getWidth()/2) >= x)
  1154. && ((getWidth()/2) <= (x+w)))
  1155. || ((((-1) * (getWidth()/2)) >= x)
  1156. && (((-1) * (getWidth()/2)) <= (x+w))))) {
  1157. if (containsAngle(Math.PI)) {
  1158. return true;
  1159. }
  1160. if (containsAngle(Math.PI*2)) {
  1161. return true;
  1162. }
  1163. }
  1164. xint = Math.abs(Math.sqrt((1-(((y-h)*(y-h))
  1165. /((getHeight()/2)*(getHeight()/2))))
  1166. *((getWidth()/2)*(getWidth()/2))));
  1167. intersect_angle = Math.abs(Math.atan((y-h)/(xintsquash)));
  1168. if (((y-h) > 0) && (((xint >= x) && (xint <= (x+w)))
  1169. || ((((-1) * xint) >= x)
  1170. && (((-1) * xint) <= (x+w))))) {
  1171. if (containsAngle(intersect_angleMath.PI * 180)) {
  1172. return true;
  1173. }
  1174. if (containsAngle(((Math.PI) - intersect_angle)/Math.PI * 180)) {
  1175. return true;
  1176. }
  1177. }
  1178. if (((y-h) < 0) && (((xint >= x) && (xint <= (x+w)))
  1179. || ((((-1) * xint) >= x)
  1180. && (((-1) * xint) <= (x+w))))) {
  1181. if (containsAngle(((Math.PI*2) - intersect_angle)/Math.PI * 180)) {
  1182. return true;
  1183. }
  1184. if (containsAngle((Math.PI + intersect_angle)/Math.PI * 180)) {
  1185. return true;
  1186. }
  1187. }
  1188. }
  1189. return false;
  1190. }
  1191. /**
  1192. * Determine whether or not the interior of the arc entirely contains
  1193. * the specified rectangle.
  1194. *
  1195. * @param x, y The coordinates of the rectangle's upper left corner.
  1196. * (Specified in double precision.)
  1197. * @param w The width of the rectangle. (Specified in double precision.)
  1198. * @param h The height of the rectangle. (Specified in double precision.)
  1199. *
  1200. * @return <CODE>true</CODE> if the arc contains the rectangle,
  1201. * <CODE>false</CODE> if the arc doesn't contain the rectangle.
  1202. */
  1203. public boolean contains(double x, double y, double w, double h) {
  1204. return contains(x, y, w, h, null);
  1205. }
  1206. /**
  1207. * Determine whether or not the interior of the arc entirely contains
  1208. * the specified rectangle.
  1209. *
  1210. * @param r The <CODE>Rectangle2D</CODE> to test.
  1211. *
  1212. * @return <CODE>true</CODE> if the arc contains the rectangle,
  1213. * <CODE>false</CODE> if the arc doesn't contain the rectangle.
  1214. */
  1215. public boolean contains(Rectangle2D r) {
  1216. return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight(), r);
  1217. }
  1218. private boolean contains(double x, double y, double w, double h,
  1219. Rectangle2D origrect) {
  1220. if (!(contains(x, y) &&
  1221. contains(x + w, y) &&
  1222. contains(x, y + h) &&
  1223. contains(x + w, y + h))) {
  1224. return false;
  1225. }
  1226. // If the shape is convex then we have done all the testing
  1227. // we need. Only PIE arcs can be concave and then only if
  1228. // the angular extents are greater than 180 degrees.
  1229. if (type != PIE || getAngleExtent() <= 180.0) {
  1230. return true;
  1231. }
  1232. // For a PIE shape we have an additional test for the case where
  1233. // the angular extents are greater than 180 degrees and all four
  1234. // rectangular corners are inside the shape but one of the
  1235. // rectangle edges spans across the "missing wedge" of the arc.
  1236. // We can test for this case by checking if the rectangle intersects
  1237. // either of the pie angle segments.
  1238. if (origrect == null) {
  1239. origrect = new Rectangle2D.Double(x, y, w, h);
  1240. }
  1241. double halfW = getWidth() / 2.0;
  1242. double halfH = getHeight() / 2.0;
  1243. double xc = getX() + halfW;
  1244. double yc = getY() + halfH;
  1245. double angle = Math.toRadians(-getAngleStart());
  1246. double xe = xc + halfW * Math.cos(angle);
  1247. double ye = yc + halfH * Math.sin(angle);
  1248. if (origrect.intersectsLine(xc, yc, xe, ye)) {
  1249. return false;
  1250. }
  1251. angle += Math.toRadians(-getAngleExtent());
  1252. xe = xc + halfW * Math.cos(angle);
  1253. ye = yc + halfH * Math.sin(angle);
  1254. return !origrect.intersectsLine(xc, yc, xe, ye);
  1255. }
  1256. /**
  1257. * Returns an iteration object that defines the boundary of the
  1258. * arc.
  1259. * This iterator is multithread safe.
  1260. * <code>Arc2D</code> guarantees that
  1261. * modifications to the geometry of the arc
  1262. * do not affect any iterations of that geometry that
  1263. * are already in process.
  1264. *
  1265. * @param at an optional <CODE>AffineTransform</CODE> to be applied
  1266. * to the coordinates as they are returned in the iteration, or null
  1267. * if the untransformed coordinates are desired.
  1268. *
  1269. * @return A <CODE>PathIterator</CODE> that defines the arc's boundary.
  1270. */
  1271. public PathIterator getPathIterator(AffineTransform at) {
  1272. return new ArcIterator(this, at);
  1273. }
  1274. }