private boolean
isPointInRect(Point p) {
return ((p.getX()
>= LL.getX() && p.getX() <= LR.getX())&&
(p.getY()
<= UL.getY() && p.getY() >= LL.getY()));
}
// # 1
public boolean
checkAllCorners(Rect r1) {
boolean flag = false;
flag = flag ||
isPointInRect(r1.LL);
flag = flag ||
isPointInRect(r1.LR);
flag = flag ||
isPointInRect(r1.UL);
flag = flag ||
isPointInRect(r1.UR);
flag = flag || r1.isPointInRect(LL);
flag = flag || r1.isPointInRect(LR);
flag = flag || r1.isPointInRect(UL);
flag = flag || r1.isPointInRect(UR);
return flag;
}
public boolean
checkRule4(Rect r1) {
boolean flag1, flag2;
flag1 = (UL.getX() <= r1.UL.getX()
&& r1.UR.getX() <= UR.getX());
flag1 = flag1
&& (r1.UL.getY() >= UL.getY()
&& LL.getY() >= r1.LL.getY());
flag2 = (r1.UL.getX()
<= UL.getX() && UR.getX() <= r1.UR.getX());
flag2 = flag2
&& (UL.getY() >= r1.UL.getY()
&& r1.LL.getY() >= LL.getY());
return flag1 || flag2;
}
public boolean hasIntersction(Rect r1) {
return checkAllCorners(r1) || checkRule4(r1);
}