nus-yam/ex-repair huggingface dataset:
Program: 18832
Project: 18832
Buggy source:
private void setData(int count,float range){
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < count; i++) {
    xVals.add((i) + "String_Node_Str");
  }
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < count; i++) {
    float mult=(range + 1);
    float val=(float)(Math.random() * mult) + 3;
    yVals.add(new Entry(val,i));
  }
  LineDataSet set1=new LineDataSet(yVals,"String_Node_Str");
  set1.enableDashedLine(10f,5f,0f);
  set1.setLineWidth(1f);
  set1.setCircleSize(4f);
  ArrayList<LineDataSet> dataSets=new ArrayList<LineDataSet>();
  dataSets.add(set1);
  LineData data=new LineData(xVals,dataSets);
  LimitLine ll1=new LimitLine(130f);
  ll1.setLineWidth(4f);
  ll1.enableDashedLine(10f,10f,0f);
  LimitLine ll2=new LimitLine(-30f);
  ll2.setLineWidth(4f);
  ll2.enableDashedLine(10f,10f,0f);
  data.addLimitLine(ll1);
  data.addLimitLine(ll2);
  mChart.setData(data);
}

Fixed version (ground truth):
private void setData(int count,float range){
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < count; i++) {
    xVals.add((i) + "String_Node_Str");
  }
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < count; i++) {
    float mult=(range + 1);
    float val=(float)(Math.random() * mult) + 3;
    yVals.add(new Entry(val,i));
  }
  LineDataSet set1=new LineDataSet(yVals,"String_Node_Str");
  set1.enableDashedLine(10f,5f,0f);
  set1.setColor(Color.BLACK);
  set1.setCircleColor(Color.BLACK);
  set1.setLineWidth(1f);
  set1.setCircleSize(4f);
  set1.setFillAlpha(65);
  set1.setFillColor(Color.BLACK);
  ArrayList<LineDataSet> dataSets=new ArrayList<LineDataSet>();
  dataSets.add(set1);
  LineData data=new LineData(xVals,dataSets);
  LimitLine ll1=new LimitLine(130f);
  ll1.setLineWidth(4f);
  ll1.enableDashedLine(10f,10f,0f);
  LimitLine ll2=new LimitLine(-30f);
  ll2.setLineWidth(4f);
  ll2.enableDashedLine(10f,10f,0f);
  data.addLimitLine(ll1);
  data.addLimitLine(ll2);
  mChart.setData(data);
}
Program: 18833
Project: 18833
Buggy source:
/** 
 * sets up the content rect that restricts the chart surface
 */
protected void prepareContentRect(){
  mContentRect.set((int)mOffsetLeft,(int)mOffsetTop,getMeasuredWidth() - (int)mOffsetRight,getMeasuredHeight() - (int)mOffsetBottom + 1);
}

Fixed version (ground truth):
/** 
 * sets up the content rect that restricts the chart surface
 */
protected void prepareContentRect(){
  mContentRect.set((int)mOffsetLeft - 1,(int)mOffsetTop,getMeasuredWidth() - (int)mOffsetRight + 1,getMeasuredHeight() - (int)mOffsetBottom + 1);
}
Program: 18834
Project: 18834
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: 18835
Project: 18835
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: 18836
Project: 18836
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: 18837
Project: 18837
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: 18838
Project: 18838
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: 18840
Project: 18840
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: 18841
Project: 18841
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: 18842
Project: 18842
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: 18843
Project: 18843
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: 18844
Project: 18844
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: 18845
Project: 18845
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: 18846
Project: 18846
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: 18847
Project: 18847
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: 18848
Project: 18848
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: 18849
Project: 18849
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: 18850
Project: 18850
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: 18851
Project: 18851
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: 18852
Project: 18852
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);
  }
}
Program: 18853
Project: 18853
Buggy source:
/** 
 * Draws the spider web.
 */
private void drawWeb(){
  float sliceangle=getSliceAngle();
  float factor=getFactor();
  PointF c=getCenter();
  mWebPaint.setStrokeWidth(mWebLineWidth);
  mWebPaint.setColor(mWebColor);
  mWebPaint.setAlpha(mWebAlpha);
  for (int i=0; i < mCurrentData.getXValCount(); i++) {
    PointF p=getPosition(c,mYChartMax * factor,sliceangle * i + mRotationAngle);
    mDrawCanvas.drawLine(c.x,c.y,p.x,p.y,mWebPaint);
  }
  mWebPaint.setStrokeWidth(mInnerWebLineWidth);
  mWebPaint.setColor(mWebColorInner);
  mWebPaint.setAlpha(mWebAlpha);
  int labelCount=mYLabels.mEntryCount;
  for (int j=0; j < labelCount; j++) {
    for (int i=0; i < mCurrentData.getXValCount(); i++) {
      float r=((mYChartMax / labelCount) * (j + 1)) * factor;
      PointF p1=getPosition(c,r,sliceangle * i + mRotationAngle);
      PointF p2=getPosition(c,r,sliceangle * (i + 1) + mRotationAngle);
      mDrawCanvas.drawLine(p1.x,p1.y,p2.x,p2.y,mWebPaint);
    }
  }
}

