Program: 69324
Project: 69324
Buggy source:
/** 
 * @param dBlockX
 * @param aax
 * @param axPV
 * @param scX
 * @param iXLabelLocation
 * @param iYLabelLocation
 * @param iYTitleLocation
 * @param laXAxisLabels
 * @param bTicksLeft
 * @param bTicksRight
 * @param dAppliedYAxisPlotSpacing
 * @param dYAxisLabelsThickness
 * @param dDecorationThickness
 * @param dYAxisTitleThickness
 * @param dX
 * @param dWTotal
 * @return
 * @throws ChartException
 */
private double adjustHorizontalWithOrigin(double dBlockX,AllAxes aax,final OneAxis axPV,final AutoScale scX,final int iXLabelLocation,final int iYLabelLocation,final int iYTitleLocation,final Label laXAxisLabels,final boolean bTicksLeft,final boolean bTicksRight,final double dAppliedYAxisPlotSpacing,double dYAxisLabelsThickness,double[] dDecorationThickness,double dYAxisTitleThickness,double dX,double dWTotal) throws ChartException {
  double dStart;
  double dEnd;
  double dX1;
  double dX2;
  if (scX.getDirection() == BACKWARD) {
    dX=getLocation(scX,IntersectionValue.MAX_VALUE);
  }
  dX-=dAppliedYAxisPlotSpacing;
  dX1=dX;
  dX2=dX;
  double dTickSize=getTickSize();
  if (bTicksLeft && dTickSize <= dWTotal) {
    dX1-=getTickSize();
    dWTotal-=dTickSize;
  }
 else {
    dTickSize=0;
  }
  double dW1=0, dW2=0;
  if (iYLabelLocation == LEFT) {
    dW1=Math.max(dYAxisLabelsThickness,dDecorationThickness[0]);
    dW2=Math.max(bTicksRight ? getTickSize() : 0,dAppliedYAxisPlotSpacing);
  }
 else   if (iYLabelLocation == RIGHT) {
    dW1=dDecorationThickness[0];
    dW2=Math.max((bTicksRight ? getTickSize() : 0) + dYAxisLabelsThickness,dAppliedYAxisPlotSpacing);
  }
  if (dW1 + dW2 <= dWTotal) {
    dX1-=dW1;
    dX2+=dW2;
    dWTotal-=(dW1 + dW2);
  }
 else {
    axPV.setShowLabels(false);
  }
  if (iYTitleLocation == LEFT) {
    dX1-=dYAxisTitleThickness;
  }
 else   if (iYTitleLocation == RIGHT) {
    dX2+=dYAxisTitleThickness;
  }
  if (dX1 < dBlockX) {
    final double dDelta=(dBlockX - dX1);
    dX1=dBlockX;
    dX+=dDelta;
    dX2+=dDelta;
  }
  final double dDeltaX1=dX - dX1;
  final double dDeltaX2=dX2 - dX;
  if (iYLabelLocation == RIGHT) {
    dX2=(dX + dAppliedYAxisPlotSpacing);
  }
  double dYAxisThickness=dX2 - dX1;
  scX.computeAxisStartEndShifts(ids,laXAxisLabels,HORIZONTAL,iXLabelLocation,aax);
  boolean startEndChanged=false;
  if (scX.getDirection() == BACKWARD) {
    if (dYAxisThickness > scX.getEndShift()) {
      dEnd=dX2;
      startEndChanged=true;
    }
 else {
      dEnd=scX.getEnd();
    }
    dStart=scX.getStart();
  }
 else {
    if (dYAxisThickness > scX.getStartShift()) {
      dStart=dX2;
      startEndChanged=true;
    }
 else {
      dStart=scX.getStart();
    }
    dEnd=scX.getEnd();
  }
  scX.resetShifts();
  scX.setEndPoints(dStart,dEnd);
  if (scX.getDirection() == BACKWARD) {
    scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,true,!startEndChanged,aax);
  }
 else {
    scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,!startEndChanged,true,aax);
  }
  if (!scX.isStepFixed()) {
    final Object[] oaMinMax=scX.getMinMax();
    while (!scX.checkFit(ids,laXAxisLabels,iXLabelLocation)) {
      if (!scX.zoomOut()) {
        break;
      }
      scX.updateAxisMinMax(oaMinMax[0],oaMinMax[1]);
      int tickCount;
      if (scX.getDirection() == BACKWARD) {
        tickCount=scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,true,!startEndChanged,aax);
      }
 else {
        tickCount=scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,!startEndChanged,true,aax);
      }
      if (scX.getUnit() != null && asInteger(scX.getUnit()) == Calendar.YEAR && tickCount <= 3 || isSharedScale()) {
        break;
      }
    }
  }
  if (scX.getDirection() == BACKWARD) {
    if (dYAxisThickness < scX.getEndShift()) {
      dX=scX.getEnd() - (dX2 - dX);
    }
  }
 else {
    if (dYAxisThickness < scX.getStartShift()) {
      dX=scX.getStart() - (dX2 - dX);
    }
  }
  dX-=insCA.getLeft();
  dX2=dX + dDeltaX2;
  dX1=dX - dDeltaX1;
  axPV.setTitleCoordinate((iYTitleLocation == LEFT) ? dX1 - 1 : dX2 + 1 - dYAxisTitleThickness);
  return dX;
}

