code: public static final boolean intersection(Rectangle src1, Rectangle src2, Rectangle dest)
      {
          int x1 = Math.max(src1.x, src2.x);
          int y1 = Math.max(src1.y, src2.y);
          int x2 = Math.min(src1.x + src1.width, src2.x + src2.width);
          int y2 = Math.min(src1.y + src1.height, src2.y + src2.height);
          dest.setBounds(x1, y1, x2 - x1, y2 - y1);
  
          if (dest.width <= 0 || dest.height <= 0)
              return false;
  
          return true; // non-empty intersection
      }
docs: Calculates intersection of two rectangles
  
  @param src1
  the src1
  @param src2
  the src2
  @param dest
  the dest
  @return true, if there is non empty intersection