static float distance(ScoutWidget a,ScoutWidget b){
  float ax1, ax2, ay1, ay2;
  float bx1, bx2, by1, by2;
  ax1=a.mX;
  ax2=a.mX + a.mWidth;
  ay1=a.mY;
  ay2=a.mY + a.mHeight;
  bx1=b.mX;
  bx2=b.mX + b.mWidth;
  by1=b.mY;
  by2=b.mY + b.mHeight;
  float xdiff11=Math.abs(ax1 - bx1);
  float xdiff12=Math.abs(ax1 - bx2);
  float xdiff21=Math.abs(ax2 - bx1);
  float xdiff22=Math.abs(ax2 - bx2);
  float ydiff11=Math.abs(ay1 - by1);
  float ydiff12=Math.abs(ay1 - by2);
  float ydiff21=Math.abs(ay2 - by1);
  float ydiff22=Math.abs(ay2 - by2);
  float xmin=Math.min(Math.min(xdiff11,xdiff12),Math.min(xdiff21,xdiff22));
  float ymin=Math.min(Math.min(ydiff11,ydiff12),Math.min(ydiff21,ydiff22));
  boolean yOverlap=ay1 <= by2 && by1 <= ay2;
  boolean xOverlap=ax1 <= bx2 && bx1 <= ax2;
  float xReturn=(yOverlap) ? xmin : (float)Math.hypot(xmin,ymin);
  float yReturn=(xOverlap) ? ymin : (float)Math.hypot(xmin,ymin);
  return Math.min(xReturn,yReturn);
}

static float distance ( ScoutWidget a , ScoutWidget b ) { float ax1 , ax2 , ay1 , ay2 ; float bx1 , bx2 , by1 , by2 ; ax1 = a . mX ; ax2 = a . mX + a . mWidth ; ay1 = a . mY ; ay2 = a . mY + a . mHeight ; bx1 = b . mX ; bx2 = b . mX + b . mWidth ; by1 = b . mY ; by2 = b . mY + b . mHeight ; float xdiff11 = Math . abs ( ax1 - bx1 ) ; float xdiff12 = Math . abs ( ax1 - bx2 ) ; float xdiff21 = Math . abs ( ax2 - bx1 ) ; float xdiff22 = Math . abs ( ax2 - bx2 ) ; float ydiff11 = Math . abs ( ay1 - by1 ) ; float ydiff12 = Math . abs ( ay1 - by2 ) ; float ydiff21 = Math . abs ( ay2 - by1 ) ; float ydiff22 = Math . abs ( ay2 - by2 ) ; float xmin = Math . min ( Math . min ( xdiff11 , xdiff12 ) , Math . min ( xdiff21 , xdiff22 ) ) ; float ymin = Math . min ( Math . min ( ydiff11 , ydiff12 ) , Math . min ( ydiff21 , ydiff22 ) ) ; boolean yOverlap = ay1 <= by2 && by1 <= ay2 ; boolean xOverlap = ax1 <= bx2 && bx1 <= ax2 ; float xReturn = ( yOverlap ) ? xmin : ( float ) Math . hypot ( xmin , ymin ) ; float yReturn = ( xOverlap ) ? ymin : ( float ) Math . hypot ( xmin , ymin ) ; return Math . min ( xReturn , yReturn ) ; }
calculates the distance between two widgets ( assumed to be rectangles )
