Polygon

Name

Polygon

[Graphic: Figure from the text]

Description

The Polygon class encapsulates a collection of points used to create a series of line segments.

Class Definition

public class java.awt.Polygon extends java.lang.Object implements java.awt.Shape, java.io.Serializable {
 // Variables protected Rectangle bounds; public int npoints;
public int xpoints[];
public int ypoints[]; // Constructors public Polygon();
public Polygon (int xpoints[], int ypoints, int npoints); // Instance Methods public void addPoint (int x, int y);
public boolean contains (int x, int y); public boolean contains (Point p); public Rectangle getBoundingBox(); (Deprecated) public Rectangle getBounds(); public boolean inside (int x,int y); (Deprecated) public void translate (int deltaX, int deltaY);
}

Variables

bounds

protected Rectangle bounds

The rectangle that describes the boundaries of the Polygon.

npoints

public int npoints

The number of elements to use in the xpoints and ypoints arrays.

xpoints

public int xpoints[]

The array of x coordinates for each point.

ypoints

public int ypoints[]

The array of y coordinates for each point.

Constructors

Polygon

public Polygon()

public Polygon (int xPoints[], int yPoints[], int numPoints)

Instance Methods

addPoint

public void addPoint (int x, int y)

contains

public boolean contains (int x, int y)

public boolean contains (Point p)

getBoundingBox

public Rectangle getBoundingBox() (Deprecated)

getBounds

public Rectangle getBounds()

inside

public boolean inside (int x,int y) (Deprecated)

translate

public void translate (int deltaX, int deltaY)

See Also

Graphics, Object, Rectangle