nus-yam/ex-repair huggingface dataset:
Program: 26871
Project: 26871
Buggy source:
@Override protected void calculateOffsets(){
  if (mDrawLegend) {
    float legendRight=0f, legendBottom=0f;
    if (mLegend == null)     return;
    if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART || mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART_CENTER) {
      float spacing=Utils.convertDpToPixel(13f);
      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) {
      legendBottom=mLegendLabelPaint.getTextSize() * 4f;
    }
    mLegend.setOffsetBottom(legendBottom);
    mLegend.setOffsetRight(legendRight);
    float min=Utils.convertDpToPixel(11f);
    mLegend.setOffsetTop(min);
    mLegend.setOffsetLeft(min);
    mOffsetTop=min;
    mOffsetRight=Math.max(min,legendRight);
    mOffsetBottom=Math.max(min,legendBottom);
    applyCalculatedOffsets();
  }
}

Fixed version (ground truth):
@Override protected void calculateOffsets(){
  float legendRight=0f, legendBottom=0f;
  if (mDrawLegend) {
    if (mLegend == null)     return;
    if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART || mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART_CENTER) {
      float spacing=Utils.convertDpToPixel(13f);
      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) {
      legendBottom=mLegendLabelPaint.getTextSize() * 4f;
    }
    mLegend.setOffsetBottom(legendBottom);
    mLegend.setOffsetRight(legendRight);
  }
  float min=Utils.convertDpToPixel(11f);
  mLegend.setOffsetTop(min);
  mLegend.setOffsetLeft(min);
  mOffsetLeft=min;
  mOffsetTop=min;
  mOffsetRight=Math.max(min,legendRight);
  mOffsetBottom=Math.max(min,legendBottom);
  applyCalculatedOffsets();
}
Program: 26872
Project: 26872
Buggy source:
@Override protected void calculateOffsets(){
  if (mDrawLegend) {
    float legendRight=0f, legendBottom=0f;
    if (mLegend == null)     return;
    if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART || mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART_CENTER) {
      float spacing=Utils.convertDpToPixel(8f);
      legendRight=mLegend.getMaximumEntryLength(mLegendLabelPaint) + mLegend.getFormSize() + mLegend.getFormToTextSpace()+ spacing+ mXLabels.mLabelWidth;
      mLegendLabelPaint.setTextAlign(Align.LEFT);
    }
 else     if (mLegend.getPosition() == LegendPosition.BELOW_CHART_LEFT || mLegend.getPosition() == LegendPosition.BELOW_CHART_RIGHT || mLegend.getPosition() == LegendPosition.BELOW_CHART_CENTER) {
      legendBottom=mLegendLabelPaint.getTextSize() * 5.5f;
    }
    mLegend.setOffsetBottom(legendBottom);
    mLegend.setOffsetRight(legendRight);
    float min=Utils.convertDpToPixel(11f);
    mOffsetBottom=Math.max(mXLabels.mLabelWidth,min);
    mOffsetTop=Math.max(mXLabels.mLabelWidth,min);
    mOffsetRight=Math.max(legendRight,min);
    mOffsetLeft=Math.max(mXLabels.mLabelWidth,min);
    mOffsetBottom=Math.max(mOffsetBottom,legendBottom);
    mOffsetRight=Math.max(mOffsetRight,legendRight / 3f * 2f);
    mLegend.setOffsetTop(min);
    mLegend.setOffsetLeft(min);
    applyCalculatedOffsets();
  }
}

