Program: 70975
Project: 70975
Buggy source:
/** 
 * Compute the wrapping with maxWidth, maxHeight. If the wrapping is set to 0, namely auto, this method should be called before calling limitLabelSize.
 * @param xs
 * @param la
 * @param lbLimit
 * @return
 */
public static final double computeWrapping(IDisplayServer xs,Label la,LabelLimiter lbLimit){
  double dWrapping=0;
  final double dSafe=10;
  if (lbLimit != null) {
    double dScale=xs.getDpiResolution() / 72d;
    double fRotation=la.getCaption().getFont().getRotation();
    Insets insets=la.getInsets().scaledInstance(dScale);
    double dInsetsWidth=insets.getLeft() + insets.getRight();
    double dInsetsHeight=insets.getTop() + insets.getBottom();
    if (ChartUtil.mathEqual(fRotation,0)) {
      dWrapping=Math.floor(lbLimit.maxWidth - dInsetsWidth) - dSafe;
    }
 else     if (ChartUtil.mathEqual(fRotation,90)) {
      dWrapping=Math.floor(lbLimit.maxHeight - dInsetsHeight) - dSafe;
    }
 else {
      fRotation%=180;
      if (fRotation < 0) {
        fRotation+=180;
      }
      double rad=Math.toRadians(fRotation % 90);
      double tg=Math.tan(rad);
      double m=1 - tg * tg;
      double r=2 * tg / (1 + tg * tg);
      double wd1=lbLimit.maxWidth;
      double ht1=lbLimit.maxHeight;
      double b, d;
      double wd2;
      if (wd1 < ht1) {
        if (((tg < 1) && (r < wd1 / ht1)) || ((tg > 1) && (r < wd1 / ht1))) {
          b=(wd1 - ht1 * tg) / m;
          d=(ht1 - wd1 * tg) / m;
        }
 else {
          b=wd1 / 2;
          d=b / tg;
        }
      }
 else {
        if (((tg < 1) && (r < ht1 / wd1)) || ((tg > 1) && (r < ht1 / wd1))) {
          b=(wd1 - ht1 * tg) / m;
          d=(ht1 - wd1 * tg) / m;
        }
 else {
          d=ht1 / 2;
          b=d / tg;
        }
      }
      double cos=Math.cos(rad);
      if (fRotation < 90) {
        wd2=b / cos;
      }
 else {
        wd2=d / cos;
      }
      dWrapping=Math.floor(wd2) - dInsetsWidth - dSafe;
    }
    lbLimit.wrapping=dWrapping;
  }
  return dWrapping;
}

Fixed version (ground truth):
/** 
 * Compute the wrapping with maxWidth, maxHeight. If the wrapping is set to 0, namely auto, this method should be called before calling limitLabelSize.
 * @param xs
 * @param la
 * @param lbLimit
 * @return
 */
public static final double computeWrapping(IDisplayServer xs,Label la,LabelLimiter lbLimit){
  double dWrapping=0;
  boolean bIsSWT=xs.getClass().getName().equals("String_Node_Str");
  final double dSafe=bIsSWT ? 10 : 0;
  if (lbLimit != null) {
    double dScale=xs.getDpiResolution() / 72d;
    double fRotation=la.getCaption().getFont().getRotation();
    Insets insets=la.getInsets().scaledInstance(dScale);
    double dInsetsWidth=insets.getLeft() + insets.getRight();
    if (ChartUtil.mathEqual(fRotation,0)) {
      dWrapping=Math.floor(lbLimit.maxWidth - dInsetsWidth) - dSafe;
    }
 else     if (ChartUtil.mathEqual(fRotation,90)) {
      dWrapping=Math.floor(lbLimit.maxHeight - dInsetsWidth) - dSafe;
    }
 else {
      fRotation%=180;
      if (fRotation < 0) {
        fRotation+=180;
      }
      double rad=Math.toRadians(fRotation % 90);
      double tg=Math.tan(rad);
      double m=1 - tg * tg;
      double r=2 * tg / (1 + tg * tg);
      double wd1=lbLimit.maxWidth;
      double ht1=lbLimit.maxHeight;
      double b, d;
      double wd2;
      if (wd1 < ht1) {
        if (((tg < 1) && (r < wd1 / ht1)) || ((tg > 1) && (r < wd1 / ht1))) {
          b=(wd1 - ht1 * tg) / m;
          d=(ht1 - wd1 * tg) / m;
        }
 else {
          b=wd1 / 2;
          d=b / tg;
        }
      }
 else {
        if (((tg < 1) && (r < ht1 / wd1)) || ((tg > 1) && (r < ht1 / wd1))) {
          b=(wd1 - ht1 * tg) / m;
          d=(ht1 - wd1 * tg) / m;
        }
 else {
          d=ht1 / 2;
          b=d / tg;
        }
      }
      double cos=Math.cos(rad);
      if (fRotation < 90) {
        wd2=b / cos;
      }
 else {
        wd2=d / cos;
      }
      dWrapping=Math.floor(wd2) - dInsetsWidth - dSafe;
    }
    lbLimit.wrapping=dWrapping;
  }
  return dWrapping;
}