com.seisw.util.geom
Class PolySimple
- java.lang.Object
-
- com.seisw.util.geom.PolySimple
-
-
Constructor Summary
Constructors Constructor and Description PolySimple()Creates a new instance of PolySimple
-
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)Throws IllegalStateexception if calledvoidclear()Remove all of the points.booleanequals(java.lang.Object obj)Return true if the given object is equal to this one.doublegetArea()Returns the area of the polygon.java.awt.geom.Rectangle2DgetBounds()Returns the bounding rectangle of this polygon.PolygetInnerPoly(int polyIndex)ReturnsthisifpolyIndex = 0, else it throws IllegalStateException.intgetNumInnerPoly()Always returns 1.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()Always returns false since PolySimples cannot be holes.voidsetContributing(int polyIndex, boolean contributes)Set whether or not this inner polygon is constributing to the set operation.voidsetIsHole(boolean isHole)Throws IllegalStateException if called.Polysubtract(Poly p)java.lang.StringtoString()Return a string briefly describing the polygon.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
-
equals
public boolean equals(java.lang.Object obj)
Return true if the given object is equal to this one.WARNING: This method failse if the first point appears more than once in the list.
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Return the hashCode of the object.WARNING:Hash and Equals break contract.
- 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()
Return a string briefly describing the polygon.- 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.
-
add
public void add(java.awt.geom.Point2D p)
Add a point to the first inner polygon.
-
add
public void add(Poly p)
Throws IllegalStateexception if called
-
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.
-
getInnerPoly
public Poly getInnerPoly(int polyIndex)
ReturnsthisifpolyIndex = 0, else it throws IllegalStateException.- Specified by:
getInnerPolyin interfacePoly
-
getNumInnerPoly
public int getNumInnerPoly()
Always returns 1.- 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()
Always returns false since PolySimples cannot be holes.
-
setIsHole
public void setIsHole(boolean isHole)
Throws IllegalStateException if called.
-
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- Throws:
java.lang.IllegalStateException- ifpolyIndex != 0
-
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- ifpolyIndex != 0
-
intersection
public Poly intersection(Poly p)
Return a Poly that is the intersection of this polygon with the given polygon. The returned polygon is simple.- Specified by:
intersectionin interfacePoly- Returns:
- The returned Poly is of type PolySimple
-
union
public Poly union(Poly p)
Return a Poly that is the union of this polygon with the given polygon. The returned polygon is simple.
-
xor
public Poly xor(Poly p)
Return a Poly that is the exclusive-or of this polygon with the given polygon. The returned polygon is simple.
-
getArea
public double getArea()
Returns the area of the polygon.The algorithm for the area of a complex polygon was take from code by Joseph O'Rourke author of " Computational Geometry in C".
-
getPolygon
public java.awt.Polygon getPolygon()
- Specified by:
getPolygonin interfacePoly
-
-
DMelt 3.0 © DataMelt by jWork.ORG