Fixed version (ground truth):
@Override protected void calculateOffsets(){
  float legendRight=0f, legendBottom=0f;
  if (mDrawLegend) {
    if (mLegend == null)     return;
    if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART || mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART_CENTER) {
      float spacing=Utils.convertDpToPixel(8f);
      legendRight=mLegend.getMaximumEntryLength(mLegendLabelPaint) + mLegend.getFormSize() + mLegend.getFormToTextSpace()+ spacing+ mXLabels.mLabelWidth;
      mLegendLabelPaint.setTextAlign(Align.LEFT);
    }
 else     if (mLegend.getPosition() == LegendPosition.BELOW_CHART_LEFT || mLegend.getPosition() == LegendPosition.BELOW_CHART_RIGHT || mLegend.getPosition() == LegendPosition.BELOW_CHART_CENTER) {
      legendBottom=mLegendLabelPaint.getTextSize() * 5.5f;
    }
    mLegend.setOffsetBottom(legendBottom);
    mLegend.setOffsetRight(legendRight);
  }
  float min=Utils.convertDpToPixel(11f);
  mOffsetBottom=Math.max(mXLabels.mLabelWidth,min);
  mOffsetTop=Math.max(mXLabels.mLabelWidth,min);
  mOffsetRight=Math.max(legendRight,min);
  mOffsetLeft=Math.max(mXLabels.mLabelWidth,min);
  mOffsetBottom=Math.max(mOffsetBottom,legendBottom);
  mOffsetRight=Math.max(mOffsetRight,legendRight / 3f * 2f);
  mLegend.setOffsetTop(min);
  mLegend.setOffsetLeft(min);
  applyCalculatedOffsets();
}
Program: 26873
Project: 26873
Buggy source:
@Override public boolean onSingleTapUp(MotionEvent e){
  OnChartGestureListener l=mChart.getOnChartGestureListener();
  if (l != null) {
    l.onChartSingleTapped(e);
  }
  Highlight h=mChart.getHighlightByTouchPoint(e.getX(),e.getY());
  if (h == null || h.equalTo(mLastHighlighted)) {
    mChart.highlightTouch(null);
    mLastHighlighted=null;
  }
 else {
    mLastHighlighted=h;
    mChart.highlightTouch(h);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onSingleTapUp(MotionEvent e){
  OnChartGestureListener l=mChart.getOnChartGestureListener();
  if (l != null) {
    l.onChartSingleTapped(e);
  }
  Highlight h=mChart.getHighlightByTouchPoint(e.getX(),e.getY());
  if (h == null || h.equalTo(mLastHighlighted)) {
    mChart.highlightTouch(null);
    mLastHighlighted=null;
  }
 else {
    mLastHighlighted=h;
    mChart.highlightTouch(h);
  }
  return super.onSingleTapUp(e);
}
Program: 26874
Project: 26874
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_barchart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(BarChart)findViewById(R.id.chart1);
  mChart.setDrawYValues(false);
  mChart.setUnit("String_Node_Str");
  mChart.setDescription("String_Node_Str");
  mChart.setMaxVisibleValueCount(60);
  mChart.set3DEnabled(false);
  mChart.setPinchZoom(false);
  mChart.setDrawBarShadow(false);
  mChart.setDrawVerticalGrid(false);
  mChart.setDrawHorizontalGrid(false);
  mChart.setDrawGridBackground(false);
  XLabels xLabels=mChart.getXLabels();
  xLabels.setPosition(XLabelPosition.BOTTOM);
  xLabels.setCenterXLabelText(true);
  xLabels.setSpaceBetweenLabels(0);
  mChart.setDrawYLabels(false);
  mChart.setDrawLegend(false);
  mSeekBarX.setProgress(10);
  mSeekBarY.setProgress(100);
  mChart.animateY(2500);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_barchart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(BarChart)findViewById(R.id.chart1);
  mChart.setDrawYValues(false);
  mChart.setUnit("String_Node_Str");
  mChart.setDescription("String_Node_Str");
  mChart.setDrawYValues(true);
  mChart.setMaxVisibleValueCount(60);
  mChart.set3DEnabled(false);
  mChart.setPinchZoom(false);
  mChart.setDrawBarShadow(false);
  mChart.setDrawVerticalGrid(false);
  mChart.setDrawHorizontalGrid(false);
  mChart.setDrawGridBackground(false);
  XLabels xLabels=mChart.getXLabels();
  xLabels.setPosition(XLabelPosition.BOTTOM);
  xLabels.setCenterXLabelText(true);
  xLabels.setSpaceBetweenLabels(0);
  mChart.setDrawYLabels(false);
  mChart.setDrawLegend(false);
  mSeekBarX.setProgress(10);
  mSeekBarY.setProgress(100);
  mChart.animateY(2500);
}
Program: 26875
Project: 26875
Buggy source:
/** 
 * calculates the required number of digits for the values that might be drawn in the chart (if enabled)
 */
protected void calcFormats(){
  if (!mUseCustomFormatter) {
    float reference=0f;
    if (mOriginalData == null || mOriginalData.getXValCount() < 2) {
      reference=Math.max(Math.abs(mYChartMin),Math.abs(mYChartMax));
    }
 else {
      reference=mDeltaY;
    }
    int digits=Utils.getFormatDigits(reference);
    StringBuffer b=new StringBuffer();
    for (int i=0; i < digits; i++) {
      if (i == 0)       b.append("String_Node_Str");
      b.append("String_Node_Str");
    }
    mValueFormat=new DecimalFormat("String_Node_Str" + b.toString());
  }
}

Fixed version (ground truth):
/** 
 * calculates the required number of digits for the values that might be drawn in the chart (if enabled)
 */
protected void calcFormats(){
  if (!mUseCustomFormatter) {
    float reference=0f;
    if (mOriginalData == null || mOriginalData.getXValCount() < 2) {
      reference=Math.max(Math.abs(mYChartMin),Math.abs(mYChartMax));
    }
 else {
      reference=mDeltaY;
    }
    int digits=Utils.getDecimals(reference);
    StringBuffer b=new StringBuffer();
    for (int i=0; i < digits; i++) {
      if (i == 0)       b.append("String_Node_Str");
      b.append("String_Node_Str");
    }
    mValueFormat=new DecimalFormat("String_Node_Str" + b.toString());
  }
}
Program: 26877
Project: 26877
Buggy source:
@Override protected void drawData(){
  float angle=mRotationAngle;
  ArrayList<PieDataSet> dataSets=mCurrentData.getDataSets();
  int cnt=0;
  for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
    PieDataSet dataSet=dataSets.get(i);
    ArrayList<Entry> entries=dataSet.getYVals();
    for (int j=0; j < entries.size(); j++) {
      float newangle=mDrawAngles[cnt];
      float sliceSpace=dataSet.getSliceSpace();
      if (!needsHighlight(entries.get(j).getXIndex(),i)) {
        mRenderPaint.setColor(dataSet.getColor(j));
        mDrawCanvas.drawArc(mCircleBox,angle + sliceSpace / 2f,newangle * mPhaseY - sliceSpace / 2f,true,mRenderPaint);
      }
      angle+=newangle * mPhaseX;
      cnt++;
    }
  }
}

Fixed version (ground truth):
@Override protected void drawData(){
  float angle=mRotationAngle;
  ArrayList<PieDataSet> dataSets=mCurrentData.getDataSets();
  int cnt=0;
  for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
    PieDataSet dataSet=dataSets.get(i);
    ArrayList<Entry> entries=dataSet.getYVals();
    for (int j=0; j < entries.size(); j++) {
      float newangle=mDrawAngles[cnt];
      float sliceSpace=dataSet.getSliceSpace();
      Entry e=entries.get(j);
      if ((Math.abs(e.getVal()) > 0.000001)) {
        if (!needsHighlight(e.getXIndex(),i)) {
          mRenderPaint.setColor(dataSet.getColor(j));
          mDrawCanvas.drawArc(mCircleBox,angle + sliceSpace / 2f,newangle * mPhaseY - sliceSpace / 2f,true,mRenderPaint);
        }
      }
      angle+=newangle * mPhaseX;
      cnt++;
    }
  }
}
Program: 26878
Project: 26878
Buggy source:
/** 
 * calculates the needed angles for the chart slices
 */
private void calcAngles(){
  mDrawAngles=new float[mCurrentData.getYValCount()];
  mAbsoluteAngles=new float[mCurrentData.getYValCount()];
  ArrayList<PieDataSet> dataSets=mCurrentData.getDataSets();
  int cnt=0;
  for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
    PieDataSet set=dataSets.get(i);
    ArrayList<Entry> entries=set.getYVals();
    for (int j=0; j < entries.size(); j++) {
      mDrawAngles[cnt]=calcAngle(entries.get(j).getVal());
      if (cnt == 0) {
        mAbsoluteAngles[cnt]=mDrawAngles[cnt];
      }
 else {
        mAbsoluteAngles[cnt]=mAbsoluteAngles[cnt - 1] + mDrawAngles[cnt];
      }
      cnt++;
    }
  }
}

Fixed version (ground truth):
/** 
 * calculates the needed angles for the chart slices
 */
