// Helper function to test any non-empty rectangle private static void testInterior(Rectangle r) { assertTrue(r.interior(r.center())); assertFalse(r.interior(r.lowerRight())); assertFalse(r.interior(r.upperLeft())); assertFalse(r.interior(r.upperLeft().offset(0, 1))); assertFalse(r.interior(r.lowerLeft().offset(0, -1))); assertFalse(r.interior(r.upperRight().offset(1, 0))); assertFalse(r.interior(r.lowerRight().offset(1, 1))); assertTrue(r.interior(r.lowerLeft().offset(r.width() / 4, r.height() / 10))); }
// Helper function for any rectangle. // Expects the lower left coordinates (llx,lly) // and upper-right coordinates (urx, ury), // even if that's not how the rectangle is // internally represented. private static void testGeometry(Rectangle r, double llx, double lly, double urx, double ury) { // Sanity-check the inputs assertTrue(llx <= urx); assertTrue(lly <= ury); // Check the corners assertTrue(r.lowerLeft().getX() == llx); assertTrue(r.lowerLeft().getY() == lly); assertTrue(r.upperRight().getX() == urx); assertTrue(r.upperRight().getY() == ury); assertTrue(r.lowerRight().getX() == urx); assertTrue(r.lowerRight().getY() == lly); assertTrue(r.upperLeft().getX() == llx); assertTrue(r.upperLeft().getY() == ury); // Check the center assertTrue(r.center().getX() == (llx + urx) / 2.0); assertTrue(r.center().getY() == (lly + ury) / 2.0); // Check the width assertTrue(r.width() == (urx - llx)); assertTrue(r.height() == (ury - lly)); }