public void calculatePath() {
    path = new Path2D.Double();

    path.moveTo(xpoints[0], ypoints[0]);
    for (int i = 1; i < npoints; i++) path.lineTo(xpoints[i], ypoints[i]);

    bounds = path.getBounds2D();
  }
 @Override
 public Rectangle2D getBounds2D() {
   return shape.getBounds2D();
 }