/android/LGame-Android-0.2.6S/org/loon/framework/android/game/core/graphics/geom/PathIterator.java

http://loon-simple.googlecode.com/ · Java · 202 lines · 15 code · 13 blank · 174 comment · 0 complexity · d05e1a3481e9bccd540b33547d7d7775 MD5 · raw file

  1. /*
  2. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  3. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4. *
  5. * This code is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 only, as
  7. * published by the Free Software Foundation. Sun designates this
  8. * particular file as subject to the "Classpath" exception as provided
  9. * by Sun in the LICENSE file that accompanied this code.
  10. *
  11. * This code is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14. * version 2 for more details (a copy is included in the LICENSE file that
  15. * accompanied this code).
  16. *
  17. * You should have received a copy of the GNU General Public License version
  18. * 2 along with this work; if not, write to the Free Software Foundation,
  19. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20. *
  21. * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  22. * CA 95054 USA or visit www.sun.com if you need additional information or
  23. * have any questions.
  24. */
  25. package org.loon.framework.android.game.core.graphics.geom;
  26. /**
  27. * The <code>PathIterator</code> interface provides the mechanism for objects
  28. * that implement the {@link and.awt.Shape Shape} interface to return the
  29. * geometry of their boundary by allowing a caller to retrieve the path of that
  30. * boundary a segment at a time. This interface allows these objects to retrieve
  31. * the path of their boundary a segment at a time by using 1st through 3rd order
  32. * B&eacute;zier curves, which are lines and quadratic or cubic B&eacute;zier
  33. * splines.
  34. * <p>
  35. * Multiple subpaths can be expressed by using a "MOVETO" segment to create a
  36. * discontinuity in the geometry to move from the end of one subpath to the
  37. * beginning of the next.
  38. * <p>
  39. * Each subpath can be closed manually by ending the last segment in the subpath
  40. * on the same coordinate as the beginning "MOVETO" segment for that subpath or
  41. * by using a "CLOSE" segment to append a line segment from the last point back
  42. * to the first. Be aware that manually closing an outline as opposed to using a
  43. * "CLOSE" segment to close the path might result in different line style
  44. * decorations being used at the end points of the subpath. For example, the
  45. * {@link java.awt.BasicStroke BasicStroke} object uses a line "JOIN" decoration
  46. * to connect the first and last points if a "CLOSE" segment is encountered,
  47. * whereas simply ending the path on the same coordinate as the beginning
  48. * coordinate results in line "CAP" decorations being used at the ends.
  49. *
  50. * @see and.awt.Shape
  51. * @see java.awt.BasicStroke
  52. *
  53. * @author Jim Graham
  54. */
  55. public interface PathIterator {
  56. /**
  57. * The winding rule constant for specifying an even-odd rule for determining
  58. * the interior of a path. The even-odd rule specifies that a point lies
  59. * inside the path if a ray drawn in any direction from that point to
  60. * infinity is crossed by path segments an odd number of times.
  61. */
  62. public static final int WIND_EVEN_ODD = 0;
  63. /**
  64. * The winding rule constant for specifying a non-zero rule for determining
  65. * the interior of a path. The non-zero rule specifies that a point lies
  66. * inside the path if a ray drawn in any direction from that point to
  67. * infinity is crossed by path segments a different number of times in the
  68. * counter-clockwise direction than the clockwise direction.
  69. */
  70. public static final int WIND_NON_ZERO = 1;
  71. /**
  72. * The segment type constant for a point that specifies the starting
  73. * location for a new subpath.
  74. */
  75. public static final int SEG_MOVETO = 0;
  76. /**
  77. * The segment type constant for a point that specifies the end point of a
  78. * line to be drawn from the most recently specified point.
  79. */
  80. public static final int SEG_LINETO = 1;
  81. /**
  82. * The segment type constant for the pair of points that specify a quadratic
  83. * parametric curve to be drawn from the most recently specified point. The
  84. * curve is interpolated by solving the parametric control equation in the
  85. * range <code>(t=[0..1])</code> using the most recently specified (current)
  86. * point (CP), the first control point (P1), and the final interpolated
  87. * control point (P2). The parametric control equation for this curve is:
  88. *
  89. * <pre>
  90. * P(t) = B(2,0)*CP + B(2,1)*P1 + B(2,2)*P2
  91. * 0 &lt;= t &lt;= 1
  92. *
  93. * B(n,m) = mth coefficient of nth degree Bernstein polynomial
  94. * = C(n,m) * t^(m) * (1 - t)^(n-m)
  95. * C(n,m) = Combinations of n things, taken m at a time
  96. * = n! / (m! * (n-m)!)
  97. * </pre>
  98. */
  99. public static final int SEG_QUADTO = 2;
  100. /**
  101. * The segment type constant for the set of 3 points that specify a cubic
  102. * parametric curve to be drawn from the most recently specified point. The
  103. * curve is interpolated by solving the parametric control equation in the
  104. * range <code>(t=[0..1])</code> using the most recently specified (current)
  105. * point (CP), the first control point (P1), the second control point (P2),
  106. * and the final interpolated control point (P3). The parametric control
  107. * equation for this curve is:
  108. *
  109. * <pre>
  110. * P(t) = B(3,0)*CP + B(3,1)*P1 + B(3,2)*P2 + B(3,3)*P3
  111. * 0 &lt;= t &lt;= 1
  112. *
  113. * B(n,m) = mth coefficient of nth degree Bernstein polynomial
  114. * = C(n,m) * t^(m) * (1 - t)^(n-m)
  115. * C(n,m) = Combinations of n things, taken m at a time
  116. * = n! / (m! * (n-m)!)
  117. * </pre>
  118. *
  119. * This form of curve is commonly known as a B&eacute;zier curve.
  120. */
  121. public static final int SEG_CUBICTO = 3;
  122. /**
  123. * The segment type constant that specifies that the preceding subpath
  124. * should be closed by appending a line segment back to the point
  125. * corresponding to the most recent SEG_MOVETO.
  126. */
  127. public static final int SEG_CLOSE = 4;
  128. /**
  129. * Returns the winding rule for determining the interior of the path.
  130. *
  131. * @return the winding rule.
  132. * @see #WIND_EVEN_ODD
  133. * @see #WIND_NON_ZERO
  134. */
  135. public int getWindingRule();
  136. /**
  137. * Tests if the iteration is complete.
  138. *
  139. * @return <code>true</code> if all the segments have been read;
  140. * <code>false</code> otherwise.
  141. */
  142. public boolean isDone();
  143. /**
  144. * Moves the iterator to the next segment of the path forwards along the
  145. * primary direction of traversal as long as there are more points in that
  146. * direction.
  147. */
  148. public void next();
  149. /**
  150. * Returns the coordinates and type of the current path segment in the
  151. * iteration. The return value is the path-segment type: SEG_MOVETO,
  152. * SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE. A float array of
  153. * length 6 must be passed in and can be used to store the coordinates of
  154. * the point(s). Each point is stored as a pair of float x,y coordinates.
  155. * SEG_MOVETO and SEG_LINETO types returns one point, SEG_QUADTO returns two
  156. * points, SEG_CUBICTO returns 3 points and SEG_CLOSE does not return any
  157. * points.
  158. *
  159. * @param coords
  160. * an array that holds the data returned from this method
  161. * @return the path-segment type of the current path segment.
  162. * @see #SEG_MOVETO
  163. * @see #SEG_LINETO
  164. * @see #SEG_QUADTO
  165. * @see #SEG_CUBICTO
  166. * @see #SEG_CLOSE
  167. */
  168. public int currentSegment(float[] coords);
  169. /**
  170. * Returns the coordinates and type of the current path segment in the
  171. * iteration. The return value is the path-segment type: SEG_MOVETO,
  172. * SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE. A double array of
  173. * length 6 must be passed in and can be used to store the coordinates of
  174. * the point(s). Each point is stored as a pair of double x,y coordinates.
  175. * SEG_MOVETO and SEG_LINETO types returns one point, SEG_QUADTO returns two
  176. * points, SEG_CUBICTO returns 3 points and SEG_CLOSE does not return any
  177. * points.
  178. *
  179. * @param coords
  180. * an array that holds the data returned from this method
  181. * @return the path-segment type of the current path segment.
  182. * @see #SEG_MOVETO
  183. * @see #SEG_LINETO
  184. * @see #SEG_QUADTO
  185. * @see #SEG_CUBICTO
  186. * @see #SEG_CLOSE
  187. */
  188. public int currentSegment(double[] coords);
  189. }