sclass BoxWithColor implements RenderableWithHints { Pt a, b; RGB color; *() {} *(Pt *a, Pt *b, RGB *color) {} *(Rect r, Color color) { a = pt(r.x, r.y); b = pt(r.x2(), r.y2()); this.color = RGB(color); } *(Rect rect, int r, int g, int b) { this(rect, new Color(r, g, b)); } public void renderOn(Graphics2D g, int w, int h) { int x1 = min(a.x, b.x), y1 = min(a.y, b.y); int x2 = max(a.x, b.x), y2 = max(a.y, b.y); fillRect(g, x1, y1, x2-x1+1, y2-y1+1, toColor(color)); } public void renderHints(Graphics2D g, int w, int h) { int x1 = min(a.x, b.x), y1 = min(a.y, b.y); int x2 = max(a.x, b.x), y2 = max(a.y, b.y); drawRect(g, x1, y1, x2-x1+1, y2-y1+1, hintColor()); } }