public void insertPoint(int n, int x, int y) {
    if (type!=TYPE_POLY) return;
    Polygon pnew = new Polygon();
    for (int i=0; i<poly.npoints; i++) {
       pnew.addPoint(poly.xpoints[i], poly.ypoints[i]);
       if (i==n) pnew.addPoint(x,y);
    }
    poly=pnew;
  }