Program: 65704
Project: 65704
Buggy source:
/** 
 * Calculates visibility for axis labels.
 * @param xs
 * @param la
 * @param iLabelLocation
 * @param iOrientation
 * @throws ChartException
 */
final protected void checkTickLabelsVisibility(IDisplayServer xs,Label la,int iLabelLocation,int iOrientation) 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;
  double ellipsisWidth=0;
  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;
        String str=la.getCaption().getValue();
        if (iOrientation == VERTICAL && isCategoryScale() && axisLabelInfo.dMaxSize > 0) {
          double size=info.cComp.computeWidth(xs,la);
          if (ellipsisWidth <= 0) {
            la.getCaption().setValue(EllipsisHelper.ELLIPSIS_STRING);
            ellipsisWidth=info.cComp.computeWidth(xs,la);
          }
          if (ChartUtil.mathGT(size,axisLabelInfo.dMaxSize)) {
            int count=(int)(str.length() * (axisLabelInfo.dMaxSize - ellipsisWidth) / size);
            hmComputedLabelText.put(i,str.substring(0,count) + EllipsisHelper.ELLIPSIS_STRING);
          }
 else {
            hmComputedLabelText.put(i,str);
          }
        }
 else {
          hmComputedLabelText.put(i,str);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Calculates visibility for axis labels.
 * @param xs
 * @param la
 * @param iLabelLocation
 * @param iOrientation
 * @throws ChartException
 */
final protected void checkTickLabelsVisibility(IDisplayServer xs,Label la,int iLabelLocation,int iOrientation) 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;
  double ellipsisWidth=0;
  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;
        String str=la.getCaption().getValue();
        double rotation=la.getCaption().getFont().getRotation();
        if (iOrientation == VERTICAL && isCategoryScale() && axisLabelInfo.dMaxSize > 0 && Math.abs(rotation) <= 45) {
          double size=info.cComp.computeWidth(xs,la);
          if (ellipsisWidth <= 0) {
            la.getCaption().setValue(EllipsisHelper.ELLIPSIS_STRING);
            ellipsisWidth=info.cComp.computeWidth(xs,la);
          }
          if (ChartUtil.mathGT(size,axisLabelInfo.dMaxSize)) {
            int count=(int)(str.length() * (axisLabelInfo.dMaxSize - ellipsisWidth) / size);
            if (count >= 0) {
              hmComputedLabelText.put(i,str.substring(0,count) + EllipsisHelper.ELLIPSIS_STRING);
            }
 else {
              hmComputedLabelText.put(i,str);
            }
          }
 else {
            hmComputedLabelText.put(i,str);
          }
        }
 else {
          hmComputedLabelText.put(i,str);
        }
      }
    }
  }
}