Program: 70439
Project: 70439
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.isSetVisible() && 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=computePolygon(xs,iLabelLocation,la,x,y);
        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,int iOrientation) throws ChartException {
  hmComputedLabelText=new HashMap<Integer,String>();
  boolean vis=la.isSetVisible() && 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);
  double dUnitSize=getUnitSize();
  int iCount=atcTickCoordinates.size();
  for (int i=start_id; i < iCount; i+=indexStep) {
    Object oValue=null;
    double blankSize=dUnitSize * (iCount - i);
    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=computePolygon(xs,iLabelLocation,la,x,y);
        bVis=true;
      }
 else {
        tester.setFPara(rrPrev[arrayIndex],x,y);
        bVis=eHelper.checkLabelEllipsis(sText,null);
        rrCurr=tester.getCurrentRR();
      }
      if (bVis) {
        if (iOrientation == HORIZONTAL) {
          bVis=rrCurr.getBounds().getWidth() / 2 < blankSize;
        }
 else {
          bVis=rrCurr.getBounds().getHeight() / 2 < blankSize;
        }
      }
      if (bVis) {
        labelVisHelper.addVisible(i);
        rrPrev[arrayIndex]=rrCurr;
        hmComputedLabelText.put(i,la.getCaption().getValue());
      }
    }
  }
}