private void calcAngles(){
  mDrawAngles=new float[mCurrentData.getYValCount()];
  mAbsoluteAngles=new float[mCurrentData.getYValCount()];
  ArrayList<PieDataSet> dataSets=mCurrentData.getDataSets();
  int cnt=0;
  for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
    PieDataSet set=dataSets.get(i);
    ArrayList<Entry> entries=set.getYVals();
    for (int j=0; j < entries.size(); j++) {
      mDrawAngles[cnt]=calcAngle(Math.abs(entries.get(j).getVal()));
      if (cnt == 0) {
        mAbsoluteAngles[cnt]=mDrawAngles[cnt];
      }
 else {
        mAbsoluteAngles[cnt]=mAbsoluteAngles[cnt - 1] + mDrawAngles[cnt];
      }
      cnt++;
    }
  }
}
Program: 26879
Project: 26879
Buggy source:
/** 
 * enable this to force the y-axis labels to always start at zero
 * @param enabled
 */
public void setStartAtZero(boolean enabled){
  this.mStartAtZero=enabled;
  prepare();
  prepareMatrix();
  calculateOffsets();
}

Fixed version (ground truth):
/** 
 * enable this to force the y-axis labels to always start at zero
 * @param enabled
 */
public void setStartAtZero(boolean enabled){
  this.mStartAtZero=enabled;
  prepare();
  prepareMatrix();
}
Program: 26880
Project: 26880
Buggy source:
@Override protected void calculateOffsets(){
  if (mLegend == null)   return;
  if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART) {
    mLegend.setOffsetRight(mLegend.getMaximumEntryLength(mLegendLabelPaint));
    mLegendLabelPaint.setTextAlign(Align.LEFT);
  }
 else   if (mLegend.getPosition() == LegendPosition.BELOW_CHART_LEFT || mLegend.getPosition() == LegendPosition.BELOW_CHART_RIGHT || mLegend.getPosition() == LegendPosition.BELOW_CHART_CENTER) {
    mLegend.setOffsetBottom(mLegendLabelPaint.getTextSize() * 4f);
  }
  if (mDrawLegend) {
    mOffsetBottom=Math.max(mOffsetBottom,mLegend.getOffsetBottom());
    mOffsetRight=Math.max(mOffsetRight,mLegend.getOffsetRight() / 3 * 2);
  }
  mLegend.setOffsetTop(mOffsetTop);
  mLegend.setOffsetLeft(mOffsetLeft);
  applyCalculatedOffsets();
}

Fixed version (ground truth):
@Override protected void calculateOffsets(){
  if (mDrawLegend) {
    float legendRight=0f, legendBottom=0f;
    if (mLegend == null)     return;
    if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART) {
      float spacing=Utils.convertDpToPixel(7f);
      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) {
      legendBottom=mLegendLabelPaint.getTextSize() * 4f;
    }
    mLegend.setOffsetBottom(legendBottom);
    mLegend.setOffsetRight(legendRight);
    float min=Utils.convertDpToPixel(11f);
    mLegend.setOffsetTop(min);
    mLegend.setOffsetLeft(min);
    mOffsetTop=Math.max(mLegend.getFullHeight(mLegendLabelPaint),min);
    applyCalculatedOffsets();
  }
}
Program: 26881
Project: 26881
Buggy source:
@Override public void prepare(){
  if (mDataNotSet)   return;
  calcMinMax(false);
  prepareLegend();
}

Fixed version (ground truth):
@Override public void prepare(){
  if (mDataNotSet)   return;
  calcMinMax(false);
  prepareLegend();
  calculateOffsets();
}
Program: 26882
Project: 26882
Buggy source:
@Override protected void calculateOffsets(){
  if (mLegend == null)   return;
  if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART) {
    mLegend.setOffsetRight(mLegend.getMaximumEntryLength(mLegendLabelPaint));
    mLegendLabelPaint.setTextAlign(Align.LEFT);
  }
 else   if (mLegend.getPosition() == LegendPosition.BELOW_CHART_LEFT || mLegend.getPosition() == LegendPosition.BELOW_CHART_RIGHT || mLegend.getPosition() == LegendPosition.BELOW_CHART_CENTER) {
    mLegend.setOffsetBottom(mLegendLabelPaint.getTextSize() * 5.5f);
  }
  mLegend.setOffsetTop(mOffsetTop);
  mLegend.setOffsetLeft(mOffsetLeft);
  if (mDrawLegend) {
    mOffsetBottom=Math.max(mXLabels.mLabelWidth,mOffsetBottom);
    mOffsetTop=Math.max(mXLabels.mLabelWidth,mOffsetTop);
    mOffsetRight=Math.max(mXLabels.mLabelWidth,mOffsetRight);
    mOffsetLeft=Math.max(mXLabels.mLabelWidth,mOffsetLeft);
    mOffsetBottom=Math.max(mOffsetBottom,mLegend.getOffsetBottom());
    mOffsetRight=Math.max(mOffsetRight,mLegend.getOffsetRight() / 3 * 2);
  }
  applyCalculatedOffsets();
}

Fixed version (ground truth):
@Override protected void calculateOffsets(){
  if (mDrawLegend) {
    float legendRight=0f, legendBottom=0f;
    if (mLegend == null)     return;
    if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART) {
      float spacing=Utils.convertDpToPixel(7f);
      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) {
      legendBottom=mLegendLabelPaint.getTextSize() * 5.5f;
    }
    mLegend.setOffsetBottom(legendBottom);
    mLegend.setOffsetRight(legendRight);
    float min=Utils.convertDpToPixel(11f);
    mOffsetBottom=Math.max(mXLabels.mLabelWidth,min);
    mOffsetTop=Math.max(mXLabels.mLabelWidth,min);
    mOffsetRight=Math.max(mXLabels.mLabelWidth,min);
    mOffsetLeft=Math.max(mXLabels.mLabelWidth,min);
    mOffsetBottom=Math.max(mOffsetBottom,legendBottom);
    mOffsetRight=Math.max(mOffsetRight,legendRight / 3f * 2f);
    mLegend.setOffsetTop(min);
    mLegend.setOffsetLeft(min);
    applyCalculatedOffsets();
  }
}
Program: 26883
Project: 26883
Buggy source:
/** 
 * calculates the full width the fully drawn legend will use in pixels
 * @return
 */
