示例#1
0
  public Rect expandIn(int w, int h, int maxW, int maxH) {
    Rect r = expand(w, h);
    if (r.getX() < 0) {
      r.setWidth(r.getWidth() + r.getX());
      r.setX(0);
    }
    if (r.getY() < 0) {
      r.setHeight(r.getHeight() + r.getY());
      r.setX(y);
    }
    if (r.getRightPos() > maxW) {
      r.setWidth(maxW - r.getX());
    }

    if (r.getBottomPos() > maxH) {
      r.setHeight(maxH - r.getY());
    }
    return r;
  }
示例#2
0
 public boolean contains(Rect r) {
   return contains(r.x, r.y) && contains(r.x + r.getWidth(), r.y + r.getHeight());
 }