Program: 69326
Project: 69326
Buggy source:
/** 
 * @param dBlockY
 * @param dBlockHeight
 * @param aax
 * @param axPH
 * @param scY
 * @param iXLabelLocation
 * @param iYLabelLocation
 * @param iXTitleLocation
 * @param laYAxisLabels
 * @param dXAxisLabelsThickness
 * @param dDecorationThickness
 * @param dXAxisTitleThickness
 * @param dHTotal
 * @param dY
 * @param bTicksAbove
 * @param bTicksBelow
 * @param dAppliedXAxisPlotSpacing
 * @param bForwardScale
 * @return
 * @throws ChartException
 */
private double adjustVerticalWithMaxOrigin(double dBlockY,double dBlockHeight,AllAxes aax,final OneAxis axPH,final AutoScale scY,final int iXLabelLocation,final int iYLabelLocation,final int iXTitleLocation,final Label laYAxisLabels,double dXAxisLabelsThickness,double[] dDecorationThickness,double dXAxisTitleThickness,double dHTotal,double dY,final boolean bTicksAbove,final boolean bTicksBelow,final double dAppliedXAxisPlotSpacing,final boolean bForwardScale) throws ChartException {
  double dY1;
  double dY2;
  dY+=dAppliedXAxisPlotSpacing;
  dHTotal-=dAppliedXAxisPlotSpacing;
  dY1=dY;
  dY2=dY;
  double dTickSize=getTickSize();
  if (bTicksBelow && dTickSize < dHTotal) {
    dY2+=dTickSize;
    dHTotal-=dTickSize;
  }
 else {
    dTickSize=0;
  }
  if (iXLabelLocation == ABOVE) {
    double dXLabelHeight=Math.max((bTicksAbove ? dTickSize : 0) + dXAxisLabelsThickness,dAppliedXAxisPlotSpacing);
    if (dXLabelHeight + dDecorationThickness[1] < dHTotal) {
      dY1-=dXLabelHeight;
      dY2+=dDecorationThickness[1];
      dHTotal-=(dXLabelHeight + dDecorationThickness[1]);
    }
 else {
      dXLabelHeight=0;
      axPH.setShowLabels(false);
    }
  }
 else   if (iXLabelLocation == BELOW) {
    double dXLabelHeight=Math.max(dXAxisLabelsThickness,dDecorationThickness[1]);
    double dHt1=Math.max(bTicksAbove ? dTickSize : 0,dAppliedXAxisPlotSpacing);
    if (dXLabelHeight + dHt1 <= dHTotal) {
      dY2+=dXLabelHeight;
      dY1-=dHt1;
      dHTotal-=(dXLabelHeight + dHt1);
    }
 else {
      dXLabelHeight=0;
      axPH.setShowLabels(false);
    }
  }
  if (iXTitleLocation == ABOVE) {
    dY1-=dXAxisTitleThickness;
  }
 else   if (iXTitleLocation == BELOW) {
    dY2+=dXAxisTitleThickness;
  }
  if (dY2 > dBlockY + dBlockHeight) {
    final double dDelta=(dY2 - (dBlockY + dBlockHeight));
    dY2=dBlockY + dBlockHeight;
    dY-=dDelta;
    dY1-=dDelta;
  }
  double dDeltaY1=dY - dY1;
  double dDeltaY2=dY2 - dY;
  double dXAxisThickness=0;
  if (iXLabelLocation == ABOVE) {
    dY1=(dY - dAppliedXAxisPlotSpacing);
    dXAxisThickness=dY2 - dY1;
  }
 else   if (iXLabelLocation == BELOW) {
    dXAxisThickness=dY2 - dY1;
  }
  if ((bForwardScale && dXAxisThickness > scY.getEndShift()) || (!bForwardScale && dXAxisThickness > scY.getStartShift())) {
    double dStart=dY1 + scY.getStartShift(), dEnd=scY.getEnd();
    if (bForwardScale) {
      dStart=scY.getStart();
      dEnd=dY1 + scY.getEndShift();
    }
    scY.resetShifts();
    if (dStart < dEnd + 1) {
      dStart=dEnd + 1;
    }
    scY.setEndPoints(dStart,dEnd);
    scY.computeTicks(ids,laYAxisLabels,iYLabelLocation,VERTICAL,dStart,dEnd,true,aax);
    if (!scY.isStepFixed()) {
      final Object[] oaMinMax=scY.getMinMax();
      while (!scY.checkFit(ids,laYAxisLabels,iYLabelLocation)) {
        if (!scY.zoomOut()) {
          break;
        }
        double dOldStep=((Number)scY.getStep()).doubleValue();
        scY.updateAxisMinMax(oaMinMax[0],oaMinMax[1]);
        int tickCount=scY.computeTicks(ids,laYAxisLabels,iYLabelLocation,VERTICAL,dStart,dEnd,true,aax);
        double dNewStep=((Number)scY.getStep()).doubleValue();
        if (dNewStep < dOldStep) {
          break;
        }
        if (scY.getUnit() != null && asInteger(scY.getUnit()) == Calendar.YEAR && tickCount <= 3 || isSharedScale()) {
          break;
        }
      }
    }
  }
  dY+=insCA.getBottom();
  dY1=dY - dDeltaY1;
  dY2=dY + dDeltaY2;
  axPH.setTitleCoordinate((iXTitleLocation == ABOVE) ? dY1 - 1 : dY2 + 1 - dXAxisTitleThickness);
  return dY;
}

