Program: 18935
Project: 18935
Buggy source:
@Override protected void calculateOffsets(){
  if (mLegend == null)   return;
  Log.i(LOG_TAG,"String_Node_Str");
  if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART) {
    float spacing=Utils.convertDpToPixel(7f);
    mLegend.setOffsetRight(mLegend.getMaximumEntryLength(mLegendLabelPaint) + mLegend.getFormSize() + mLegend.getFormToTextSpace()+ spacing);
    mLegendLabelPaint.setTextAlign(Align.LEFT);
  }
 else   if (mLegend.getPosition() == LegendPosition.BELOW_CHART_LEFT || mLegend.getPosition() == LegendPosition.BELOW_CHART_RIGHT || mLegend.getPosition() == LegendPosition.BELOW_CHART_CENTER) {
    if (mXLabels.getPosition() == XLabelPosition.TOP)     mLegend.setOffsetBottom(mLegendLabelPaint.getTextSize() * 3.5f);
 else {
      mLegend.setOffsetBottom(mLegendLabelPaint.getTextSize() * 2.5f);
    }
  }
  float yleft=0f, yright=0f;
  float xtop=0f, xbottom=0f;
  if (mYLabels.getPosition() == YLabelPosition.LEFT) {
    if (mYChartMin >= 0)     yleft=Utils.calcTextWidth(mYLabelPaint,(int)mDeltaY + "String_Node_Str" + mUnit);
 else     yleft=Utils.calcTextWidth(mYLabelPaint,(int)(mDeltaY * -1) + "String_Node_Str" + mUnit);
    mYLabelPaint.setTextAlign(Align.RIGHT);
  }
 else   if (mYLabels.getPosition() == YLabelPosition.RIGHT) {
    if (mYChartMin >= 0)     yright=Utils.calcTextWidth(mYLabelPaint,(int)mDeltaY + "String_Node_Str" + mUnit);
 else     yright=Utils.calcTextWidth(mYLabelPaint,(int)(mDeltaY * -1) + "String_Node_Str" + mUnit);
    mYLabelPaint.setTextAlign(Align.LEFT);
  }
 else   if (mYLabels.getPosition() == YLabelPosition.BOTH_SIDED) {
    float width=0f;
    if (mYChartMin >= 0)     width=Utils.calcTextWidth(mYLabelPaint,(int)mDeltaY + "String_Node_Str" + mUnit);
 else     width=Utils.calcTextWidth(mYLabelPaint,(int)(mDeltaY * -1) + "String_Node_Str" + mUnit);
    yright=width;
    yleft=width;
  }
  if (mXLabels.getPosition() == XLabelPosition.BOTTOM) {
    xbottom=Utils.calcTextHeight(mXLabelPaint,"String_Node_Str") * 2f;
  }
 else   if (mXLabels.getPosition() == XLabelPosition.TOP) {
    xtop=Utils.calcTextHeight(mXLabelPaint,"String_Node_Str") * 2f;
  }
 else   if (mXLabels.getPosition() == XLabelPosition.BOTH_SIDED) {
    float height=Utils.calcTextHeight(mXLabelPaint,"String_Node_Str") * 2f;
    xbottom=height;
    xtop=height;
  }
  if (mDrawLegend) {
    if (mDrawXLabels) {
      mOffsetBottom=Math.max(mOffsetBottom,xbottom + mLegend.getOffsetBottom());
      mOffsetTop=Math.max(mOffsetTop,xtop + mLegend.getOffsetTop());
    }
 else {
      mOffsetBottom=Math.max(mOffsetBottom,mLegend.getOffsetBottom());
      mOffsetTop=Math.max(mOffsetTop,mLegend.getOffsetTop());
    }
    if (mDrawYLabels) {
      mOffsetLeft=Math.max(mOffsetLeft,yleft + mLegend.getOffsetLeft());
      mOffsetRight=Math.max(mOffsetRight,yright + mLegend.getOffsetRight());
    }
 else {
      mOffsetLeft=Math.max(mOffsetLeft,mLegend.getOffsetLeft());
      mOffsetRight=Math.max(mOffsetRight,mLegend.getOffsetRight());
    }
  }
 else {
    if (mDrawXLabels) {
      mOffsetBottom=Math.max(mOffsetBottom,xbottom);
      mOffsetTop=Math.max(mOffsetTop,xtop);
    }
    if (mDrawYLabels) {
      mOffsetLeft=Math.max(mOffsetLeft,yleft);
      mOffsetRight=Math.max(mOffsetRight,yright);
    }
  }
  mLegend.setOffsetTop(mOffsetTop);
  mLegend.setOffsetLeft(mOffsetLeft);
  prepareContentRect();
  float scaleX=(float)((getWidth() - mOffsetLeft - mOffsetRight) / mDeltaX);
  float scaleY=(float)((getHeight() - mOffsetBottom - mOffsetTop) / mDeltaY);
  Matrix val=new Matrix();
  val.postTranslate(0,-mYChartMin);
  val.postScale(scaleX,-scaleY);
  mMatrixValueToPx.set(val);
  Matrix offset=new Matrix();
  if (!mInvertYAxis)   offset.postTranslate(mOffsetLeft,getHeight() - mOffsetBottom);
 else {
    offset.setTranslate(mOffsetLeft,-getOffsetTop());
    offset.postScale(1.0f,-1.0f);
  }
  mMatrixOffset.set(offset);
}

