/[classpath]/classpath/java/awt/geom/QuadCurve2D.java
ViewVC logotype

Diff of /classpath/java/awt/geom/QuadCurve2D.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by brawer, Wed Oct 22 07:53:35 2003 UTC revision 1.8 by brawer, Thu Oct 23 10:15:42 2003 UTC
# Line 51  import java.util.NoSuchElementException; Line 51  import java.util.NoSuchElementException;
51   * alt="A drawing of a QuadCurve2D" />   * alt="A drawing of a QuadCurve2D" />
52   *   *
53   * @author Eric Blake (ebb9@email.byu.edu)   * @author Eric Blake (ebb9@email.byu.edu)
54     * @author Graydon Hoare (graydon@redhat.com)
55   * @author Sascha Brawer (brawer@dandelis.ch)   * @author Sascha Brawer (brawer@dandelis.ch)
56   *   *
57   * @since 1.2   * @since 1.2
# Line 129  public abstract class QuadCurve2D Line 130  public abstract class QuadCurve2D
130    
131    
132    /**    /**
133     * Changes the geometry of the curve.     * Changes the curve geometry, separately specifying each coordinate
134       * value.
135     *     *
136     * @param x1 the <i>x</i> coordinate of the curve&#x2019;s new start     * @param x1 the <i>x</i> coordinate of the curve&#x2019;s new start
137     * point.     * point.
# Line 153  public abstract class QuadCurve2D Line 155  public abstract class QuadCurve2D
155                                  double x2, double y2);                                  double x2, double y2);
156    
157    
158      /**
159       * Changes the curve geometry, passing coordinate values in an
160       * array.
161       *
162       * @param coords an array containing the new coordinate values.  The
163       * <i>x</i> coordinate of the new start point is located at
164       * <code>coords[offset]</code>, its <i>y</i> coordinate at
165       * <code>coords[offset + 1]</code>.  The <i>x</i> coordinate of the
166       * new control point is located at <code>coords[offset + 2]</code>,
167       * its <i>y</i> coordinate at <code>coords[offset + 3]</code>. The
168       * <i>x</i> coordinate of the new end point is located at
169       * <code>coords[offset + 4]</code>, its <i>y</i> coordinate at
170       * <code>coords[offset + 5]</code>.
171       *
172       * @param offset the offset of the first coordinate value in
173       * <code>coords</code>.
174       */
175    public void setCurve(double[] coords, int offset)    public void setCurve(double[] coords, int offset)
176    {    {
177      setCurve(coords[offset++], coords[offset++],      setCurve(coords[offset++], coords[offset++],
# Line 161  public abstract class QuadCurve2D Line 180  public abstract class QuadCurve2D
180    }    }
181    
182    
183      /**
184       * Changes the curve geometry, specifying coordinate values in
185       * separate Point objects.
186       *
187       * <p><img src="doc-files/QuadCurve2D-1.png" width="350" height="180"
188       * alt="A drawing of a QuadCurve2D" />
189       *
190       * <p>The curve does not keep any reference to the passed point
191       * objects. Therefore, a later change to <code>p1</code>,
192       * <code>c</code> <code>p2</code> will not affect the curve
193       * geometry.
194       *
195       * @param p1 the new start point.
196       * @param c the new control point.
197       * @param p2 the new end point.
198       */
199    public void setCurve(Point2D p1, Point2D c, Point2D p2)    public void setCurve(Point2D p1, Point2D c, Point2D p2)
200    {    {
201      setCurve(p1.getX(), p1.getY(), c.getX(), c.getY(),      setCurve(p1.getX(), p1.getY(), c.getX(), c.getY(),
# Line 168  public abstract class QuadCurve2D Line 203  public abstract class QuadCurve2D
203    }    }
204    
205    
206      /**
207       * Changes the curve geometry, specifying coordinate values in an
208       * array of Point objects.
209       *
210       * <p><img src="doc-files/QuadCurve2D-1.png" width="350" height="180"
211       * alt="A drawing of a QuadCurve2D" />
212       *
213       * <p>The curve does not keep references to the passed point
214       * objects. Therefore, a later change to the <code>pts</code> array
215       * or any of its elements will not affect the curve geometry.
216       *
217       * @param pts an array containing the points. The new start point
218       * is located at <code>pts[offset]</code>, the new control
219       * point at <code>pts[offset + 1]</code>, and the new end point
220       * at <code>pts[offset + 2]</code>.
221       *
222       * @param offset the offset of the start point in <code>pts</code>.
223       */
224    public void setCurve(Point2D[] pts, int offset)    public void setCurve(Point2D[] pts, int offset)
225    {    {
226      setCurve(pts[offset].getX(), pts[offset++].getY(),      setCurve(pts[offset].getX(), pts[offset].getY(),
227               pts[offset].getX(), pts[offset++].getY(),               pts[offset + 1].getX(), pts[offset + 1].getY(),
228               pts[offset].getX(), pts[offset++].getY());               pts[offset + 2].getX(), pts[offset + 2].getY());
229    }    }
230    
231    
# Line 188  public abstract class QuadCurve2D Line 241  public abstract class QuadCurve2D
241    }    }
242    
243    
244      /**
245       * Calculates the squared flatness of a quadratic curve, directly
246       * specifying each coordinate value. The flatness is the distance of
247       * the control point to the line between start and end point.
248       *
249       * <p><img src="doc-files/QuadCurve2D-4.png" width="350" height="180"
250       * alt="A drawing that illustrates the flatness" />
251       *
252       * <p>In the above drawing, the straight line connecting start point
253       * P1 and end point P2 is depicted in gray.  The result will be the
254       * the square of the distance between C and the gray line, i.e.
255       * the squared length of the red line.
256       *
257       * @param x1 the <i>x</i> coordinate of the start point P1.
258       * @param y1 the <i>y</i> coordinate of the start point P1.
259       * @param cx the <i>x</i> coordinate of the control point C.
260       * @param cy the <i>y</i> coordinate of the control point C.
261       * @param x2 the <i>x</i> coordinate of the end point P2.
262       * @param y2 the <i>y</i> coordinate of the end point P2.
263       */
264    public static double getFlatnessSq(double x1, double y1, double cx,    public static double getFlatnessSq(double x1, double y1, double cx,
265                                       double cy, double x2, double y2)                                       double cy, double x2, double y2)
266    {    {
# Line 195  public abstract class QuadCurve2D Line 268  public abstract class QuadCurve2D
268    }    }
269    
270    
271      /**
272       * Calculates the flatness of a quadratic curve, directly specifying
273       * each coordinate value. The flatness is the distance of the
274       * control point to the line between start and end point.
275       *
276       * <p><img src="doc-files/QuadCurve2D-4.png" width="350" height="180"
277       * alt="A drawing that illustrates the flatness" />
278       *
279       * <p>In the above drawing, the straight line connecting start point
280       * P1 and end point P2 is depicted in gray.  The result will be the
281       * the distance between C and the gray line, i.e. the length of
282       * the red line.
283       *
284       * @param x1 the <i>x</i> coordinate of the start point P1.
285       * @param y1 the <i>y</i> coordinate of the start point P1.
286       * @param cx the <i>x</i> coordinate of the control point C.
287       * @param cy the <i>y</i> coordinate of the control point C.
288       * @param x2 the <i>x</i> coordinate of the end point P2.
289       * @param y2 the <i>y</i> coordinate of the end point P2.
290       */
291    public static double getFlatness(double x1, double y1, double cx, double cy,    public static double getFlatness(double x1, double y1, double cx, double cy,
292                                     double x2, double y2)                                     double x2, double y2)
293    {    {
# Line 202  public abstract class QuadCurve2D Line 295  public abstract class QuadCurve2D
295    }    }
296    
297    
298      /**
299       * Calculates the squared flatness of a quadratic curve, specifying
300       * the coordinate values in an array. The flatness is the distance
301       * of the control point to the line between start and end point.
302       *
303       * <p><img src="doc-files/QuadCurve2D-4.png" width="350" height="180"
304       * alt="A drawing that illustrates the flatness" />
305       *
306       * <p>In the above drawing, the straight line connecting start point
307       * P1 and end point P2 is depicted in gray.  The result will be the
308       * the square of the distance between C and the gray line, i.e.
309       * the squared length of the red line.
310       *
311       * @param coords an array containing the coordinate values.  The
312       * <i>x</i> coordinate of the start point P1 is located at
313       * <code>coords[offset]</code>, its <i>y</i> coordinate at
314       * <code>coords[offset + 1]</code>.  The <i>x</i> coordinate of the
315       * control point C is located at <code>coords[offset + 2]</code>,
316       * its <i>y</i> coordinate at <code>coords[offset + 3]</code>. The
317       * <i>x</i> coordinate of the end point P2 is located at
318       * <code>coords[offset + 4]</code>, its <i>y</i> coordinate at
319       * <code>coords[offset + 5]</code>.
320       *
321       * @param offset the offset of the first coordinate value in
322       * <code>coords</code>.
323       */
324    public static double getFlatnessSq(double[] coords, int offset)    public static double getFlatnessSq(double[] coords, int offset)
325    {    {
326      return Line2D.ptSegDistSq(coords[offset], coords[offset + 1],      return Line2D.ptSegDistSq(coords[offset], coords[offset + 1],
# Line 210  public abstract class QuadCurve2D Line 329  public abstract class QuadCurve2D
329    }    }
330    
331    
332      /**
333       * Calculates the flatness of a quadratic curve, specifying the
334       * coordinate values in an array. The flatness is the distance of
335       * the control point to the line between start and end point.
336       *
337       * <p><img src="doc-files/QuadCurve2D-4.png" width="350" height="180"
338       * alt="A drawing that illustrates the flatness" />
339       *
340       * <p>In the above drawing, the straight line connecting start point
341       * P1 and end point P2 is depicted in gray.  The result will be the
342       * the the distance between C and the gray line, i.e.  the length of
343       * the red line.
344       *
345       * @param coords an array containing the coordinate values.  The
346       * <i>x</i> coordinate of the start point P1 is located at
347       * <code>coords[offset]</code>, its <i>y</i> coordinate at
348       * <code>coords[offset + 1]</code>.  The <i>x</i> coordinate of the
349       * control point C is located at <code>coords[offset + 2]</code>,
350       * its <i>y</i> coordinate at <code>coords[offset + 3]</code>. The
351       * <i>x</i> coordinate of the end point P2 is located at
352       * <code>coords[offset + 4]</code>, its <i>y</i> coordinate at
353       * <code>coords[offset + 5]</code>.
354       *
355       * @param offset the offset of the first coordinate value in
356       * <code>coords</code>.
357       */
358    public static double getFlatness(double[] coords, int offset)    public static double getFlatness(double[] coords, int offset)
359    {    {
360      return Line2D.ptSegDist(coords[offset], coords[offset + 1],      return Line2D.ptSegDist(coords[offset], coords[offset + 1],
# Line 218  public abstract class QuadCurve2D Line 363  public abstract class QuadCurve2D
363    }    }
364    
365    
366      /**
367       * Calculates the squared flatness of this curve. The flatness is
368       * the distance of the control point to the line between start and
369       * end point.
370       *
371       * <p><img src="doc-files/QuadCurve2D-4.png" width="350" height="180"
372       * alt="A drawing that illustrates the flatness" />
373       *
374       * <p>In the above drawing, the straight line connecting start point
375       * P1 and end point P2 is depicted in gray.  The result will be the
376       * the square of the distance between C and the gray line, i.e. the
377       * squared length of the red line.
378       */
379    public double getFlatnessSq()    public double getFlatnessSq()
380    {    {
381      return Line2D.ptSegDistSq(getX1(), getY1(),      return Line2D.ptSegDistSq(getX1(), getY1(),
# Line 226  public abstract class QuadCurve2D Line 384  public abstract class QuadCurve2D
384    }    }
385    
386    
387      /**
388       * Calculates the flatness of this curve. The flatness is the
389       * distance of the control point to the line between start and end
390       * point.
391       *
392       * <p><img src="doc-files/QuadCurve2D-4.png" width="350" height="180"
393       * alt="A drawing that illustrates the flatness" />
394       *
395       * <p>In the above drawing, the straight line connecting start point
396       * P1 and end point P2 is depicted in gray.  The result will be the
397       * the distance between C and the gray line, i.e.  the length of the
398       * red line.
399       */
400    public double getFlatness()    public double getFlatness()
401    {    {
402      return Line2D.ptSegDist(getX1(), getY1(),      return Line2D.ptSegDist(getX1(), getY1(),
# Line 417  public abstract class QuadCurve2D Line 588  public abstract class QuadCurve2D
588    }    }
589    
590    
591      /**
592       * Determines whether a point lies inside the area that is bounded
593       * by the curve and the straight line connecting its end points.
594       *
595       * <p><img src="QuadCurve2D-5.png" width="350" height="180"
596       * alt="A drawing of the area spanned by the curve" />
597       *
598       * <p>The above drawing illustrates in which area points are
599       * considered &#x2013;contained&#x2014; in a QuadCurve2D.
600       */
601    public boolean contains(double x, double y)    public boolean contains(double x, double y)
602    {    {
603      // XXX Implement.      // XXX Implement.
# Line 424  public abstract class QuadCurve2D Line 605  public abstract class QuadCurve2D
605    }    }
606    
607    
608      /**
609       * Determines whether a point lies inside the area that is bounded
610       * by the curve and the straight line connecting its end points.
611       *
612       * <p><img src="QuadCurve2D-5.png" width="350" height="180"
613       * alt="A drawing of the area spanned by the curve" />
614       *
615       * <p>The above drawing illustrates in which area points are
616       * considered &#x2013;contained&#x2014; in a QuadCurve2D.
617       */
618    public boolean contains(Point2D p)    public boolean contains(Point2D p)
619    {    {
620      return contains(p.getX(), p.getY());      return contains(p.getX(), p.getY());
# Line 563  public abstract class QuadCurve2D Line 754  public abstract class QuadCurve2D
754    
755    
756    /**    /**
757     * Creates a new curve with the same contents as     * Creates a new curve with the same contents as this one.
    * this one.  
758     *     *
759     * @return the clone.     * @return the clone.
760     */     */

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26