public float getFullWidth(Paint labelpaint){
  float width=0f;
  for (int i=0; i < mLegendLabels.length; i++) {
    if (mLegendLabels[i] != null) {
      if (mColors[i] != -1)       width+=mFormSize + mFormToTextSpace;
      width+=Utils.calcTextWidth(labelpaint,mLegendLabels[i]) + mXEntrySpace;
    }
 else {
      width+=mFormSize + mStackSpace;
    }
  }
  return width;
}

Fixed version (ground truth):
/** 
 * calculates the full width the fully drawn legend will use in pixels
 * @return
 */
public float getFullWidth(Paint labelpaint){
  float width=0f;
  for (int i=0; i < mLegendLabels.length; i++) {
    if (mLegendLabels[i] != null) {
      if (mColors[i] != -2)       width+=mFormSize + mFormToTextSpace;
      width+=Utils.calcTextWidth(labelpaint,mLegendLabels[i]) + mXEntrySpace;
    }
 else {
      width+=mFormSize + mStackSpace;
    }
  }
  return width;
}
Program: 26884
Project: 26884
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_colored_lines);
  mCharts[0]=(LineChart)findViewById(R.id.chart1);
  mCharts[1]=(LineChart)findViewById(R.id.chart2);
  mCharts[2]=(LineChart)findViewById(R.id.chart3);
  mCharts[3]=(LineChart)findViewById(R.id.chart4);
  mTf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  LineData data=getData(36,100);
  for (int i=0; i < mCharts.length; i++)   setupChart(mCharts[i],data,mColors[i % mColors.length] & 0x90FFFFFF);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_colored_lines);
  mCharts[0]=(LineChart)findViewById(R.id.chart1);
  mCharts[1]=(LineChart)findViewById(R.id.chart2);
  mCharts[2]=(LineChart)findViewById(R.id.chart3);
  mCharts[3]=(LineChart)findViewById(R.id.chart4);
  mTf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  LineData data=getData(36,100);
  for (int i=0; i < mCharts.length; i++)   setupChart(mCharts[i],data,mColors[i % mColors.length]);
}
Program: 26885
Project: 26885
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_piechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(PieChart)findViewById(R.id.chart1);
  Typeface tf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  mChart.setValueTypeface(tf);
  mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(),"String_Node_Str"));
  mChart.setHoleRadius(60f);
  mChart.setDescription("String_Node_Str");
  mChart.setDrawYValues(true);
  mChart.setDrawCenterText(true);
  mChart.setDrawHoleEnabled(true);
  mChart.setRotationAngle(0);
  mChart.setDrawXValues(true);
  mChart.setRotationEnabled(true);
  mChart.setUsePercentValues(true);
  mChart.setOnChartValueSelectedListener(this);
  mSeekBarX.setProgress(3);
  mSeekBarY.setProgress(100);
  mChart.animateXY(1500,1500);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.BELOW_CHART_CENTER);
  l.setXEntrySpace(7f);
  l.setYEntrySpace(5f);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_piechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(PieChart)findViewById(R.id.chart1);
  Typeface tf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  mChart.setValueTypeface(tf);
  mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(),"String_Node_Str"));
  mChart.setHoleRadius(60f);
  mChart.setDescription("String_Node_Str");
  mChart.setDrawYValues(true);
  mChart.setDrawCenterText(true);
  mChart.setDrawHoleEnabled(true);
  mChart.setRotationAngle(0);
  mChart.setDrawXValues(true);
  mChart.setRotationEnabled(true);
  mChart.setUsePercentValues(true);
  mChart.setOnChartValueSelectedListener(this);
  mSeekBarX.setProgress(3);
  mSeekBarY.setProgress(100);
  mChart.animateXY(1500,1500);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
  l.setXEntrySpace(7f);
  l.setYEntrySpace(5f);
}
Program: 26886
Project: 26886
Buggy source:
/** 
 * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch point inside the BarChart.
 * @param x
 * @param y
 * @return
 */
@Override public Highlight getHighlightByTouchPoint(float x,float y){
  if (mDataNotSet) {
    Log.e(LOG_TAG,"String_Node_Str");
    return null;
  }
  float[] pts=new float[2];
  pts[0]=x;
  pts[1]=y;
  Matrix tmp=new Matrix();
  mMatrixOffset.invert(tmp);
  tmp.mapPoints(pts);
  mMatrixTouch.invert(tmp);
  tmp.mapPoints(pts);
  mMatrixValueToPx.invert(tmp);
  tmp.mapPoints(pts);
  double xTouchVal=pts[0];
  double base=xTouchVal;
  if (xTouchVal < 0 || xTouchVal > mDeltaX)   return null;
  if (base < 0)   base=0;
  if (base >= mDeltaX)   base=mDeltaX - 1;
  int setCount=mOriginalData.getDataSetCount();
  int valCount=setCount * mOriginalData.getXValCount();
  BarData bd=(BarData)mCurrentData;
  float space=(float)(((float)valCount / (float)setCount) / (mDeltaX / base));
  float reduction=(float)space * bd.getGroupSpace();
  int xIndex=(int)((base - reduction) / setCount);
  int dataSetIndex=((int)(base - reduction)) % setCount;
  if (dataSetIndex == -1)   return null;
  return new Highlight(xIndex,dataSetIndex);
}

Fixed version (ground truth):
/** 
 * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch point inside the BarChart.
 * @param x
 * @param y
 * @return
 */
@Override public Highlight getHighlightByTouchPoint(float x,float y){
  if (mDataNotSet || mCurrentData == null) {
    Log.e(LOG_TAG,"String_Node_Str");
    return null;
  }
  float[] pts=new float[2];
  pts[0]=x;
  pts[1]=y;
  Matrix tmp=new Matrix();
  mMatrixOffset.invert(tmp);
  tmp.mapPoints(pts);
  mMatrixTouch.invert(tmp);
  tmp.mapPoints(pts);
  mMatrixValueToPx.invert(tmp);
  tmp.mapPoints(pts);
  double xTouchVal=pts[0];
  double base=xTouchVal;
  if (xTouchVal < 0 || xTouchVal > mDeltaX)   return null;
  if (base < 0)   base=0;
  if (base >= mDeltaX)   base=mDeltaX - 1;
  int setCount=mOriginalData.getDataSetCount();
  int valCount=setCount * mOriginalData.getXValCount();
  BarData bd=(BarData)mCurrentData;
  float space=(float)(((float)valCount / (float)setCount) / (mDeltaX / base));
  float reduction=(float)space * bd.getGroupSpace();
  int xIndex=(int)((base - reduction) / setCount);
  int dataSetIndex=((int)(base - reduction)) % setCount;
  if (dataSetIndex == -1)   return null;
  return new Highlight(xIndex,dataSetIndex);
}
Program: 26887
Project: 26887
Buggy source:
/** 
 * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch point inside the Line-, Scatter-, or CandleStick-Chart.
 * @param x
 * @param y
 * @return
 */
