math.geom2d.polygon
Class MultiPolygon2D

java.lang.Object
  extended by math.geom2d.polygon.MultiPolygon2D
All Implemented Interfaces:
java.awt.Shape, Domain2D, PolygonalShape2D, Shape2D

public class MultiPolygon2D
extends java.lang.Object
implements Domain2D, PolygonalShape2D

A polygonal domain whose boundary is composed of several disjoint continuous ClosedPolyline2D.

Author:
dlegland

Field Summary
 
Fields inherited from interface math.geom2d.Shape2D
ACCURACY, defaultClipWindow, EMPTY_SET
 
Constructor Summary
MultiPolygon2D()
           
MultiPolygon2D(ClosedPolyline2D polyline)
           
MultiPolygon2D(java.util.Collection<ClosedPolyline2D> lines)
           
MultiPolygon2D(Polygon2D polygon)
           
 
Method Summary
 void addPolygon(Polygon2D polygon)
           
 void addPolyline(ClosedPolyline2D polyline)
           
 MultiPolygon2D clip(Box2D box)
          Returns a new instance of MultiPolygon2D.
 boolean contains(double x, double y)
           
 boolean contains(double xr, double yr, double wr, double hr)
           
 boolean contains(java.awt.geom.Point2D point)
           
 boolean contains(java.awt.geom.Rectangle2D rect)
           
 BoundarySet2D<ClosedPolyline2D> getBoundary()
          returns the boundary of the set.
 Box2D getBoundingBox()
          Returns the bounding box of the shape.
 java.awt.Rectangle getBounds()
           
 java.awt.geom.Rectangle2D getBounds2D()
           
 MultiPolygon2D 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)
          get the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.
 java.util.Collection<LineSegment2D> getEdges()
          Return the edges as line segments of the polygon
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at, double fl)
           
 java.util.Collection<Polygon2D> getPolygons()
          Return the set of (oriented) polygons forming this MultiPolygon2D.
 java.util.Collection<Point2D> getVertices()
          Return the vertices (singular points) of the polygon
 int getVerticesNumber()
          Return the number of vertices of the polygon
 boolean intersects(double xr, double yr, double wr, double hr)
           
 boolean intersects(java.awt.geom.Rectangle2D rect)
           
 boolean isBounded()
          Returns true if the shape is bounded, that is if we can draw a finite rectangle enclosing the shape.
 MultiPolygon2D 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
 

Constructor Detail

MultiPolygon2D

public MultiPolygon2D()

MultiPolygon2D

public MultiPolygon2D(ClosedPolyline2D polyline)

MultiPolygon2D

public MultiPolygon2D(Polygon2D polygon)

MultiPolygon2D

public MultiPolygon2D(java.util.Collection<ClosedPolyline2D> lines)
Method Detail

addPolygon

public void addPolygon(Polygon2D polygon)

getPolygons

public java.util.Collection<Polygon2D> getPolygons()
Return the set of (oriented) polygons forming this MultiPolygon2D.

Returns:
a set of Polygon2D.

addPolyline

public void addPolyline(ClosedPolyline2D polyline)

getBoundary

public BoundarySet2D<ClosedPolyline2D> getBoundary()
Description copied from interface: Domain2D
returns the boundary of the set. This boundary is either a continuous non intersecting curve (connected domain), or a set of non intersecting continuous curve (one continuous non-intersection for each connected part of the domain).

The returned curve is oriented, with an interior and an exterior.

Specified by:
getBoundary in interface Domain2D
Returns:
the boundary of the domain

getEdges

public java.util.Collection<LineSegment2D> getEdges()
Description copied from interface: PolygonalShape2D
Return the edges as line segments of the polygon

Specified by:
getEdges in interface PolygonalShape2D

getVertices

public java.util.Collection<Point2D> getVertices()
Description copied from interface: PolygonalShape2D
Return the vertices (singular points) of the polygon

Specified by:
getVertices in interface PolygonalShape2D

getVerticesNumber

public int getVerticesNumber()
Description copied from interface: PolygonalShape2D
Return the number of vertices of the polygon

Specified by:
getVerticesNumber in interface PolygonalShape2D

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.

getClippedShape

public MultiPolygon2D getClippedShape(Box2D box)

clip

public MultiPolygon2D clip(Box2D box)
Returns a new instance of MultiPolygon2D.

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

getDistance

public double getDistance(java.awt.geom.Point2D p)
Description copied from interface: Shape2D
get the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.

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()
Description copied from interface: Shape2D
Returns true if the shape is bounded, that is if we can draw a finite rectangle enclosing the shape. For example, a straight line or a parabola are not bounded.

Specified by:
isBounded in interface Shape2D

transform

public MultiPolygon2D 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 PolygonalShape2D
Specified by:
transform in interface Shape2D
Parameters:
trans - an affine transform
Returns:
the transformed shape

contains

public boolean contains(java.awt.geom.Point2D point)
Specified by:
contains 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.Rectangle2D rect)
Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(double xr,
                        double yr,
                        double wr,
                        double hr)
Specified by:
contains in interface java.awt.Shape

getBounds

public java.awt.Rectangle getBounds()
Specified by:
getBounds in interface java.awt.Shape

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()
Specified by:
getBounds2D in interface java.awt.Shape

getPathIterator

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

getPathIterator

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

intersects

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

intersects

public boolean intersects(double xr,
                          double yr,
                          double wr,
                          double hr)
Specified by:
intersects in interface java.awt.Shape