nl.skybound.awt
Class DoublePolygon

java.lang.Object
  |
  +--nl.skybound.awt.DoublePolygon
All Implemented Interfaces:
java.io.Serializable

public class DoublePolygon
extends java.lang.Object
implements java.io.Serializable

Similar to but not a descendent of java.awt.Polygon that uses double values instead of int values.

See Also:
Polygon, Serialized Form

Field Summary
 int npoints
          The total number of points.
 double[] xpoints
          The array of x coordinates.
 double[] ypoints
          The array of y coordinates.
 
Constructor Summary
DoublePolygon()
          Creates an empty polygon.
DoublePolygon(double[] xpoints, double[] ypoints, int npoints)
          Constructs and initializes a DoublePolygon from the specified parameters.
 
Method Summary
 void addPoint(double x, double y)
          Appends the specified coordinates to this DoublePolygon.
 boolean contains(double x, double y)
          Determines whether the specified coordinates are inside this Polygon.
 double getMaxX()
          Returns the maximum x coordinate.
 double getMaxY()
          Returns the maximum y coordinate.
 double getMinX()
          Returns the minimum x coordinate.
 double getMinY()
          Returns the minimum y coordinate.
 void translate(double deltaX, double deltaY)
          Translates the vertices of the DoublePolygon by deltaX along the x axis and by deltaY along the y axis.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

npoints

public int npoints
The total number of points. This value can be NULL.
See Also:
addPoint(double, double)

xpoints

public double[] xpoints
The array of x coordinates.
See Also:
addPoint(double, double)

ypoints

public double[] ypoints
The array of y coordinates.
See Also:
addPoint(double, double)
Constructor Detail

DoublePolygon

public DoublePolygon()
Creates an empty polygon.

DoublePolygon

public DoublePolygon(double[] xpoints,
                     double[] ypoints,
                     int npoints)
Constructs and initializes a DoublePolygon from the specified parameters.
Parameters:
xpoints - an array of x coordinates
ypoints - an array of y coordinates
npoints - the total number of points in the Polygon
Throws:
NegativeArraySizeException - if the value of npoints is negative.
IndexOutOfBoundsException - if npoints is greater than the length of xpoints or the length of ypoints.
NullPointerException - if xpoints or ypoints is null.
Method Detail

translate

public void translate(double deltaX,
                      double deltaY)
Translates the vertices of the DoublePolygon by deltaX along the x axis and by deltaY along the y axis.
Parameters:
deltaX - the amount to translate along the x axis
deltaY - the amount to translate along the y axis

addPoint

public void addPoint(double x,
                     double y)
Appends the specified coordinates to this DoublePolygon.

Parameters:
x, y - the specified coordinates
See Also:
contains(double, double)

contains

public boolean contains(double x,
                        double y)
Determines whether the specified coordinates are inside this Polygon. For the definition of insideness, see the class comments of Shape.
Parameters:
x, y - the specified coordinates
Returns:
true if this Polygon contains the specified coordinates; false otherwise.

getMinX

public double getMinX()
Returns the minimum x coordinate.

getMinY

public double getMinY()
Returns the minimum y coordinate.

getMaxX

public double getMaxX()
Returns the maximum x coordinate.

getMaxY

public double getMaxY()
Returns the maximum y coordinate.