private static void estimateProbability(ScoutWidget from,Direction fromDir,ScoutWidget to,Direction toDir,ScoutWidget[] list,float[] result){
  result[RESULT_PROBABILITY]=0;
  result[RESULT_MARGIN]=0;
  if (from == to) {
    return;
  }
  if (from.isGuideline()) {
    return;
  }
  if (to.isGuideline()) {
    if ((toDir == Direction.NORTH || toDir == Direction.SOUTH) && to.isVerticalGuideline()) {
      return;
    }
    if ((toDir == Direction.EAST || toDir == Direction.WEST) && to.isHorizontalGuideline()) {
      return;
    }
  }
  if ((toDir == Direction.NORTH || toDir == Direction.SOUTH) & from.hasBaseline()) {
    if (from.hasConnection(Direction.BASE)) {
      return;
    }
  }
  if (fromDir == Direction.BASE) {
    if (!from.hasBaseline() || !to.hasBaseline()) {
      return;
    }
  }
  float fromLocation=from.getLocation(fromDir);
  float toLocation=to.getLocation(toDir);
  float positionDiff=(fromDir.reverse()) ? fromLocation - toLocation : toLocation - fromLocation;
  float distance=2 * ScoutWidget.distance(from,to);
  if (to.isRoot()) {
    distance=Math.abs(distance - ROOT_MARGIN_DISCOUNT);
  }
  float probability=1 / (1 + distance * distance + positionDiff * positionDiff);
  if (fromDir == Direction.BASE) {
    if (Math.abs(positionDiff) > BASELINE_ERROR) {
      return;
    }
    probability*=2;
  }
  if (to.isRoot()) {
    probability*=2;
  }
  result[RESULT_PROBABILITY]=(positionDiff >= 0) ? probability : NEGATIVE_GAP_FLAG;
  result[RESULT_MARGIN]=positionDiff;
}

private static void estimateProbability ( ScoutWidget from , Direction fromDir , ScoutWidget to , Direction toDir , ScoutWidget [ ] list , float [ ] result ) { result [ RESULT_PROBABILITY ] = 0 ; result [ RESULT_MARGIN ] = 0 ; if ( from == to ) { return ; } if ( from . isGuideline ( ) ) { return ; } if ( to . isGuideline ( ) ) { if ( ( toDir == Direction . NORTH || toDir == Direction . SOUTH ) && to . isVerticalGuideline ( ) ) { return ; } if ( ( toDir == Direction . EAST || toDir == Direction . WEST ) && to . isHorizontalGuideline ( ) ) { return ; } } if ( ( toDir == Direction . NORTH || toDir == Direction . SOUTH ) & from . hasBaseline ( ) ) { if ( from . hasConnection ( Direction . BASE ) ) { return ; } } if ( fromDir == Direction . BASE ) { if ( ! from . hasBaseline ( ) || ! to . hasBaseline ( ) ) { return ; } } float fromLocation = from . getLocation ( fromDir ) ; float toLocation = to . getLocation ( toDir ) ; float positionDiff = ( fromDir . reverse ( ) ) ? fromLocation - toLocation : toLocation - fromLocation ; float distance = 2 * ScoutWidget . distance ( from , to ) ; if ( to . isRoot ( ) ) { distance = Math . abs ( distance - ROOT_MARGIN_DISCOUNT ) ; } float probability = 1 / ( 1 + distance * distance + positionDiff * positionDiff ) ; if ( fromDir == Direction . BASE ) { if ( Math . abs ( positionDiff ) > BASELINE_ERROR ) { return ; } probability *= 2 ; } if ( to . isRoot ( ) ) { probability *= 2 ; } result [ RESULT_PROBABILITY ] = ( positionDiff >= 0 ) ? probability : NEGATIVE_GAP_FLAG ; result [ RESULT_MARGIN ] = positionDiff ; }
this defines the " probability " of a constraint between two widgets .
