Program: 66915
Project: 66915
Buggy source:
/** 
 * @param la
 * @param iLabelLocation
 * @param iOrientation
 * @param dStart
 * @param dEnd
 * @param bConsiderStartEndLabels
 * @param aax
 */
public final int computeTicks(IDisplayServer xs,Label la,int iLabelLocation,int iOrientation,double dStart,double dEnd,boolean bConsiderStartLabel,boolean bConsiderEndLabel,AllAxes aax) throws ChartException {
  boolean bMaxIsNotIntegralMultipleOfStep=false;
  int nTicks=0;
  double dLength=0;
  double dTickGap=0;
  int iDirection=(info.iScaleDirection == AUTO) ? ((iOrientation == HORIZONTAL) ? FORWARD : BACKWARD) : info.iScaleDirection;
  if (bConsiderStartLabel || bConsiderEndLabel) {
    computeAxisStartEndShifts(xs,la,iOrientation,iLabelLocation,aax);
    if (!info.bLabelWithinAxes && bConsiderStartLabel) {
      double dNewStart=dStart + dStartShift * iDirection;
      if (dEnd > dStart && dNewStart > dEnd - 1) {
        dNewStart=dEnd - 1;
      }
 else       if (dEnd < dStart && dNewStart < dEnd + 1) {
        dNewStart=dEnd + 1;
      }
      dStartShift=(dNewStart - dStart) / iDirection;
      dStart=dNewStart;
    }
    if (bConsiderEndLabel) {
      double dNewEnd=dEnd + dEndShift * -iDirection;
      if (dEnd > dStart && dNewEnd < dStart + 1) {
        dNewEnd=dStart + 1;
      }
 else       if (dEnd < dStart && dNewEnd > dStart - 1) {
        dNewEnd=dStart - 1;
      }
      dEndShift=(dNewEnd - dEnd) / -iDirection;
      dEnd=dNewEnd;
    }
  }
  this.dStart=dStart;
  this.dEnd=dEnd;
  if (isSetFactor()) {
    double step=Methods.asDouble(getStep()).doubleValue();
    dTickGap=step / getFactor();
    int stepNum=(int)(Math.abs(dStart - dEnd) / dTickGap);
    AxisTickCoordinates atc=new AxisTickCoordinates(stepNum + 1,dStart,dStart < dEnd ? dStart + dTickGap * stepNum : dStart - dTickGap * stepNum,dTickGap * iDirection,true);
    setTickCordinates(atc);
    checkTickLabelsVisibility(xs,la,iLabelLocation);
    return stepNum + 1;
  }
  nTicks=getTickCount();
  dLength=Math.abs(dStart - dEnd);
  if (!info.bCategoryScale && (info.type & NUMERICAL) == NUMERICAL && (info.type & LINEAR) == LINEAR) {
    double dMax=asDouble(context.getMax()).doubleValue();
    double dMin=asDouble(context.getMin()).doubleValue();
    double dStep=asDouble(context.getStep()).doubleValue();
    bMaxIsNotIntegralMultipleOfStep=!ChartUtil.mathEqual(dMax / dStep,(int)(dMax / dStep),isBigNumber());
    if (info.bStepFixed && context.getStepNumber() != null) {
      dTickGap=dLength / (context.getStepNumber().intValue()) * iDirection;
    }
 else {
      double dStepSize=asDouble(context.getStep()).doubleValue();
      dTickGap=Math.min(Math.abs(dStepSize / (dMax - dMin) * dLength),dLength) * iDirection;
    }
  }
 else {
    if (isTickBetweenCategories()) {
      dTickGap=dLength / (nTicks - 1) * iDirection;
    }
 else {
      dTickGap=dLength / (nTicks - 2) * iDirection;
    }
  }
  if (nTicks > TICKS_MAX && info.bStepFixed && !info.bCategoryScale) {
    throw new ChartException(ChartEnginePlugin.ID,ChartException.GENERATION,"String_Node_Str",Messages.getResourceBundle(info.rtc.getULocale()));
  }
  AxisTickCoordinates atc=new AxisTickCoordinates(nTicks,dStart,dEnd,dTickGap,!info.bCategoryScale || isTickBetweenCategories());
  setTickCordinates(null);
  setEndPoints(dStart,dEnd);
  setTickCordinates(atc);
  if (info.bStepFixed && context.getStepNumber() == null && (nTicks > 2) && bMaxIsNotIntegralMultipleOfStep) {
    if (!checkFit(xs,la,iLabelLocation)) {
      nTicks--;
      AxisTickCoordinates atc1=new AxisTickCoordinates(nTicks,dStart,dEnd,dTickGap,!info.bCategoryScale || isTickBetweenCategories());
      setTickCordinates(null);
      setTickCordinates(atc1);
    }
  }
  checkTickLabelsVisibility(xs,la,iLabelLocation);
  return nTicks;
}

Fixed version (ground truth):
/** 
 * @param la
 * @param iLabelLocation
 * @param iOrientation
 * @param dStart
 * @param dEnd
 * @param bConsiderStartEndLabels
 * @param aax
 */
