Program: 26794
Project: 26794
Buggy source:
@Override protected void calculateOffsets(){
  float legendRight=0f, legendBottom=0f;
  if (mDrawLegend && mLegend != null && mLegend.getPosition() != LegendPosition.NONE) {
    if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART || mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART_CENTER) {
      float spacing=Utils.convertDpToPixel(12f);
      legendRight=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 (mXAxis.getPosition() == XLabelPosition.TOP)       legendBottom=mLegendLabelPaint.getTextSize() * 3.5f;
 else {
        legendBottom=mLegendLabelPaint.getTextSize() * 2.5f;
      }
    }
    mLegend.setOffsetBottom(legendBottom);
    mLegend.setOffsetRight(legendRight);
  }
  float yleft=0f, yright=0f;
  String label=mAxisLeft.getLongestLabel();
  if (mDrawYAxis) {
    if (mAxisLeft.isEnabled()) {
      float ylabelwidth=Utils.calcTextWidth(mAxisRendererLeft.getAxisPaint(),label + (mYChartMin < 0 ? "String_Node_Str" : "String_Node_Str"));
      yleft=ylabelwidth;
    }
    if (mAxisRight.isEnabled()) {
      float ylabelwidth=Utils.calcTextWidth(mAxisRendererRight.getAxisPaint(),label + (mYChartMin < 0 ? "String_Node_Str" : "String_Node_Str"));
      yright=ylabelwidth;
    }
  }
  float xtop=0f, xbottom=0f;
  float xlabelheight=Utils.calcTextHeight(mXAxisRenderer.getAxisPaint(),"String_Node_Str") * 2f;
  if (mDrawXLabels) {
    if (mXAxis.getPosition() == XLabelPosition.BOTTOM) {
      xbottom=xlabelheight;
    }
 else     if (mXAxis.getPosition() == XLabelPosition.TOP) {
      xtop=xlabelheight;
    }
 else     if (mXAxis.getPosition() == XLabelPosition.BOTH_SIDED) {
      xbottom=xlabelheight;
      xtop=xlabelheight;
    }
  }
  float min=Utils.convertDpToPixel(11f);
  float offsetBottom=Math.max(min,xbottom + legendBottom);
  float offsetTop=Math.max(min,xtop);
  float offsetLeft=Math.max(min,yleft);
  float offsetRight=Math.max(min,yright + legendRight);
  if (mLegend != null) {
    mLegend.setOffsetTop(offsetTop + min / 3f);
    mLegend.setOffsetLeft(offsetLeft);
  }
  mViewPortHandler.restrainViewPort(offsetLeft,offsetTop,offsetRight,offsetBottom);
  prepareMatrix();
}

Fixed version (ground truth):
@Override protected void calculateOffsets(){
  float legendRight=0f, legendBottom=0f;
  if (mDrawLegend && mLegend != null && mLegend.getPosition() != LegendPosition.NONE) {
    if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART || mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART_CENTER) {
      float spacing=Utils.convertDpToPixel(12f);
      legendRight=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 (mXAxis.getPosition() == XLabelPosition.TOP)       legendBottom=mLegendLabelPaint.getTextSize() * 3.5f;
 else {
        legendBottom=mLegendLabelPaint.getTextSize() * 2.5f;
      }
    }
    mLegend.setOffsetBottom(legendBottom);
    mLegend.setOffsetRight(legendRight);
  }
  float yleft=0f, yright=0f;
  if (mDrawYAxis) {
    if (mAxisLeft.isEnabled()) {
      String label=mAxisLeft.getLongestLabel();
      float ylabelwidth=Utils.calcTextWidth(mAxisRendererLeft.getAxisPaint(),label + (mYChartMin < 0 ? "String_Node_Str" : "String_Node_Str"));
      yleft=ylabelwidth + mAxisRendererLeft.getXOffset() / 2f;
    }
    if (mAxisRight.isEnabled()) {
      String label=mAxisRight.getLongestLabel();
      float ylabelwidth=Utils.calcTextWidth(mAxisRendererRight.getAxisPaint(),label + (mYChartMin < 0 ? "String_Node_Str" : "String_Node_Str"));
      yright=ylabelwidth + mAxisRendererRight.getXOffset() / 2f;
    }
  }
  float xtop=0f, xbottom=0f;
  float xlabelheight=Utils.calcTextHeight(mXAxisRenderer.getAxisPaint(),"String_Node_Str") * 2f;
  if (mDrawXLabels) {
    if (mXAxis.getPosition() == XLabelPosition.BOTTOM) {
      xbottom=xlabelheight;
    }
 else     if (mXAxis.getPosition() == XLabelPosition.TOP) {
      xtop=xlabelheight;
    }
 else     if (mXAxis.getPosition() == XLabelPosition.BOTH_SIDED) {
      xbottom=xlabelheight;
      xtop=xlabelheight;
    }
  }
  float min=Utils.convertDpToPixel(11f);
  float offsetBottom=Math.max(min,xbottom + legendBottom);
  float offsetTop=Math.max(min,xtop);
  float offsetLeft=Math.max(min,yleft);
  float offsetRight=Math.max(min,yright + legendRight);
  if (mLegend != null) {
    mLegend.setOffsetTop(offsetTop + min / 3f);
    mLegend.setOffsetLeft(offsetLeft);
  }
  mViewPortHandler.restrainViewPort(offsetLeft,offsetTop,offsetRight,offsetBottom);
  if (mLogEnabled) {
    Log.i(LOG_TAG,"String_Node_Str" + offsetLeft + "String_Node_Str"+ offsetTop+ "String_Node_Str"+ offsetRight+ "String_Node_Str"+ offsetBottom);
    Log.i(LOG_TAG,"String_Node_Str" + mViewPortHandler.getContentRect().toString());
  }
  prepareMatrix();
}