import java.awt.geom.*; static Rect toRect(Rectangle r) { ret r == null ? null : Rect(r); } static Rect toRect(RectangularShape r) { ret r == null ? null : toRect(r.getBounds()); } ifclass DoubleRect static Rect toRect(DoubleRect r) { if (r == null) null; int x = iround(r.x), y = iround(r.y); ret Rect(x, y, iround(r.x2())-x, iround(r.y2())-y); } endif static Rect toRect(Rect r) { ret r; }