public final int computeTicks(IDisplayServer xs,Label la,int iLabelLocation,int iOrientation,double dStart,double dEnd,boolean bConsiderStartLabel,boolean bConsiderEndLabel,AllAxes aax) throws ChartException {
  boolean bMaxIsNotIntegralMultipleOfStep=false;
  int nTicks=0;
  double dLength=0;
  double dTickGap=0;
  int iDirection=(info.iScaleDirection == AUTO) ? ((iOrientation == HORIZONTAL) ? FORWARD : BACKWARD) : info.iScaleDirection;
  if (bConsiderStartLabel || bConsiderEndLabel) {
    computeAxisStartEndShifts(xs,la,iOrientation,iLabelLocation,aax);
    if (!info.bLabelWithinAxes && bConsiderStartLabel) {
      double dNewStart=dStart + dStartShift * iDirection;
      if (dEnd > dStart && dNewStart > dEnd - 1) {
        dNewStart=dEnd - 1;
      }
 else       if (dEnd < dStart && dNewStart < dEnd + 1) {
        dNewStart=dEnd + 1;
      }
      dStartShift=(dNewStart - dStart) / iDirection;
      dStart=dNewStart;
    }
    if (bConsiderEndLabel) {
      double dNewEnd=dEnd + dEndShift * -iDirection;
      if (dEnd > dStart && dNewEnd < dStart + 1) {
        dNewEnd=dStart + 1;
      }
 else       if (dEnd < dStart && dNewEnd > dStart - 1) {
        dNewEnd=dStart - 1;
      }
      dEndShift=(dNewEnd - dEnd) / -iDirection;
      dEnd=dNewEnd;
    }
  }
  this.dStart=dStart;
  this.dEnd=dEnd;
  if (isSetFactor()) {
    double step=Methods.asDouble(getStep()).doubleValue();
    dTickGap=step / getFactor();
    int stepNum=(int)(Math.abs(dStart - dEnd) / dTickGap);
    AxisTickCoordinates atc=new AxisTickCoordinates(stepNum + 1,dStart,dStart < dEnd ? dStart + dTickGap * stepNum : dStart - dTickGap * stepNum,dTickGap * iDirection,true);
    setTickCordinates(atc);
    checkTickLabelsVisibility(xs,la,iLabelLocation);
    double length=Math.abs(this.dEnd - this.dStart);
    double valueLength=length * getFactor();
    double dMaxValue=((Number)this.getMinimum()).doubleValue() + valueLength;
    this.setMaximum(Double.valueOf(dMaxValue));
    return stepNum + 1;
  }
  nTicks=getTickCount();
  dLength=Math.abs(dStart - dEnd);
  if (!info.bCategoryScale && (info.type & NUMERICAL) == NUMERICAL && (info.type & LINEAR) == LINEAR) {
    double dMax=asDouble(context.getMax()).doubleValue();
    double dMin=asDouble(context.getMin()).doubleValue();
    double dStep=asDouble(context.getStep()).doubleValue();
    bMaxIsNotIntegralMultipleOfStep=!ChartUtil.mathEqual(dMax / dStep,(int)(dMax / dStep),isBigNumber());
    if (info.bStepFixed && context.getStepNumber() != null) {
      dTickGap=dLength / (context.getStepNumber().intValue()) * iDirection;
    }
 else {
      double dStepSize=asDouble(context.getStep()).doubleValue();
      dTickGap=Math.min(Math.abs(dStepSize / (dMax - dMin) * dLength),dLength) * iDirection;
    }
  }
 else {
    if (isTickBetweenCategories()) {
      dTickGap=dLength / (nTicks - 1) * iDirection;
    }
 else {
      dTickGap=dLength / (nTicks - 2) * iDirection;
    }
  }
  if (nTicks > TICKS_MAX && info.bStepFixed && !info.bCategoryScale) {
    throw new ChartException(ChartEnginePlugin.ID,ChartException.GENERATION,"String_Node_Str",Messages.getResourceBundle(info.rtc.getULocale()));
  }
  AxisTickCoordinates atc=new AxisTickCoordinates(nTicks,dStart,dEnd,dTickGap,!info.bCategoryScale || isTickBetweenCategories());
  setTickCordinates(null);
  setEndPoints(dStart,dEnd);
  setTickCordinates(atc);
  if (info.bStepFixed && context.getStepNumber() == null && (nTicks > 2) && bMaxIsNotIntegralMultipleOfStep) {
    if (!checkFit(xs,la,iLabelLocation)) {
      nTicks--;
      AxisTickCoordinates atc1=new AxisTickCoordinates(nTicks,dStart,dEnd,dTickGap,!info.bCategoryScale || isTickBetweenCategories());
      setTickCordinates(null);
      setTickCordinates(atc1);
    }
  }
  checkTickLabelsVisibility(xs,la,iLabelLocation);
  return nTicks;
}