com.seisw.util.geom
Class PolyDefault
- java.lang.Object
-
- com.seisw.util.geom.PolyDefault
-
- All Implemented Interfaces:
- Poly
public class PolyDefault extends java.lang.Object implements Poly
PolyDefaultis a defaultPolyimplementation. It provides support for both complex and simple polygons. A complex polygon is a polygon that consists of more than one polygon. A simple polygon is a more traditional polygon that contains of one inner polygon and is just a collection of points.Implementation Note: If a point is added to an empty
PolyDefaultobject, it will create an inner polygon of typePolySimple.- See Also:
PolySimple
-
-
Constructor Summary
Constructors Constructor and Description PolyDefault()Creates a new instance of PolyDefaultPolyDefault(boolean isHole)PolyDefault(java.awt.Rectangle rect)
-
Method Summary
All Methods Instance Methods Concrete 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.booleanequals(java.lang.Object obj)Return true if the given object is equal to this one.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 polygoninthashCode()Return the hashCode of the object.Polyintersection(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)Subtracts Polypand returns a new Poly.java.lang.StringtoString()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.
-
-
-
Constructor Detail
-
PolyDefault
public PolyDefault()
Creates a new instance of PolyDefault
-
PolyDefault
public PolyDefault(boolean isHole)
-
PolyDefault
public PolyDefault(java.awt.Rectangle rect)
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
Return true if the given object is equal to this one.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Return the hashCode of the object.- Overrides:
hashCodein classjava.lang.Object- Returns:
- an integer value that is the same for two objects whenever their internal representation is the same (equals() is true)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
clear
public void clear()
Remove all of the points. Creates an empty polygon.
-
add
public void add(double x, double y)Add a point to the first inner polygon.Implementation Note: If a point is added to an empty PolyDefault object, it will create an inner polygon of type
PolySimple.
-
add
public void add(java.awt.geom.Point2D p)
Add a point to the first inner polygon.Implementation Note: If a point is added to an empty PolyDefault object, it will create an inner polygon of type
PolySimple.
-
add
public void add(Poly p)
Add an inner polygon to this polygon - assumes that adding polygon does not have any inner polygons.
-
isEmpty
public boolean isEmpty()
Return true if the polygon is empty
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
Returns the bounding rectangle of this polygon. WARNING Not supported on complex polygons.
-
getInnerPoly
public Poly getInnerPoly(int polyIndex)
Returns the polygon at this index.- Specified by:
getInnerPolyin interfacePoly
-
getNumInnerPoly
public int getNumInnerPoly()
Returns the number of inner polygons - inner polygons are assumed to return one here.- Specified by:
getNumInnerPolyin interfacePoly
-
getNumPoints
public int getNumPoints()
Return the number points of the first inner polygon- Specified by:
getNumPointsin interfacePoly
-
getX
public double getX(int index)
Return the X value of the point at the index in the first inner polygon
-
getY
public double getY(int index)
Return the Y value of the point at the index in the first inner polygon
-
isHole
public boolean isHole()
Return true if this polygon is a hole. Holes are assumed to be inner polygons of a more complex polygon.
-
setIsHole
public void setIsHole(boolean isHole)
Set whether or not this polygon is a hole. Cannot be called on a complex polygon.
-
isContributing
public 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.- Specified by:
isContributingin interfacePoly
-
setContributing
public 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.- Specified by:
setContributingin interfacePoly- Throws:
java.lang.IllegalStateException- if called on a complex polygon
-
intersection
public Poly intersection(Poly p)
Return a Poly that is the intersection of this polygon with the given polygon. The returned polygon could be complex.- Specified by:
intersectionin interfacePoly- Returns:
- the returned Poly will be an instance of PolyDefault.
-
union
public 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
public 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.
-
getArea
public double getArea()
Return the area of the polygon in square units.
-
getPolygon
public java.awt.Polygon getPolygon()
- Specified by:
getPolygonin interfacePoly
-
-
DMelt 3.0 © DataMelt by jWork.ORG