Fixed version (ground truth):
/** 
 * @param dBlockY
 * @param dBlockHeight
 * @param aax
 * @param axPH
 * @param scY
 * @param iXLabelLocation
 * @param iYLabelLocation
 * @param iXTitleLocation
 * @param laYAxisLabels
 * @param dXAxisLabelsThickness
 * @param dDecorationThickness
 * @param dXAxisTitleThickness
 * @param dHTotal
 * @param dY
 * @param bTicksAbove
 * @param bTicksBelow
 * @param dAppliedXAxisPlotSpacing
 * @param bForwardScale
 * @return
 * @throws ChartException
 */
private double adjustVerticalWithMaxOrigin(double dBlockY,double dBlockHeight,AllAxes aax,final OneAxis axPH,final AutoScale scY,final int iXLabelLocation,final int iYLabelLocation,final int iXTitleLocation,final Label laYAxisLabels,double dXAxisLabelsThickness,double[] dDecorationThickness,double dXAxisTitleThickness,double dHTotal,double dY,final boolean bTicksAbove,final boolean bTicksBelow,final double dAppliedXAxisPlotSpacing,final boolean bForwardScale) throws ChartException {
  double dY1;
  double dY2;
  dY+=dAppliedXAxisPlotSpacing;
  dHTotal-=dAppliedXAxisPlotSpacing;
  dY1=dY;
  dY2=dY;
  double dTickSize=getTickSize();
  if (bTicksBelow && dTickSize < dHTotal) {
    dY2+=dTickSize;
    dHTotal-=dTickSize;
  }
 else {
    dTickSize=0;
  }
  if (iXLabelLocation == ABOVE) {
    double dXLabelHeight=Math.max((bTicksAbove ? dTickSize : 0) + dXAxisLabelsThickness,dAppliedXAxisPlotSpacing);
    if (dXLabelHeight + dDecorationThickness[1] < dHTotal) {
      dY1-=dXLabelHeight;
      dY2+=dDecorationThickness[1];
    }
 else {
      dXLabelHeight=0;
      axPH.setShowLabels(false);
    }
  }
 else   if (iXLabelLocation == BELOW) {
    double dXLabelHeight=Math.max(dXAxisLabelsThickness,dDecorationThickness[1]);
    double dHt1=Math.max(bTicksAbove ? dTickSize : 0,dAppliedXAxisPlotSpacing);
    if (dXLabelHeight + dHt1 <= dHTotal) {
      dY2+=dXLabelHeight;
      dY1-=dHt1;
    }
 else {
      dXLabelHeight=0;
      axPH.setShowLabels(false);
    }
  }
  if (iXTitleLocation == ABOVE) {
    dY1-=dXAxisTitleThickness;
  }
 else   if (iXTitleLocation == BELOW) {
    dY2+=dXAxisTitleThickness;
  }
  if (dY2 > dBlockY + dBlockHeight) {
    final double dDelta=(dY2 - (dBlockY + dBlockHeight));
    dY2=dBlockY + dBlockHeight;
    dY-=dDelta;
    dY1-=dDelta;
  }
  double dDeltaY1=dY - dY1;
  double dDeltaY2=dY2 - dY;
  double dXAxisThickness=0;
  if (iXLabelLocation == ABOVE) {
    dY1=(dY - dAppliedXAxisPlotSpacing);
    dXAxisThickness=dY2 - dY1;
  }
 else   if (iXLabelLocation == BELOW) {
    dXAxisThickness=dY2 - dY1;
  }
  if ((bForwardScale && dXAxisThickness > scY.getEndShift()) || (!bForwardScale && dXAxisThickness > scY.getStartShift())) {
    double dStart=dY1 + scY.getStartShift(), dEnd=scY.getEnd();
    if (bForwardScale) {
      dStart=scY.getStart();
      dEnd=dY1 + scY.getEndShift();
    }
    scY.resetShifts();
    if (dStart < dEnd + 1) {
      dStart=dEnd + 1;
    }
    scY.setEndPoints(dStart,dEnd);
    scY.computeTicks(ids,laYAxisLabels,iYLabelLocation,VERTICAL,dStart,dEnd,true,aax);
    if (!scY.isStepFixed()) {
      final Object[] oaMinMax=scY.getMinMax();
      while (!scY.checkFit(ids,laYAxisLabels,iYLabelLocation)) {
        if (!scY.zoomOut()) {
          break;
        }
        double dOldStep=((Number)scY.getStep()).doubleValue();
        scY.updateAxisMinMax(oaMinMax[0],oaMinMax[1]);
        int tickCount=scY.computeTicks(ids,laYAxisLabels,iYLabelLocation,VERTICAL,dStart,dEnd,true,aax);
        double dNewStep=((Number)scY.getStep()).doubleValue();
        if (dNewStep < dOldStep) {
          break;
        }
        if (scY.getUnit() != null && asInteger(scY.getUnit()) == Calendar.YEAR && tickCount <= 3 || isSharedScale()) {
          break;
        }
      }
    }
  }
  dY+=insCA.getBottom();
  dY1=dY - dDeltaY1;
  dY2=dY + dDeltaY2;
  axPH.setTitleCoordinate((iXTitleLocation == ABOVE) ? dY1 - 1 : dY2 + 1 - dXAxisTitleThickness);
  return dY;
}