A Polygon consists of a list of x and y coordinates where each successive parts of co-ordinates defines a side of a Polygon.

The class structure of the Polygon is defined as below:

The class structure of the Polygon is defined as below:

```
public class java.awt.Polygon extends java.lang.Object{
//member elements
public int npoints//total number of points
public int xpoints[]//the array of x coordinates
public int ypoints[]//the array of y coordinates
//constructors
public Polygon();// creates an empty Polygon
public Polygon(int xpoints[],int ypoints[],int npoints);// creates and initializes a Polygon
//from the specified parameters
//methods:
public void addPoint(int x,int y);//appends a point to this Polygon.If an operation that calculates the bounding
//box of this Polygon(getBoundingBox() or inside()) has already been performed ,this method updates the bounding box.
public Rectangle getBoundingBox();//returns the smallest rectangle that contains this Polygon.
public boolean inside(int x,int y);//Determines if the specified point is inside this Polygon.This method
//uses an even odd insideness rule also known as alternating rule to determine whether point (x,y) is inside this
//Polygon.Returns true if the point (x,y) is inside this Polygon ,false otherwise.
}
```

All About Class Polygon In AWT in Java
Reviewed by Animesh Chatterjee
on
November 21, 2018
Rating:

## No comments: