boolean (boolean horizontal, GridConstraints constraints, Rectangle rc) { int start = constraints.getCell(!horizontal); int end = start + constraints.getSpan(!horizontal) - 1; int otherStart = horizontal ? rc.x : rc.y; int otherEnd = otherStart + (horizontal ? rc.width : rc.height) - 1; return start <= otherEnd && otherStart <= end; }