Fixed version (ground truth):
/** 
 * Draws the spider web.
 */
private void drawWeb(){
  float sliceangle=getSliceAngle();
  float factor=getFactor();
  PointF c=getCenterOffsets();
  mWebPaint.setStrokeWidth(mWebLineWidth);
  mWebPaint.setColor(mWebColor);
  mWebPaint.setAlpha(mWebAlpha);
  for (int i=0; i < mCurrentData.getXValCount(); i++) {
    PointF p=getPosition(c,mYChartMax * factor,sliceangle * i + mRotationAngle);
    mDrawCanvas.drawLine(c.x,c.y,p.x,p.y,mWebPaint);
  }
  mWebPaint.setStrokeWidth(mInnerWebLineWidth);
  mWebPaint.setColor(mWebColorInner);
  mWebPaint.setAlpha(mWebAlpha);
  int labelCount=mYLabels.mEntryCount;
  for (int j=0; j < labelCount; j++) {
    for (int i=0; i < mCurrentData.getXValCount(); i++) {
      float r=((mYChartMax / labelCount) * (j + 1)) * factor;
      PointF p1=getPosition(c,r,sliceangle * i + mRotationAngle);
      PointF p2=getPosition(c,r,sliceangle * (i + 1) + mRotationAngle);
      mDrawCanvas.drawLine(p1.x,p1.y,p2.x,p2.y,mWebPaint);
    }
  }
}
Program: 18854
Project: 18854
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=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,mYLabels.isSeparateThousandsEnabled()),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);
    float val=r / factor;
    String label=Utils.formatNumber(val,mYLabels.mDecimals,mYLabels.isSeparateThousandsEnabled());
    mDrawCanvas.drawText(label,p.x + 10,p.y - 5,mYLabelPaint);
  }
}
Program: 18855
Project: 18855
Buggy source:
/** 
 * Formats the given number to the given number of decimals, and returns the number as a string, maximum 35 characters.
 * @param number
 * @param digitCount
 * @param separateTousands set this to true to separate thousands values
 * @return
 */
public static String formatNumber(float number,int digitCount,boolean separateThousands){
  char[] out=new char[35];
  boolean neg=false;
  if (number == 0) {
    return "String_Node_Str";
  }
  boolean zero=false;
  if (number < 1 && number > -1) {
    zero=true;
  }
  if (number < 0) {
    neg=true;
    number=-number;
  }
  if (digitCount > POW_10.length) {
    digitCount=POW_10.length - 1;
  }
  number*=POW_10[digitCount];
  long lval=Math.round(number);
  int ind=out.length - 1;
  int charCount=0;
  boolean decimalPointAdded=false;
  while (lval != 0 || charCount < (digitCount + 1)) {
    int digit=(int)(lval % 10);
    lval=lval / 10;
    out[ind--]=(char)(digit + '0');
    charCount++;
    if (charCount == digitCount) {
      out[ind--]=',';
      charCount++;
      decimalPointAdded=true;
    }
 else     if (separateThousands && lval != 0 && charCount > digitCount) {
      if (decimalPointAdded) {
        if ((charCount - digitCount) % 4 == 0) {
          out[ind--]='.';
          charCount++;
        }
      }
 else {
        if ((charCount - digitCount) % 4 == 3) {
          out[ind--]='.';
          charCount++;
        }
      }
    }
  }
  if (zero)   out[ind--]='0';
  if (neg)   out[ind--]='-';
  return new String(out);
}

Fixed version (ground truth):
/** 
 * Formats the given number to the given number of decimals, and returns the number as a string, maximum 35 characters.
 * @param number
 * @param digitCount
 * @param separateTousands set this to true to separate thousands values
 * @return
 */
