math.geom2d.polygon
Class MultiPolygon2D

Package class diagram package MultiPolygon2D
java.lang.Object
  extended by math.geom2d.polygon.MultiPolygon2D
All Implemented Interfaces:
Serializable, CirculinearDomain2D, CirculinearShape2D, Domain2D, Polygon2D, Shape2D

public class MultiPolygon2D
extends Object
implements Domain2D, Polygon2D

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

Author:
dlegland
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface math.geom2d.Shape2D
ACCURACY
 
Constructor Summary
MultiPolygon2D()
           
MultiPolygon2D(Collection<LinearRing2D> lines)
           
MultiPolygon2D(LinearRing2D ring)
           
MultiPolygon2D(LinearRing2D[] rings)
           
MultiPolygon2D(SimplePolygon2D polygon)
           
 
Method Summary
 void addPolygon(SimplePolygon2D polygon)
           
 void addPolyline(LinearRing2D ring)
          Deprecated. 
 void addRing(LinearRing2D ring)
           
 MultiPolygon2D clip(Box2D box)
          Returns a new instance of MultiPolygon2D.
 MultiPolygon2D clone()
           
 Polygon2D complement()
          Returns the domain which complements this domain in the plane.
 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.
 void draw(Graphics2D g2)
          Draws the boundary of the domain, using current Stroke and color.
 boolean equals(Object obj)
           
 void fill(Graphics2D g)
          Fills the interior of the domain, using the Graphics current Paint.
 CirculinearBoundarySet2D<LinearRing2D> getBoundary()
          Returns the boundary of the set.
 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)
          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.
 int getEdgeNumber()
          Returns the number of edges of the polygon
 Collection<LineSegment2D> getEdges()
          Return the edges as line segments of the polygon
 Collection<SimplePolygon2D> getPolygons()
          Return the set of (oriented) polygons forming this MultiPolygon2D.
 Collection<LinearRing2D> getRings()
          Returns the set of rings comprising the boundary of this polygon.
 Point2D getVertex(int i)
          Returns the i-th vertex of the polygon.
 int getVertexNumber()
          Returns the number of vertices of the polygon
 Collection<Point2D> getVertices()
          Returns the vertices (singular points) of the polygon
 boolean isBounded()
          Returns true if the shape is bounded, that is if we can draw a finite rectangle enclosing the shape.
 boolean isEmpty()
          The MultiPolygon2D is empty either if it contains no ring, or if all rings are empty.
 MultiPolygon2D transform(AffineTransform2D trans)
          Transforms the shape by an affine transform.
 CirculinearDomain2D 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
 

Constructor Detail

MultiPolygon2D

public MultiPolygon2D()

MultiPolygon2D

public MultiPolygon2D(LinearRing2D ring)

MultiPolygon2D

public MultiPolygon2D(LinearRing2D[] rings)

MultiPolygon2D

public MultiPolygon2D(SimplePolygon2D polygon)

MultiPolygon2D

public MultiPolygon2D(Collection<LinearRing2D> lines)
Method Detail

addPolygon

public void addPolygon(SimplePolygon2D polygon)

getPolygons

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

Returns:
a set of Polygon2D.

addPolyline

@Deprecated
public void addPolyline(LinearRing2D ring)
Deprecated. 

Deprecated use addRing instead (0.8.0)


addRing

public void addRing(LinearRing2D ring)

getRings

public Collection<LinearRing2D> getRings()
Description copied from interface: Polygon2D
Returns the set of rings comprising the boundary of this polygon.

Specified by:
getRings in interface Polygon2D
Returns:
the set of boundary rings.

transform

public CirculinearDomain2D 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 CirculinearDomain2D
Specified by:
transform in interface CirculinearShape2D
Parameters:
inv - the circle inversion
Returns:
the transformed shape

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

getBoundary

public CirculinearBoundarySet2D<LinearRing2D> 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 CirculinearDomain2D
Specified by:
getBoundary in interface Domain2D
Specified by:
getBoundary in interface Polygon2D
Returns:
the boundary of the domain

complement

public Polygon2D complement()
Description copied from interface: Domain2D
Returns the domain which complements this domain in the plane.

Specified by:
complement in interface Domain2D
Specified by:
complement in interface Polygon2D
Returns:
the complement of this domain.

getEdges

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

Specified by:
getEdges in interface Polygon2D

getEdgeNumber

public int getEdgeNumber()
Description copied from interface: Polygon2D
Returns the number of edges of the polygon

Specified by:
getEdgeNumber in interface Polygon2D

getVertices

public Collection<Point2D> getVertices()
Description copied from interface: Polygon2D
Returns the vertices (singular points) of the polygon

Specified by:
getVertices in interface Polygon2D

getVertex

public Point2D getVertex(int i)
Returns the i-th vertex of the polygon.

Specified by:
getVertex in interface Polygon2D
Parameters:
i - index of the vertex, between 0 and the number of vertices

getVertexNumber

public int getVertexNumber()
Description copied from interface: Polygon2D
Returns the number of vertices of the polygon

Specified by:
getVertexNumber in interface Polygon2D

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.

clip

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

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

getDistance

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

isEmpty

public boolean isEmpty()
The MultiPolygon2D is empty either if it contains no ring, or if all rings are empty.

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

transform

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

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

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

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

draw

public void draw(Graphics2D g2)
Description copied from interface: Domain2D
Draws the boundary of the domain, using current Stroke and color.

Specified by:
draw in interface Domain2D
Specified by:
draw in interface Shape2D
Parameters:
g2 - the Graphics to draw on

fill

public void fill(Graphics2D g)
Description copied from interface: Domain2D
Fills the interior of the domain, using the Graphics current Paint.

Specified by:
fill in interface Domain2D
Parameters:
g - the Graphics to fill on

equals

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

clone

public MultiPolygon2D 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.