View Javadoc

1   /* File Polygon2D.java 
2    *
3    * Project : Java Geometry Library
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  
24  // package
25  
26  package math.geom2d.polygon;
27  
28  // Imports
29  import java.util.Collection;
30  
31  import math.geom2d.AffineTransform2D;
32  import math.geom2d.Point2D;
33  import math.geom2d.circulinear.CirculinearBoundarySet2D;
34  import math.geom2d.circulinear.CirculinearDomain2D;
35  import math.geom2d.line.LineSegment2D;
36  
37  /**
38   * Represent any class made of a finite set of simply connected edges. This
39   * include simple polygons, multiple polygons, or more specialized shapes like
40   * rectangles, squares...
41   */
42  public interface Polygon2D extends CirculinearDomain2D {
43  
44      /** Returns the vertices (singular points) of the polygon */
45      public abstract Collection<Point2D> getVertices();
46  
47      /**
48       * Returns the i-th vertex of the polygon.
49       * 
50       * @param i index of the vertex, between 0 and the number of vertices
51       */
52      public abstract Point2D getVertex(int i);
53  
54      /**
55       * Returns the number of vertices of the polygon
56       * 
57       * @since 0.6.3
58       */
59      public abstract int getVertexNumber();
60  
61      /** Return the edges as line segments of the polygon */
62      public abstract Collection<? extends LineSegment2D> getEdges();
63  
64      /** Returns the number of edges of the polygon */
65      public abstract int getEdgeNumber();
66      
67      /**
68       * Returns the set of rings comprising the boundary of this polygon.
69       * @return the set of boundary rings.
70       */
71      public abstract Collection<? extends LinearRing2D> getRings();
72  
73      
74      // ===================================================================
75      // general methods
76  
77      public abstract CirculinearBoundarySet2D<? extends LinearRing2D> 
78      getBoundary();
79  
80      /**
81       * Returns the new Polygon created by an affine transform of this polygon.
82       */
83      public abstract Polygon2D transform(AffineTransform2D trans);
84  
85      /**
86       * Returns the complementary polygon.
87       * 
88       * @return the polygon complementary to this
89       */
90      public Polygon2D complement();
91  }