Returns an integer
Rectangle that completely encloses the
Shape. Note that there is no guarantee that the returned
Rectangle is the smallest bounding box that encloses the
Shape, only that the
Shape lies entirely within the indicated
Rectangle. The returned
Rectangle might also fail to completely enclose the
Shape if the
Shape overflows the limited range of the integer data type. The
getBounds2D method generally returns a tighter bounding box due to its greater flexibility in representation.
Note that the definition of insideness can lead to situations where points on the defining outline of the shape may not be considered contained in the returned bounds object, but only in cases where those points are also not considered contained in the original shape.
If a point is inside the shape according to the contains(point) method, then it must be inside the returned Rectangle bounds object according to the contains(point) method of the bounds. Specifically:
shape.contains(x,y) requires bounds.contains(x,y)
If a point is not inside the shape, then it might still be contained in the bounds object:
bounds.contains(x,y) does not imply shape.contains(x,y)