private static Rectangle applyTransform(Rectangle srcRect, AffineTransform at) {
    Point2D leftTop = at.transform(new Point(srcRect.x, srcRect.y), null);
    Point2D rightBottom = at.transform(new Point(srcRect.x + srcRect.width, srcRect.y + srcRect.height), null);
    int left = (int)Math.floor(leftTop.getX());
    int top = (int)Math.floor(leftTop.getY());
    int right = (int)Math.ceil(rightBottom.getX());
    int bottom = (int)Math.ceil(rightBottom.getY());
    return new Rectangle(left, top, right - left, bottom - top);
  }
private static Rectangle applyTransform(Rectangle srcRect, AffineTransform at)