Class PolygonShape

  • All Implemented Interfaces:
    java.awt.Shape

    public class PolygonShape
    extends java.lang.Object
    implements java.awt.Shape
    A Shape which represents a polygon which may contain holes. Provided because the standard AWT Polygon class does not support holes.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.geom.GeneralPath polygonPath  
      private java.awt.geom.GeneralPath ringPath  
    • Constructor Summary

      Constructors 
      Constructor Description
      PolygonShape()  
      PolygonShape​(Coordinate[] shellVertices, java.util.Collection holeVerticesCollection)
      Creates a new polygon Shape.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void addToRing​(java.awt.geom.Point2D p)  
      boolean contains​(double x, double y)  
      boolean contains​(double x, double y, double w, double h)  
      boolean contains​(java.awt.geom.Point2D p)  
      boolean contains​(java.awt.geom.Rectangle2D r)  
      (package private) void endRing()  
      java.awt.Rectangle getBounds()  
      java.awt.geom.Rectangle2D getBounds2D()  
      java.awt.geom.PathIterator getPathIterator​(java.awt.geom.AffineTransform at)  
      java.awt.geom.PathIterator getPathIterator​(java.awt.geom.AffineTransform at, double flatness)  
      boolean intersects​(double x, double y, double w, double h)  
      boolean intersects​(java.awt.geom.Rectangle2D r)  
      private java.awt.geom.GeneralPath toPath​(Coordinate[] coordinates)
      Creates a GeneralPath representing a polygon ring having the given coordinate sequence.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • polygonPath

        private java.awt.geom.GeneralPath polygonPath
      • ringPath

        private java.awt.geom.GeneralPath ringPath
    • Constructor Detail

      • PolygonShape

        public PolygonShape​(Coordinate[] shellVertices,
                            java.util.Collection holeVerticesCollection)
        Creates a new polygon Shape.
        Parameters:
        shellVertices - the vertices of the shell
        holeVerticesCollection - a collection of Coordinate[] for each hole
      • PolygonShape

        public PolygonShape()
    • Method Detail

      • addToRing

        void addToRing​(java.awt.geom.Point2D p)
      • endRing

        void endRing()
      • toPath

        private java.awt.geom.GeneralPath toPath​(Coordinate[] coordinates)
        Creates a GeneralPath representing a polygon ring having the given coordinate sequence. Uses the GeneralPath.WIND_EVEN_ODD winding rule.
        Parameters:
        coordinates - a coordinate sequence
        Returns:
        the path for the coordinate sequence
      • getBounds

        public java.awt.Rectangle getBounds()
        Specified by:
        getBounds in interface java.awt.Shape
      • getBounds2D

        public java.awt.geom.Rectangle2D getBounds2D()
        Specified by:
        getBounds2D in interface java.awt.Shape
      • contains

        public boolean contains​(double x,
                                double y)
        Specified by:
        contains in interface java.awt.Shape
      • contains

        public boolean contains​(java.awt.geom.Point2D p)
        Specified by:
        contains in interface java.awt.Shape
      • intersects

        public boolean intersects​(double x,
                                  double y,
                                  double w,
                                  double h)
        Specified by:
        intersects in interface java.awt.Shape
      • intersects

        public boolean intersects​(java.awt.geom.Rectangle2D r)
        Specified by:
        intersects in interface java.awt.Shape
      • contains

        public boolean contains​(double x,
                                double y,
                                double w,
                                double h)
        Specified by:
        contains in interface java.awt.Shape
      • contains

        public boolean contains​(java.awt.geom.Rectangle2D r)
        Specified by:
        contains in interface java.awt.Shape
      • getPathIterator

        public java.awt.geom.PathIterator getPathIterator​(java.awt.geom.AffineTransform at)
        Specified by:
        getPathIterator in interface java.awt.Shape
      • getPathIterator

        public java.awt.geom.PathIterator getPathIterator​(java.awt.geom.AffineTransform at,
                                                          double flatness)
        Specified by:
        getPathIterator in interface java.awt.Shape