private static int stretchTo(int[] size, int tgt0, int tgt1, int delta, double oldProportion) {
    int d0 = tgt0 - size[0];
    if ((d0 >= 0) != (delta >= 0)) d0 = 0;
    int d1 = tgt1 - size[1];
    if ((d1 >= 0) != (delta >= 0)) d1 = 0;
    if (abs(d0 + d1) > abs(delta)) {
      int p0 = computePortion(size, delta, oldProportion);
      int p1 = delta - p0;
      if (abs(p0) > abs(d0)) {
        p0 = d0;
        p1 = delta - d0;
      }
      else if (abs(p1) > abs(d1)) {
        p0 = delta - d1;
        p1 = d1;
      }
      size[0] += p0;
      size[1] += p1;
      return 0;
    }
    else {
      size[0] += d0;
      size[1] += d1;
      return delta - (d0 + d1);
    }
  }
private static int stretchTo(int[] size, int tgt0, int tgt1, int delta, double oldProportion)