Program: 69969
Project: 69969
Buggy source:
/** 
 * Calculates visibility for axis labels.
 * @param xs
 * @param la
 * @param iLabelLocation
 * @return
 * @throws ChartException
 */
final protected void checkTickLabelsVisibility(IDisplayServer xs,Label la,int iLabelLocation) throws ChartException {
  hmComputedLabelText=new HashMap<Integer,String>();
  boolean vis=la.isVisible();
  if (!vis && rtc.getSharedScale() != null) {
    vis=true;
  }
  boolean staggerEnabled=isAxisLabelStaggered();
  this.staggeredHelper=StaggeredHelper.createInstance(staggerEnabled,atcTickCoordinates.size(),iLabelShowingInterval);
  this.labelVisHelper=LabelVisibleHelper.createInstance(vis,isCategoryScale(),atcTickCoordinates.size(),iLabelShowingInterval);
  if (!vis || !isCategoryScale()) {
    return;
  }
  DataSetIterator dsi=getData();
  dsi.reset();
  final int iDateTimeUnit=(iType == IConstants.DATE_TIME) ? CDateTime.computeUnit(dsi) : IConstants.UNDEFINED;
  dsi.reset();
  CateLabVisTester tester=this.createCateLabVisTester(xs,la,iLabelLocation);
  EllipsisHelper eHelper=new EllipsisHelper(tester,la.getEllipsis());
  int start_id=isTickBetweenCategories() ? 0 : 1;
  RotatedRectangle rrPrev[]=new RotatedRectangle[2];
  double dStep=Math.abs(atcTickCoordinates.getStep() * dZoomFactor);
  int indexStep=dStep > 1 ? 1 : (int)(1d / dStep);
  for (int i=start_id; i < atcTickCoordinates.size() - 1; i+=indexStep) {
    Object oValue=null;
    if (dsi.hasNext()) {
      oValue=dsi.next();
    }
    if (labelVisHelper.shouldTickLabelVisible(i)) {
      double x=0, y=0;
      String sText=formatCategoryValue(iType,oValue,iDateTimeUnit);
      if (iLabelLocation == ABOVE || iLabelLocation == BELOW) {
        x=this.atcTickCoordinates.getCoordinate(i) * dZoomFactor;
      }
 else       if (iLabelLocation == LEFT || iLabelLocation == RIGHT) {
        y=this.atcTickCoordinates.getCoordinate(i) * dZoomFactor;
      }
      la.getCaption().setValue(sText);
      RotatedRectangle rrCurr=null;
      int arrayIndex=isAxisLabelStaggered() && isTickLabelStaggered(i) ? 1 : 0;
      boolean bVis;
      if (rrPrev[arrayIndex] == null) {
        rrCurr=cComp.computePolygon(xs,iLabelLocation,la,x,y,null);
        bVis=true;
      }
 else {
        tester.setFPara(rrPrev[arrayIndex],x,y);
        bVis=eHelper.checkLabelEllipsis(sText,null);
        rrCurr=tester.getCurrentRR();
      }
      if (bVis) {
        labelVisHelper.addVisible(i);
        rrPrev[arrayIndex]=rrCurr;
        hmComputedLabelText.put(i,la.getCaption().getValue());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Calculates visibility for axis labels.
 * @param xs
 * @param la
 * @param iLabelLocation
 * @return
 * @throws ChartException
 */
final protected void checkTickLabelsVisibility(IDisplayServer xs,Label la,int iLabelLocation) throws ChartException {
  hmComputedLabelText=new HashMap<Integer,String>();
  boolean vis=la.isVisible();
  if (!vis && rtc.getSharedScale() != null) {
    vis=true;
  }
  boolean staggerEnabled=isAxisLabelStaggered();
  this.staggeredHelper=StaggeredHelper.createInstance(staggerEnabled,atcTickCoordinates.size(),iLabelShowingInterval);
  this.labelVisHelper=LabelVisibleHelper.createInstance(vis,isCategoryScale(),atcTickCoordinates.size(),iLabelShowingInterval);
  if (!vis || !isCategoryScale()) {
    return;
  }
  DataSetIterator dsi=getData();
  dsi.reset();
  final int iDateTimeUnit=(iType == IConstants.DATE_TIME) ? CDateTime.computeUnit(dsi) : IConstants.UNDEFINED;
  dsi.reset();
  CateLabVisTester tester=this.createCateLabVisTester(xs,la,iLabelLocation);
  EllipsisHelper eHelper=new EllipsisHelper(tester,la.getEllipsis());
  int start_id=isTickBetweenCategories() ? 0 : 1;
  RotatedRectangle rrPrev[]=new RotatedRectangle[2];
  double dStep=Math.abs(atcTickCoordinates.getStep() * dZoomFactor);
  int indexStep=dStep > 1 ? 1 : (int)(1d / dStep);
  int iSkip=indexStep - 1;
  for (int i=start_id; i < atcTickCoordinates.size() - 1; i+=indexStep) {
    Object oValue=null;
    if (iSkip > 0) {
      if (dsi.skip(iSkip) < iSkip) {
        break;
      }
    }
    if (dsi.hasNext()) {
      oValue=dsi.next();
    }
 else {
      break;
    }
    if (labelVisHelper.shouldTickLabelVisible(i)) {
      double x=0, y=0;
      String sText=formatCategoryValue(iType,oValue,iDateTimeUnit);
      if (iLabelLocation == ABOVE || iLabelLocation == BELOW) {
        x=this.atcTickCoordinates.getCoordinate(i) * dZoomFactor;
      }
 else       if (iLabelLocation == LEFT || iLabelLocation == RIGHT) {
        y=this.atcTickCoordinates.getCoordinate(i) * dZoomFactor;
      }
      la.getCaption().setValue(sText);
      RotatedRectangle rrCurr=null;
      int arrayIndex=isAxisLabelStaggered() && isTickLabelStaggered(i) ? 1 : 0;
      boolean bVis;
      if (rrPrev[arrayIndex] == null) {
        rrCurr=cComp.computePolygon(xs,iLabelLocation,la,x,y,null);
        bVis=true;
      }
 else {
        tester.setFPara(rrPrev[arrayIndex],x,y);
        bVis=eHelper.checkLabelEllipsis(sText,null);
        rrCurr=tester.getCurrentRR();
      }
      if (bVis) {
        labelVisHelper.addVisible(i);
        rrPrev[arrayIndex]=rrCurr;
        hmComputedLabelText.put(i,la.getCaption().getValue());
      }
    }
  }
}