Program: 66565
Project: 66565
Buggy source:
/** 
 * Computes the axis start/end shifts (due to start/end labels) and also takes into consideration all start/end shifts of any overlay axes in the same direction as the current scale.
 * @param la
 * @param iOrientation
 * @param iLocation
 * @param aax
 */
final void computeAxisStartEndShifts(IDisplayServer xs,Label la,int iOrientation,int iLocation,AllAxes aax) throws ChartException {
  final double dMaxSS=(aax != null && iOrientation == aax.getOrientation()) ? aax.getMaxStartShift() : 0;
  final double dMaxES=(aax != null && iOrientation == aax.getOrientation()) ? aax.getMaxEndShift() : 0;
  if ((!la.isVisible()) && !info.bLabelWithinAxes) {
    dStartShift=dMaxSS;
    dEndShift=dMaxES;
    return;
  }
  if (isCategoryScale()) {
    final double dUnitSize=getUnitSize();
    final DataSetIterator dsi=getData();
    final int iDateTimeUnit;
    BoundingBox bb=null;
    try {
      iDateTimeUnit=(getType() == IConstants.DATE_TIME) ? CDateTime.computeUnit(dsi) : IConstants.UNDEFINED;
    }
 catch (    ClassCastException e) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.GENERATION,"String_Node_Str",Messages.getResourceBundle(info.rtc.getULocale()));
    }
    final double rotation=la.getCaption().getFont().getRotation();
    final boolean bCenter=rotation == 0 || rotation == 90 || rotation == -90;
    if (!isTickLabelVisible(labelVisHelper.getFirstVisibleIndex())) {
      dStartShift=dMaxSS;
    }
 else {
      la.getCaption().setValue(formatCategoryValue(getType(),dsi.first(),iDateTimeUnit));
      bb=info.cComp.computeBox(xs,iLocation,la,0,0);
      if (iOrientation == VERTICAL) {
        if (bCenter) {
          dStartShift=Math.max(dMaxSS,(dUnitSize > bb.getHeight()) ? 0 : (bb.getHeight() - dUnitSize) / 2);
        }
 else         if (info.iScaleDirection == FORWARD) {
          dStartShift=Math.max(dMaxSS,bb.getHotPoint() - dUnitSize / 2);
        }
 else {
          dStartShift=Math.max(dMaxSS,bb.getHeight() - bb.getHotPoint() - dUnitSize / 2);
        }
      }
 else       if (iOrientation == HORIZONTAL) {
        if (bCenter) {
          dStartShift=Math.max(dMaxSS,(dUnitSize > bb.getWidth()) ? 0 : (bb.getWidth() - dUnitSize) / 2);
        }
 else         if (info.iScaleDirection == BACKWARD) {
          dStartShift=Math.max(dMaxSS,bb.getWidth() - bb.getHotPoint() - dUnitSize / 2);
        }
 else {
          dStartShift=Math.max(dMaxSS,bb.getHotPoint() - dUnitSize / 2);
        }
      }
    }
    if (!isTickLabelVisible(labelVisHelper.getLastVisibleIndex())) {
      dEndShift=dMaxES;
    }
 else {
      la.getCaption().setValue(formatCategoryValue(getType(),dsi.last(),iDateTimeUnit));
      bb=info.cComp.computeBox(xs,iLocation,la,0,dEnd);
      if (iOrientation == VERTICAL) {
        if (bCenter) {
          dEndShift=Math.max(dMaxES,(dUnitSize > bb.getHeight()) ? 0 : (bb.getHeight() - dUnitSize) / 2);
        }
 else         if (info.iScaleDirection == FORWARD) {
          dEndShift=Math.max(dMaxES,bb.getHeight() - bb.getHotPoint() - dUnitSize / 2);
        }
 else {
          dEndShift=Math.max(dMaxES,bb.getHotPoint() - dUnitSize / 2);
        }
      }
 else       if (iOrientation == HORIZONTAL) {
        if (bCenter) {
          dEndShift=Math.max(dMaxES,(dUnitSize > bb.getWidth()) ? 0 : (bb.getWidth() - dUnitSize) / 2);
        }
 else         if (info.iScaleDirection == BACKWARD) {
          dEndShift=Math.max(dMaxES,bb.getHotPoint() - dUnitSize / 2);
        }
 else {
          dEndShift=Math.max(dMaxES,bb.getWidth() - bb.getHotPoint() - dUnitSize / 2);
        }
      }
    }
  }
 else   if ((info.type & NUMERICAL) == NUMERICAL) {
    if ((info.type & LINEAR) == LINEAR) {
      DecimalFormat df=null;
      Object value=AxisValueProvider.getValue(getMinimum(),isBigNumber() ? this.getBigNumberDivisor() : null);
      if (info.fs == null) {
        if (!isBigNumber()) {
          df=new DecimalFormat(getNumericPattern());
        }
 else {
          df=new DecimalFormat(ValueFormatter.getNumericPattern((Number)value));
        }
      }
      String sValue=null;
      try {
        sValue=ValueFormatter.format(value,info.fs,info.rtc.getULocale(),df);
      }
 catch (      ChartException dfex) {
        logger.log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      BoundingBox bb=info.cComp.computeBox(xs,iLocation,la,0,0);
      if (iOrientation == VERTICAL) {
        dStartShift=Math.max(dMaxSS,(bb.getHeight() - bb.getHotPoint()));
      }
 else       if (iOrientation == HORIZONTAL) {
        dStartShift=Math.max(dMaxSS,bb.getHotPoint());
      }
      value=AxisValueProvider.getValue(getMaximum(),isBigNumber() ? this.getBigNumberDivisor() : null);
      if (info.fs == null) {
        df=new DecimalFormat(ValueFormatter.getNumericPattern((Number)value));
      }
      try {
        sValue=ValueFormatter.format(value,info.fs,info.rtc.getULocale(),df);
      }
 catch (      ChartException dfex) {
        logger.log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      bb=info.cComp.computeBox(xs,iLocation,la,0,0);
      if (iOrientation == VERTICAL) {
        dEndShift=Math.max(dMaxES,bb.getHotPoint());
      }
 else       if (iOrientation == HORIZONTAL) {
        dEndShift=Math.max(dMaxES,(bb.getWidth() - bb.getHotPoint()));
      }
    }
 else     if ((info.type & LOGARITHMIC) == LOGARITHMIC) {
      DecimalFormat df=null;
      Object value=AxisValueProvider.getValue(getMinimum(),isBigNumber() ? this.getBigNumberDivisor() : null);
      if (info.fs == null) {
        df=new DecimalFormat(ValueFormatter.getNumericPattern((Number)value));
      }
      String sValue=null;
      try {
        sValue=ValueFormatter.format(value,info.fs,info.rtc.getULocale(),df);
      }
 catch (      ChartException dfex) {
        logger.log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      BoundingBox bb=null;
      bb=info.cComp.computeBox(xs,iLocation,la,0,0);
      if (iOrientation == VERTICAL) {
        dStartShift=Math.max(dMaxSS,(bb.getHeight() - bb.getHotPoint()));
      }
 else       if (iOrientation == HORIZONTAL) {
        dStartShift=Math.max(dMaxSS,bb.getHotPoint());
      }
      value=AxisValueProvider.getValue(getMaximum(),isBigNumber() ? this.getBigNumberDivisor() : null);
      if (info.fs == null) {
        df=new DecimalFormat(ValueFormatter.getNumericPattern((Number)value));
      }
      try {
        sValue=ValueFormatter.format(value,info.fs,info.rtc.getULocale(),df);
      }
 catch (      ChartException dfex) {
        logger.log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      bb=info.cComp.computeBox(xs,iLocation,la,0,0);
      if (iOrientation == VERTICAL) {
        dEndShift=Math.max(dMaxES,bb.getHotPoint());
      }
 else       if (iOrientation == HORIZONTAL) {
        dEndShift=Math.max(dMaxES,(bb.getWidth() - bb.getHotPoint()));
      }
    }
  }
 else   if (getType() == DATE_TIME) {
    CDateTime cdt=asDateTime(getMinimum());
    final int iUnit=asInteger(context.getUnit());
    IDateFormatWrapper sdf=null;
    String sText=null;
    if (info.fs == null) {
      sdf=DateFormatWrapperFactory.getPreferredDateFormat(iUnit,info.rtc.getULocale());
    }
    try {
      sText=ValueFormatter.format(cdt,info.fs,info.rtc.getULocale(),sdf);
    }
 catch (    ChartException dfex) {
      logger.log(dfex);
      sText=IConstants.NULL_STRING;
    }
    la.getCaption().setValue(sText);
    BoundingBox bb=info.cComp.computeBox(xs,iLocation,la,0,0);
    if (iOrientation == VERTICAL) {
      dStartShift=Math.max(dMaxSS,(bb.getHeight() - bb.getHotPoint()));
    }
 else     if (iOrientation == HORIZONTAL) {
      dStartShift=Math.max(dMaxSS,bb.getHotPoint());
    }
    cdt=asDateTime(getMaximum());
    try {
      sText=ValueFormatter.format(cdt,info.fs,info.rtc.getULocale(),sdf);
    }
 catch (    ChartException dfex) {
      logger.log(dfex);
      sText=IConstants.NULL_STRING;
    }
    la.getCaption().setValue(sText);
    bb=info.cComp.computeBox(xs,iLocation,la,0,dEnd);
    if (iOrientation == VERTICAL) {
      dEndShift=Math.max(dMaxES,bb.getHotPoint());
    }
 else     if (iOrientation == HORIZONTAL) {
      dEndShift=Math.max(dMaxES,(bb.getWidth() - bb.getHotPoint()));
    }
  }
}

Fixed version (ground truth):
/** 
 * Computes the axis start/end shifts (due to start/end labels) and also takes into consideration all start/end shifts of any overlay axes in the same direction as the current scale.
 * @param la
 * @param iOrientation
 * @param iLocation
 * @param aax
 */
final void computeAxisStartEndShifts(IDisplayServer xs,Label la,int iOrientation,int iLocation,AllAxes aax) throws ChartException {
  final double dMaxSS=(aax != null && iOrientation == aax.getOrientation()) ? aax.getMaxStartShift() : 0;
  final double dMaxES=(aax != null && iOrientation == aax.getOrientation()) ? aax.getMaxEndShift() : 0;
  if ((!la.isVisible()) && !info.bLabelWithinAxes) {
    dStartShift=dMaxSS;
    dEndShift=dMaxES;
    return;
  }
  if (isCategoryScale()) {
    final double dUnitSize=getUnitSize();
    final DataSetIterator dsi=getData();
    final int iDateTimeUnit;
    BoundingBox bb=null;
    try {
      iDateTimeUnit=(getType() == IConstants.DATE_TIME) ? CDateTime.computeUnit(dsi) : IConstants.UNDEFINED;
    }
 catch (    ClassCastException e) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.GENERATION,"String_Node_Str",Messages.getResourceBundle(info.rtc.getULocale()));
    }
    final double rotation=la.getCaption().getFont().getRotation();
    final boolean bCenter=rotation == 0 || rotation == 90 || rotation == -90;
    if (!isTickLabelVisible(0)) {
      dStartShift=dMaxSS;
    }
 else {
      la.getCaption().setValue(formatCategoryValue(getType(),dsi.first(),iDateTimeUnit));
      bb=info.cComp.computeBox(xs,iLocation,la,0,0);
      if (iOrientation == VERTICAL) {
        if (bCenter) {
          dStartShift=Math.max(dMaxSS,(dUnitSize > bb.getHeight()) ? 0 : (bb.getHeight() - dUnitSize) / 2);
        }
 else         if (info.iScaleDirection == FORWARD) {
          dStartShift=Math.max(dMaxSS,bb.getHotPoint() - dUnitSize / 2);
        }
 else {
          dStartShift=Math.max(dMaxSS,bb.getHeight() - bb.getHotPoint() - dUnitSize / 2);
        }
      }
 else       if (iOrientation == HORIZONTAL) {
        if (bCenter) {
          dStartShift=Math.max(dMaxSS,(dUnitSize > bb.getWidth()) ? 0 : (bb.getWidth() - dUnitSize) / 2);
        }
 else         if (info.iScaleDirection == BACKWARD) {
          dStartShift=Math.max(dMaxSS,bb.getWidth() - bb.getHotPoint() - dUnitSize / 2);
        }
 else {
          dStartShift=Math.max(dMaxSS,bb.getHotPoint() - dUnitSize / 2);
        }
      }
    }
    if (!isTickLabelVisible(dsi.size() - 1)) {
      dEndShift=dMaxES;
      if (labelVisHelper.getLastVisibleIndex() < (dsi.size() - 1)) {
        double tmpEndShift=computeEndShift(xs,la,iOrientation,iLocation,dMaxES,dUnitSize * (dsi.size() - labelVisHelper.getLastVisibleIndex()),dsi,iDateTimeUnit,bCenter);
        if (tmpEndShift > dEndShift) {
          dEndShift=tmpEndShift;
        }
      }
    }
 else {
      dEndShift=computeEndShift(xs,la,iOrientation,iLocation,dMaxES,dUnitSize,dsi,iDateTimeUnit,bCenter);
    }
  }
 else   if ((info.type & NUMERICAL) == NUMERICAL) {
    if ((info.type & LINEAR) == LINEAR) {
      DecimalFormat df=null;
      Object value=AxisValueProvider.getValue(getMinimum(),isBigNumber() ? this.getBigNumberDivisor() : null);
      if (info.fs == null) {
        if (!isBigNumber()) {
          df=new DecimalFormat(getNumericPattern());
        }
 else {
          df=new DecimalFormat(ValueFormatter.getNumericPattern((Number)value));
        }
      }
      String sValue=null;
      try {
        sValue=ValueFormatter.format(value,info.fs,info.rtc.getULocale(),df);
      }
 catch (      ChartException dfex) {
        logger.log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      BoundingBox bb=info.cComp.computeBox(xs,iLocation,la,0,0);
      if (iOrientation == VERTICAL) {
        dStartShift=Math.max(dMaxSS,(bb.getHeight() - bb.getHotPoint()));
      }
 else       if (iOrientation == HORIZONTAL) {
        dStartShift=Math.max(dMaxSS,bb.getHotPoint());
      }
      value=AxisValueProvider.getValue(getMaximum(),isBigNumber() ? this.getBigNumberDivisor() : null);
      if (info.fs == null) {
        df=new DecimalFormat(ValueFormatter.getNumericPattern((Number)value));
      }
      try {
        sValue=ValueFormatter.format(value,info.fs,info.rtc.getULocale(),df);
      }
 catch (      ChartException dfex) {
        logger.log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      bb=info.cComp.computeBox(xs,iLocation,la,0,0);
      if (iOrientation == VERTICAL) {
        dEndShift=Math.max(dMaxES,bb.getHotPoint());
      }
 else       if (iOrientation == HORIZONTAL) {
        dEndShift=Math.max(dMaxES,(bb.getWidth() - bb.getHotPoint()));
      }
    }
 else     if ((info.type & LOGARITHMIC) == LOGARITHMIC) {
      DecimalFormat df=null;
      Object value=AxisValueProvider.getValue(getMinimum(),isBigNumber() ? this.getBigNumberDivisor() : null);
      if (info.fs == null) {
        df=new DecimalFormat(ValueFormatter.getNumericPattern((Number)value));
      }
      String sValue=null;
      try {
        sValue=ValueFormatter.format(value,info.fs,info.rtc.getULocale(),df);
      }
 catch (      ChartException dfex) {
        logger.log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      BoundingBox bb=null;
      bb=info.cComp.computeBox(xs,iLocation,la,0,0);
      if (iOrientation == VERTICAL) {
        dStartShift=Math.max(dMaxSS,(bb.getHeight() - bb.getHotPoint()));
      }
 else       if (iOrientation == HORIZONTAL) {
        dStartShift=Math.max(dMaxSS,bb.getHotPoint());
      }
      value=AxisValueProvider.getValue(getMaximum(),isBigNumber() ? this.getBigNumberDivisor() : null);
      if (info.fs == null) {
        df=new DecimalFormat(ValueFormatter.getNumericPattern((Number)value));
      }
      try {
        sValue=ValueFormatter.format(value,info.fs,info.rtc.getULocale(),df);
      }
 catch (      ChartException dfex) {
        logger.log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      bb=info.cComp.computeBox(xs,iLocation,la,0,0);
      if (iOrientation == VERTICAL) {
        dEndShift=Math.max(dMaxES,bb.getHotPoint());
      }
 else       if (iOrientation == HORIZONTAL) {
        dEndShift=Math.max(dMaxES,(bb.getWidth() - bb.getHotPoint()));
      }
    }
  }
 else   if (getType() == DATE_TIME) {
    CDateTime cdt=asDateTime(getMinimum());
    final int iUnit=asInteger(context.getUnit());
    IDateFormatWrapper sdf=null;
    String sText=null;
    if (info.fs == null) {
      sdf=DateFormatWrapperFactory.getPreferredDateFormat(iUnit,info.rtc.getULocale());
    }
    try {
      sText=ValueFormatter.format(cdt,info.fs,info.rtc.getULocale(),sdf);
    }
 catch (    ChartException dfex) {
      logger.log(dfex);
      sText=IConstants.NULL_STRING;
    }
    la.getCaption().setValue(sText);
    BoundingBox bb=info.cComp.computeBox(xs,iLocation,la,0,0);
    if (iOrientation == VERTICAL) {
      dStartShift=Math.max(dMaxSS,(bb.getHeight() - bb.getHotPoint()));
    }
 else     if (iOrientation == HORIZONTAL) {
      dStartShift=Math.max(dMaxSS,bb.getHotPoint());
    }
    cdt=asDateTime(getMaximum());
    try {
      sText=ValueFormatter.format(cdt,info.fs,info.rtc.getULocale(),sdf);
    }
 catch (    ChartException dfex) {
      logger.log(dfex);
      sText=IConstants.NULL_STRING;
    }
    la.getCaption().setValue(sText);
    bb=info.cComp.computeBox(xs,iLocation,la,0,dEnd);
    if (iOrientation == VERTICAL) {
      dEndShift=Math.max(dMaxES,bb.getHotPoint());
    }
 else     if (iOrientation == HORIZONTAL) {
      dEndShift=Math.max(dMaxES,(bb.getWidth() - bb.getHotPoint()));
    }
  }
}