Documentation of 'com.seisw.util.geom.PolyDefault' Java class
PolyDefault
com.seisw.util.geom

Class PolyDefault

  • All Implemented Interfaces:
    Poly


    public class PolyDefault
    extends java.lang.Object
    implements Poly
    PolyDefault is a default Poly implementation. 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 PolyDefault object, it will create an inner polygon of type PolySimple.

    See Also:
    PolySimple
    • Constructor Summary

      Constructors 
      Constructor and Description
      PolyDefault()
      Creates a new instance of PolyDefault
      PolyDefault(boolean isHole) 
      PolyDefault(java.awt.Rectangle rect) 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void add(double x, double y)
      Add a point to the first inner polygon.
      void add(java.awt.geom.Point2D p)
      Add a point to the first inner polygon.
      void add(Poly p)
      Add an inner polygon to this polygon - assumes that adding polygon does not have any inner polygons.
      void clear()
      Remove all of the points.
      boolean equals(java.lang.Object obj)
      Return true if the given object is equal to this one.
      double getArea()
      Return the area of the polygon in square units.
      java.awt.geom.Rectangle2D getBounds()
      Returns the bounding rectangle of this polygon.
      Poly getInnerPoly(int polyIndex)
      Returns the polygon at this index.
      int getNumInnerPoly()
      Returns the number of inner polygons - inner polygons are assumed to return one here.
      int getNumPoints()
      Return the number points of the first inner polygon
      java.awt.Polygon getPolygon() 
      double getX(int index)
      Return the X value of the point at the index in the first inner polygon
      double getY(int index)
      Return the Y value of the point at the index in the first inner polygon
      int hashCode()
      Return the hashCode of the object.
      Poly intersection(Poly p)
      Return a Poly that is the intersection of this polygon with the given polygon.
      boolean isContributing(int polyIndex)
      Return true if the given inner polygon is contributing to the set operation.
      boolean isEmpty()
      Return true if the polygon is empty
      boolean isHole()
      Return true if this polygon is a hole.
      void setContributing(int polyIndex, boolean contributes)
      Set whether or not this inner polygon is constributing to the set operation.
      void setIsHole(boolean isHole)
      Set whether or not this polygon is a hole.
      Poly subtract(Poly p)
      Subtracts Poly p and returns a new Poly.
      java.lang.String toString() 
      Poly union(Poly p)
      Return a Poly that is the union of this polygon with the given polygon.
      Poly xor(Poly p)
      Return a Poly that is the exclusive-or of this polygon with the given polygon.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • 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:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Return the hashCode of the object.
        Overrides:
        hashCode in class java.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:
        toString in class java.lang.Object
      • clear

        public void clear()
        Remove all of the points. Creates an empty polygon.
        Specified by:
        clear in interface Poly
      • 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.

        Specified by:
        add in interface Poly
      • 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.

        Specified by:
        add in interface Poly
      • add

        public void add(Poly p)
        Add an inner polygon to this polygon - assumes that adding polygon does not have any inner polygons.
        Specified by:
        add in interface Poly
        Throws:
        java.lang.IllegalStateException - if the number of inner polygons is greater than zero and this polygon was designated a hole. This would break the assumption that only simple polygons can be holes.
      • isEmpty

        public boolean isEmpty()
        Return true if the polygon is empty
        Specified by:
        isEmpty in interface Poly
      • getBounds

        public java.awt.geom.Rectangle2D getBounds()
        Returns the bounding rectangle of this polygon. WARNING Not supported on complex polygons.
        Specified by:
        getBounds in interface Poly
      • getInnerPoly

        public Poly getInnerPoly(int polyIndex)
        Returns the polygon at this index.
        Specified by:
        getInnerPoly in interface Poly
      • getNumInnerPoly

        public int getNumInnerPoly()
        Returns the number of inner polygons - inner polygons are assumed to return one here.
        Specified by:
        getNumInnerPoly in interface Poly
      • getNumPoints

        public int getNumPoints()
        Return the number points of the first inner polygon
        Specified by:
        getNumPoints in interface Poly
      • getX

        public double getX(int index)
        Return the X value of the point at the index in the first inner polygon
        Specified by:
        getX in interface Poly
      • getY

        public double getY(int index)
        Return the Y value of the point at the index in the first inner polygon
        Specified by:
        getY in interface Poly
      • isHole

        public boolean isHole()
        Return true if this polygon is a hole. Holes are assumed to be inner polygons of a more complex polygon.
        Specified by:
        isHole in interface Poly
        Throws:
        java.lang.IllegalStateException - if called on a complex polygon.
      • setIsHole

        public void setIsHole(boolean isHole)
        Set whether or not this polygon is a hole. Cannot be called on a complex polygon.
        Specified by:
        setIsHole in interface Poly
        Throws:
        java.lang.IllegalStateException - if 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:
        isContributing in interface Poly
      • 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:
        setContributing in interface Poly
        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:
        intersection in interface Poly
        Returns:
        the returned Poly will be an instance of PolyDefault.
      • subtract

        public Poly subtract(Poly p)
        Subtracts Poly p and returns a new Poly.
        Specified by:
        subtract in interface Poly
        Parameters:
        p - The Poly to subtract.
        Returns:
        The difference of this and p.
      • 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.
        Specified by:
        union in interface Poly
        Returns:
        the returned Poly will be an instance of PolyDefault.
      • 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.
        Specified by:
        xor in interface Poly
        Returns:
        the returned Poly will be an instance of PolyDefault.
      • getArea

        public double getArea()
        Return the area of the polygon in square units.
        Specified by:
        getArea in interface Poly
      • getPolygon

        public java.awt.Polygon getPolygon()
        Specified by:
        getPolygon in interface Poly

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.