private void pickCenterOverlap(ScoutWidget[] list){
  for (int i=0; i < list.length; i++) {
    ScoutWidget scoutWidget=list[i];
    float centerX=scoutWidget.getX() + scoutWidget.getWidth() / 2;
    float centerY=scoutWidget.getY() + scoutWidget.getHeight() / 2;
    for (int j=0; j < list.length; j++) {
      if (i == j)       continue;
      ScoutWidget widget=list[j];
      if (scoutWidget.isGuideline()) {
        continue;
      }
      if (!widget.isGuideline() && ScoutWidget.distance(scoutWidget,widget) > MAX_DIST_FOR_CENTER_OVERLAP) {
        continue;
      }
      if (!widget.isGuideline() || widget.isVerticalGuideline()) {
        if (Math.abs(widget.getX() - centerX) < CENTER_ERROR) {
          scoutWidget.setEdgeCentered(1,widget,Direction.WEST);
        }
        if (Math.abs(widget.getX() + widget.getWidth() - centerX) < CENTER_ERROR) {
          scoutWidget.setEdgeCentered(1,widget,Direction.EAST);
        }
      }
      if (!widget.isGuideline() || widget.isHorizontalGuideline()) {
        if (Math.abs(widget.getY() - centerY) < CENTER_ERROR) {
          scoutWidget.setEdgeCentered(0,widget,Direction.NORTH);
        }
        if (Math.abs(widget.getY() + widget.getHeight() - centerY) < CENTER_ERROR) {
          scoutWidget.setEdgeCentered(0,widget,Direction.SOUTH);
        }
      }
    }
  }
}

private void pickCenterOverlap ( ScoutWidget [ ] list ) { for ( int i = 0 ; i < list . length ; i ++ ) { ScoutWidget scoutWidget = list [ i ] ; float centerX = scoutWidget . getX ( ) + scoutWidget . getWidth ( ) / 2 ; float centerY = scoutWidget . getY ( ) + scoutWidget . getHeight ( ) / 2 ; for ( int j = 0 ; j < list . length ; j ++ ) { if ( i == j ) continue ; ScoutWidget widget = list [ j ] ; if ( scoutWidget . isGuideline ( ) ) { continue ; } if ( ! widget . isGuideline ( ) && ScoutWidget . distance ( scoutWidget , widget ) > MAX_DIST_FOR_CENTER_OVERLAP ) { continue ; } if ( ! widget . isGuideline ( ) || widget . isVerticalGuideline ( ) ) { if ( Math . abs ( widget . getX ( ) - centerX ) < CENTER_ERROR ) { scoutWidget . setEdgeCentered ( 1 , widget , Direction . WEST ) ; } if ( Math . abs ( widget . getX ( ) + widget . getWidth ( ) - centerX ) < CENTER_ERROR ) { scoutWidget . setEdgeCentered ( 1 , widget , Direction . EAST ) ; } } if ( ! widget . isGuideline ( ) || widget . isHorizontalGuideline ( ) ) { if ( Math . abs ( widget . getY ( ) - centerY ) < CENTER_ERROR ) { scoutWidget . setEdgeCentered ( 0 , widget , Direction . NORTH ) ; } if ( Math . abs ( widget . getY ( ) + widget . getHeight ( ) - centerY ) < CENTER_ERROR ) { scoutWidget . setEdgeCentered ( 0 , widget , Direction . SOUTH ) ; } } } } }
find and connect widgets centered over other widgets
