View Javadoc

1   /* file : Polyline2D.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.line;
28  
29  import java.util.ArrayList;
30  import java.util.Collection;
31  
32  import math.geom2d.Point2D;
33  
34  /**
35   * A polyline is a continuous curve where each piece of the curve is a
36   * LineSegment2D.
37   * 
38   * @deprecated use math.geom2d.polygon.Polyline2D instead (0.7.0)
39   * @author dlegland
40   */
41  @Deprecated
42  public class Polyline2D extends math.geom2d.polygon.Polyline2D {
43  
44      protected ArrayList<Point2D> points = new ArrayList<Point2D>();
45  
46      // ===================================================================
47      // Contructors
48  
49      public Polyline2D() {
50          super();
51      }
52  
53      public Polyline2D(Point2D initialPoint) {
54          super(initialPoint);
55      }
56  
57      public Polyline2D(Point2D[] points) {
58         super(points);
59      }
60  
61      public Polyline2D(Collection<? extends Point2D> points) {
62          super(points);
63      }
64  
65      public Polyline2D(double[] xcoords, double[] ycoords) {
66          super(xcoords, ycoords);
67      }
68  
69      // ===================================================================
70      // Methods specific to Polyline2D
71  
72      /**
73       * Returns the polyline with same points considered in reverse order.
74       * Reversed polyline keep same references as original polyline.
75       */
76  	@Override
77      public Polyline2D getReverseCurve() {
78          Point2D[] points2 = new Point2D[points.size()];
79          int n = points.size();
80          if (n>0) {
81              for (int i = 0; i<n; i++)
82                  points2[i] = points.get(n-1-i);
83          }
84          return new Polyline2D(points2);
85      }
86  }