View Javadoc

1   /* file : PolyBezierCurve2D.java
2    * 
3    * Project : geometry
4    *
5    * ===========================================
6    * 
7    * This library is free software; you can redistribute it and/or modify it 
8    * under the terms of the GNU Lesser General Public License as published by
9    * the Free Software Foundation, either version 2.1 of the License, or (at
10   * your option) any later version.
11   *
12   * This library is distributed in the hope that it will be useful, but 
13   * WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
14   * or FITNESS FOR A PARTICULAR PURPOSE.
15   *
16   * See the GNU Lesser General Public License for more details.
17   *
18   * You should have received a copy of the GNU Lesser General Public License
19   * along with this library. if not, write to :
20   * The Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21   * Boston, MA 02111-1307, USA.
22   * 
23   * Created on 8 mai 2006
24   *
25   */
26  
27  package math.geom2d.spline;
28  
29  import java.util.Collection;
30  
31  import math.geom2d.AffineTransform2D;
32  import math.geom2d.Box2D;
33  import math.geom2d.curve.Curve2D;
34  import math.geom2d.curve.Curve2DUtils;
35  import math.geom2d.curve.CurveSet2D;
36  import math.geom2d.curve.PolyCurve2D;
37  
38  /**
39   * A set of Bezier curves, making a continuous curve.
40   * 
41   * @deprecated use PolyCubicBezierCurve2D instead
42   * @author dlegland
43   */
44  @Deprecated
45  public class PolyBezierCurve2D extends PolyCurve2D<CubicBezierCurve2D> {
46  
47  	@Deprecated
48      public PolyBezierCurve2D() {
49          super();
50      }
51  
52      @Deprecated
53      public PolyBezierCurve2D(CubicBezierCurve2D[] curves) {
54          super(curves);
55      }
56  
57      @Deprecated
58      public PolyBezierCurve2D(Collection<CubicBezierCurve2D> curves) {
59          super(curves);
60      }
61  
62      /**
63       * returns a new PolyBezierCurve2D.
64       */
65      @Override
66      public PolyBezierCurve2D clip(Box2D box) {
67          // Clip the curve
68          CurveSet2D<? extends Curve2D> set = Curve2DUtils.clipCurve(this, box);
69  
70          // Stores the result in appropriate structure
71          PolyBezierCurve2D result = new PolyBezierCurve2D();
72  
73          // convert the result
74          for (Curve2D curve : set.getCurves()) {
75              if (curve instanceof CubicBezierCurve2D)
76                  result.addCurve((CubicBezierCurve2D) curve);
77          }
78          return result;
79      }
80  
81      @Override
82      public PolyBezierCurve2D transform(AffineTransform2D trans) {
83          PolyBezierCurve2D result = new PolyBezierCurve2D();
84          for (CubicBezierCurve2D curve : curves)
85              result.addCurve(curve.transform(trans));
86          return result;
87      }
88  
89  }