public Highlight getHighlightByTouchPoint(float x,float y){
  if (mDataNotSet) {
    Log.e(LOG_TAG,"String_Node_Str");
    return null;
  }
  float[] pts=new float[2];
  pts[0]=x;
  pts[1]=y;
  Matrix tmp=new Matrix();
  mMatrixOffset.invert(tmp);
  tmp.mapPoints(pts);
  mMatrixTouch.invert(tmp);
  tmp.mapPoints(pts);
  mMatrixValueToPx.invert(tmp);
  tmp.mapPoints(pts);
  double xTouchVal=pts[0];
  double yTouchVal=pts[1];
  double base=Math.floor(xTouchVal);
  double touchOffset=mDeltaX * 0.025;
  if (xTouchVal < -touchOffset || xTouchVal > mDeltaX + touchOffset)   return null;
  if (this instanceof CandleStickChart)   base-=0.5;
  if (base < 0)   base=0;
  if (base >= mDeltaX)   base=mDeltaX - 1;
  int xIndex=(int)base;
  int dataSetIndex=0;
  if (xTouchVal - base > 0.5) {
    xIndex=(int)base + 1;
  }
  ArrayList<SelInfo> valsAtIndex=getYValsAtIndex(xIndex);
  dataSetIndex=Utils.getClosestDataSetIndex(valsAtIndex,(float)yTouchVal);
  if (dataSetIndex == -1)   return null;
  return new Highlight(xIndex,dataSetIndex);
}

Fixed version (ground truth):
/** 
 * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch point inside the Line-, Scatter-, or CandleStick-Chart.
 * @param x
 * @param y
 * @return
 */
public Highlight getHighlightByTouchPoint(float x,float y){
  if (mDataNotSet || mCurrentData == null) {
    Log.e(LOG_TAG,"String_Node_Str");
    return null;
  }
  float[] pts=new float[2];
  pts[0]=x;
  pts[1]=y;
  Matrix tmp=new Matrix();
  mMatrixOffset.invert(tmp);
  tmp.mapPoints(pts);
  mMatrixTouch.invert(tmp);
  tmp.mapPoints(pts);
  mMatrixValueToPx.invert(tmp);
  tmp.mapPoints(pts);
  double xTouchVal=pts[0];
  double yTouchVal=pts[1];
  double base=Math.floor(xTouchVal);
  double touchOffset=mDeltaX * 0.025;
  if (xTouchVal < -touchOffset || xTouchVal > mDeltaX + touchOffset)   return null;
  if (this instanceof CandleStickChart)   base-=0.5;
  if (base < 0)   base=0;
  if (base >= mDeltaX)   base=mDeltaX - 1;
  int xIndex=(int)base;
  int dataSetIndex=0;
  if (xTouchVal - base > 0.5) {
    xIndex=(int)base + 1;
  }
  ArrayList<SelInfo> valsAtIndex=getYValsAtIndex(xIndex);
  dataSetIndex=Utils.getClosestDataSetIndex(valsAtIndex,(float)yTouchVal);
  if (dataSetIndex == -1)   return null;
  return new Highlight(xIndex,dataSetIndex);
}
Program: 26888
Project: 26888
Buggy source:
/** 
 * Returns the actual position in pixels of the MarkerView for the given Entry in the given DataSet.
 * @param xIndex
 * @param dataSetIndex
 * @return
 */
private float[] getMarkerPosition(Entry e,int dataSetIndex){
  float xPos=(float)e.getXIndex();
  if (this instanceof CandleStickChart)   xPos+=0.5f;
 else   if (this instanceof BarChart) {
    BarData bd=(BarData)mCurrentData;
    float space=bd.getGroupSpace();
    float j=mCurrentData.getDataSetByIndex(dataSetIndex).getEntryPosition(e);
    float x=(j * (mCurrentData.getDataSetCount() - 1)) + dataSetIndex + space * j + space / 2f + 0.5f;
    xPos+=x;
  }
 else   if (this instanceof RadarChart) {
    RadarChart rc=(RadarChart)this;
    float angle=rc.getSliceAngle() * e.getXIndex() + rc.getRotationAngle();
    float val=e.getVal() * rc.getFactor();
    PointF c=getCenter();
    PointF p=new PointF((float)(c.x + val * Math.cos(Math.toRadians(angle))),(float)(c.y + val * Math.sin(Math.toRadians(angle))));
    return new float[]{p.x,p.y};
  }
  float[] pts=new float[]{xPos,e.getVal() * mPhaseY};
  transformPointArray(pts);
  return pts;
}

Fixed version (ground truth):
/** 
 * Returns the actual position in pixels of the MarkerView for the given Entry in the given DataSet.
 * @param xIndex
 * @param dataSetIndex
 * @return
 */
private float[] getMarkerPosition(Entry e,int dataSetIndex){
  float xPos=(float)e.getXIndex();
  if (this instanceof CandleStickChart)   xPos+=0.5f;
 else   if (this instanceof BarChart) {
    BarData bd=(BarData)mCurrentData;
    float space=bd.getGroupSpace();
    float j=mCurrentData.getDataSetByIndex(dataSetIndex).getEntryPosition(e);
    float x=(j * (mCurrentData.getDataSetCount() - 1)) + dataSetIndex + space * j + space / 2f + 0.5f;
    xPos+=x;
  }
 else   if (this instanceof RadarChart) {
    RadarChart rc=(RadarChart)this;
    float angle=rc.getSliceAngle() * e.getXIndex() + rc.getRotationAngle();
    float val=e.getVal() * rc.getFactor();
    PointF c=getCenterOffsets();
    PointF p=new PointF((float)(c.x + val * Math.cos(Math.toRadians(angle))),(float)(c.y + val * Math.sin(Math.toRadians(angle))));
    return new float[]{p.x,p.y};
  }
  float[] pts=new float[]{xPos,e.getVal() * mPhaseY};
  transformPointArray(pts);
  return pts;
}
Program: 26890
Project: 26890
Buggy source:
/** 
 * returns the center point of the chart in pixels
 * @return
 */
