public static void main(String[] args) throws Exception {
    List circleGrid = createCircleGrid(GRID_SIZE);

    PreparedGeometryIndex pgIndex = new PreparedGeometryIndex();
    pgIndex.insert(circleGrid);

    Stopwatch sw = new Stopwatch();
    int inCount = runIndexedQuery(pgIndex);
    String indexTime = sw.getTimeString();

    System.out.println("Number of iterations       = " + MAX_ITER);
    System.out.println("Number of circles in grid  = " + circleGrid.size());
    System.out.println();
    System.out.println(
        "The fraction of intersecting points should approximate the total area of the circles:");
    System.out.println();
    System.out.println("Area of circles                = " + area(circleGrid));
    System.out.println("Fraction of points in circles  = " + inCount / (double) MAX_ITER);
    System.out.println();
    System.out.println("Indexed Execution time: " + indexTime);

    /** For comparison purposes run the same query without using an index */
    Stopwatch sw2 = new Stopwatch();
    int inCount2 = runBruteForceQuery(circleGrid);
    String bruteForceTime = sw2.getTimeString();

    System.out.println();
    System.out.println("Execution time: " + bruteForceTime);
  }
 static int runIndexedQuery(PreparedGeometryIndex pgIndex) {
   int inCount = 0;
   for (int i = 0; i < MAX_ITER; i++) {
     Point randPt = createRandomPoint();
     if (pgIndex.intersects(randPt).size() > 0) {
       inCount++;
     }
   }
   return inCount;
 }