Program: 71362
Project: 71362
Buggy source:
/** 
 * This method computes the entire chart within the given bounds. If the dataset has changed but none of the axis attributes have changed, simply re-compute without 'rebuilding axes'.
 * @param bo
 */
public final void compute(Bounds bo) throws ChartException, IllegalArgumentException {
  bo=bo.scaledInstance(dPointToPixel);
  dSeriesThickness=(ids.getDpiResolution() / 72d) * cwa.getSeriesThickness();
  dSeriesThickness=cwa.getPlot().getClientArea().isVisible() ? dSeriesThickness : 0;
  double dX=bo.getLeft() + insCA.getLeft();
  double dY=bo.getTop() + insCA.getTop();
  double dW=bo.getWidth() - insCA.getLeft() - insCA.getRight();
  double dH=bo.getHeight() - insCA.getTop() - insCA.getBottom();
  iDimension=getDimension(cwa.getDimension());
  dXAxisPlotSpacing=cwa.getPlot().getHorizontalSpacing() * dPointToPixel;
  dYAxisPlotSpacing=cwa.getPlot().getVerticalSpacing() * dPointToPixel;
  if (iDimension == TWO_5_D) {
    dY+=dSeriesThickness;
    dH-=dSeriesThickness;
    dW-=dSeriesThickness;
    bo.setHeight(dH);
    bo.setTop(dY);
    bo.setWidth(dW);
  }
  if (aax.getOverlayCount() > 0) {
    if (aax.areAxesSwapped()) {
      updateOverlayScales(aax,dX,dX + dW,dY,dH);
      dY=aax.getStart();
      dH=aax.getLength();
    }
 else {
      updateOverlayScales(aax,dY - dH,dY,dX,dW);
      dX=aax.getStart();
      dW=aax.getLength();
    }
  }
  double dStart, dEnd;
  final Axis[] axa=cwa.getPrimaryBaseAxes();
  final Axis axPrimaryBase=axa[0];
  final Axis axPrimaryOrthogonal=cwa.getPrimaryOrthogonalAxis(axPrimaryBase);
  Scale sc=axPrimaryBase.getScale();
  AutoScale scPrimaryBase=null;
  OneAxis oaxPrimaryBase=aax.getPrimaryBase();
  int iAxisType=getAxisType(axPrimaryBase);
  Object oaData=null;
  if (iAxisType == TEXT || oaxPrimaryBase.isCategoryScale()) {
    oaData=getTypedDataSet(axPrimaryBase,iAxisType,0);
  }
 else   if ((iAxisType & NUMERICAL) == NUMERICAL) {
    oaData=getMinMax(axPrimaryBase,iAxisType);
  }
 else   if ((iAxisType & DATE_TIME) == DATE_TIME) {
    oaData=getMinMax(axPrimaryBase,iAxisType);
  }
  DataSetIterator dsi=(oaData instanceof DataSetIterator) ? (DataSetIterator)oaData : new DataSetIterator(oaData,iAxisType);
  oaData=null;
  dStart=(aax.areAxesSwapped()) ? dY + dH : dX;
  dEnd=(aax.areAxesSwapped()) ? dY : dStart + dW;
  int iDirection=AUTO;
  scPrimaryBase=AutoScale.computeScale(ids,oaxPrimaryBase,dsi,iAxisType,dStart,dEnd,sc,axPrimaryBase.getFormatSpecifier(),rtc,iDirection,1,iMarginPercent);
  oaxPrimaryBase.set(scPrimaryBase);
  AutoScale scPrimaryOrthogonal=null;
  OneAxis oaxPrimaryOrthogonal=aax.getPrimaryOrthogonal();
  iAxisType=getAxisType(axPrimaryOrthogonal);
  oaData=null;
  if ((iAxisType & NUMERICAL) == NUMERICAL || (iAxisType & DATE_TIME) == DATE_TIME) {
    dsi=new DataSetIterator(getMinMax(axPrimaryOrthogonal,iAxisType),iAxisType);
    dsi.reverse(cwa.isReverseCategory());
  }
 else {
    throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_FORMAT,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
  }
  dStart=(aax.areAxesSwapped()) ? dX : dY + dH;
  dEnd=(aax.areAxesSwapped()) ? dX + dW : dY;
  sc=axPrimaryOrthogonal.getScale();
  scPrimaryOrthogonal=AutoScale.computeScale(ids,oaxPrimaryOrthogonal,dsi,iAxisType,dStart,dEnd,sc,oaxPrimaryBase.getModelAxis().getOrigin(),axPrimaryOrthogonal.getFormatSpecifier(),rtc,AUTO,1,iMarginPercent);
  oaxPrimaryOrthogonal.set(scPrimaryOrthogonal);
  double dYAxisLocation=adjustHorizontal(dX,dW,aax);
  double dXAxisLocation=adjustVerticalDueToHorizontal(dY,dH,aax);
  iAxisType=getAxisType(axPrimaryOrthogonal);
  oaData=getTypedDataSet(axPrimaryOrthogonal,iAxisType,0);
  scPrimaryOrthogonal.setData(dsi);
  iAxisType=getAxisType(axPrimaryBase);
  if (iAxisType != IConstants.TEXT) {
    scPrimaryBase.setData(getTypedDataSet(axPrimaryBase,iAxisType,0));
  }
  scPrimaryBase.resetShifts();
  scPrimaryOrthogonal.resetShifts();
  updateOverlayAxes(aax);
  growBaseAxis(aax,BoundsImpl.create(dX,dY,dW,dH));
  final OneAxis axPH=aax.areAxesSwapped() ? aax.getPrimaryOrthogonal() : aax.getPrimaryBase();
  final OneAxis axPV=aax.areAxesSwapped() ? aax.getPrimaryBase() : aax.getPrimaryOrthogonal();
  axPH.setAxisCoordinate(dXAxisLocation);
  axPV.setAxisCoordinate(dYAxisLocation);
  double[] daX=axPH.getScale().getEndPoints();
  double[] daY=axPV.getScale().getEndPoints();
  if (axPH.getScale().getDirection() == BACKWARD) {
    boPlotBackground.setLeft(daX[1] - insCA.getLeft());
    boPlotBackground.setWidth(daX[0] - daX[1] + insCA.getLeft() + insCA.getRight() + 1);
  }
 else {
    boPlotBackground.setLeft(daX[0] - insCA.getLeft());
    boPlotBackground.setWidth(daX[1] - daX[0] + insCA.getLeft() + insCA.getRight() + 1);
  }
  if (axPV.getScale().getDirection() == FORWARD) {
    boPlotBackground.setTop(daY[0] - insCA.getTop());
    boPlotBackground.setHeight(daY[1] - daY[0] + insCA.getTop() + insCA.getBottom() + 1);
  }
 else {
    boPlotBackground.setTop(daY[1] - insCA.getTop());
    boPlotBackground.setHeight(daY[0] - daY[1] + insCA.getTop() + insCA.getBottom() + 1);
  }
  if (iDimension == TWO_5_D) {
    boPlotBackground.delta(dSeriesThickness,-dSeriesThickness,0,0);
  }
  boPlotWithMargin=BoundsImpl.copyInstance(boPlotBackground);
  if (iMarginPercent > 0) {
    AutoScale scale=axPH.getScale();
    if (scale.getMaxWithMargin() != null || scale.getMinWithMargin() != null) {
      if ((scale.getType() & LINEAR) == LINEAR) {
        double factor=Math.abs(daX[1] - daX[0]) / (asDouble(scale.getMaximum()).doubleValue() - asDouble(scale.getMinimum()).doubleValue());
        if (scale.getMinWithMargin() != null) {
          boPlotWithMargin.setLeft(boPlotWithMargin.getLeft() - factor * (asDouble(scale.getMinimum()).doubleValue() - asDouble(scale.getMinWithMargin()).doubleValue()));
        }
        boPlotWithMargin.setWidth(factor * (asDouble(scale.getMaxWithMargin() == null ? scale.getMaximum() : scale.getMaxWithMargin()).doubleValue() - asDouble(scale.getMinWithMargin() == null ? scale.getMinimum() : scale.getMinWithMargin()).doubleValue()) + insCA.getLeft() + insCA.getRight() + 1);
      }
    }
    scale=axPV.getScale();
    if (scale.getMaxWithMargin() != null || scale.getMinWithMargin() != null) {
      if ((scale.getType() & LINEAR) == LINEAR) {
        double factor=Math.abs(daX[1] - daX[0]) / (asDouble(scale.getMaximum()).doubleValue() - asDouble(scale.getMinimum()).doubleValue());
        if (scale.getMaxWithMargin() != null) {
          boPlotWithMargin.setTop(boPlotWithMargin.getTop() - factor * (asDouble(scale.getMaxWithMargin()).doubleValue() - asDouble(scale.getMaximum()).doubleValue()));
        }
        boPlotWithMargin.setHeight(factor * (asDouble(scale.getMaxWithMargin() == null ? scale.getMaximum() : scale.getMaxWithMargin()).doubleValue() - asDouble(scale.getMinWithMargin() == null ? scale.getMinimum() : scale.getMinWithMargin()).doubleValue()) + insCA.getTop() + insCA.getBottom() + 1);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * This method computes the entire chart within the given bounds. If the dataset has changed but none of the axis attributes have changed, simply re-compute without 'rebuilding axes'.
 * @param bo
 */
public final void compute(Bounds bo) throws ChartException, IllegalArgumentException {
  bo=bo.scaledInstance(dPointToPixel);
  dSeriesThickness=(ids.getDpiResolution() / 72d) * cwa.getSeriesThickness();
  dSeriesThickness=cwa.getPlot().getClientArea().isVisible() ? dSeriesThickness : 0;
  double dX=bo.getLeft() + insCA.getLeft();
  double dY=bo.getTop() + insCA.getTop();
  double dW=bo.getWidth() - insCA.getLeft() - insCA.getRight();
  double dH=bo.getHeight() - insCA.getTop() - insCA.getBottom();
  iDimension=getDimension(cwa.getDimension());
  dXAxisPlotSpacing=cwa.getPlot().getHorizontalSpacing() * dPointToPixel;
  dYAxisPlotSpacing=cwa.getPlot().getVerticalSpacing() * dPointToPixel;
  if (iDimension == TWO_5_D) {
    dY+=dSeriesThickness;
    dH-=dSeriesThickness;
    dW-=dSeriesThickness;
    bo.setHeight(dH);
    bo.setTop(dY);
    bo.setWidth(dW);
  }
  if (aax.getOverlayCount() > 0) {
    if (aax.areAxesSwapped()) {
      updateOverlayScales(aax,dX,dX + dW,dY,dH);
      dY=aax.getStart();
      dH=aax.getLength();
    }
 else {
      updateOverlayScales(aax,dY - dH,dY,dX,dW);
      dX=aax.getStart();
      dW=aax.getLength();
    }
  }
  double dStart, dEnd;
  final Axis[] axa=cwa.getPrimaryBaseAxes();
  final Axis axPrimaryBase=axa[0];
  final Axis axPrimaryOrthogonal=cwa.getPrimaryOrthogonalAxis(axPrimaryBase);
  Scale sc=axPrimaryBase.getScale();
  AutoScale scPrimaryBase=null;
  OneAxis oaxPrimaryBase=aax.getPrimaryBase();
  int iAxisType=getAxisType(axPrimaryBase);
  Object oaData=null;
  if (iAxisType == TEXT || oaxPrimaryBase.isCategoryScale()) {
    oaData=getTypedDataSet(axPrimaryBase,iAxisType,0);
  }
 else   if ((iAxisType & NUMERICAL) == NUMERICAL) {
    oaData=getMinMax(axPrimaryBase,iAxisType);
  }
 else   if ((iAxisType & DATE_TIME) == DATE_TIME) {
    oaData=getMinMax(axPrimaryBase,iAxisType);
  }
  DataSetIterator dsi=(oaData instanceof DataSetIterator) ? (DataSetIterator)oaData : new DataSetIterator(oaData,iAxisType);
  oaData=null;
  dStart=(aax.areAxesSwapped()) ? dY + dH : dX;
  dEnd=(aax.areAxesSwapped()) ? dY : dStart + dW;
  int iDirection=AUTO;
  scPrimaryBase=AutoScale.computeScale(ids,oaxPrimaryBase,dsi,iAxisType,dStart,dEnd,sc,axPrimaryBase.getFormatSpecifier(),rtc,iDirection,1,iMarginPercent);
  oaxPrimaryBase.set(scPrimaryBase);
  AutoScale scPrimaryOrthogonal=null;
  OneAxis oaxPrimaryOrthogonal=aax.getPrimaryOrthogonal();
  iAxisType=getAxisType(axPrimaryOrthogonal);
  oaData=null;
  if ((iAxisType & NUMERICAL) == NUMERICAL || (iAxisType & DATE_TIME) == DATE_TIME) {
    if (rtc.getScale() != null && rtc.getState(AutoScale.KEY_SHARED_MINMAX) != null) {
      dsi=new DataSetIterator(rtc.getState(AutoScale.KEY_SHARED_MINMAX),iAxisType);
    }
 else {
      dsi=new DataSetIterator(getMinMax(axPrimaryOrthogonal,iAxisType),iAxisType);
    }
    dsi.reverse(cwa.isReverseCategory());
  }
 else {
    throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_FORMAT,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
  }
  dStart=(aax.areAxesSwapped()) ? dX : dY + dH;
  dEnd=(aax.areAxesSwapped()) ? dX + dW : dY;
  sc=axPrimaryOrthogonal.getScale();
  scPrimaryOrthogonal=AutoScale.computeScale(ids,oaxPrimaryOrthogonal,dsi,iAxisType,dStart,dEnd,sc,oaxPrimaryBase.getModelAxis().getOrigin(),axPrimaryOrthogonal.getFormatSpecifier(),rtc,AUTO,1,iMarginPercent);
  oaxPrimaryOrthogonal.set(scPrimaryOrthogonal);
  double dYAxisLocation=adjustHorizontal(dX,dW,aax);
  double dXAxisLocation=adjustVerticalDueToHorizontal(dY,dH,aax);
  iAxisType=getAxisType(axPrimaryOrthogonal);
  oaData=getTypedDataSet(axPrimaryOrthogonal,iAxisType,0);
  scPrimaryOrthogonal.setData(dsi);
  iAxisType=getAxisType(axPrimaryBase);
  if (iAxisType != IConstants.TEXT) {
    scPrimaryBase.setData(getTypedDataSet(axPrimaryBase,iAxisType,0));
  }
  scPrimaryBase.resetShifts();
  scPrimaryOrthogonal.resetShifts();
  updateOverlayAxes(aax);
  growBaseAxis(aax,BoundsImpl.create(dX,dY,dW,dH));
  final OneAxis axPH=aax.areAxesSwapped() ? aax.getPrimaryOrthogonal() : aax.getPrimaryBase();
  final OneAxis axPV=aax.areAxesSwapped() ? aax.getPrimaryBase() : aax.getPrimaryOrthogonal();
  axPH.setAxisCoordinate(dXAxisLocation);
  axPV.setAxisCoordinate(dYAxisLocation);
  double[] daX=axPH.getScale().getEndPoints();
  double[] daY=axPV.getScale().getEndPoints();
  if (axPH.getScale().getDirection() == BACKWARD) {
    boPlotBackground.setLeft(daX[1] - insCA.getLeft());
    boPlotBackground.setWidth(daX[0] - daX[1] + insCA.getLeft() + insCA.getRight() + 1);
  }
 else {
    boPlotBackground.setLeft(daX[0] - insCA.getLeft());
    boPlotBackground.setWidth(daX[1] - daX[0] + insCA.getLeft() + insCA.getRight() + 1);
  }
  if (axPV.getScale().getDirection() == FORWARD) {
    boPlotBackground.setTop(daY[0] - insCA.getTop());
    boPlotBackground.setHeight(daY[1] - daY[0] + insCA.getTop() + insCA.getBottom() + 1);
  }
 else {
    boPlotBackground.setTop(daY[1] - insCA.getTop());
    boPlotBackground.setHeight(daY[0] - daY[1] + insCA.getTop() + insCA.getBottom() + 1);
  }
  if (iDimension == TWO_5_D) {
    boPlotBackground.delta(dSeriesThickness,-dSeriesThickness,0,0);
  }
  boPlotWithMargin=BoundsImpl.copyInstance(boPlotBackground);
  if (iMarginPercent > 0) {
    AutoScale scale=axPH.getScale();
    if (scale.getMaxWithMargin() != null || scale.getMinWithMargin() != null) {
      if ((scale.getType() & LINEAR) == LINEAR) {
        double factor=Math.abs(daX[1] - daX[0]) / (asDouble(scale.getMaximum()).doubleValue() - asDouble(scale.getMinimum()).doubleValue());
        if (scale.getMinWithMargin() != null) {
          boPlotWithMargin.setLeft(boPlotWithMargin.getLeft() - factor * (asDouble(scale.getMinimum()).doubleValue() - asDouble(scale.getMinWithMargin()).doubleValue()));
        }
        boPlotWithMargin.setWidth(factor * (asDouble(scale.getMaxWithMargin() == null ? scale.getMaximum() : scale.getMaxWithMargin()).doubleValue() - asDouble(scale.getMinWithMargin() == null ? scale.getMinimum() : scale.getMinWithMargin()).doubleValue()) + insCA.getLeft() + insCA.getRight() + 1);
      }
    }
    scale=axPV.getScale();
    if (scale.getMaxWithMargin() != null || scale.getMinWithMargin() != null) {
      if ((scale.getType() & LINEAR) == LINEAR) {
        double factor=Math.abs(daX[1] - daX[0]) / (asDouble(scale.getMaximum()).doubleValue() - asDouble(scale.getMinimum()).doubleValue());
        if (scale.getMaxWithMargin() != null) {
          boPlotWithMargin.setTop(boPlotWithMargin.getTop() - factor * (asDouble(scale.getMaxWithMargin()).doubleValue() - asDouble(scale.getMaximum()).doubleValue()));
        }
        boPlotWithMargin.setHeight(factor * (asDouble(scale.getMaxWithMargin() == null ? scale.getMaximum() : scale.getMaxWithMargin()).doubleValue() - asDouble(scale.getMinWithMargin() == null ? scale.getMinimum() : scale.getMinWithMargin()).doubleValue()) + insCA.getTop() + insCA.getBottom() + 1);
      }
    }
  }
}