public PointF getCenter(){
  return new PointF(getWidth() / 2f,getHeight() / 2f);
}

Fixed version (ground truth):
/** 
 * Returns the center point of the chart (the whole View) in pixels.
 * @return
 */
public PointF getCenter(){
  return new PointF(getWidth() / 2f,getHeight() / 2f);
}
Program: 26891
Project: 26891
Buggy source:
/** 
 * returns the center of the chart taking offsets under consideration
 * @return
 */
public PointF getCenterOffsets(){
  return new PointF(mContentRect.left + mContentRect.width() / 2,mContentRect.top + mContentRect.height() / 2);
}

Fixed version (ground truth):
/** 
 * Returns the center of the chart taking offsets under consideration. (returns the center of the content rectangle)
 * @return
 */
public PointF getCenterOffsets(){
  return new PointF(mContentRect.centerX(),mContentRect.centerY());
}
Program: 26892
Project: 26892
Buggy source:
@Override protected void prepareContentRect(){
  super.prepareContentRect();
  if (mDataNotSet)   return;
  float width=mContentRect.width() + mOffsetLeft + mOffsetRight;
  float height=mContentRect.height() + mOffsetTop + mOffsetBottom;
  float diameter=getDiameter();
  float shift=((PieData)mCurrentData).getDataSet().getSelectionShift();
  mCircleBox.set(width / 2 - diameter / 2 + shift,height / 2 - diameter / 2 + shift,width / 2 + diameter / 2 - shift,height / 2 + diameter / 2 - shift);
}

Fixed version (ground truth):
@Override protected void prepareContentRect(){
  super.prepareContentRect();
  if (mDataNotSet)   return;
  float diameter=getDiameter();
  float boxSize=diameter / 2f;
  PointF c=getCenterOffsets();
  mCircleBox.set(c.x - boxSize,c.y - boxSize,c.x + boxSize,c.y + boxSize);
}
Program: 26893
Project: 26893
Buggy source:
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (mDataNotSet)   return;
  long starttime=System.currentTimeMillis();
  drawHighlights();
  drawData();
  drawAdditional();
  drawValues();
  drawLegend();
  drawDescription();
  drawCenterText();
  canvas.drawBitmap(mDrawBitmap,0,0,mDrawPaint);
  Log.i(LOG_TAG,"String_Node_Str" + (System.currentTimeMillis() - starttime) + "String_Node_Str");
  PointF c1=getCenter();
  PointF c2=getCenterCircleBox();
  Log.i(LOG_TAG,"String_Node_Str" + c1.x + "String_Node_Str"+ c1.y);
  Log.i(LOG_TAG,"String_Node_Str" + c2.x + "String_Node_Str"+ c2.y);
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (mDataNotSet)   return;
  long starttime=System.currentTimeMillis();
  drawHighlights();
  drawData();
  drawAdditional();
  drawValues();
  drawLegend();
  drawDescription();
  drawCenterText();
  canvas.drawBitmap(mDrawBitmap,0,0,mDrawPaint);
  Log.i(LOG_TAG,"String_Node_Str" + (System.currentTimeMillis() - starttime) + "String_Node_Str");
}
Program: 26894
Project: 26894
Buggy source:
/** 
 * returns the angle relative to the chart center for the given point on the chart in degrees. The angle is always between 0 and 360°, 0° is NORTH, 90° is EAST, ...
 * @param x
 * @param y
 * @return
 */
public float getAngleForPoint(float x,float y){
  PointF c=getCenter();
  double tx=x - c.x, ty=y - c.y;
  double length=Math.sqrt(tx * tx + ty * ty);
  double r=Math.acos(ty / length);
  float angle=(float)Math.toDegrees(r);
  if (x > c.x)   angle=360f - angle;
  angle=angle + 90f;
  if (angle > 360f)   angle=angle - 360f;
  return angle;
}

Fixed version (ground truth):
/** 
 * returns the angle relative to the chart center for the given point on the chart in degrees. The angle is always between 0 and 360°, 0° is NORTH, 90° is EAST, ...
 * @param x
 * @param y
 * @return
 */
public float getAngleForPoint(float x,float y){
  PointF c=getCenterOffsets();
  double tx=x - c.x, ty=y - c.y;
  double length=Math.sqrt(tx * tx + ty * ty);
  double r=Math.acos(ty / length);
  float angle=(float)Math.toDegrees(r);
  if (x > c.x)   angle=360f - angle;
  angle=angle + 90f;
  if (angle > 360f)   angle=angle - 360f;
  return angle;
}
Program: 26895
Project: 26895
Buggy source:
/** 
 * Returns the distance of a certain point on the chart to the center of the chart.
 * @param x
 * @param y
 * @return
 */
public float distanceToCenter(float x,float y){
  PointF c=getCenter();
  float dist=0f;
  float xDist=0f;
  float yDist=0f;
  if (x > c.x) {
    xDist=x - c.x;
  }
 else {
    xDist=c.x - x;
  }
  if (y > c.y) {
    yDist=y - c.y;
  }
 else {
    yDist=c.y - y;
  }
  dist=(float)Math.sqrt(Math.pow(xDist,2.0) + Math.pow(yDist,2.0));
  return dist;
}

Fixed version (ground truth):
/** 
 * Returns the distance of a certain point on the chart to the center of the chart.
 * @param x
 * @param y
 * @return
 */
public float distanceToCenter(float x,float y){
  PointF c=getCenterOffsets();
  float dist=0f;
  float xDist=0f;
  float yDist=0f;
  if (x > c.x) {
    xDist=x - c.x;
  }
 else {
    xDist=c.x - x;
  }
  if (y > c.y) {
    yDist=y - c.y;
  }
 else {
    yDist=c.y - y;
  }
  dist=(float)Math.sqrt(Math.pow(xDist,2.0) + Math.pow(yDist,2.0));
  return dist;
}
Program: 26896
Project: 26896
Buggy source:
@Override protected void calculateOffsets(){
  if (mLegend == null)   return;
  if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART) {
    mLegend.setOffsetRight(mLegend.getMaximumEntryLength(mLegendLabelPaint));
    mLegendLabelPaint.setTextAlign(Align.LEFT);
  }
 else   if (mLegend.getPosition() == LegendPosition.BELOW_CHART_LEFT || mLegend.getPosition() == LegendPosition.BELOW_CHART_RIGHT || mLegend.getPosition() == LegendPosition.BELOW_CHART_CENTER) {
    mLegend.setOffsetBottom(mLegendLabelPaint.getTextSize() * 3.5f);
  }
  if (mDrawLegend) {
    mOffsetBottom=Math.max(mOffsetBottom,mLegend.getOffsetBottom());
    mOffsetRight=Math.max(mOffsetRight,mLegend.getOffsetRight() / 3 * 2);
  }
  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();
  offset.postTranslate(mOffsetLeft,getHeight() - mOffsetBottom);
  mMatrixOffset.set(offset);
}

