code: public static GeneralPath createPolygon(int[] xPoints, int[] yPoints, 
              int nPoints, boolean close) {
          GeneralPath p = new GeneralPath();
          p.moveTo(xPoints[0], yPoints[0]);
          for (int i = 1; i < nPoints; i++) {
              p.lineTo(xPoints[i], yPoints[i]);
          }
          if (close) {
              p.closePath();
          }
          return p;
      }
docs: Creates a polygon from the specified {@code x} and {@code y} coordinate
  arrays.
  
  @param xPoints  the x-points.
  @param yPoints  the y-points.
  @param nPoints  the number of points to use for the polyline.
  @param close  closed?
  
  @return A polygon.