math.geom2d
Class PointSet2D

java.lang.Object
  extended by math.geom2d.PointSet2D
All Implemented Interfaces:
java.awt.Shape, java.lang.Iterable<Point2D>, Shape2D

public class PointSet2D
extends java.lang.Object
implements Shape2D, java.lang.Iterable<Point2D>

Represent the union of a finite number of Point2D.

Author:
dlegland

Field Summary
protected  java.util.Collection<Point2D> points
           
 
Fields inherited from interface math.geom2d.Shape2D
ACCURACY, defaultClipWindow, EMPTY_SET
 
Constructor Summary
PointSet2D()
           
PointSet2D(java.util.Collection<? extends java.awt.geom.Point2D> points)
          points must be a collection of java.awt.Point.
PointSet2D(java.awt.geom.Point2D[] points)
          Instances of Point2D are directly added, other Point are converted to Point2D with the same location.
 
Method Summary
 void addPoint(java.awt.geom.Point2D point)
          add a new point to the set of point.
 void addPoints(java.util.Collection<Point2D> points)
           
 void addPoints(java.awt.geom.Point2D[] points)
          Add a series of points
 void clearPoints()
          remove all points of the set.
 Shape2D clip(Box2D box)
          Clip the shape with the given box, and returns a new shape.
 boolean contains(double x, double y)
           
 boolean contains(double arg0, double arg1, double arg2, double arg3)
          Always return false : a point cannot contain a rectangle...
 boolean contains(java.awt.geom.Point2D point)
           
 boolean contains(java.awt.geom.Rectangle2D arg0)
          Always return false : a point cannot contain a rectangle...
 Box2D getBoundingBox()
          Returns the bounding box of the shape.
 java.awt.Rectangle getBounds()
          Return bounding box of the shape.
 java.awt.geom.Rectangle2D getBounds2D()
          Return more precise bounds for the shape.
 Shape2D getClippedShape(Box2D box)
           
 double getDistance(double x, double y)
          get the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e. fillable) shape.
 double getDistance(java.awt.geom.Point2D p)
          Return distance to the closest point of the collection
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans)
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans, double flatness)
           
 java.util.Iterator<Point2D> getPoints()
          return an iterator on the internal point collection.
 int getPointsNumber()
          Return the number of points in the set.
 boolean intersects(double x0, double y0, double w, double h)
          Return true if at least one of the points intersect the rectangle defined by x0, y0 , w, and y.
 boolean intersects(java.awt.geom.Rectangle2D rect)
           
 boolean isBounded()
          always return true.
 java.util.Iterator<Point2D> iterator()
           
 PointSet2D transform(AffineTransform2D trans)
          transform the shape by an affine transform.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

points

protected java.util.Collection<Point2D> points
Constructor Detail

PointSet2D

public PointSet2D()

PointSet2D

public PointSet2D(java.awt.geom.Point2D[] points)
Instances of Point2D are directly added, other Point are converted to Point2D with the same location.


PointSet2D

public PointSet2D(java.util.Collection<? extends java.awt.geom.Point2D> points)
points must be a collection of java.awt.Point. Instances of Point2D are directly added, other Point are converted to Point2D with the same location.

Parameters:
points -
Method Detail

addPoint

public void addPoint(java.awt.geom.Point2D point)
add a new point to the set of point. If point is not an instance of Point2D, a Point2D with same location is added instead of point.

Parameters:
point -

addPoints

public void addPoints(java.awt.geom.Point2D[] points)
Add a series of points

Parameters:
points - an array of points

addPoints

public void addPoints(java.util.Collection<Point2D> points)

getPoints

public java.util.Iterator<Point2D> getPoints()
return an iterator on the internal point collection.

Returns:
the collection of points

clearPoints

public void clearPoints()
remove all points of the set.


getPointsNumber

public int getPointsNumber()
Return the number of points in the set.

Returns:
the number of points

getDistance

public double getDistance(java.awt.geom.Point2D p)
Return distance to the closest point of the collection

Specified by:
getDistance in interface Shape2D

getDistance

public double getDistance(double x,
                          double y)
Description copied from interface: Shape2D
get the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e. fillable) shape.

Specified by:
getDistance in interface Shape2D

isBounded

public boolean isBounded()
always return true.

Specified by:
isBounded in interface Shape2D

getClippedShape

public Shape2D getClippedShape(Box2D box)

clip

public Shape2D clip(Box2D box)
Description copied from interface: Shape2D
Clip the shape with the given box, and returns a new shape.

Specified by:
clip in interface Shape2D
Parameters:
box - the clipping box
Returns:
the clipped shape

getBoundingBox

public Box2D getBoundingBox()
Description copied from interface: Shape2D
Returns the bounding box of the shape.

Specified by:
getBoundingBox in interface Shape2D
Returns:
the bounding box of the shape.

transform

public PointSet2D transform(AffineTransform2D trans)
Description copied from interface: Shape2D
transform the shape by an affine transform. Subclasses may override the type of returned shape.

Specified by:
transform in interface Shape2D
Parameters:
trans - an affine transform
Returns:
the transformed shape

getBounds

public java.awt.Rectangle getBounds()
Return bounding box of the shape.

Specified by:
getBounds in interface java.awt.Shape

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()
Return more precise bounds for the shape.

Specified by:
getBounds2D in interface java.awt.Shape

contains

public boolean contains(double x,
                        double y)
Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Point2D point)
Specified by:
contains in interface java.awt.Shape

intersects

public boolean intersects(double x0,
                          double y0,
                          double w,
                          double h)
Return true if at least one of the points intersect the rectangle defined by x0, y0 , w, and y.

Specified by:
intersects in interface java.awt.Shape

intersects

public boolean intersects(java.awt.geom.Rectangle2D rect)
Specified by:
intersects in interface java.awt.Shape

contains

public boolean contains(double arg0,
                        double arg1,
                        double arg2,
                        double arg3)
Always return false : a point cannot contain a rectangle...

Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Rectangle2D arg0)
Always return false : a point cannot contain a rectangle...

Specified by:
contains in interface java.awt.Shape

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans)
Specified by:
getPathIterator in interface java.awt.Shape

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans,
                                                  double flatness)
Specified by:
getPathIterator in interface java.awt.Shape

iterator

public java.util.Iterator<Point2D> iterator()
Specified by:
iterator in interface java.lang.Iterable<Point2D>