Program: 79319
Project: 79319
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 GenerationException {
  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()) {
    dStartShift=dMaxSS;
    dEndShift=dMaxES;
    return;
  }
  if (getType() == TEXT || bCategoryScale) {
    final double dUnitSize=getUnitSize();
    final DataSetIterator dsi=getData();
    final int iDateTimeUnit=(getType() == IConstants.DATE_TIME) ? CDateTime.computeUnit(dsi) : IConstants.UNDEFINED;
    la.getCaption().setValue(formatCategoryValue(getType(),dsi.first(),iDateTimeUnit));
    BoundingBox bb=null;
    try {
      bb=computeBox(xs,iLocation,la,0,0);
    }
 catch (    UnexpectedInputException uiex) {
      throw new GenerationException(uiex);
    }
    if (iOrientation == VERTICAL) {
      dStartShift=Math.max(dMaxSS,(dUnitSize > bb.getHeight()) ? 0 : (bb.getHeight() - dUnitSize) / 2);
    }
 else     if (iOrientation == HORIZONTAL) {
      dStartShift=Math.max(dMaxSS,(dUnitSize > bb.getWidth()) ? 0 : (bb.getWidth() - dUnitSize) / 2);
    }
    la.getCaption().setValue(formatCategoryValue(getType(),dsi.last(),iDateTimeUnit));
    try {
      bb=computeBox(xs,iLocation,la,0,dEnd);
    }
 catch (    UnexpectedInputException uiex) {
      throw new GenerationException(uiex);
    }
    if (iOrientation == VERTICAL) {
      dEndShift=Math.max(dMaxES,(dUnitSize > bb.getHeight()) ? 0 : (bb.getHeight() - dUnitSize) / 2);
    }
 else     if (iOrientation == HORIZONTAL) {
      dEndShift=Math.max(dMaxES,(dUnitSize > bb.getWidth()) ? 0 : (bb.getWidth() - dUnitSize) / 2);
    }
  }
 else   if ((iType & NUMERICAL) == NUMERICAL) {
    if ((iType & LINEAR) == LINEAR) {
      DecimalFormat df=null;
      if (fs == null) {
        df=new DecimalFormat(getNumericPattern());
      }
      String sValue=null;
      try {
        sValue=ValueFormatter.format(getMinimum(),fs,lcl,df);
      }
 catch (      DataFormatException dfex) {
        DefaultLoggerImpl.instance().log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      BoundingBox bb=null;
      try {
        bb=computeBox(xs,iLocation,la,0,0);
      }
 catch (      UnexpectedInputException uiex) {
        throw new GenerationException(uiex);
      }
      if (iOrientation == VERTICAL) {
        dStartShift=Math.max(dMaxSS,(bb.getHeight() - bb.getHotPoint()));
      }
 else       if (iOrientation == HORIZONTAL) {
        dStartShift=Math.max(dMaxSS,bb.getHotPoint());
      }
      try {
        sValue=ValueFormatter.format(getMaximum(),fs,lcl,df);
      }
 catch (      DataFormatException dfex) {
        DefaultLoggerImpl.instance().log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      try {
        bb=computeBox(xs,iLocation,la,0,0);
      }
 catch (      UnexpectedInputException uiex) {
        throw new GenerationException(uiex);
      }
      if (iOrientation == VERTICAL) {
        dEndShift=Math.max(dMaxES,bb.getHotPoint());
      }
 else       if (iOrientation == HORIZONTAL) {
        dEndShift=Math.max(dMaxES,(bb.getWidth() - bb.getHotPoint()));
      }
    }
 else     if ((iType & LOGARITHMIC) == LOGARITHMIC) {
      final double dMinimum=asDouble(getMinimum()).doubleValue();
      DecimalFormat df=null;
      if (fs == null) {
        df=new DecimalFormat(getNumericPattern(dMinimum));
      }
      String sValue=null;
      try {
        sValue=ValueFormatter.format(getMinimum(),fs,lcl,df);
      }
 catch (      DataFormatException dfex) {
        DefaultLoggerImpl.instance().log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      BoundingBox bb=null;
      try {
        bb=computeBox(xs,iLocation,la,0,0);
      }
 catch (      UnexpectedInputException uiex) {
        throw new GenerationException(uiex);
      }
      if (iOrientation == VERTICAL) {
        dStartShift=Math.max(dMaxSS,(bb.getHeight() - bb.getHotPoint()));
      }
 else       if (iOrientation == HORIZONTAL) {
        dStartShift=Math.max(dMaxSS,bb.getHotPoint());
      }
      final double dMaximum=asDouble(getMaximum()).doubleValue();
      if (fs == null) {
        df=new DecimalFormat(getNumericPattern(dMaximum));
      }
      try {
        sValue=ValueFormatter.format(getMaximum(),fs,lcl,df);
      }
 catch (      DataFormatException dfex) {
        DefaultLoggerImpl.instance().log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      try {
        bb=computeBox(xs,iLocation,la,0,0);
      }
 catch (      UnexpectedInputException uiex) {
        throw new GenerationException(uiex);
      }
      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) {
    double dUnitSize=getUnitSize();
    CDateTime cdt=asDateTime(getMinimum());
    final int iUnit=asInteger(oUnit);
    SimpleDateFormat sdf=null;
    String sText=null;
    if (fs != null) {
      sdf=new SimpleDateFormat(CDateTime.getPreferredFormat(iUnit));
    }
    try {
      sText=ValueFormatter.format(cdt,fs,lcl,sdf);
    }
 catch (    DataFormatException dfex) {
      DefaultLoggerImpl.instance().log(dfex);
      sText=IConstants.NULL_STRING;
    }
    la.getCaption().setValue(sText);
    BoundingBox bb=null;
    try {
      bb=computeBox(xs,iLocation,la,0,0);
    }
 catch (    UnexpectedInputException uiex) {
      throw new GenerationException(uiex);
    }
    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,fs,lcl,sdf);
    }
 catch (    DataFormatException dfex) {
      DefaultLoggerImpl.instance().log(dfex);
      sText=IConstants.NULL_STRING;
    }
    la.getCaption().setValue(sText);
    try {
      bb=computeBox(xs,iLocation,la,0,dEnd);
    }
 catch (    UnexpectedInputException uiex) {
      throw new GenerationException(uiex);
    }
    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 GenerationException {
  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()) {
    dStartShift=dMaxSS;
    dEndShift=dMaxES;
    return;
  }
  if (getType() == TEXT || bCategoryScale) {
    final double dUnitSize=getUnitSize();
    final DataSetIterator dsi=getData();
    final int iDateTimeUnit=(getType() == IConstants.DATE_TIME) ? CDateTime.computeUnit(dsi) : IConstants.UNDEFINED;
    la.getCaption().setValue(formatCategoryValue(getType(),dsi.first(),iDateTimeUnit));
    BoundingBox bb=null;
    try {
      bb=computeBox(xs,iLocation,la,0,0);
    }
 catch (    UnexpectedInputException uiex) {
      throw new GenerationException(uiex);
    }
    if (iOrientation == VERTICAL) {
      dStartShift=Math.max(dMaxSS,(dUnitSize > bb.getHeight()) ? 0 : (bb.getHeight() - dUnitSize) / 2);
    }
 else     if (iOrientation == HORIZONTAL) {
      dStartShift=Math.max(dMaxSS,(dUnitSize > bb.getWidth()) ? 0 : (bb.getWidth() - dUnitSize) / 2);
    }
    la.getCaption().setValue(formatCategoryValue(getType(),dsi.last(),iDateTimeUnit));
    try {
      bb=computeBox(xs,iLocation,la,0,dEnd);
    }
 catch (    UnexpectedInputException uiex) {
      throw new GenerationException(uiex);
    }
    if (iOrientation == VERTICAL) {
      dEndShift=Math.max(dMaxES,(dUnitSize > bb.getHeight()) ? 0 : (bb.getHeight() - dUnitSize) / 2);
    }
 else     if (iOrientation == HORIZONTAL) {
      dEndShift=Math.max(dMaxES,(dUnitSize > bb.getWidth()) ? 0 : (bb.getWidth() - dUnitSize) / 2);
    }
  }
 else   if ((iType & NUMERICAL) == NUMERICAL) {
    if ((iType & LINEAR) == LINEAR) {
      DecimalFormat df=null;
      if (fs == null) {
        df=new DecimalFormat(getNumericPattern());
      }
      String sValue=null;
      try {
        sValue=ValueFormatter.format(getMinimum(),fs,lcl,df);
      }
 catch (      DataFormatException dfex) {
        DefaultLoggerImpl.instance().log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      BoundingBox bb=null;
      try {
        bb=computeBox(xs,iLocation,la,0,0);
      }
 catch (      UnexpectedInputException uiex) {
        throw new GenerationException(uiex);
      }
      if (iOrientation == VERTICAL) {
        dStartShift=Math.max(dMaxSS,(bb.getHeight() - bb.getHotPoint()));
      }
 else       if (iOrientation == HORIZONTAL) {
        dStartShift=Math.max(dMaxSS,bb.getHotPoint());
      }
      try {
        sValue=ValueFormatter.format(getMaximum(),fs,lcl,df);
      }
 catch (      DataFormatException dfex) {
        DefaultLoggerImpl.instance().log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      try {
        bb=computeBox(xs,iLocation,la,0,0);
      }
 catch (      UnexpectedInputException uiex) {
        throw new GenerationException(uiex);
      }
      if (iOrientation == VERTICAL) {
        dEndShift=Math.max(dMaxES,bb.getHotPoint());
      }
 else       if (iOrientation == HORIZONTAL) {
        dEndShift=Math.max(dMaxES,(bb.getWidth() - bb.getHotPoint()));
      }
    }
 else     if ((iType & LOGARITHMIC) == LOGARITHMIC) {
      final double dMinimum=asDouble(getMinimum()).doubleValue();
      DecimalFormat df=null;
      if (fs == null) {
        df=new DecimalFormat(getNumericPattern(dMinimum));
      }
      String sValue=null;
      try {
        sValue=ValueFormatter.format(getMinimum(),fs,lcl,df);
      }
 catch (      DataFormatException dfex) {
        DefaultLoggerImpl.instance().log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      BoundingBox bb=null;
      try {
        bb=computeBox(xs,iLocation,la,0,0);
      }
 catch (      UnexpectedInputException uiex) {
        throw new GenerationException(uiex);
      }
      if (iOrientation == VERTICAL) {
        dStartShift=Math.max(dMaxSS,(bb.getHeight() - bb.getHotPoint()));
      }
 else       if (iOrientation == HORIZONTAL) {
        dStartShift=Math.max(dMaxSS,bb.getHotPoint());
      }
      final double dMaximum=asDouble(getMaximum()).doubleValue();
      if (fs == null) {
        df=new DecimalFormat(getNumericPattern(dMaximum));
      }
      try {
        sValue=ValueFormatter.format(getMaximum(),fs,lcl,df);
      }
 catch (      DataFormatException dfex) {
        DefaultLoggerImpl.instance().log(dfex);
        sValue=IConstants.NULL_STRING;
      }
      la.getCaption().setValue(sValue);
      try {
        bb=computeBox(xs,iLocation,la,0,0);
      }
 catch (      UnexpectedInputException uiex) {
        throw new GenerationException(uiex);
      }
      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(oUnit);
    SimpleDateFormat sdf=null;
    String sText=null;
    if (fs != null) {
      sdf=new SimpleDateFormat(CDateTime.getPreferredFormat(iUnit));
    }
    try {
      sText=ValueFormatter.format(cdt,fs,lcl,sdf);
    }
 catch (    DataFormatException dfex) {
      DefaultLoggerImpl.instance().log(dfex);
      sText=IConstants.NULL_STRING;
    }
    la.getCaption().setValue(sText);
    BoundingBox bb=null;
    try {
      bb=computeBox(xs,iLocation,la,0,0);
    }
 catch (    UnexpectedInputException uiex) {
      throw new GenerationException(uiex);
    }
    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,fs,lcl,sdf);
    }
 catch (    DataFormatException dfex) {
      DefaultLoggerImpl.instance().log(dfex);
      sText=IConstants.NULL_STRING;
    }
    la.getCaption().setValue(sText);
    try {
      bb=computeBox(xs,iLocation,la,0,dEnd);
    }
 catch (    UnexpectedInputException uiex) {
      throw new GenerationException(uiex);
    }
    if (iOrientation == VERTICAL) {
      dEndShift=Math.max(dMaxES,bb.getHotPoint());
    }
 else     if (iOrientation == HORIZONTAL) {
      dEndShift=Math.max(dMaxES,(bb.getWidth() - bb.getHotPoint()));
    }
  }
}