math.geom2d.point
Class PointArray2D

Package class diagram package PointArray2D
java.lang.Object
  extended by math.geom2d.point.PointArray2D
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Point2D>, CirculinearShape2D, PointSet2D, PointShape2D, Shape2D

public class PointArray2D
extends Object
implements PointSet2D, CirculinearShape2D, Cloneable

Represent the union of a finite number of Point2D.

Author:
dlegland
See Also:
Serialized Form

Field Summary
protected  ArrayList<Point2D> points
          The inner collection of points composing the set.
 
Fields inherited from interface math.geom2d.Shape2D
ACCURACY
 
Constructor Summary
PointArray2D()
          Creates a new PointArray2D without any points.
PointArray2D(Collection<? extends Point2D> points)
          Points must be a collection of java.awt.Point.
PointArray2D(int n)
          Creates a new empty PointArray2D, but preallocates the memory for storing a given amount of points.
PointArray2D(Point2D[] points)
          Instances of Point2D are directly added, other Point are converted to Point2D with the same location.
 
Method Summary
 void addPoint(Point2D point)
          Add a new point to the set of point.
 void addPoints(Collection<? extends Point2D> points)
          Add a series of points
 void addPoints(Point2D[] points)
          Add a series of points
 void clearPoints()
          remove all points of the set.
 PointArray2D clip(Box2D box)
          Returns a new point set containing only points located within the box.
 PointArray2D clone()
           
 boolean contains(double x, double y)
          Checks if the shape contains the planar point defined by (x,y).
 boolean contains(Point2D point)
          Checks if the shape contains the given point.
static PointSet2D create(Collection<? extends Point2D> points)
           
static PointSet2D create(int size)
           
static PointSet2D create(Point2D[] points)
           
 void draw(Graphics2D g2)
          Draws the point set on the specified Graphics2D, using default radius equal to 1.
 void draw(Graphics2D g2, double r)
          Draws the point set on the specified Graphics2D, by filling a disc with a given radius.
 boolean equals(Object obj)
           
 Box2D getBoundingBox()
          Returns the bounding box of the shape.
 CirculinearDomain2D getBuffer(double dist)
          Computes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d.
 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.
 double getDistance(Point2D p)
          Return distance to the closest point of the collection
 int getPointNumber()
          Returns the number of points in the set.
 Collection<Point2D> getPoints()
          return an iterator on the internal point collection.
 boolean isBounded()
          always return true.
 boolean isEmpty()
          Returns true if the shape does not contain any point.
 Iterator<Point2D> iterator()
           
 PointArray2D transform(AffineTransform2D trans)
          Transforms the point set by returning a new point set containing each transformed point.
 PointArray2D transform(CircleInversion2D inv)
          Transforms the shape by a circle inversion.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

points

protected ArrayList<Point2D> points
The inner collection of points composing the set.

Constructor Detail

PointArray2D

public PointArray2D()
Creates a new PointArray2D without any points.


PointArray2D

public PointArray2D(int n)
Creates a new empty PointArray2D, but preallocates the memory for storing a given amount of points.

Parameters:
n - the expected number of points in the PointArray2D.

PointArray2D

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


PointArray2D

public PointArray2D(Collection<? extends 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

create

public static final PointSet2D create(Collection<? extends Point2D> points)

create

public static final PointSet2D create(Point2D[] points)

create

public static final PointSet2D create(int size)

addPoint

public void addPoint(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.

Specified by:
addPoint in interface PointSet2D
Parameters:
point -

addPoints

public void addPoints(Point2D[] points)
Add a series of points

Parameters:
points - an array of points

addPoints

public void addPoints(Collection<? extends Point2D> points)
Description copied from interface: PointSet2D
Add a series of points

Specified by:
addPoints in interface PointSet2D
Parameters:
points - an array of points

getPoints

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

Specified by:
getPoints in interface PointSet2D
Specified by:
getPoints in interface PointShape2D
Returns:
the collection of points

clearPoints

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


getPointNumber

public int getPointNumber()
Returns the number of points in the set.

Specified by:
getPointNumber in interface PointSet2D
Specified by:
getPointNumber in interface PointShape2D
Returns:
the number of points

getBuffer

public CirculinearDomain2D getBuffer(double dist)
Description copied from interface: CirculinearShape2D
Computes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d.

Specified by:
getBuffer in interface CirculinearShape2D
Parameters:
dist - the maximal distance between a point of the buffer and the shape
Returns:
the buffer of the shape

transform

public PointArray2D transform(CircleInversion2D inv)
Description copied from interface: CirculinearShape2D
Transforms the shape by a circle inversion. The result is still an instance a CirculinearShape2D.

Specified by:
transform in interface CirculinearShape2D
Parameters:
inv - the circle inversion
Returns:
the transformed shape

getDistance

public double getDistance(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

isEmpty

public boolean isEmpty()
Description copied from interface: Shape2D
Returns true if the shape does not contain any point. This is the case for example for PointSet2D without any point.

Specified by:
isEmpty in interface Shape2D
Returns:
true if the shape does not contain any point.

clip

public PointArray2D clip(Box2D box)
Description copied from interface: PointSet2D
Returns a new point set containing only points located within the box.

Specified by:
clip in interface PointSet2D
Specified by:
clip in interface PointShape2D
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 PointArray2D transform(AffineTransform2D trans)
Description copied from interface: PointSet2D
Transforms the point set by returning a new point set containing each transformed point.

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

contains

public boolean contains(double x,
                        double y)
Description copied from interface: Shape2D
Checks if the shape contains the planar point defined by (x,y).

Specified by:
contains in interface Shape2D

contains

public boolean contains(Point2D point)
Description copied from interface: Shape2D
Checks if the shape contains the given point.

Specified by:
contains in interface Shape2D

draw

public void draw(Graphics2D g2)
Draws the point set on the specified Graphics2D, using default radius equal to 1.

Specified by:
draw in interface Shape2D
Parameters:
g2 - the graphics to draw the point set

draw

public void draw(Graphics2D g2,
                 double r)
Draws the point set on the specified Graphics2D, by filling a disc with a given radius.

Parameters:
g2 - the graphics to draw the point set

iterator

public Iterator<Point2D> iterator()
Specified by:
iterator in interface Iterable<Point2D>

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

clone

public PointArray2D clone()
Overrides:
clone in class Object


Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.