public static String formatNumber(float number,int digitCount,boolean separateThousands){
  char[] out=new char[35];
  boolean neg=false;
  if (number == 0) {
    return "String_Node_Str";
  }
  boolean zero=false;
  if (number < 1 && number > -1) {
    zero=true;
  }
  if (number < 0) {
    neg=true;
    number=-number;
  }
  if (digitCount > POW_10.length) {
    digitCount=POW_10.length - 1;
  }
  number*=POW_10[digitCount];
  long lval=Math.round(number);
  int ind=out.length - 1;
  int charCount=0;
  boolean decimalPointAdded=false;
  while (lval != 0 || charCount < (digitCount + 1)) {
    int digit=(int)(lval % 10);
    lval=lval / 10;
    out[ind--]=(char)(digit + '0');
    charCount++;
    if (charCount == digitCount) {
      out[ind--]=',';
      charCount++;
      decimalPointAdded=true;
    }
 else     if (separateThousands && lval != 0 && charCount > digitCount) {
      if (decimalPointAdded) {
        if ((charCount - digitCount) % 4 == 0) {
          out[ind--]='.';
          charCount++;
        }
      }
 else {
        if ((charCount - digitCount) % 4 == 3) {
          out[ind--]='.';
          charCount++;
        }
      }
    }
  }
  if (zero)   out[ind--]='0';
  if (neg)   out[ind--]='-';
  int start=out.length - charCount;
  return String.valueOf(out,start,out.length - start);
}
Program: 18858
Project: 18858
Buggy source:
/** 
 * Returns the first Entry object found at the given xIndex with binary search. Returns null if no Entry object at that index. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @param xIndex
 * @return
 */
public Entry getEntryForXIndex(int x){
  int low=0;
  int high=mYVals.size();
  while (low <= high) {
    int m=(high + low) / 2;
    if (x == mYVals.get(m).getXIndex()) {
      return mYVals.get(m);
    }
    if (x > mYVals.get(m).getXIndex())     low=m + 1;
 else     high=m - 1;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the first Entry object found at the given xIndex with binary search. Returns null if no Entry object at that index. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @param xIndex
 * @return
 */
public Entry getEntryForXIndex(int x){
  int low=0;
  int high=mYVals.size() - 1;
  while (low <= high) {
    int m=(high + low) / 2;
    if (x == mYVals.get(m).getXIndex()) {
      return mYVals.get(m);
    }
    if (x > mYVals.get(m).getXIndex())     low=m + 1;
 else     high=m - 1;
  }
  return null;
}
Program: 18860
Project: 18860
Buggy source:
/** 
 * Generates the path that is used for filled drawing.
 * @param entries
 * @return
 */
private Path generateFilledPath(ArrayList<? extends Entry> entries){
  Path filled=new Path();
  filled.moveTo(entries.get(0).getXIndex(),entries.get(0).getVal() * mPhaseY);
  for (int x=1; x < entries.size() * mPhaseX; x++) {
    Entry e=entries.get(x);
    filled.lineTo(e.getXIndex(),e.getVal() * mPhaseY);
  }
  filled.lineTo(entries.get((int)((entries.size() - 1) * mPhaseX)).getXIndex(),mYChartMin);
  filled.lineTo(entries.get(0).getXIndex(),mYChartMin);
  filled.close();
  return filled;
}

Fixed version (ground truth):
/** 
 * Generates the path that is used for filled drawing.
 * @param entries
 * @return
 */
private Path generateFilledPath(ArrayList<? extends Entry> entries,float fillMin){
  Path filled=new Path();
  filled.moveTo(entries.get(0).getXIndex(),entries.get(0).getVal() * mPhaseY);
  for (int x=1; x < entries.size() * mPhaseX; x++) {
    Entry e=entries.get(x);
    filled.lineTo(e.getXIndex(),e.getVal() * mPhaseY);
  }
  filled.lineTo(entries.get((int)((entries.size() - 1) * mPhaseX)).getXIndex(),fillMin);
  filled.lineTo(entries.get(0).getXIndex(),fillMin);
  filled.close();
  return filled;
}
Program: 18861
Project: 18861
Buggy source:
/** 
 * This method converts device specific pixels to density independent pixels. NEEDS UTILS TO BE INITIALIZED BEFORE USAGE.
 * @param px A value in px (pixels) unit. Which we need to convert into db
 * @return A float value to represent dp equivalent to px value
 */
public static float convertPixelsToDp(float px){
  if (mRes == null)   throw new IllegalStateException("String_Node_Str");
  DisplayMetrics metrics=mRes.getDisplayMetrics();
  float dp=px / (metrics.densityDpi / 160f);
  return dp;
}

Fixed version (ground truth):
/** 
 * This method converts device specific pixels to density independent pixels. NEEDS UTILS TO BE INITIALIZED BEFORE USAGE.
 * @param px A value in px (pixels) unit. Which we need to convert into db
 * @return A float value to represent dp equivalent to px value
 */
public static float convertPixelsToDp(float px){
  if (mRes == null) {
    Log.e("String_Node_Str","String_Node_Str");
    return px;
  }
  DisplayMetrics metrics=mRes.getDisplayMetrics();
  float dp=px / (metrics.densityDpi / 160f);
  return dp;
}
Program: 18862
Project: 18862
Buggy source:
/** 
 * This method converts dp unit to equivalent pixels, depending on device density. NEEDS UTILS TO BE INITIALIZED BEFORE USAGE.
 * @param dp A value in dp (density independent pixels) unit. Which we needto convert into pixels
 * @return A float value to represent px equivalent to dp depending ondevice density
 */
public static float convertDpToPixel(float dp){
  if (mRes == null)   throw new IllegalStateException("String_Node_Str");
  DisplayMetrics metrics=mRes.getDisplayMetrics();
  float px=dp * (metrics.densityDpi / 160f);
  return px;
}

Fixed version (ground truth):
/** 
 * This method converts dp unit to equivalent pixels, depending on device density. NEEDS UTILS TO BE INITIALIZED BEFORE USAGE.
 * @param dp A value in dp (density independent pixels) unit. Which we needto convert into pixels
 * @return A float value to represent px equivalent to dp depending ondevice density
 */
public static float convertDpToPixel(float dp){
  if (mRes == null) {
    Log.e("String_Node_Str","String_Node_Str");
    return dp;
  }
  DisplayMetrics metrics=mRes.getDisplayMetrics();
  float px=dp * (metrics.densityDpi / 160f);
  return px;
}
Program: 18863
Project: 18863
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.setOnChartValueSelectedListener(this);
  mChart.setDescription("String_Node_Str");
  mChart.setDrawYValues(false);
  mChart.setPinchZoom(false);
  mChart.setDrawBarShadow(false);
  mChart.setDrawGridBackground(false);
  mChart.setDrawHorizontalGrid(false);
  mSeekBarX.setProgress(10);
  mSeekBarY.setProgress(100);
  Typeface tf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
  l.setTypeface(tf);
  XLabels xl=mChart.getXLabels();
  xl.setCenterXLabelText(true);
  xl.setTypeface(tf);
  YLabels yl=mChart.getYLabels();
  yl.setTypeface(tf);
  mChart.setValueTypeface(tf);
}

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.setOnChartValueSelectedListener(this);
  mChart.setDescription("String_Node_Str");
  mChart.setDrawYValues(false);
  mChart.setPinchZoom(false);
  mChart.setDrawBarShadow(false);
  mChart.setDrawGridBackground(false);
  mChart.setDrawHorizontalGrid(false);
  MyMarkerView mv=new MyMarkerView(this,R.layout.custom_marker_view);
  mv.setOffsets(-mv.getMeasuredWidth() / 2,-mv.getMeasuredHeight());
  mChart.setMarkerView(mv);
  mSeekBarX.setProgress(10);
  mSeekBarY.setProgress(100);
  Typeface tf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
  l.setTypeface(tf);
  XLabels xl=mChart.getXLabels();
  xl.setCenterXLabelText(true);
  xl.setTypeface(tf);
  YLabels yl=mChart.getYLabels();
  yl.setTypeface(tf);
  mChart.setValueTypeface(tf);
}
Program: 18865
Project: 18865
Buggy source:
/** 
 * Draws the view that is displayed when a value is highlighted.
 * @param xIndex the selected x-index
 * @param dataSetIndex the index of the selected DataSet
 */
