Program: 69325
Project: 69325
Buggy source:
/** 
 * @param dBlockX
 * @param dBlockWidth
 * @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 adjustHorizontalWithMaxOrigin(double dBlockX,double dBlockWidth,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.MIN_VALUE);
  }
  dX+=dAppliedYAxisPlotSpacing;
  dWTotal-=dAppliedYAxisPlotSpacing;
  dX1=dX;
  dX2=dX;
  if (bTicksRight && getTickSize() <= dWTotal) {
    dX2+=getTickSize();
    dWTotal-=getTickSize();
  }
 else {
  }
  double dW1=0, dW2=0;
  if (iYLabelLocation == RIGHT) {
    dW1=Math.max((bTicksLeft ? getTickSize() : 0) + dDecorationThickness[0],dAppliedYAxisPlotSpacing);
    dW2=Math.max(dYAxisLabelsThickness,dDecorationThickness[1]);
  }
 else   if (iYLabelLocation == LEFT) {
    dW1=Math.max((bTicksLeft ? getTickSize() : 0) + Math.max(dYAxisLabelsThickness,dDecorationThickness[0]),dAppliedYAxisPlotSpacing);
    dW2=dDecorationThickness[1];
  }
  if (dW1 + dW2 <= dWTotal) {
    dX1-=dW1;
    dX2+=dW2;
    dWTotal-=(dW1 + dW2);
  }
 else {
    axPV.setShowLabels(false);
  }
  if (iYTitleLocation == RIGHT) {
    dX2+=dYAxisTitleThickness;
  }
 else   if (iYTitleLocation == LEFT) {
    dX1-=dYAxisTitleThickness;
  }
  if (dX2 > dBlockX + dBlockWidth) {
    final double dDelta=dX2 - (dBlockX + dBlockWidth);
    dX2=dBlockX + dBlockWidth;
    dX-=dDelta;
    dX1-=dDelta;
  }
  final double dDeltaX1=dX - dX1;
  final double dDeltaX2=dX2 - dX;
  if (iYLabelLocation == LEFT) {
    dX1=(dX - dAppliedYAxisPlotSpacing);
  }
  double dYAxisThickness=dX2 - dX1;
  scX.computeAxisStartEndShifts(ids,laXAxisLabels,HORIZONTAL,iXLabelLocation,aax);
  boolean startEndChanged=false;
  if (scX.getDirection() == BACKWARD) {
    if (dYAxisThickness > scX.getStartShift()) {
      dStart=dX1;
      startEndChanged=true;
    }
 else {
      dStart=scX.getStart();
    }
    dEnd=scX.getEnd();
  }
 else {
    if (dYAxisThickness > scX.getEndShift()) {
      dEnd=dX1;
      startEndChanged=true;
    }
 else {
      dEnd=scX.getEnd();
    }
    dStart=scX.getStart();
  }
  scX.resetShifts();
  scX.setEndPoints(dStart,dEnd);
  if (scX.getDirection() == BACKWARD) {
    scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,!startEndChanged,true,aax);
  }
 else {
    scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,true,!startEndChanged,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,!startEndChanged,true,aax);
      }
 else {
        tickCount=scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,true,!startEndChanged,aax);
      }
      if (scX.getUnit() != null && asInteger(scX.getUnit()) == Calendar.YEAR && tickCount <= 3 || isSharedScale()) {
        break;
      }
    }
  }
  if (scX.getDirection() == BACKWARD) {
    if (dYAxisThickness < scX.getStartShift()) {
      dX=scX.getStart() - (dX1 - dX);
    }
  }
 else {
    if (dYAxisThickness < scX.getEndShift()) {
      dX=scX.getEnd() - (dX1 - dX);
    }
  }
  dX+=insCA.getRight();
  dX2=dX + dDeltaX2;
  dX1=dX - dDeltaX1;
  axPV.setTitleCoordinate((iYTitleLocation == LEFT) ? dX1 - 1 : dX2 + 1 - dYAxisTitleThickness);
  return dX;
}

Fixed version (ground truth):
/** 
 * @param dBlockX
 * @param dBlockWidth
 * @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 adjustHorizontalWithMaxOrigin(double dBlockX,double dBlockWidth,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.MIN_VALUE);
  }
  dX+=dAppliedYAxisPlotSpacing;
  dWTotal-=dAppliedYAxisPlotSpacing;
  dX1=dX;
  dX2=dX;
  if (bTicksRight && getTickSize() <= dWTotal) {
    dX2+=getTickSize();
    dWTotal-=getTickSize();
  }
 else {
  }
  double dW1=0, dW2=0;
  if (iYLabelLocation == RIGHT) {
    dW1=Math.max((bTicksLeft ? getTickSize() : 0) + dDecorationThickness[0],dAppliedYAxisPlotSpacing);
    dW2=Math.max(dYAxisLabelsThickness,dDecorationThickness[1]);
  }
 else   if (iYLabelLocation == LEFT) {
    dW1=Math.max((bTicksLeft ? getTickSize() : 0) + Math.max(dYAxisLabelsThickness,dDecorationThickness[0]),dAppliedYAxisPlotSpacing);
    dW2=dDecorationThickness[1];
  }
  if (dW1 + dW2 <= dWTotal) {
    dX1-=dW1;
    dX2+=dW2;
  }
 else {
    axPV.setShowLabels(false);
  }
  if (iYTitleLocation == RIGHT) {
    dX2+=dYAxisTitleThickness;
  }
 else   if (iYTitleLocation == LEFT) {
    dX1-=dYAxisTitleThickness;
  }
  if (dX2 > dBlockX + dBlockWidth) {
    final double dDelta=dX2 - (dBlockX + dBlockWidth);
    dX2=dBlockX + dBlockWidth;
    dX-=dDelta;
    dX1-=dDelta;
  }
  final double dDeltaX1=dX - dX1;
  final double dDeltaX2=dX2 - dX;
  if (iYLabelLocation == LEFT) {
    dX1=(dX - dAppliedYAxisPlotSpacing);
  }
  double dYAxisThickness=dX2 - dX1;
  scX.computeAxisStartEndShifts(ids,laXAxisLabels,HORIZONTAL,iXLabelLocation,aax);
  boolean startEndChanged=false;
  if (scX.getDirection() == BACKWARD) {
    if (dYAxisThickness > scX.getStartShift()) {
      dStart=dX1;
      startEndChanged=true;
    }
 else {
      dStart=scX.getStart();
    }
    dEnd=scX.getEnd();
  }
 else {
    if (dYAxisThickness > scX.getEndShift()) {
      dEnd=dX1;
      startEndChanged=true;
    }
 else {
      dEnd=scX.getEnd();
    }
    dStart=scX.getStart();
  }
  scX.resetShifts();
  scX.setEndPoints(dStart,dEnd);
  if (scX.getDirection() == BACKWARD) {
    scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,!startEndChanged,true,aax);
  }
 else {
    scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,true,!startEndChanged,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,!startEndChanged,true,aax);
      }
 else {
        tickCount=scX.computeTicks(ids,laXAxisLabels,iXLabelLocation,HORIZONTAL,dStart,dEnd,true,!startEndChanged,aax);
      }
      if (scX.getUnit() != null && asInteger(scX.getUnit()) == Calendar.YEAR && tickCount <= 3 || isSharedScale()) {
        break;
      }
    }
  }
  if (scX.getDirection() == BACKWARD) {
    if (dYAxisThickness < scX.getStartShift()) {
      dX=scX.getStart() - (dX1 - dX);
    }
  }
 else {
    if (dYAxisThickness < scX.getEndShift()) {
      dX=scX.getEnd() - (dX1 - dX);
    }
  }
  dX+=insCA.getRight();
  dX2=dX + dDeltaX2;
  dX1=dX - dDeltaX1;
  axPV.setTitleCoordinate((iYTitleLocation == LEFT) ? dX1 - 1 : dX2 + 1 - dYAxisTitleThickness);
  return dX;
}