is new. 
 java.lang.Objectjava.awt.Polygon
public class Polygon
The Polygon class encapsulates a description of a  closed, two-dimensional region within a coordinate space. This  region is bounded by an arbitrary number of line segments, each of  which is one side of the polygon. Internally, a polygon comprises of a list of 
(x,y) coordinate pairs, where each pair defines a 
( 
x 
,  
y 
) coordinate pairs, where each pair defines a 
vertex
of the polygon, and two successive pairs are the endpoints of a line that is a side of the polygon. The first and final pairs of 
(x,y) points are joined by a line segment that closes the polygon. This Polygon is defined with an even-odd winding rule. See 
WIND_EVEN_ODD
for a definition of the even-odd winding rule. This class's hit-testing methods, which include the contains, intersects and inside methods, use the 
( 
x 
,  
y 
) points are joined by a line segment that closes the polygon. This Polygon is defined with an even-odd winding rule. See 
WIND_EVEN_ODD
for a definition of the even-odd winding rule. This class's hit-testing methods, which include the contains, intersects and inside methods, use the 
insideness
 definition described in the  
Shape
 class comments.
1.0 
| Field Summary | |
|---|---|
| protected Rectangle | 
bounds
 
          The bounds 
 
 
this Polygon. 
 
 | 
| int | 
npoints
 The total number of points.  | 
| int[] | 
xpoints
 The array of  
X 
 
 | 
| int[] | 
ypoints
 The array of  
Y 
 
 | 
| Constructor Summary | |
|---|---|
| 
Polygon
() Creates an empty polygon.  | 
|
| 
Polygon
(int[] xpoints,        int[] ypoints,        int npoints) Constructs and initializes a Polygon from the specified parameters.  | 
|
| Method Summary | |
|---|---|
| void | 
addPoint
(int x,         int y) Appends the specified coordinates to this Polygon.  | 
| boolean | 
contains
(double x, double y)  
          Tests 
 
 
the boundary of the Shape. 
 
 | 
| boolean | 
contains
(double x, double y, double w, double h)  Tests if the interior of  
the Shape 
 
 
 
area. 
 
 | 
| boolean | 
contains
(int x,         int y) Determines whether the specified coordinates are inside this Polygon.  | 
| boolean | 
contains
(
Point
 p) Determines whether the specified Point is inside this Polygon.  | 
