Class java.awt.Polygon
All Packages  Class Hierarchy  This Package  Previous  Next  Index
  Class java.awt.Polygon
java.lang.Object
   |
   +----java.awt.Polygon
  -  public class Polygon
  -  extends Object
A polygon consists of a list of x and y coordinates.
   
  -   npoints npoints
-  The total number of points.
  
-   xpoints xpoints
-  The array of x coordinates.
  
-   ypoints ypoints
-  The array of y coordinates.
   
  -   Polygon() Polygon()
-  Creates an empty polygon.
  
-   Polygon(int[], int[], int) Polygon(int[], int[], int)
-  Constructs and initializes a Polygon from the specified parameters.
   
  -   addPoint(int, int) addPoint(int, int)
-  Appends a point to a polygon.
  
-   getBoundingBox() getBoundingBox()
-  Determines the area spanned by this Polygon.
  
-   inside(int, int) inside(int, int)
-  Determines whether the point (x,y) is inside the Polygon.
   
 npoints
npoints
  public int npoints
  -  The total number of points.
 xpoints
xpoints
  public int xpoints[]
  -  The array of x coordinates.
 ypoints
ypoints
  public int ypoints[]
  -  The array of y coordinates.
   
 Polygon
Polygon
  public Polygon()
  -  Creates an empty polygon.
 Polygon
Polygon
  public Polygon(int xpoints[],
                 int ypoints[],
                 int npoints)
  -  Constructs and initializes a Polygon from the specified parameters.
  
    -  Parameters:
    
-  xpoints - the array of x coordinates
    -  ypoints - the array of y coordinates
    -  npoints - the total number of points in the Polygon
  
 
   
 addPoint
addPoint
  public void addPoint(int x,
                       int y)
  -  Appends a point to a polygon.  If inside(x, y) or another
operation that calculates the bounding box has already been
performed, this method updates the bounds accordingly.
  
    -  Parameters:
    
-  x - the x coordinate of the point
    -  y - the y coordinate of the point
  
 
 getBoundingBox
getBoundingBox
  public Rectangle getBoundingBox()
  -  Determines the area spanned by this Polygon.
  
    -  Returns:
    
-  a Rectangle defining the bounds of the Polygon.
  
 
 inside
inside
  public boolean inside(int x,
                        int y)
  -  Determines whether the point (x,y) is inside the Polygon. Uses
an even-odd insideness rule (also known as an alternating
rule).
  
    -  Parameters:
    
-  x - the X coordinate of the point to be tested
    -  y - the Y coordinate of the point to be tested
Based on code by Hanpeter van Vliet .
   
 
All Packages  Class Hierarchy  This Package  Previous  Next  Index