Program: 69614
Project: 69614
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 && info.rtc.getSharedScale() != null) {
    vis=true;
  }
  boolean staggerEnabled=isAxisLabelStaggered();
  this.staggeredHelper=StaggeredHelper.createInstance(staggerEnabled,atcTickCoordinates.size(),info.iLabelShowingInterval);
  this.labelVisHelper=LabelVisibleHelper.createInstance(vis,isCategoryScale(),atcTickCoordinates.size(),info.iLabelShowingInterval);
  if (!vis || !isCategoryScale()) {
    return;
  }
  DataSetIterator dsi=getData();
  dsi.reset();
  final int iDateTimeUnit=(info.type == 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() * info.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(info.type,oValue,iDateTimeUnit);
      if (iLabelLocation == ABOVE || iLabelLocation == BELOW) {
        x=this.atcTickCoordinates.getCoordinate(i) * info.dZoomFactor;
      }
 else       if (iLabelLocation == LEFT || iLabelLocation == RIGHT) {
        y=this.atcTickCoordinates.getCoordinate(i) * info.dZoomFactor;
      }
      la.getCaption().setValue(sText);
      RotatedRectangle rrCurr=null;
      int arrayIndex=isAxisLabelStaggered() && isTickLabelStaggered(i) ? 1 : 0;
      boolean bVis;
      if (rrPrev[arrayIndex] == null) {
        rrCurr=info.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 && info.rtc.getSharedScale() != null) {
    vis=true;
  }
  boolean staggerEnabled=isAxisLabelStaggered();
  this.staggeredHelper=StaggeredHelper.createInstance(staggerEnabled,atcTickCoordinates.size(),info.iLabelShowingInterval);
  this.labelVisHelper=LabelVisibleHelper.createInstance(vis,isCategoryScale(),atcTickCoordinates.size(),info.iLabelShowingInterval);
  if (!vis || !isCategoryScale()) {
    return;
  }
  DataSetIterator dsi=getData();
  dsi.reset();
  int iDateTimeUnit=IConstants.UNDEFINED;
  if (info.type == IConstants.DATE_TIME) {
    iDateTimeUnit=ChartUtil.computeDateTimeCategoryUnit(info.plotComp.getModel(),dsi);
  }
  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() * info.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(info.type,oValue,iDateTimeUnit);
      if (iLabelLocation == ABOVE || iLabelLocation == BELOW) {
        x=this.atcTickCoordinates.getCoordinate(i) * info.dZoomFactor;
      }
 else       if (iLabelLocation == LEFT || iLabelLocation == RIGHT) {
        y=this.atcTickCoordinates.getCoordinate(i) * info.dZoomFactor;
      }
      la.getCaption().setValue(sText);
      RotatedRectangle rrCurr=null;
      int arrayIndex=isAxisLabelStaggered() && isTickLabelStaggered(i) ? 1 : 0;
      boolean bVis;
      if (rrPrev[arrayIndex] == null) {
        rrCurr=info.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());
      }
    }
  }
}