1. /*
  2. * @(#)Polygon.java 1.49 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;
  8. import java.awt.geom.AffineTransform;
  9. import java.awt.geom.PathIterator;
  10. import java.awt.geom.Point2D;
  11. import java.awt.geom.Rectangle2D;
  12. import sun.awt.geom.Crossings;
  13. /**
  14. * The <code>Polygon</code> class encapsulates a description of a
  15. * closed, two-dimensional region within a coordinate space. This
  16. * region is bounded by an arbitrary number of line segments, each of
  17. * which is one side of the polygon. Internally, a polygon
  18. * comprises of a list of (<i>x</i>, <i>y</i>)
  19. * coordinate pairs, where each pair defines a <i>vertex</i> of the
  20. * polygon, and two successive pairs are the endpoints of a
  21. * line that is a side of the polygon. The first and final
  22. * pairs of (<i>x</i>, <i>y</i>) points are joined by a line segment
  23. * that closes the polygon. This <code>Polygon</code> is defined with
  24. * an even-odd winding rule. See
  25. * {@link java.awt.geom.PathIterator#WIND_EVEN_ODD WIND_EVEN_ODD}
  26. * for a definition of the even-odd winding rule.
  27. * This class's hit-testing methods, which include the
  28. * <code>contains</code>, <code>intersects</code> and <code>inside</code>
  29. * methods, use the <i>insideness</i> definition described in the
  30. * {@link Shape} class comments.
  31. *
  32. * @version 1.26, 07/24/98
  33. * @author Sami Shaio
  34. * @see Shape
  35. * @author Herb Jellinek
  36. * @since JDK1.0
  37. */
  38. public class Polygon implements Shape, java.io.Serializable {
  39. /**
  40. * The total number of points. The value of <code>npoints</code>
  41. * represents the number of valid points in this <code>Polygon</code>
  42. * and might be less than the number of elements in
  43. * {@link #xpoints xpoints} or {@link #ypoints ypoints}.
  44. * This value can be NULL.
  45. *
  46. * @serial
  47. * @see #addPoint(int, int)
  48. */
  49. public int npoints;
  50. /**
  51. * The array of <i>x</i> coordinates. The number of elements in
  52. * this array might be more than the number of <i>x</i> coordinates
  53. * in this <code>Polygon</code>. The extra elements allow new points
  54. * to be added to this <code>Polygon</code> without re-creating this
  55. * array. The value of {@link #npoints npoints} is equal to the
  56. * number of valid points in this <code>Polygon</code>.
  57. *
  58. * @serial
  59. * @see #addPoint(int, int)
  60. */
  61. public int xpoints[];
  62. /**
  63. * The array of <i>y</i> coordinates. The number of elements in
  64. * this array might be more than the number of <i>y</i> coordinates
  65. * in this <code>Polygon</code>. The extra elements allow new points
  66. * to be added to this <code>Polygon</code> without re-creating this
  67. * array. The value of <code>npoints</code> is equal to the
  68. * number of valid points in this <code>Polygon</code>.
  69. *
  70. * @serial
  71. * @see #addPoint(int, int)
  72. */
  73. public int ypoints[];
  74. /**
  75. * Bounds of the polygon.
  76. * This value can be NULL.
  77. * Please see the javadoc comments getBounds().
  78. *
  79. * @serial
  80. * @see #getBoundingBox()
  81. * @see #getBounds()
  82. */
  83. protected Rectangle bounds;
  84. /*
  85. * JDK 1.1 serialVersionUID
  86. */
  87. private static final long serialVersionUID = -6460061437900069969L;
  88. /**
  89. * Creates an empty polygon.
  90. */
  91. public Polygon() {
  92. xpoints = new int[4];
  93. ypoints = new int[4];
  94. }
  95. /**
  96. * Constructs and initializes a <code>Polygon</code> from the specified
  97. * parameters.
  98. * @param xpoints an array of <i>x</i> coordinates
  99. * @param ypoints an array of <i>y</i> coordinates
  100. * @param npoints the total number of points in the
  101. * <code>Polygon</code>
  102. * @exception NegativeArraySizeException if the value of
  103. * <code>npoints</code> is negative.
  104. * @exception IndexOutOfBoundsException if <code>npoints</code> is
  105. * greater than the length of <code>xpoints</code>
  106. * or the length of <code>ypoints</code>.
  107. * @exception NullPointerException if <code>xpoints</code> or
  108. * <code>ypoints</code> is <code>null</code>.
  109. */
  110. public Polygon(int xpoints[], int ypoints[], int npoints) {
  111. // Fix 4489009: should throw IndexOutofBoundsException instead
  112. // of OutofMemoryException if npoints is huge and > {x,y}points.length
  113. if (npoints > xpoints.length || npoints > ypoints.length) {
  114. throw new IndexOutOfBoundsException("npoints > xpoints.length || npoints > ypoints.length");
  115. }
  116. this.npoints = npoints;
  117. this.xpoints = new int[npoints];
  118. this.ypoints = new int[npoints];
  119. System.arraycopy(xpoints, 0, this.xpoints, 0, npoints);
  120. System.arraycopy(ypoints, 0, this.ypoints, 0, npoints);
  121. }
  122. /**
  123. * Resets this <code>Polygon</code> object to an empty polygon.
  124. * The coordinate arrays and the data in them are left untouched
  125. * but the number of points is reset to zero to mark the old
  126. * vertex data as invalid and to start accumulating new vertex
  127. * data at the beginning.
  128. * All internally-cached data relating to the old vertices
  129. * are discarded.
  130. * Note that since the coordinate arrays from before the reset
  131. * are reused, creating a new empty <code>Polygon</code> might
  132. * be more memory efficient than resetting the current one if
  133. * the number of vertices in the new polygon data is significantly
  134. * smaller than the number of vertices in the data from before the
  135. * reset.
  136. * @see java.awt.Polygon#invalidate
  137. * @since 1.4
  138. */
  139. public void reset() {
  140. npoints = 0;
  141. bounds = null;
  142. }
  143. /**
  144. * Invalidates or flushes any internally-cached data that depends
  145. * on the vertex coordinates of this <code>Polygon</code>.
  146. * This method should be called after any direct manipulation
  147. * of the coordinates in the <code>xpoints</code> or
  148. * <code>ypoints</code> arrays to avoid inconsistent results
  149. * from methods such as <code>getBounds</code> or <code>contains</code>
  150. * that might cache data from earlier computations relating to
  151. * the vertex coordinates.
  152. * @see java.awt.Polygon#getBounds
  153. * @since 1.4
  154. */
  155. public void invalidate() {
  156. bounds = null;
  157. }
  158. /**
  159. * Translates the vertices of the <code>Polygon</code> by
  160. * <code>deltaX</code> along the x axis and by
  161. * <code>deltaY</code> along the y axis.
  162. * @param deltaX the amount to translate along the <i>x</i> axis
  163. * @param deltaY the amount to translate along the <i>y</i> axis
  164. * @since JDK1.1
  165. */
  166. public void translate(int deltaX, int deltaY) {
  167. for (int i = 0; i < npoints; i++) {
  168. xpoints[i] += deltaX;
  169. ypoints[i] += deltaY;
  170. }
  171. if (bounds != null) {
  172. bounds.translate(deltaX, deltaY);
  173. }
  174. }
  175. /*
  176. * Calculates the bounding box of the points passed to the constructor.
  177. * Sets <code>bounds</code> to the result.
  178. * @param xpoints[] array of <i>x</i> coordinates
  179. * @param ypoints[] array of <i>y</i> coordinates
  180. * @param npoints the total number of points
  181. */
  182. void calculateBounds(int xpoints[], int ypoints[], int npoints) {
  183. int boundsMinX = Integer.MAX_VALUE;
  184. int boundsMinY = Integer.MAX_VALUE;
  185. int boundsMaxX = Integer.MIN_VALUE;
  186. int boundsMaxY = Integer.MIN_VALUE;
  187. for (int i = 0; i < npoints; i++) {
  188. int x = xpoints[i];
  189. boundsMinX = Math.min(boundsMinX, x);
  190. boundsMaxX = Math.max(boundsMaxX, x);
  191. int y = ypoints[i];
  192. boundsMinY = Math.min(boundsMinY, y);
  193. boundsMaxY = Math.max(boundsMaxY, y);
  194. }
  195. bounds = new Rectangle(boundsMinX, boundsMinY,
  196. boundsMaxX - boundsMinX,
  197. boundsMaxY - boundsMinY);
  198. }
  199. /*
  200. * Resizes the bounding box to accomodate the specified coordinates.
  201. * @param x, y the specified coordinates
  202. */
  203. void updateBounds(int x, int y) {
  204. if (x < bounds.x) {
  205. bounds.width = bounds.width + (bounds.x - x);
  206. bounds.x = x;
  207. }
  208. else {
  209. bounds.width = Math.max(bounds.width, x - bounds.x);
  210. // bounds.x = bounds.x;
  211. }
  212. if (y < bounds.y) {
  213. bounds.height = bounds.height + (bounds.y - y);
  214. bounds.y = y;
  215. }
  216. else {
  217. bounds.height = Math.max(bounds.height, y - bounds.y);
  218. // bounds.y = bounds.y;
  219. }
  220. }
  221. /**
  222. * Appends the specified coordinates to this <code>Polygon</code>.
  223. * <p>
  224. * If an operation that calculates the bounding box of this
  225. * <code>Polygon</code> has already been performed, such as
  226. * <code>getBounds</code> or <code>contains</code>, then this
  227. * method updates the bounding box.
  228. * @param x the specified x coordinate
  229. * @param y the specified y coordinate
  230. * @see java.awt.Polygon#getBounds
  231. * @see java.awt.Polygon#contains
  232. */
  233. public void addPoint(int x, int y) {
  234. if (npoints == xpoints.length) {
  235. int tmp[];
  236. tmp = new int[npoints * 2];
  237. System.arraycopy(xpoints, 0, tmp, 0, npoints);
  238. xpoints = tmp;
  239. tmp = new int[npoints * 2];
  240. System.arraycopy(ypoints, 0, tmp, 0, npoints);
  241. ypoints = tmp;
  242. }
  243. xpoints[npoints] = x;
  244. ypoints[npoints] = y;
  245. npoints++;
  246. if (bounds != null) {
  247. updateBounds(x, y);
  248. }
  249. }
  250. /**
  251. * Gets the bounding box of this <code>Polygon</code>.
  252. * The bounding box is the smallest {@link Rectangle} whose
  253. * sides are parallel to the x and y axes of the
  254. * coordinate space, and can completely contain the <code>Polygon</code>.
  255. * @return a <code>Rectangle</code> that defines the bounds of this
  256. * <code>Polygon</code>.
  257. * @since JDK1.1
  258. */
  259. public Rectangle getBounds() {
  260. return getBoundingBox();
  261. }
  262. /**
  263. * Returns the bounds of this <code>Polygon</code>.
  264. * @return the bounds of this <code>Polygon</code>.
  265. * @deprecated As of JDK version 1.1,
  266. * replaced by <code>getBounds()</code>.
  267. */
  268. public Rectangle getBoundingBox() {
  269. if (npoints == 0) {
  270. return new Rectangle();
  271. }
  272. if (bounds == null) {
  273. calculateBounds(xpoints, ypoints, npoints);
  274. }
  275. return bounds.getBounds();
  276. }
  277. /**
  278. * Determines whether the specified {@link Point} is inside this
  279. * <code>Polygon</code>.
  280. * @param p the specified <code>Point</code> to be tested
  281. * @return <code>true</code> if the <code>Polygon</code> contains the
  282. * <code>Point</code> <code>false</code> otherwise.
  283. * @see #contains(double, double)
  284. */
  285. public boolean contains(Point p) {
  286. return contains(p.x, p.y);
  287. }
  288. /**
  289. * Determines whether the specified coordinates are inside this
  290. * <code>Polygon</code>.
  291. * <p>
  292. * @param x the specified x coordinate to be tested
  293. * @param y the specified y coordinate to be tested
  294. * @return <code>true</code> if this <code>Polygon</code> contains
  295. * the specified coordinates, (<i>x</i>, <i>y</i>);
  296. * <code>false</code> otherwise.
  297. * @see #contains(double, double)
  298. * @since JDK1.1
  299. */
  300. public boolean contains(int x, int y) {
  301. return contains((double) x, (double) y);
  302. }
  303. /**
  304. * Determines whether the specified coordinates are contained in this
  305. * <code>Polygon</code>.
  306. * @param x the specified x coordinate to be tested
  307. * @param y the specified y coordinate to be tested
  308. * @return <code>true</code> if this <code>Polygon</code> contains
  309. * the specified coordinates, (<i>x</i>, <i>y</i>);
  310. * <code>false</code> otherwise.
  311. * @see #contains(double, double)
  312. * @deprecated As of JDK version 1.1,
  313. * replaced by <code>contains(int, int)</code>.
  314. */
  315. public boolean inside(int x, int y) {
  316. return contains((double) x, (double) y);
  317. }
  318. /**
  319. * Returns the high precision bounding box of the {@link Shape}.
  320. * @return a {@link Rectangle2D} that precisely
  321. * bounds the <code>Shape</code>.
  322. */
  323. public Rectangle2D getBounds2D() {
  324. return getBounds();
  325. }
  326. /**
  327. * Determines if the specified coordinates are inside this
  328. * <code>Polygon</code>. For the definition of
  329. * <i>insideness</i>, see the class comments of {@link Shape}.
  330. * @param x the specified x coordinate
  331. * @param y the specified y coordinate
  332. * @return <code>true</code> if the <code>Polygon</code> contains the
  333. * specified coordinates; <code>false</code> otherwise.
  334. */
  335. public boolean contains(double x, double y) {
  336. if (npoints <= 2 || !getBoundingBox().contains(x, y)) {
  337. return false;
  338. }
  339. int hits = 0;
  340. int lastx = xpoints[npoints - 1];
  341. int lasty = ypoints[npoints - 1];
  342. int curx, cury;
  343. // Walk the edges of the polygon
  344. for (int i = 0; i < npoints; lastx = curx, lasty = cury, i++) {
  345. curx = xpoints[i];
  346. cury = ypoints[i];
  347. if (cury == lasty) {
  348. continue;
  349. }
  350. int leftx;
  351. if (curx < lastx) {
  352. if (x >= lastx) {
  353. continue;
  354. }
  355. leftx = curx;
  356. } else {
  357. if (x >= curx) {
  358. continue;
  359. }
  360. leftx = lastx;
  361. }
  362. double test1, test2;
  363. if (cury < lasty) {
  364. if (y < cury || y >= lasty) {
  365. continue;
  366. }
  367. if (x < leftx) {
  368. hits++;
  369. continue;
  370. }
  371. test1 = x - curx;
  372. test2 = y - cury;
  373. } else {
  374. if (y < lasty || y >= cury) {
  375. continue;
  376. }
  377. if (x < leftx) {
  378. hits++;
  379. continue;
  380. }
  381. test1 = x - lastx;
  382. test2 = y - lasty;
  383. }
  384. if (test1 < (test2 / (lasty - cury) * (lastx - curx))) {
  385. hits++;
  386. }
  387. }
  388. return ((hits & 1) != 0);
  389. }
  390. private Crossings getCrossings(double xlo, double ylo,
  391. double xhi, double yhi)
  392. {
  393. Crossings cross = new Crossings.EvenOdd(xlo, ylo, xhi, yhi);
  394. int lastx = xpoints[npoints - 1];
  395. int lasty = ypoints[npoints - 1];
  396. int curx, cury;
  397. // Walk the edges of the polygon
  398. for (int i = 0; i < npoints; i++) {
  399. curx = xpoints[i];
  400. cury = ypoints[i];
  401. if (cross.accumulateLine(lastx, lasty, curx, cury)) {
  402. return null;
  403. }
  404. lastx = curx;
  405. lasty = cury;
  406. }
  407. return cross;
  408. }
  409. /**
  410. * Tests if a specified {@link Point2D} is inside the boundary of this
  411. * <code>Polygon</code>.
  412. * @param p a specified <code>Point2D</code>
  413. * @return <code>true</code> if this <code>Polygon</code> contains the
  414. * specified <code>Point2D</code> <code>false</code>
  415. * otherwise.
  416. * @see #contains(double, double)
  417. */
  418. public boolean contains(Point2D p) {
  419. return contains(p.getX(), p.getY());
  420. }
  421. /**
  422. * Tests if the interior of this <code>Polygon</code> intersects the
  423. * interior of a specified set of rectangular coordinates.
  424. * @param x the x coordinate of the specified rectangular
  425. * shape's top-left corner
  426. * @param y the y coordinate of the specified rectangular
  427. * shape's top-left corner
  428. * @param w the width of the specified rectangular shape
  429. * @param h the height of the specified rectangular shape
  430. * @return <code>true</code> if the interior of this
  431. * <code>Polygon</code> and the interior of the
  432. * specified set of rectangular
  433. * coordinates intersect each other;
  434. * <code>false</code> otherwise.
  435. */
  436. public boolean intersects(double x, double y, double w, double h) {
  437. if (npoints <= 0 || !getBoundingBox().intersects(x, y, w, h)) {
  438. return false;
  439. }
  440. Crossings cross = getCrossings(x, y, x+w, y+h);
  441. return (cross == null || !cross.isEmpty());
  442. }
  443. /**
  444. * Tests if the interior of this <code>Polygon</code> intersects the
  445. * interior of a specified <code>Rectangle2D</code>.
  446. * @param r a specified <code>Rectangle2D</code>
  447. * @return <code>true</code> if this <code>Polygon</code> and the
  448. * interior of the specified <code>Rectangle2D</code>
  449. * intersect each other; <code>false</code>
  450. * otherwise.
  451. */
  452. public boolean intersects(Rectangle2D r) {
  453. return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
  454. }
  455. /**
  456. * Tests if the interior of this <code>Polygon</code> entirely
  457. * contains the specified set of rectangular coordinates.
  458. * @param x the x coordinate of the top-left corner of the
  459. * specified set of rectangular coordinates
  460. * @param y the y coordinate of the top-left corner of the
  461. * specified set of rectangular coordinates
  462. * @param w the width of the set of rectangular coordinates
  463. * @param h the height of the set of rectangular coordinates
  464. * @return <code>true</code> if this <code>Polygon</code> entirely
  465. * contains the specified set of rectangular
  466. * coordinates; <code>false</code> otherwise.
  467. */
  468. public boolean contains(double x, double y, double w, double h) {
  469. if (npoints <= 0 || !getBoundingBox().intersects(x, y, w, h)) {
  470. return false;
  471. }
  472. Crossings cross = getCrossings(x, y, x+w, y+h);
  473. return (cross != null && cross.covers(y, y+h));
  474. }
  475. /**
  476. * Tests if the interior of this <code>Polygon</code> entirely
  477. * contains the specified <code>Rectangle2D</code>.
  478. * @param r the specified <code>Rectangle2D</code>
  479. * @return <code>true</code> if this <code>Polygon</code> entirely
  480. * contains the specified <code>Rectangle2D</code>
  481. * <code>false</code> otherwise.
  482. * @see #contains(double, double, double, double)
  483. */
  484. public boolean contains(Rectangle2D r) {
  485. return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
  486. }
  487. /**
  488. * Returns an iterator object that iterates along the boundary of this
  489. * <code>Polygon</code> and provides access to the geometry
  490. * of the outline of this <code>Polygon</code>. An optional
  491. * {@link AffineTransform} can be specified so that the coordinates
  492. * returned in the iteration are transformed accordingly.
  493. * @param at an optional <code>AffineTransform</code> to be applied to the
  494. * coordinates as they are returned in the iteration, or
  495. * <code>null</code> if untransformed coordinates are desired
  496. * @return a {@link PathIterator} object that provides access to the
  497. * geometry of this <code>Polygon</code>.
  498. */
  499. public PathIterator getPathIterator(AffineTransform at) {
  500. return new PolygonPathIterator(this, at);
  501. }
  502. /**
  503. * Returns an iterator object that iterates along the boundary of
  504. * the <code>Shape</code> and provides access to the geometry of the
  505. * outline of the <code>Shape</code>. Only SEG_MOVETO, SEG_LINETO, and
  506. * SEG_CLOSE point types are returned by the iterator.
  507. * Since polygons are already flat, the <code>flatness</code> parameter
  508. * is ignored. An optional <code>AffineTransform</code> can be specified
  509. * in which case the coordinates returned in the iteration are transformed
  510. * accordingly.
  511. * @param at an optional <code>AffineTransform</code> to be applied to the
  512. * coordinates as they are returned in the iteration, or
  513. * <code>null</code> if untransformed coordinates are desired
  514. * @param flatness the maximum amount that the control points
  515. * for a given curve can vary from colinear before a subdivided
  516. * curve is replaced by a straight line connecting the
  517. * endpoints. Since polygons are already flat the
  518. * <code>flatness</code> parameter is ignored.
  519. * @return a <code>PathIterator</code> object that provides access to the
  520. * <code>Shape</code> object's geometry.
  521. */
  522. public PathIterator getPathIterator(AffineTransform at, double flatness) {
  523. return getPathIterator(at);
  524. }
  525. class PolygonPathIterator implements PathIterator {
  526. Polygon poly;
  527. AffineTransform transform;
  528. int index;
  529. public PolygonPathIterator(Polygon pg, AffineTransform at) {
  530. poly = pg;
  531. transform = at;
  532. if (pg.npoints == 0) {
  533. // Prevent a spurious SEG_CLOSE segment
  534. index = 1;
  535. }
  536. }
  537. /**
  538. * Returns the winding rule for determining the interior of the
  539. * path.
  540. * @return an integer representing the current winding rule.
  541. * @see PathIterator#WIND_NON_ZERO
  542. */
  543. public int getWindingRule() {
  544. return WIND_EVEN_ODD;
  545. }
  546. /**
  547. * Tests if there are more points to read.
  548. * @return <code>true</code> if there are more points to read;
  549. * <code>false</code> otherwise.
  550. */
  551. public boolean isDone() {
  552. return index > poly.npoints;
  553. }
  554. /**
  555. * Moves the iterator forwards, along the primary direction of
  556. * traversal, to the next segment of the path when there are
  557. * more points in that direction.
  558. */
  559. public void next() {
  560. index++;
  561. }
  562. /**
  563. * Returns the coordinates and type of the current path segment in
  564. * the iteration.
  565. * The return value is the path segment type:
  566. * SEG_MOVETO, SEG_LINETO, or SEG_CLOSE.
  567. * A <code>float</code> array of length 2 must be passed in and
  568. * can be used to store the coordinates of the point(s).
  569. * Each point is stored as a pair of <code>float</code> x, y
  570. * coordinates. SEG_MOVETO and SEG_LINETO types return one
  571. * point, and SEG_CLOSE does not return any points.
  572. * @param coords a <code>float</code> array that specifies the
  573. * coordinates of the point(s)
  574. * @return an integer representing the type and coordinates of the
  575. * current path segment.
  576. * @see PathIterator#SEG_MOVETO
  577. * @see PathIterator#SEG_LINETO
  578. * @see PathIterator#SEG_CLOSE
  579. */
  580. public int currentSegment(float[] coords) {
  581. if (index >= poly.npoints) {
  582. return SEG_CLOSE;
  583. }
  584. coords[0] = poly.xpoints[index];
  585. coords[1] = poly.ypoints[index];
  586. if (transform != null) {
  587. transform.transform(coords, 0, coords, 0, 1);
  588. }
  589. return (index == 0 ? SEG_MOVETO : SEG_LINETO);
  590. }
  591. /**
  592. * Returns the coordinates and type of the current path segment in
  593. * the iteration.
  594. * The return value is the path segment type:
  595. * SEG_MOVETO, SEG_LINETO, or SEG_CLOSE.
  596. * A <code>double</code> array of length 2 must be passed in and
  597. * can be used to store the coordinates of the point(s).
  598. * Each point is stored as a pair of <code>double</code> x, y
  599. * coordinates.
  600. * SEG_MOVETO and SEG_LINETO types return one point,
  601. * and SEG_CLOSE does not return any points.
  602. * @param coords a <code>double</code> array that specifies the
  603. * coordinates of the point(s)
  604. * @return an integer representing the type and coordinates of the
  605. * current path segment.
  606. * @see PathIterator#SEG_MOVETO
  607. * @see PathIterator#SEG_LINETO
  608. * @see PathIterator#SEG_CLOSE
  609. */
  610. public int currentSegment(double[] coords) {
  611. if (index >= poly.npoints) {
  612. return SEG_CLOSE;
  613. }
  614. coords[0] = poly.xpoints[index];
  615. coords[1] = poly.ypoints[index];
  616. if (transform != null) {
  617. transform.transform(coords, 0, coords, 0, 1);
  618. }
  619. return (index == 0 ? SEG_MOVETO : SEG_LINETO);
  620. }
  621. }
  622. }