private void drawMarkerView(int xIndex,int dataSetIndex){
  Entry e=getEntryByDataSetIndex(xIndex,dataSetIndex);
  if (e == null) {
    return;
  }
  float xPos=(float)xIndex;
  if (this instanceof BarChart || this instanceof CandleStickChart)   xPos+=0.5f;
  float[] pts=new float[]{xPos,e.getVal() * mPhaseY};
  transformPointArray(pts);
  float posX=pts[0];
  float posY=pts[1];
  mMarkerView.refreshContent(e,dataSetIndex);
  mMarkerView.draw(mDrawCanvas,posX,posY);
}

Fixed version (ground truth):
/** 
 * Draws the view that is displayed when a value is highlighted.
 * @param xIndex the selected x-index
 * @param dataSetIndex the index of the selected DataSet
 */
private void drawMarkerView(int xIndex,int dataSetIndex){
  Entry e=getEntryByDataSetIndex(xIndex,dataSetIndex);
  if (e == null) {
    return;
  }
  float xPos=(float)xIndex;
  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;
  }
  float[] pts=new float[]{xPos,e.getVal() * mPhaseY};
  transformPointArray(pts);
  float posX=pts[0];
  float posY=pts[1];
  mMarkerView.refreshContent(e,dataSetIndex);
  mMarkerView.draw(mDrawCanvas,posX,posY);
}