Java Utililty Methods Rectangle Contain

List of utility methods to do Rectangle Contain

Description

The list of methods to do Rectangle Contain are organized into topic(s).

Method

booleancontains(Rectangle c, Rectangle a)
contains
return c.x <= a.x + a.width && c.x + c.width > a.x && c.y <= a.y + a.height && c.y + c.height > a.y;
booleancontains(Rectangle rect1, Rectangle rect2)
Returns true if the first rectangle completely contains the second one.
return (rect2.x >= rect1.x) && (rect2.y >= rect1.y) && (rect2.x + rect2.width <= rect1.x + rect1.width)
        && (rect2.y + rect2.height <= rect1.y + rect1.height);
RectanglestretchToFit(Rectangle container, Rectangle item)
stretch To Fit
double scale = scaleProportional(container, item);
if (scale < 1) {
    return item;
} else {
    return new Rectangle((int) (item.width * scale), (int) (item.height * scale));