Java Utililty Methods Rectangle Grow

List of utility methods to do Rectangle Grow

Description

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

Method

voidenlargeRectangle(Rectangle2D rect, double d)
Enlarges the passed rectangle by d in all directions.
if (rect == null) {
    throw new IllegalArgumentException();
rect.setRect(rect.getX() - d, rect.getY() - d, rect.getWidth() + 2 * d, rect.getHeight() + 2 * d);
Rectangle2DenlargeRectangle(Rectangle2D toEnlarge, double size)
Returns a rectangle enlarged by size (half of size in each direction).
final Rectangle2D.Double res = new Rectangle2D.Double(toEnlarge.getX() - size / 2,
        toEnlarge.getY() - size / 2, toEnlarge.getWidth() + size, toEnlarge.getHeight() + size);
return res;
RectangleenlargeRectToGrid(Rectangle2D r)
Create a rectangle with the same area as the given input rectangle but with all of its edges snapped (rounded) to the integer grid.
final int x0 = floor(r.getMinX());
final int y0 = floor(r.getMinY());
final int x1 = ceil(r.getMaxX());
final int y1 = ceil(r.getMaxY());
return new Rectangle(x0, y0, x1 - x0, y1 - y0);
java.awt.Rectanglegrow(java.awt.Rectangle rv, int xPad, int yPad)
grow
rv.x -= xPad;
rv.y -= yPad;
rv.width += xPad + xPad;
rv.height += yPad + yPad;
return rv;
voidgrow(Rectangle2D r, float amountx, float amounty)
grow
r.setRect(r.getX() - amountx, r.getY() - amounty, r.getWidth() + amountx * 2, r.getHeight() + amounty * 2);
Rectangle2Dgrow(Rectangle2D rec, Point2D grow)
grow
double x = rec.getX();
double y = rec.getY();
double w = rec.getWidth();
double h = rec.getHeight();
x = x - grow.getX();
y = y - grow.getY();
w = w + grow.getX() * 2;
h = h + grow.getY() * 2;
...
voidgrow(Rectangle2D.Double r, double h, double v)
grow
r.x -= h;
r.y -= v;
r.width += h * 2.0D;
r.height += v * 2.0D;
Rectangle2D.Floatgrow(Rectangle2D.Float r, int size)
grow
r.x -= size;
r.y -= size;
r.width += size * 2;
r.height += size * 2;
return r;
Rectangle2DgrowRect(Rectangle2D rect, double d)
grow Rect
return growRect(rect, d, d, d, d);
Rectangle2DgrowRectangle(Rectangle2D rec, double amount_x, double amount_y)
grow Rectangle
return new Rectangle2D.Double(rec.getX() - amount_x / 2, rec.getY() - amount_y / 2,
        rec.getWidth() + amount_x, rec.getHeight() + amount_y);