| boolean | 
contains
( 
Point2D
 Tests if a specified Point2D  | 
| boolean | 
contains
( 
Rectangle2D
 Tests if the interior of  
the Shape 
 
 | 
| Rectangle | 
getBoundingBox
() Deprecated. As of JDK version 1.1, replaced by getBounds().  | 
| Rectangle | 
getBounds
() Gets the bounding box of this Polygon.  | 
| Rectangle2D | 
getBounds2D
()  Returns  
a 
 
 
and more accurate 
bounding box of the 
 
Shape than the getBounds method. 
 
 | 
| PathIterator | 
getPathIterator
(
AffineTransform
 at) Returns an iterator object that iterates along the boundary of this Polygon and provides access to the geometry of the outline of this Polygon.  | 
| PathIterator | 
getPathIterator
(
AffineTransform
 at,                double flatness) Returns an iterator object that iterates along the boundary of the Shape and provides access to the geometry of the outline of the Shape.  | 
| boolean | 
inside
(int x,       int y) Deprecated. As of JDK version 1.1, replaced by contains(int, int).  | 
| boolean | 
intersects
(double x, double y, double w, double h)  Tests if the interior of  
the Shape 
 
 
 
area. 
 
 | 
| boolean | 
intersects
( 
Rectangle2D
 Tests if the interior of  
the Shape 
 
 | 
| void | 
invalidate
() Invalidates or flushes any internally-cached data that depends on the vertex coordinates of this Polygon.  | 
| void | 
reset
() Resets this Polygon object to an empty polygon.  | 
| void | 
translate
(int deltaX,          int deltaY) Translates the vertices of the Polygon by deltaX along the x axis and by deltaY along the y axis.  | 
| Methods inherited from class java.lang. Object | 
|---|
| clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait | 
| Field Detail | 
|---|
public int npoints
Since: 
1.0 
public int[] xpoints
X 
X 
Since: 
1.0 
public int[] ypoints
Y 
Y 
Since: 
1.0 
protected Rectangle bounds
The bounds of this Polygon. This value can be null. 
Since: 
1.0 
| Constructor Detail | 
|---|
public Polygon()
Since: 
1.0 
public Polygon(int[] xpoints,
               int[] ypoints,
               int npoints)
X 
Y 
Since: 
1.0 
| Method Detail | 
|---|
public void reset()
public void invalidate()
public void translate(int deltaX,
                      int deltaY)
X 
Y 
1.1 
public void addPoint(int x,
                     int y)
If an operation that calculates the bounding box of this Polygon has already been performed, such as getBounds or contains, then this method updates the bounding box.
X 
Y 
Since: 
1.0 
public Rectangle getBounds()
1.1 
@Deprecated public Rectangle getBoundingBox()
Since: 
1.0 
public boolean contains(Point p)
Since: 
1.0 
public boolean contains(int x,
                        int y)
X 
Y 
coordinates (x,y); 
1.1 
@Deprecated
public boolean inside(int x,
                                 int y)
X 
Y 
coordinates (x,y); 
Since: 
1.0 
public Rectangle2D getBounds2D()
Returns a high precision and more accurate bounding box of the Shape than the getBounds method. Note that there is no guarantee that the returned 
Rectangle2D
is the smallest bounding box that encloses the Shape, only that the Shape lies entirely within the indicated Rectangle2D. The bounding box returned by this method is usually tighter than that returned by the getBounds method and never fails due to overflow problems since the return value can be an instance of the Rectangle2D that uses double precision values to store the dimensions. 
an instance of Rectangle2D that is a high-precision bounding box of the Shape. 
Since: 
1.2 
public boolean contains(double x,
                        double y)
Tests if the specified coordinates are inside the boundary of the Shape. 
X 
to be tested 
Y 
to be tested 
true if the specified coordinates are inside the Shape boundary; false otherwise. 
Since: 
1.2 
public boolean contains(Point2D p)
the Shape. 
the 
to be tested 
Point2D is inside the boundary of the Shape; 
Since: 
1.2 
public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Tests if the interior of the Shape intersects the interior of a specified rectangular area. The rectangular area is considered to intersect the Shape if any point is contained in both the interior of the Shape and the specified rectangular area. 
The Shape.intersects() method allows a Shape implementation to conservatively return true when: 
there is a high probability that the rectangular area and the Shape intersect, but 
the calculations to accurately determine this intersection are prohibitively expensive. 
This means that for some Shapes this method might return true even though the rectangular area does not intersect the Shape. The 
Area
class performs more accurate computations of geometric intersection than most Shape objects and therefore can be used if a more precise answer is required. 
X 
upper-left corner of the 
specified rectangular 
area 
Y 
upper-left corner of the 
specified rectangular 
area 
area 
area 
true if the interior of the Shape and the interior of the rectangular area intersect, or are both highly likely to intersect and intersection calculations would be too expensive to perform; false otherwise. 
public boolean intersects(Rectangle2D r)
Tests if the interior of the Shape intersects the interior of a specified Rectangle2D. The Shape.intersects() method allows a Shape implementation to conservatively return true when: 
there is a high probability that the Rectangle2D and the Shape intersect, but 
the calculations to accurately determine this intersection are prohibitively expensive. 
This means that for some Shapes this method might return true even though the Rectangle2D does not intersect the Shape. The 
Area
class performs more accurate computations of geometric intersection than most Shape objects and therefore can be used if a more precise answer is required. 
the 
true if the interior of the Shape and the interior of the specified Rectangle2D intersect, or are both highly likely to intersect and intersection calculations would be too expensive to perform; false otherwise. 
Since: 
1.2 
public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Tests if the interior of the Shape entirely contains the specified rectangular area. All coordinates that lie inside the rectangular area must lie within the Shape for the entire rectanglar area to be considered contained within the Shape. 
The Shape.contains() method allows a Shape implementation to conservatively return false when: 
the intersect method returns true and 
the calculations to determine whether or not the Shape entirely contains the rectangular area are prohibitively expensive. 
This means that for some Shapes this method might return false even though the Shape contains the rectangular area. The 
Area
class performs more accurate geometric computations than most Shape objects and therefore can be used if a more precise answer is required. 
X 
upper-left 
area 
Y 
upper-left 
area 
specified 
area 
specified 
area 
true if the interior of the Shape entirely contains the specified rectangular area; false otherwise or, if the Shape contains the rectangular area and the intersects method returns true and the containment calculations would be too expensive to perform. 
public boolean contains(Rectangle2D r)
Tests if the interior of the Shape entirely contains the specified Rectangle2D. The Shape.contains() method allows a Shape implementation to conservatively return false when: 
the intersect method returns true and 
the calculations to determine whether or not the Shape entirely contains the Rectangle2D are prohibitively expensive. 
This means that for some Shapes this method might return false even though the Shape contains the Rectangle2D. The 
Area
class performs more accurate geometric computations than most Shape objects and therefore can be used if a more precise answer is required. 
The 
true if the interior of the Shape entirely contains the Rectangle2D; false otherwise or, if the Shape contains the Rectangle2D and the intersects method returns true and the containment calculations would be too expensive to perform. 
Since: 
1.2 
Shape.contains(double, double, double, double)
public PathIterator getPathIterator(AffineTransform at)
Since: 
1.2 
public PathIterator getPathIterator(AffineTransform at,
                                    double flatness)
Since: 
1.2