@Override // from RectangularShape public void setFrame (float x, float y, float width, float height) { setBounds(x, y, width, height); } }
/** * Constructs a rectangle with the specified upper-left corner and dimensions. */ public Rectangle (float x, float y, float width, float height) { setBounds(x, y, width, height); }
/** * Sets the area to which menus should be confined when there isn't any other associated * bounds. */ public void setScreenArea (IRectangle screenArea) { _screenArea.setBounds(screenArea); }
/** * Expands the bounds of this rectangle to contain the specified point. */ public void add (float px, float py) { float x1 = Math.min(x, px); float x2 = Math.max(x + width, px); float y1 = Math.min(y, py); float y2 = Math.max(y + height, py); setBounds(x1, y1, x2 - x1, y2 - y1); }
/** * Constructs a rectangle with upper-left corner at (0,0) and the supplied dimensions. */ public Rectangle (IDimension d) { setBounds(0, 0, d.width(), d.height()); }
@Override // from interface IShape public Rectangle bounds (Rectangle target) { float x1 = x1(), y1 = y1(), x2 = x2(), y2 = y2(); float ctrlx = ctrlX(), ctrly = ctrlY(); float rx0 = Math.min(Math.min(x1, x2), ctrlx); float ry0 = Math.min(Math.min(y1, y2), ctrly); float rx1 = Math.max(Math.max(x1, x2), ctrlx); float ry1 = Math.max(Math.max(y1, y2), ctrly); target.setBounds(rx0, ry0, rx1 - rx0, ry1 - ry0); return target; }
/** * Constructs a rectangle with the supplied upper-left corner and dimensions (0,0). */ public Rectangle (XY p) { setBounds(p.x(), p.y(), 0, 0); }
@Override // from interface IShape public Rectangle bounds (Rectangle target) { float x1 = x1(), y1 = y1(), x2 = x2(), y2 = y2(); float ctrlx1 = ctrlX1(), ctrly1 = ctrlY1(); float ctrlx2 = ctrlX2(), ctrly2 = ctrlY2(); float rx1 = Math.min(Math.min(x1, x2), Math.min(ctrlx1, ctrlx2)); float ry1 = Math.min(Math.min(y1, y2), Math.min(ctrly1, ctrly2)); float rx2 = Math.max(Math.max(x1, x2), Math.max(ctrlx1, ctrlx2)); float ry2 = Math.max(Math.max(y1, y2), Math.max(ctrly1, ctrly2)); target.setBounds(rx1, ry1, rx2 - rx1, ry2 - ry1); return target; }
@Override // from interface IShape public Rectangle bounds (Rectangle target) { float x1 = x1(), y1 = y1(), x2 = x2(), y2 = y2(); float ctrlx = ctrlX(), ctrly = ctrlY(); float rx0 = Math.min(Math.min(x1, x2), ctrlx); float ry0 = Math.min(Math.min(y1, y2), ctrly); float rx1 = Math.max(Math.max(x1, x2), ctrlx); float ry1 = Math.max(Math.max(y1, y2), ctrly); target.setBounds(rx0, ry0, rx1 - rx0, ry1 - ry0); return target; }
/** * Writes the current bounds of this element into the supplied bounds. * @return {@code bounds} for convenience. */ public Rectangle bounds (Rectangle bounds) { bounds.setBounds(x(), y(), _size.width, _size.height); return bounds; }
@Override // from interface IShape public Rectangle bounds (Rectangle target) { float x1 = x1(), y1 = y1(), x2 = x2(), y2 = y2(); float ctrlx1 = ctrlX1(), ctrly1 = ctrlY1(); float ctrlx2 = ctrlX2(), ctrly2 = ctrlY2(); float rx1 = Math.min(Math.min(x1, x2), Math.min(ctrlx1, ctrlx2)); float ry1 = Math.min(Math.min(y1, y2), Math.min(ctrly1, ctrly2)); float rx2 = Math.max(Math.max(x1, x2), Math.max(ctrlx1, ctrlx2)); float ry2 = Math.max(Math.max(y1, y2), Math.max(ctrly1, ctrly2)); target.setBounds(rx1, ry1, rx2 - rx1, ry2 - ry1); return target; }
/** * Expands the bounds of this rectangle to contain the supplied rectangle. */ public void add (IRectangle r) { float x1 = Math.min(x, r.x()); float x2 = Math.max(x + width, r.x() + r.width()); float y1 = Math.min(y, r.y()); float y2 = Math.max(y + height, r.y() + r.height()); setBounds(x1, y1, x2 - x1, y2 - y1); }
/** * Intersects the supplied two rectangles, writing the result into {@code dst}. */ public static void intersect (IRectangle src1, IRectangle src2, Rectangle dst) { float x1 = Math.max(src1.minX(), src2.minX()); float y1 = Math.max(src1.minY(), src2.minY()); float x2 = Math.min(src1.maxX(), src2.maxX()); float y2 = Math.min(src1.maxY(), src2.maxY()); dst.setBounds(x1, y1, x2 - x1, y2 - y1); }
/** * Unions the supplied two rectangles, writing the result into {@code dst}. */ public static void union (IRectangle src1, IRectangle src2, Rectangle dst) { float x1 = Math.min(src1.minX(), src2.minX()); float y1 = Math.min(src1.minY(), src2.minY()); float x2 = Math.max(src1.maxX(), src2.maxX()); float y2 = Math.max(src1.maxY(), src2.maxY()); dst.setBounds(x1, y1, x2 - x1, y2 - y1); }
/** * Intersects the supplied two rectangles, writing the result into {@code dst}. */ public static void intersect (IRectangle src1, IRectangle src2, Rectangle dst) { float x1 = Math.max(src1.minX(), src2.minX()); float y1 = Math.max(src1.minY(), src2.minY()); float x2 = Math.min(src1.maxX(), src2.maxX()); float y2 = Math.min(src1.maxY(), src2.maxY()); dst.setBounds(x1, y1, x2 - x1, y2 - y1); }
/** * Constructs a rectangle with bounds equal to the supplied rectangle. */ public Rectangle (IRectangle r) { setBounds(r.x(), r.y(), r.width(), r.height()); }
/** * Sets the bounds of this rectangle to those of the supplied rectangle. */ public void setBounds (IRectangle r) { setBounds(r.x(), r.y(), r.width(), r.height()); }
@Override // from interface IShape public Rectangle bounds (Rectangle target) { target.setBounds(x(), y(), width(), height()); return target; }
/** * Constructs a rectangle with upper-left corner at the supplied point and with the supplied * dimensions. */ public Rectangle (XY p, IDimension d) { setBounds(p.x(), p.y(), d.width(), d.height()); }
/** * Constructs a rectangle with bounds equal to the supplied rectangle. */ public Rectangle (IRectangle r) { setBounds(r.x(), r.y(), r.width(), r.height()); }