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

Class PolySimple

  • All Implemented Interfaces:
    Poly


    public class PolySimple
    extends java.lang.Object
    implements Poly
    PolySimple is a simple polygon - contains only one inner polygon.

    WARNING: This type of Poly cannot be used for an inner polygon that is a hole.

    • 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
      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)
      Throws IllegalStateexception if called
      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()
      Returns the area of the polygon.
      java.awt.geom.Rectangle2D getBounds()
      Returns the bounding rectangle of this polygon.
      Poly getInnerPoly(int polyIndex)
      Returns this if polyIndex = 0, else it throws IllegalStateException.
      int getNumInnerPoly()
      Always returns 1.
      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()
      Always returns false since PolySimples cannot be holes.
      void setContributing(int polyIndex, boolean contributes)
      Set whether or not this inner polygon is constributing to the set operation.
      void setIsHole(boolean isHole)
      Throws IllegalStateException if called.
      Poly subtract(Poly p) 
      java.lang.String toString()
      Return a string briefly describing the polygon.
      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

      • PolySimple

        public PolySimple()
        Creates a new instance of PolySimple
    • 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:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Return the hashCode of the object.

        WARNING:Hash and Equals break contract.

        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()
        Return a string briefly describing the polygon.
        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.
        Specified by:
        add in interface Poly
      • add

        public void add(java.awt.geom.Point2D p)
        Add a point to the first inner polygon.
        Specified by:
        add in interface Poly
      • add

        public void add(Poly p)
        Throws IllegalStateexception if called
        Specified by:
        add in interface Poly
      • 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.
        Specified by:
        getBounds in interface Poly
      • getInnerPoly

        public Poly getInnerPoly(int polyIndex)
        Returns this if polyIndex = 0, else it throws IllegalStateException.
        Specified by:
        getInnerPoly in interface Poly
      • getNumInnerPoly

        public int getNumInnerPoly()
        Always returns 1.
        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()
        Always returns false since PolySimples cannot be holes.
        Specified by:
        isHole in interface Poly
      • setIsHole

        public void setIsHole(boolean isHole)
        Throws IllegalStateException if called.
        Specified by:
        setIsHole in interface Poly
      • 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
        Throws:
        java.lang.IllegalStateException - if polyIndex != 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:
        setContributing in interface Poly
        Throws:
        java.lang.IllegalStateException - if polyIndex != 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:
        intersection in interface Poly
        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.
        Specified by:
        union in interface Poly
        Returns:
        The returned Poly is of type PolySimple
      • 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.
        Specified by:
        xor in interface Poly
        Returns:
        The returned Poly is of type PolySimple
      • 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".

        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.