private static int computePortion(int[] size, int delta, double oldProportion) {
    int offset = (int)Math.round((size[0] + size[1] + delta) * oldProportion - size[0]);
    if ((offset < 0) != (delta < 0)) return 0;
    return abs(offset) > abs(delta) ? delta : offset;
  }
private static int computePortion(int[] size, int delta, double oldProportion)