com.seisw.util.geom
Interface Poly
-
- All Known Implementing Classes:
- PolyDefault, PolySimple
public interface PolyPolyis an interface to a complex polygon.Polypolygons can consist of multiple "inner" polygons that can be disjoint and can be considered holes.Currently, this interface supports two concepts:
- a set of inner polygons
- a set of points of a polygon
Refactoring. This would be a good place for some refactoring to create a ComplexPoly and an InnerPoly or something so that these two concepts are broken out. One might also consider changing from an interface to an abstract class, so the methods
isContributing()andsetContributing()could have an access of package only. Or, theClipalgorithm could not store this information in thePoly.Assumptions. The methods that access the polygon as though it were a set of points assume it is accessing the first polygon in the list of inner polygons. It is also assumed that inner polygons do not have more inner polygons.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description voidadd(double x, double y)Add a point to the first inner polygon.voidadd(java.awt.geom.Point2D p)Add a point to the first inner polygon.voidadd(Poly p)Add an inner polygon to this polygon - assumes that adding polygon does not have any inner polygons.voidclear()Remove all of the points.doublegetArea()Return the area of the polygon in square units.java.awt.geom.Rectangle2DgetBounds()Returns the bounding rectangle of this polygon.PolygetInnerPoly(int polyIndex)Returns the polygon at this index.intgetNumInnerPoly()Returns the number of inner polygons - inner polygons are assumed to return one here.intgetNumPoints()Return the number points of the first inner polygonjava.awt.PolygongetPolygon()doublegetX(int index)Return the X value of the point at the index in the first inner polygondoublegetY(int index)Return the Y value of the point at the index in the first inner polygonPolyintersection(Poly p)Return a Poly that is the intersection of this polygon with the given polygon.booleanisContributing(int polyIndex)Return true if the given inner polygon is contributing to the set operation.booleanisEmpty()Return true if the polygon is emptybooleanisHole()Return true if this polygon is a hole.voidsetContributing(int polyIndex, boolean contributes)Set whether or not this inner polygon is constributing to the set operation.voidsetIsHole(boolean isHole)Set whether or not this polygon is a hole.Polysubtract(Poly p)Polyunion(Poly p)Return a Poly that is the union of this polygon with the given polygon.Polyxor(Poly p)Return a Poly that is the exclusive-or of this polygon with the given polygon.
-
-
-
Method Detail
-
clear
void clear()
Remove all of the points. Creates an empty polygon.
-
add
void add(double x, double y)Add a point to the first inner polygon.
-
add
void add(java.awt.geom.Point2D p)
Add a point to the first inner polygon.
-
add
void add(Poly p)
Add an inner polygon to this polygon - assumes that adding polygon does not have any inner polygons.
-
isEmpty
boolean isEmpty()
Return true if the polygon is empty
-
getBounds
java.awt.geom.Rectangle2D getBounds()
Returns the bounding rectangle of this polygon.
-
getInnerPoly
Poly getInnerPoly(int polyIndex)
Returns the polygon at this index.
-
getNumInnerPoly
int getNumInnerPoly()
Returns the number of inner polygons - inner polygons are assumed to return one here.
-
getNumPoints
int getNumPoints()
Return the number points of the first inner polygon
-
getX
double getX(int index)
Return the X value of the point at the index in the first inner polygon
-
getY
double getY(int index)
Return the Y value of the point at the index in the first inner polygon
-
isHole
boolean isHole()
Return true if this polygon is a hole. Holes are assumed to be inner polygons of a more complex polygon.- Throws:
java.lang.IllegalStateException- if called on a complex polygon.
-
setIsHole
void setIsHole(boolean isHole)
Set whether or not this polygon is a hole. Cannot be called on a complex polygon.- Throws:
java.lang.IllegalStateException- if called on a complex polygon.
-
isContributing
boolean isContributing(int polyIndex)
Return true if the given inner polygon is contributing to the set operation. This method should NOT be used outside the Clip algorithm.
-
setContributing
void setContributing(int polyIndex, boolean contributes)Set whether or not this inner polygon is constributing to the set operation. This method should NOT be used outside the Clip algorithm.
-
intersection
Poly intersection(Poly p)
Return a Poly that is the intersection of this polygon with the given polygon. The returned polygon could be complex.
-
union
Poly union(Poly p)
Return a Poly that is the union of this polygon with the given polygon. The returned polygon could be complex.
-
xor
Poly xor(Poly p)
Return a Poly that is the exclusive-or of this polygon with the given polygon. The returned polygon could be complex.
-
getPolygon
java.awt.Polygon getPolygon()
-
getArea
double getArea()
Return the area of the polygon in square units.
-
-
DMelt 3.0 © DataMelt by jWork.ORG