Java Utililty Methods Rectangle

List of utility methods to do Rectangle

Description

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

Method

voidresetPosition(Window window1, Window window2)
reset Position
Rectangle r1 = window1.getBounds();
Rectangle r2 = window2.getBounds();
int lowerEdge = (int) r2.getY() + (int) r2.getHeight();
int rightEdge = (int) r2.getX() + (int) r2.getWidth();
if ((int) r1.getY() < lowerEdge && (int) r1.getX() < rightEdge) {
    r1.setLocation((int) r1.getX(), lowerEdge);
    window1.setBounds(r1);
intright(Rectangle r)
{ method
if (r != null) {
    return (r.x + r.width);
return (0);
Rectanglesize(final Component component)
Returns component size represented as a rectangle with zero X and Y coordinates.
return new Rectangle(0, 0, component.getWidth(), component.getHeight());
Listsubdivide(Dimension dimension, int threshold, int max)
Subdivides an area into a closest fit set of Rectangle with sides that are powers of 2.
return subdivide(dimension.width, dimension.height, threshold, max);
Rectangle[]subdivideRectangle(int width, int height, int numTilesX, int numTilesY, int extraBorder)
Subdivides a rectangle into tiles.
Rectangle[] rectangles = new Rectangle[numTilesX * numTilesY];
int k = 0;
float w = (float) width / numTilesX;
float h = (float) height / numTilesY;
for (int j = 0; j < numTilesY; j++) {
    int y1 = (int) Math.floor((j + 0) * h);
    int y2 = (int) Math.floor((j + 1) * h) - 1;
    if (y2 < y1) {
...
RectanglesubtractInsets(Rectangle base, Insets insets)
Returns the rectangle that results from removing the insets from a given rectangle.
return new Rectangle(base.x + insets.left, base.y + insets.top, base.width - insets.left - insets.right,
        base.height - insets.top - insets.bottom);
voidsubtractInto(Insets i1, Rectangle r2)
subtract Into
r2.x += i1.left;
r2.y += i1.top;
r2.width -= i1.left + i1.right;
r2.height -= i1.top + i1.bottom;
voidtranslate(RectangularShape r, double dx, double dy)
Moves this rectangle by a given x- and y-offset
r.setFrame(r.getX() + dx, r.getY() + dy, r.getWidth(), r.getHeight());