private static float alignmentProbability(Rectangle[] widget){
  float[] start=new float[widget.length];
  float[] center=new float[widget.length];
  float[] end=new float[widget.length];
  float widthSum=0;
  int count=0;
  for (int i=0; i < end.length; i++) {
    if (widget[i] == null) {
      start[i]=Float.NaN;
      end[i]=Float.NaN;
      center[i]=Float.NaN;
      continue;
    }
    start[i]=widget[i].x;
    end[i]=start[i] + widget[i].width;
    center[i]=(start[i] + end[i]) / 2;
    widthSum+=widget[i].width;
    count++;
  }
  float startDiv=standardDeviation(start);
  float centerDiv=standardDeviation(center);
  float endDiv=standardDeviation(end);
  if (count > 2) {
    return 1 - Math.min(startDiv,Math.min(centerDiv,endDiv)) / (widthSum / count);
  }
  return 0;
}

private static float alignmentProbability ( Rectangle [ ] widget ) { float [ ] start = new float [ widget . length ] ; float [ ] center = new float [ widget . length ] ; float [ ] end = new float [ widget . length ] ; float widthSum = 0 ; int count = 0 ; for ( int i = 0 ; i < end . length ; i ++ ) { if ( widget [ i ] == null ) { start [ i ] = Float . NaN ; end [ i ] = Float . NaN ; center [ i ] = Float . NaN ; continue ; } start [ i ] = widget [ i ] . x ; end [ i ] = start [ i ] + widget [ i ] . width ; center [ i ] = ( start [ i ] + end [ i ] ) / 2 ; widthSum += widget [ i ] . width ; count ++ ; } float startDiv = standardDeviation ( start ) ; float centerDiv = standardDeviation ( center ) ; float endDiv = standardDeviation ( end ) ; if ( count > 2 ) { return 1 - Math . min ( startDiv , Math . min ( centerDiv , endDiv ) ) / ( widthSum / count ) ; } return 0 ; }
infer alignment for each column
