All About Class Polygon In AWT in Java

0
120
Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

Class Polygon In AWT in Java
Class Polygon In AWT in Java

A Polygon consists of a list of x and y coordinates where each successive parts of coordinates defines a side of a Polygon.
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.
}
 
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here