Fixed version (ground truth):
/** 
 * @param dBlockX
 * @param aax
 * @param axPV
 * @param scX
 * @param iXLabelLocation
 * @param iYLabelLocation
 * @param iYTitleLocation
 * @param laXAxisLabels
 * @param bTicksLeft
 * @param bTicksRight
 * @param dAppliedYAxisPlotSpacing
 * @param dYAxisLabelsThickness
 * @param dDecorationThickness
 * @param dYAxisTitleThickness
 * @param dX
 * @param dWTotal
 * @return
 * @throws ChartException
 */
private double adjustHorizontalWithOrigin(double dBlockX,AllAxes aax,final OneAxis axPV,final AutoScale scX,final int iXLabelLocation,final int iYLabelLocation,final int iYTitleLocation,final Label laXAxisLabels,final boolean bTicksLeft,final boolean bTicksRight,final double dAppliedYAxisPlotSpacing,double dYAxisLabelsThickness,double[] dDecorationThickness,double dYAxisTitleThickness,double dX,double dWTotal) throws ChartException {
  double dStart;
  double dEnd;
  double dX1;
  double dX2;
  if (scX.getDirection() == BACKWARD) {
    dX=getLocation(scX,IntersectionValue.MAX_VALUE);
  }
  dX-=dAppliedYAxisPlotSpacing;
  dX1=dX;
  dX2=dX;
  double dTickSize=getTickSize();
  if (bTicksLeft && dTickSize <= dWTotal) {
    dX1-=getTickSize();
    dWTotal-=dTickSize;
  }
 else {
    dTickSize=0;
  }
  double dW1=0, dW2=0;
  if (iYLabelLocation == LEFT) {
    dW1=Math.max(dYAxisLabelsThickness,dDecorationThickness[0]);
    dW2=Math.max(bTicksRight ? getTickSize() : 0,dAppliedYAxisPlotSpacing);
  }
 else   if (iYLabelLocation == RIGHT) {
    dW1=dDecorationThickness[0];
    dW2=Math.max((bTicksRight ? getTickSize() : 0) + dYAxisLabelsThickness,dAppliedYAxisPlotSpacing);
  }
  if (dW1 + dW2 <= dWTotal) {
    dX1-=dW1;
    dX2+=dW2;
  }
 else {
    axPV.setShowLabels(false);
  }
  if (iYTitleLocation == LEFT) {
    dX1-=dYAxisTitleThickness;
  }
 else   if (iYTitleLocation == RIGHT) {
    dX2+=dYAxisTitleThickness;
  }
  if (dX1 < dBlockX) {
    final double dDelta=(dBlockX - dX1);
    dX1=dBlockX;
    dX+=dDelta;
    dX2+=dDelta;
  }
  final double dDeltaX1=dX - dX1;
  final double dDeltaX2=dX2 - dX;
  if (iYLabelLocation == RIGHT) {
    dX2=(dX + dAppliedYAxisPlotSpacing);
  }
  double dYAxisThickness=dX2 - dX1;
  scX.computeAxisStartEndShifts(ids,laXAxisLabels,HORIZONTAL,iXLabelLocation,aax);
  boolean startEndChanged=false;
  if (scX.getDirection() == BACKWARD) {
    if (dYAxisThickness > scX.getEndShift()) {
      dEnd=dX2;
      startEndChanged=true;
    }
 else {
      dEnd=scX.getEnd();
    }
    dStart=scX.getStart();
  }
 else {
    if (dYAxisThickness > scX.getStartShift()) {
      dStart=dX2;
      startEndChanged=true;
    }
 else {
      dStart=scX.getStart();
    }
    dEnd=scX.getEnd();
  }
  scX.resetShifts();
  scX.setEndPoints(dStart,dEnd);
  if (scX.getDirection() == BACKWARD) {
    scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,true,!startEndChanged,aax);
  }
 else {
    scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,!startEndChanged,true,aax);
  }
  if (!scX.isStepFixed()) {
    final Object[] oaMinMax=scX.getMinMax();
    while (!scX.checkFit(ids,laXAxisLabels,iXLabelLocation)) {
      if (!scX.zoomOut()) {
        break;
      }
      scX.updateAxisMinMax(oaMinMax[0],oaMinMax[1]);
      int tickCount;
      if (scX.getDirection() == BACKWARD) {
        tickCount=scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,true,!startEndChanged,aax);
      }
 else {
        tickCount=scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,!startEndChanged,true,aax);
      }
      if (scX.getUnit() != null && asInteger(scX.getUnit()) == Calendar.YEAR && tickCount <= 3 || isSharedScale()) {
        break;
      }
    }
  }
  if (scX.getDirection() == BACKWARD) {
    if (dYAxisThickness < scX.getEndShift()) {
      dX=scX.getEnd() - (dX2 - dX);
    }
  }
 else {
    if (dYAxisThickness < scX.getStartShift()) {
      dX=scX.getStart() - (dX2 - dX);
    }
  }
  dX-=insCA.getLeft();
  dX2=dX + dDeltaX2;
  dX1=dX - dDeltaX1;
  axPV.setTitleCoordinate((iYTitleLocation == LEFT) ? dX1 - 1 : dX2 + 1 - dYAxisTitleThickness);
  return dX;
}