Package ro.sync.exml.view.graphics
Class Polygon
java.lang.Object
ro.sync.exml.view.graphics.BaseShape
ro.sync.exml.view.graphics.Polygon
- All Implemented Interfaces:
Shape,ro.sync.exml.view.graphics.ShapePointContributor
@API(type=EXTENDABLE,
src=PRIVATE)
public class Polygon
extends BaseShape
implements ro.sync.exml.view.graphics.ShapePointContributor
The
Polygon class encapsulates a description of a
closed, two-dimensional region within a coordinate space.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
npoints
public int npointsThe total number of points. The value ofnpointsrepresents the number of valid points in thisPolygonand might be less than the number of elements inxpointsorypoints. This value can be NULL.- See Also:
-
xpoints
public int[] xpointsThe array of x coordinates. The number of elements in this array might be more than the number of x coordinates in thisPolygon. The extra elements allow new points to be added to thisPolygonwithout re-creating this array. The value ofnpointsis equal to the number of valid points in thisPolygon.- See Also:
-
ypoints
public int[] ypointsThe array of y coordinates. The number of elements in this array might be more than the number of y coordinates in thisPolygon. The extra elements allow new points to be added to thisPolygonwithout re-creating this array. The value ofnpointsis equal to the number of valid points in thisPolygon.- See Also:
-
-
Constructor Details
-
Polygon
public Polygon()Creates an empty polygon. -
Polygon
public Polygon(int[] xpoints, int[] ypoints, int npoints) Constructs and initializes aPolygonfrom the specified parameters.- Parameters:
xpoints- an array of x coordinatesypoints- an array of y coordinatesnpoints- the total number of points in thePolygon- Throws:
NegativeArraySizeException- if the value ofnpointsis negative.IndexOutOfBoundsException- ifnpointsis greater than the length ofxpointsor the length ofypoints.NullPointerException- ifxpointsorypointsisnull.
-
-
Method Details
-
addPoint
public void addPoint(int x, int y) Appends the specified coordinates to thisPolygon.If an operation that calculates the bounding box of this
Polygonhas already been performed, such asgetBoundsorcontains, then this method updates the bounding box.- Specified by:
addPointin interfacero.sync.exml.view.graphics.ShapePointContributor- Parameters:
x- the specified x coordinatey- the specified y coordinate- See Also:
-
getBounds
-
translate
Description copied from interface:ShapeTranslate the shape into another one. -
contains
public boolean contains(int x, int y) Check if this complicated shape contains the requested point.
-