Fixed version (ground truth):
@Override protected void calculateOffsets(){
  if (mLegend == null)   return;
  if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART) {
    float spacing=Utils.convertDpToPixel(7f);
    mLegend.setOffsetRight(mLegend.getMaximumEntryLength(mLegendLabelPaint) + mLegend.getFormSize() + mLegend.getFormToTextSpace()+ spacing);
    mLegendLabelPaint.setTextAlign(Align.LEFT);
  }
 else   if (mLegend.getPosition() == LegendPosition.BELOW_CHART_LEFT || mLegend.getPosition() == LegendPosition.BELOW_CHART_RIGHT || mLegend.getPosition() == LegendPosition.BELOW_CHART_CENTER) {
    if (mXLabels.getPosition() == XLabelPosition.TOP)     mLegend.setOffsetBottom(mLegendLabelPaint.getTextSize() * 3.5f);
 else {
      mLegend.setOffsetBottom(mLegendLabelPaint.getTextSize() * 2.5f);
    }
  }
  float yleft=0f, yright=0f;
  float xtop=0f, xbottom=0f;
  if (mYLabels.getPosition() == YLabelPosition.LEFT) {
    if (mYChartMin >= 0)     yleft=Utils.calcTextWidth(mYLabelPaint,(int)mDeltaY + "String_Node_Str" + mUnit);
 else     yleft=Utils.calcTextWidth(mYLabelPaint,(int)(mDeltaY * -1) + "String_Node_Str" + mUnit);
    mYLabelPaint.setTextAlign(Align.RIGHT);
  }
 else   if (mYLabels.getPosition() == YLabelPosition.RIGHT) {
    if (mYChartMin >= 0)     yright=Utils.calcTextWidth(mYLabelPaint,(int)mDeltaY + "String_Node_Str" + mUnit);
 else     yright=Utils.calcTextWidth(mYLabelPaint,(int)(mDeltaY * -1) + "String_Node_Str" + mUnit);
    mYLabelPaint.setTextAlign(Align.LEFT);
  }
 else   if (mYLabels.getPosition() == YLabelPosition.BOTH_SIDED) {
    float width=0f;
    if (mYChartMin >= 0)     width=Utils.calcTextWidth(mYLabelPaint,(int)mDeltaY + "String_Node_Str" + mUnit);
 else     width=Utils.calcTextWidth(mYLabelPaint,(int)(mDeltaY * -1) + "String_Node_Str" + mUnit);
    yright=width;
    yleft=width;
  }
  if (mXLabels.getPosition() == XLabelPosition.BOTTOM) {
    xbottom=Utils.calcTextHeight(mXLabelPaint,"String_Node_Str") * 2f;
  }
 else   if (mXLabels.getPosition() == XLabelPosition.TOP) {
    xtop=Utils.calcTextHeight(mXLabelPaint,"String_Node_Str") * 2f;
  }
 else   if (mXLabels.getPosition() == XLabelPosition.BOTH_SIDED) {
    float height=Utils.calcTextHeight(mXLabelPaint,"String_Node_Str") * 2f;
    xbottom=height;
    xtop=height;
  }
  if (mDrawLegend) {
    if (mDrawXLabels) {
      mOffsetBottom=Math.max(mOffsetBottom,xbottom + mLegend.getOffsetBottom());
      mOffsetTop=Math.max(mOffsetTop,xtop + mLegend.getOffsetTop());
    }
 else {
      mOffsetBottom=Math.max(mOffsetBottom,mLegend.getOffsetBottom());
      mOffsetTop=Math.max(mOffsetTop,mLegend.getOffsetTop());
    }
    if (mDrawYLabels) {
      mOffsetLeft=Math.max(mOffsetLeft,yleft + mLegend.getOffsetLeft());
      mOffsetRight=Math.max(mOffsetRight,yright + mLegend.getOffsetRight());
    }
 else {
      mOffsetLeft=Math.max(mOffsetLeft,mLegend.getOffsetLeft());
      mOffsetRight=Math.max(mOffsetRight,mLegend.getOffsetRight());
    }
  }
 else {
    if (mDrawXLabels) {
      mOffsetBottom=Math.max(mOffsetBottom,xbottom);
      mOffsetTop=Math.max(mOffsetTop,xtop);
    }
    if (mDrawYLabels) {
      mOffsetLeft=Math.max(mOffsetLeft,yleft);
      mOffsetRight=Math.max(mOffsetRight,yright);
    }
  }
  mLegend.setOffsetTop(mOffsetTop);
  mLegend.setOffsetLeft(mOffsetLeft);
  prepareContentRect();
  float scaleX=(float)((getWidth() - mOffsetLeft - mOffsetRight) / mDeltaX);
  float scaleY=(float)((getHeight() - mOffsetBottom - mOffsetTop) / mDeltaY);
  Matrix val=new Matrix();
  val.postTranslate(0,-mYChartMin);
  val.postScale(scaleX,-scaleY);
  mMatrixValueToPx.set(val);
  Matrix offset=new Matrix();
  if (!mInvertYAxis)   offset.postTranslate(mOffsetLeft,getHeight() - mOffsetBottom);
 else {
    offset.setTranslate(mOffsetLeft,-getOffsetTop());
    offset.postScale(1.0f,-1.0f);
  }
  mMatrixOffset.set(offset);
}