Rectangle2D.Float (Java Platform SE 8 ) (original) (raw)

Returns a high precision and more accurate bounding box of the Shape than the getBounds method. Note that there is no guarantee that the returnedRectangle2D is the smallest bounding box that encloses the Shape, only that the Shape lies entirely within the indicated Rectangle2D. The bounding box returned by this method is usually tighter than that returned by the getBounds method and never fails due to overflow problems since the return value can be an instance of the Rectangle2D that uses double precision values to store the dimensions.

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 originalshape.

If a point is inside the shape according to thecontains(point) method, then it must be inside the returned Rectangle2D bounds object according to the contains(point) method of thebounds. Specifically:

shape.contains(p) requires bounds.contains(p)

If a point is not inside the shape, then it might still be contained in the bounds object:

bounds.contains(p) does not imply shape.contains(p)