Fixed version (ground truth):
@Override protected void calculateOffsets(){
  if (mLegend == null)   return;
  if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART) {
    mLegend.setOffsetRight(mLegend.getMaximumEntryLength(mLegendLabelPaint));
    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 (this instanceof RadarChart)     mLegend.setOffsetBottom(mLegendLabelPaint.getTextSize() * 5.5f);
 else     mLegend.setOffsetBottom(mLegendLabelPaint.getTextSize() * 4f);
  }
  if (mDrawLegend) {
    mOffsetBottom=Math.max(mOffsetBottom,mLegend.getOffsetBottom());
    mOffsetRight=Math.max(mOffsetRight,mLegend.getOffsetRight() / 3 * 2);
  }
  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();
  offset.postTranslate(mOffsetLeft,getHeight() - mOffsetBottom);
  mMatrixOffset.set(offset);
}
Program: 26897
Project: 26897
Buggy source:
@Override protected void drawValues(){
  if (mDrawYValues) {
    float sliceangle=getSliceAngle();
    float factor=getFactor();
    PointF c=getCenter();
    float yoffset=Utils.convertDpToPixel(5f);
    for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
      DataSet dataSet=mCurrentData.getDataSetByIndex(i);
      ArrayList<? extends Entry> entries=dataSet.getYVals();
      for (int j=0; j < entries.size(); j++) {
        Entry e=entries.get(j);
        PointF p=getPosition(c,e.getVal() * factor,sliceangle * j + mRotationAngle);
        mDrawCanvas.drawText(Utils.formatNumber(e.getVal(),mValueFormatDigits,mSeparateTousands),p.x,p.y - yoffset,mValuePaint);
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void drawValues(){
  if (mDrawYValues) {
    float sliceangle=getSliceAngle();
    float factor=getFactor();
    PointF c=getCenterOffsets();
    float yoffset=Utils.convertDpToPixel(5f);
    for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
      DataSet dataSet=mCurrentData.getDataSetByIndex(i);
      ArrayList<? extends Entry> entries=dataSet.getYVals();
      for (int j=0; j < entries.size(); j++) {
        Entry e=entries.get(j);
        PointF p=getPosition(c,e.getVal() * factor,sliceangle * j + mRotationAngle);
        mDrawCanvas.drawText(Utils.formatNumber(e.getVal(),mValueFormatDigits,mSeparateTousands),p.x,p.y - yoffset,mValuePaint);
      }
    }
  }
}
Program: 26898
Project: 26898
Buggy source:
/** 
 * Draws the x-labels of the chart.
 */
private void drawXLabels(){
  if (!mDrawXLabels)   return;
  mXLabelPaint.setTypeface(mXLabels.getTypeface());
  mXLabelPaint.setTextSize(mXLabels.getTextSize());
  mXLabelPaint.setColor(mXLabels.getTextColor());
  float sliceangle=getSliceAngle();
  float factor=getFactor();
  PointF c=getCenter();
  for (int i=0; i < mCurrentData.getXValCount(); i++) {
    String text=mCurrentData.getXVals().get(i);
    PointF p=getPosition(c,mYChartMax * factor,sliceangle * i + mRotationAngle);
    mDrawCanvas.drawText(text,p.x,p.y,mXLabelPaint);
  }
}

Fixed version (ground truth):
/** 
 * Draws the x-labels of the chart.
 */
private void drawXLabels(){
  if (!mDrawXLabels)   return;
  mXLabelPaint.setTypeface(mXLabels.getTypeface());
  mXLabelPaint.setTextSize(mXLabels.getTextSize());
  mXLabelPaint.setColor(mXLabels.getTextColor());
  float sliceangle=getSliceAngle();
  float factor=getFactor();
  PointF c=getCenterOffsets();
  for (int i=0; i < mCurrentData.getXValCount(); i++) {
    String text=mCurrentData.getXVals().get(i);
    PointF p=getPosition(c,mYChartMax * factor,sliceangle * i + mRotationAngle);
    mDrawCanvas.drawText(text,p.x,p.y,mXLabelPaint);
  }
}
Program: 26899
Project: 26899
Buggy source:
/** 
 * Draws the y-labels of the RadarChart.
 */
private void drawYLabels(){
  if (!mDrawYLabels)   return;
  mYLabelPaint.setTypeface(mYLabels.getTypeface());
  mYLabelPaint.setTextSize(mYLabels.getTextSize());
  mYLabelPaint.setColor(mYLabels.getTextColor());
  PointF c=getCenter();
  float factor=getFactor();
  int labelCount=mYLabels.mEntryCount;
  for (int j=0; j < labelCount; j++) {
    float r=((mYChartMax / labelCount) * j) * factor;
    PointF p=getPosition(c,r,mRotationAngle);
    mDrawCanvas.drawText(Utils.formatNumber(r / factor,mYLabels.mDecimals,mSeparateTousands),p.x + 10,p.y - 5,mYLabelPaint);
  }
}

Fixed version (ground truth):
/** 
 * Draws the y-labels of the RadarChart.
 */
private void drawYLabels(){
  if (!mDrawYLabels)   return;
  mYLabelPaint.setTypeface(mYLabels.getTypeface());
  mYLabelPaint.setTextSize(mYLabels.getTextSize());
  mYLabelPaint.setColor(mYLabels.getTextColor());
  PointF c=getCenterOffsets();
  float factor=getFactor();
  int labelCount=mYLabels.mEntryCount;
  for (int j=0; j < labelCount; j++) {
    float r=((mYChartMax / labelCount) * j) * factor;
    PointF p=getPosition(c,r,mRotationAngle);
    mDrawCanvas.drawText(Utils.formatNumber(r / factor,mYLabels.mDecimals,mSeparateTousands),p.x + 10,p.y - 5,mYLabelPaint);
  }
}
Program: 26900
Project: 26900
Buggy source:
/** 
 * setup the x-axis labels
 */
private void prepareXLabels(){
  StringBuffer a=new StringBuffer();
  int max=(int)Math.round(mCurrentData.getXValAverageLength() + mXLabels.getSpaceBetweenLabels());
  for (int i=0; i < max; i++) {
    a.append("String_Node_Str");
  }
  mXLabels.mLabelWidth=Utils.calcTextWidth(mXLabelPaint,a.toString());
  mXLabels.mLabelHeight=Utils.calcTextWidth(mXLabelPaint,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * setup the x-axis labels
 */
private void prepareXLabels(){
  StringBuffer a=new StringBuffer();
  int max=(int)Math.round(mCurrentData.getXValAverageLength());
  for (int i=0; i < max; i++) {
    a.append("String_Node_Str");
  }
  mXLabels.mLabelWidth=Utils.calcTextWidth(mXLabelPaint,a.toString());
  mXLabels.mLabelHeight=Utils.calcTextWidth(mXLabelPaint,"String_Node_Str");
  Log.i(LOG_TAG,"String_Node_Str" + mXLabels.mLabelWidth);
}
Program: 26901
Project: 26901
Buggy source:
@Override protected void drawHighlights(){
  if (mHighlightEnabled && valuesToHighlight()) {
    float sliceangle=getSliceAngle();
    float factor=getFactor();
    PointF c=getCenter();
    for (int i=0; i < mIndicesToHightlight.length; i++) {
      RadarDataSet set=(RadarDataSet)mCurrentData.getDataSetByIndex(mIndicesToHightlight[i].getDataSetIndex());
      mHighlightPaint.setColor(set.getHighLightColor());
      int xIndex=mIndicesToHightlight[i].getXIndex();
      Entry e=set.getEntryForXIndex(xIndex);
      int j=set.getEntryPosition(e);
      float y=e.getVal();
      PointF p=getPosition(c,y * factor,sliceangle * j + mRotationAngle);
      float[] pts=new float[]{p.x,0,p.x,getHeight(),0,p.y,getWidth(),p.y};
      mDrawCanvas.drawLines(pts,mHighlightPaint);
    }
  }
}

Fixed version (ground truth):
@Override protected void drawHighlights(){
  if (mHighlightEnabled && valuesToHighlight()) {
    float sliceangle=getSliceAngle();
    float factor=getFactor();
    PointF c=getCenterOffsets();
    for (int i=0; i < mIndicesToHightlight.length; i++) {
      RadarDataSet set=(RadarDataSet)mCurrentData.getDataSetByIndex(mIndicesToHightlight[i].getDataSetIndex());
      mHighlightPaint.setColor(set.getHighLightColor());
      int xIndex=mIndicesToHightlight[i].getXIndex();
      Entry e=set.getEntryForXIndex(xIndex);
      int j=set.getEntryPosition(e);
      float y=e.getVal();
      PointF p=getPosition(c,y * factor,sliceangle * j + mRotationAngle);
      float[] pts=new float[]{p.x,0,p.x,getHeight(),0,p.y,getWidth(),p.y};
      mDrawCanvas.drawLines(pts,mHighlightPaint);
    }
  }
}
Program: 26902
Project: 26902
Buggy source:
@Override protected void drawData(){
  ArrayList<RadarDataSet> dataSets=(ArrayList<RadarDataSet>)mCurrentData.getDataSets();
  float sliceangle=getSliceAngle();
  float factor=getFactor();
  PointF c=getCenter();
  for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
    RadarDataSet dataSet=dataSets.get(i);
    ArrayList<? extends Entry> entries=dataSet.getYVals();
    Path surface=new Path();
    for (int j=0; j < entries.size(); j++) {
      mRenderPaint.setColor(dataSet.getColor(j));
      Entry e=entries.get(j);
      PointF p=getPosition(c,e.getVal() * factor,sliceangle * j + mRotationAngle);
      if (j == 0)       surface.moveTo(p.x,p.y);
 else       surface.lineTo(p.x,p.y);
    }
    surface.close();
    if (dataSet.isDrawFilledEnabled()) {
      mRenderPaint.setStyle(Paint.Style.FILL);
      mRenderPaint.setAlpha(dataSet.getFillAlpha());
      mDrawCanvas.drawPath(surface,mRenderPaint);
      mRenderPaint.setAlpha(255);
    }
    mRenderPaint.setStrokeWidth(dataSet.getLineWidth());
    mRenderPaint.setStyle(Paint.Style.STROKE);
    if (!dataSet.isDrawFilledEnabled() || dataSet.getFillAlpha() < 255)     mDrawCanvas.drawPath(surface,mRenderPaint);
  }
}

Fixed version (ground truth):
@Override protected void drawData(){
  ArrayList<RadarDataSet> dataSets=(ArrayList<RadarDataSet>)mCurrentData.getDataSets();
  float sliceangle=getSliceAngle();
  float factor=getFactor();
  PointF c=getCenterOffsets();
  for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
    RadarDataSet dataSet=dataSets.get(i);
    ArrayList<? extends Entry> entries=dataSet.getYVals();
    Path surface=new Path();
    for (int j=0; j < entries.size(); j++) {
      mRenderPaint.setColor(dataSet.getColor(j));
      Entry e=entries.get(j);
      PointF p=getPosition(c,e.getVal() * factor,sliceangle * j + mRotationAngle);
      if (j == 0)       surface.moveTo(p.x,p.y);
 else       surface.lineTo(p.x,p.y);
    }
    surface.close();
    if (dataSet.isDrawFilledEnabled()) {
      mRenderPaint.setStyle(Paint.Style.FILL);
      mRenderPaint.setAlpha(dataSet.getFillAlpha());
      mDrawCanvas.drawPath(surface,mRenderPaint);
      mRenderPaint.setAlpha(255);
    }
    mRenderPaint.setStrokeWidth(dataSet.getLineWidth());
    mRenderPaint.setStyle(Paint.Style.STROKE);
    if (!dataSet.isDrawFilledEnabled() || dataSet.getFillAlpha() < 255)     mDrawCanvas.drawPath(surface,mRenderPaint);
  }
}