Exemple #1
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append("polygon(");
   sb.append(fillValue);
   sb.append(")[\n");
   PathIterator iterator = path.getPathIterator(null);
   float[] values = new float[2];
   while (!iterator.isDone()) {
     int type = iterator.currentSegment(values);
     Point2D pt = new Point2D.Double(values[0], values[1]);
     sb.append("\t");
     sb.append(pt);
     sb.append("\n");
     iterator.next();
   }
   //        sb.append(iterator);
   //        for(Point2D pt : point2Ds) {
   //            sb.append("\t");
   //            sb.append(pt);
   //            sb.append("\n");
   //        }
   //        sb.append(path.toString());
   sb.append("]");
   return sb.toString();
 }
Exemple #2
0
  public NewPolygon2D clip(Rectangle2D boundingBox) {
    Area thisArea = new Area(path);
    thisArea.intersect(new Area(boundingBox));
    PathIterator iterator = thisArea.getPathIterator(null);
    double[] v = new double[2];
    while (!iterator.isDone()) {
      int type = iterator.currentSegment(v);
      System.err.println(":" + v[0] + v[1] + "\n");
      iterator.next();
    }
    System.exit(-1);

    GeneralPath path = new GeneralPath(thisArea);
    path.closePath();
    NewPolygon2D newPolygon = new NewPolygon2D(path);
    newPolygon.setFillValue(this.getFillValue());
    return newPolygon;
  }