nus-yam/ex-repair huggingface dataset:
Program: 26903
Project: 26903
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: 26904
Project: 26904
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: 26905
Project: 26905
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: 26907
Project: 26907
Buggy source:
/** 
 * set if the user should be allowed to draw onto the chart
 * @param drawingEnabled
 */
public void setDrawingEnabled(boolean drawingEnabled){
  if (mListener instanceof BarLineChartTouchListener) {
    ((BarLineChartTouchListener)mListener).setDrawingEnabled(drawingEnabled);
  }
}

Fixed version (ground truth):
/** 
 * set if the user should be allowed to draw onto the chart
 * @param drawingEnabled
 */
public void setDrawingEnabled(boolean drawingEnabled){
  if (mListener instanceof BarLineChartTouchListener) {
    ((BarLineChartTouchListener<?>)mListener).setDrawingEnabled(drawingEnabled);
  }
}
Program: 26908
Project: 26908
Buggy source:
@Override public DataSet copy(){
  ArrayList<BarEntry> yVals=new ArrayList<BarEntry>();
  for (int i=0; i < mYVals.size(); i++) {
    yVals.add(((BarEntry)mYVals.get(i)).copy());
  }
  BarDataSet copied=new BarDataSet(yVals,getLabel());
  copied.mColors=mColors;
  copied.mStackSize=mStackSize;
  copied.mBarSpace=mBarSpace;
  copied.mBarShadowColor=mBarShadowColor;
  copied.mStackLabels=mStackLabels;
  copied.mHighLightColor=mHighLightColor;
  copied.mHighLightAlpha=mHighLightAlpha;
  return copied;
}

Fixed version (ground truth):
@Override public DataSet<BarEntry> copy(){
  ArrayList<BarEntry> yVals=new ArrayList<BarEntry>();
  for (int i=0; i < mYVals.size(); i++) {
    yVals.add(((BarEntry)mYVals.get(i)).copy());
  }
  BarDataSet copied=new BarDataSet(yVals,getLabel());
  copied.mColors=mColors;
  copied.mStackSize=mStackSize;
  copied.mBarSpace=mBarSpace;
  copied.mBarShadowColor=mBarShadowColor;
  copied.mStackLabels=mStackLabels;
  copied.mHighLightColor=mHighLightColor;
  copied.mHighLightAlpha=mHighLightAlpha;
  return copied;
}
Program: 26909
Project: 26909
Buggy source:
@Override public DataSet copy(){
  ArrayList<CandleEntry> yVals=new ArrayList<CandleEntry>();
  for (int i=0; i < mYVals.size(); i++) {
    yVals.add(((CandleEntry)mYVals.get(i)).copy());
  }
  CandleDataSet copied=new CandleDataSet(yVals,getLabel());
  copied.mColors=mColors;
  copied.mShadowWidth=mShadowWidth;
  copied.mBodySpace=mBodySpace;
  copied.mHighLightColor=mHighLightColor;
  return copied;
}

Fixed version (ground truth):
@Override public DataSet<CandleEntry> copy(){
  ArrayList<CandleEntry> yVals=new ArrayList<CandleEntry>();
  for (int i=0; i < mYVals.size(); i++) {
    yVals.add(((CandleEntry)mYVals.get(i)).copy());
  }
  CandleDataSet copied=new CandleDataSet(yVals,getLabel());
  copied.mColors=mColors;
  copied.mShadowWidth=mShadowWidth;
  copied.mBodySpace=mBodySpace;
  copied.mHighLightColor=mHighLightColor;
  return copied;
}
Program: 26910
Project: 26910
Buggy source:
/** 
 * Provides an exact copy of the DataSet this method is used on.
 * @return
 */
public abstract DataSet copy();

Fixed version (ground truth):
/** 
 * Provides an exact copy of the DataSet this method is used on.
 * @return
 */
public abstract DataSet<T> copy();
Program: 26911
Project: 26911
Buggy source:
@Override public DataSet copy(){
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < mYVals.size(); i++) {
    yVals.add(mYVals.get(i).copy());
  }
  LineDataSet copied=new LineDataSet(yVals,getLabel());
  copied.mColors=mColors;
  copied.mCircleSize=mCircleSize;
  copied.mCircleColors=mCircleColors;
  copied.mDashPathEffect=mDashPathEffect;
  copied.mDrawCircles=mDrawCircles;
  copied.mDrawCubic=mDrawCubic;
  copied.mHighLightColor=mHighLightColor;
  return copied;
}

Fixed version (ground truth):
@Override public DataSet<Entry> copy(){
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < mYVals.size(); i++) {
    yVals.add(mYVals.get(i).copy());
  }
  LineDataSet copied=new LineDataSet(yVals,getLabel());
  copied.mColors=mColors;
  copied.mCircleSize=mCircleSize;
  copied.mCircleColors=mCircleColors;
  copied.mDashPathEffect=mDashPathEffect;
  copied.mDrawCircles=mDrawCircles;
  copied.mDrawCubic=mDrawCubic;
  copied.mHighLightColor=mHighLightColor;
  return copied;
}
Program: 26912
Project: 26912
Buggy source:
@Override public DataSet copy(){
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < mYVals.size(); i++) {
    yVals.add(mYVals.get(i).copy());
  }
  PieDataSet copied=new PieDataSet(yVals,getLabel());
  copied.mColors=mColors;
  copied.mSliceSpace=mSliceSpace;
  copied.mShift=mShift;
  return copied;
}

Fixed version (ground truth):
@Override public DataSet<Entry> copy(){
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < mYVals.size(); i++) {
    yVals.add(mYVals.get(i).copy());
  }
  PieDataSet copied=new PieDataSet(yVals,getLabel());
  copied.mColors=mColors;
  copied.mSliceSpace=mSliceSpace;
  copied.mShift=mShift;
  return copied;
}
Program: 26913
Project: 26913
Buggy source:
@Override public DataSet copy(){
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < mYVals.size(); i++) {
    yVals.add(mYVals.get(i).copy());
  }
  RadarDataSet copied=new RadarDataSet(yVals,getLabel());
  copied.mColors=mColors;
  copied.mHighLightColor=mHighLightColor;
  return copied;
}

Fixed version (ground truth):
@Override public DataSet<Entry> copy(){
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < mYVals.size(); i++) {
    yVals.add(mYVals.get(i).copy());
  }
  RadarDataSet copied=new RadarDataSet(yVals,getLabel());
  copied.mColors=mColors;
  copied.mHighLightColor=mHighLightColor;
  return copied;
}
Program: 26914
Project: 26914
Buggy source:
@Override public DataSet copy(){
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < mYVals.size(); i++) {
    yVals.add(mYVals.get(i).copy());
  }
  ScatterDataSet copied=new ScatterDataSet(yVals,getLabel());
  copied.mColors=mColors;
  copied.mShapeSize=mShapeSize;
  copied.mScatterShape=mScatterShape;
  copied.mCustomScatterPath=mCustomScatterPath;
  copied.mHighLightColor=mHighLightColor;
  return copied;
}

Fixed version (ground truth):
@Override public DataSet<Entry> copy(){
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < mYVals.size(); i++) {
    yVals.add(mYVals.get(i).copy());
  }
  ScatterDataSet copied=new ScatterDataSet(yVals,getLabel());
  copied.mColors=mColors;
  copied.mShapeSize=mShapeSize;
  copied.mScatterShape=mScatterShape;
  copied.mCustomScatterPath=mCustomScatterPath;
  copied.mHighLightColor=mHighLightColor;
  return copied;
}
Program: 26916
Project: 26916
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: 26917
Project: 26917
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: 26918
Project: 26918
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_candlechart);
  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=(CandleStickChart)findViewById(R.id.chart1);
  mChart.setDescription("String_Node_Str");
  mChart.setMaxVisibleValueCount(60);
  mChart.setPinchZoom(false);
  mChart.setDrawVerticalGrid(false);
  mChart.setDrawGridBackground(false);
  XLabels xLabels=mChart.getXLabels();
  xLabels.setPosition(XLabelPosition.BOTTOM);
  xLabels.setCenterXLabelText(true);
  xLabels.setSpaceBetweenLabels(2);
  YLabels yLabels=mChart.getYLabels();
  yLabels.setLabelCount(7);
  yLabels.setPosition(YLabelPosition.RIGHT_INSIDE);
  mChart.setDrawYLabels(true);
  mChart.setDrawLegend(false);
  mSeekBarX.setProgress(15);
  mSeekBarY.setProgress(100);
}

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_candlechart);
  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=(CandleStickChart)findViewById(R.id.chart1);
  mChart.setDescription("String_Node_Str");
  mChart.setMaxVisibleValueCount(60);
  mChart.setPinchZoom(false);
  mChart.setDrawVerticalGrid(false);
  mChart.setDrawGridBackground(false);
  XLabels xLabels=mChart.getXLabels();
  xLabels.setPosition(XLabelPosition.BOTTOM);
  xLabels.setCenterXLabelText(true);
  xLabels.setSpaceBetweenLabels(2);
  YLabels yLabels=mChart.getYLabels();
  yLabels.setLabelCount(7);
  yLabels.setPosition(YLabelPosition.LEFT);
  mChart.setDrawYLabels(true);
  mChart.setDrawLegend(false);
  mSeekBarX.setProgress(15);
  mSeekBarY.setProgress(100);
}
Program: 26919
Project: 26919
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_linechart_noseekbar);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setDrawYValues(false);
  mChart.setDrawGridBackground(false);
  mChart.setDescription("String_Node_Str");
  String[] xVals=new String[30];
  for (int i=0; i < 30; i++)   xVals[i]="String_Node_Str" + i;
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < 10; i++)   yVals.add(new Entry((float)(Math.random() * 50) + 50f,i));
  LineDataSet set=new LineDataSet(yVals,"String_Node_Str");
  set.setLineWidth(2.5f);
  set.setCircleSize(4.5f);
  set.setColor(Color.rgb(240,99,99));
  set.setCircleColor(Color.rgb(240,99,99));
  set.setHighLightColor(Color.rgb(190,190,190));
  mData=new LineData(xVals,set);
  mChart.setData(mData);
  mChart.invalidate();
}

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_linechart_noseekbar);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setDrawYValues(false);
  mChart.setDrawGridBackground(false);
  mChart.setDescription("String_Node_Str");
  String[] xVals=new String[30];
  for (int i=0; i < 30; i++)   xVals[i]="String_Node_Str" + i;
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < 10; i++)   yVals.add(new Entry((float)(Math.random() * 50) + 50f,i));
  LineDataSet set=new LineDataSet(yVals,"String_Node_Str");
  set.setLineWidth(2.5f);
  set.setCircleSize(4.5f);
  set.setColor(Color.rgb(240,99,99));
  set.setCircleColor(Color.rgb(240,99,99));
  set.setHighLightColor(Color.rgb(190,190,190));
  LineData data=new LineData(xVals,set);
  mChart.setData(data);
  mChart.invalidate();
}
Program: 26920
Project: 26920
Buggy source:
private void removeDataSet(){
  mData.removeDataSet(mData.getDataSetByIndex(mData.getDataSetCount() - 1));
  mChart.notifyDataSetChanged();
  mChart.invalidate();
}

Fixed version (ground truth):
private void removeDataSet(){
  LineData data=mChart.getDataOriginal();
  data.removeDataSet(data.getDataSetByIndex(data.getDataSetCount() - 1));
  mChart.notifyDataSetChanged();
  mChart.invalidate();
}
Program: 26921
Project: 26921
Buggy source:
private void addEntry(){
  LineDataSet set=mData.getDataSetByIndex(0);
  mData.addEntry(new Entry((float)(Math.random() * 50) + 50f,set.getEntryCount()),0);
  mChart.notifyDataSetChanged();
  mChart.invalidate();
}

Fixed version (ground truth):
private void addEntry(){
  LineData data=mChart.getDataOriginal();
  LineDataSet set=data.getDataSetByIndex(0);
  data.addEntry(new Entry((float)(Math.random() * 50) + 50f,set.getEntryCount()),0);
  mChart.notifyDataSetChanged();
  mChart.invalidate();
}
Program: 26922
Project: 26922
Buggy source:
private void removeLastEntry(){
  LineDataSet set=mData.getDataSetByIndex(0);
  Entry e=set.getEntryForXIndex(set.getEntryCount() - 1);
  mData.removeEntry(e,0);
  mChart.notifyDataSetChanged();
  mChart.invalidate();
}

Fixed version (ground truth):
private void removeLastEntry(){
  LineData data=mChart.getDataOriginal();
  LineDataSet set=data.getDataSetByIndex(0);
  Entry e=set.getEntryForXIndex(set.getEntryCount() - 1);
  data.removeEntry(e,0);
  mChart.notifyDataSetChanged();
  mChart.invalidate();
}
Program: 26923
Project: 26923
Buggy source:
private void addDataSet(){
  int count=(mData.getDataSetCount() + 1);
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < mData.getXValCount(); i++)   yVals.add(new Entry((float)(Math.random() * 50f) + 50f * count,i));
  LineDataSet set=new LineDataSet(yVals,"String_Node_Str" + count);
  set.setLineWidth(2.5f);
  set.setCircleSize(4.5f);
  int color=getResources().getColor(mColors[count % mColors.length]);
  set.setColor(color);
  set.setCircleColor(color);
  set.setHighLightColor(color);
  mData.addDataSet(set);
  mChart.notifyDataSetChanged();
  mChart.invalidate();
}

Fixed version (ground truth):
private void addDataSet(){
  LineData data=mChart.getDataOriginal();
  int count=(data.getDataSetCount() + 1);
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  for (int i=0; i < data.getXValCount(); i++)   yVals.add(new Entry((float)(Math.random() * 50f) + 50f * count,i));
  LineDataSet set=new LineDataSet(yVals,"String_Node_Str" + count);
  set.setLineWidth(2.5f);
  set.setCircleSize(4.5f);
  int color=getResources().getColor(mColors[count % mColors.length]);
  set.setColor(color);
  set.setCircleColor(color);
  set.setHighLightColor(color);
  data.addDataSet(set);
  mChart.notifyDataSetChanged();
  mChart.invalidate();
}
Program: 26924
Project: 26924
Buggy source:
@Override protected void drawXLabels(float yPos){
  float[] position=new float[]{0f,0f};
  BarData bd=(BarData)mCurrentData;
  int step=mCurrentData.getDataSetCount();
  for (int i=0; i < mCurrentData.getXValCount(); i+=mXLabels.mXAxisLabelModulus) {
    position[0]=i * step + i * bd.getGroupSpace() + bd.getGroupSpace() / 2f;
    if (mXLabels.isCenterXLabelsEnabled())     position[0]+=(step / 2f);
    transformPointArray(position);
    if (position[0] >= mOffsetLeft && position[0] <= getWidth() - mOffsetRight) {
      String label=mCurrentData.getXVals().get(i);
      if (mXLabels.isAvoidFirstLastClippingEnabled()) {
        if (i == mCurrentData.getXValCount() - 1) {
          float width=Utils.calcTextWidth(mXLabelPaint,label);
          if (width > getOffsetRight() * 2 && position[0] + width > getWidth())           position[0]-=width / 2;
        }
 else         if (i == 0) {
          float width=Utils.calcTextWidth(mXLabelPaint,label);
          position[0]+=width / 2;
        }
      }
      mDrawCanvas.drawText(label,position[0],yPos,mXLabelPaint);
    }
  }
}

Fixed version (ground truth):
@Override protected void drawXLabels(float yPos){
  float[] position=new float[]{0f,0f};
  int step=mCurrentData.getDataSetCount();
  for (int i=0; i < mCurrentData.getXValCount(); i+=mXLabels.mXAxisLabelModulus) {
    position[0]=i * step + i * mOriginalData.getGroupSpace() + mOriginalData.getGroupSpace() / 2f;
    if (mXLabels.isCenterXLabelsEnabled())     position[0]+=(step / 2f);
    transformPointArray(position);
    if (position[0] >= mOffsetLeft && position[0] <= getWidth() - mOffsetRight) {
      String label=mCurrentData.getXVals().get(i);
      if (mXLabels.isAvoidFirstLastClippingEnabled()) {
        if (i == mCurrentData.getXValCount() - 1) {
          float width=Utils.calcTextWidth(mXLabelPaint,label);
          if (width > getOffsetRight() * 2 && position[0] + width > getWidth())           position[0]-=width / 2;
        }
 else         if (i == 0) {
          float width=Utils.calcTextWidth(mXLabelPaint,label);
          position[0]+=width / 2;
        }
      }
      mDrawCanvas.drawText(label,position[0],yPos,mXLabelPaint);
    }
  }
}
Program: 26925
Project: 26925
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 || 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);
}

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();
  float space=(float)(((float)valCount / (float)setCount) / (mDeltaX / base));
  float reduction=(float)space * mOriginalData.getGroupSpace();
  int xIndex=(int)((base - reduction) / setCount);
  int dataSetIndex=((int)(base - reduction)) % setCount;
  if (dataSetIndex == -1)   return null;
  return new Highlight(xIndex,dataSetIndex);
}
Program: 26926
Project: 26926
Buggy source:
@Override protected void calcMinMax(boolean fixedValues){
  super.calcMinMax(fixedValues);
  mDeltaX++;
  mDeltaX*=mOriginalData.getDataSetCount();
  int maxEntry=0;
  for (int i=0; i < mOriginalData.getDataSetCount(); i++) {
    DataSet<? extends Entry> set=mOriginalData.getDataSetByIndex(i);
    if (maxEntry < set.getEntryCount())     maxEntry=set.getEntryCount();
  }
  float groupSpace=((BarData)mOriginalData).getGroupSpace();
  mDeltaX+=maxEntry * groupSpace;
}

Fixed version (ground truth):
@Override protected void calcMinMax(boolean fixedValues){
  super.calcMinMax(fixedValues);
  mDeltaX++;
  mDeltaX*=mOriginalData.getDataSetCount();
  int maxEntry=0;
  for (int i=0; i < mOriginalData.getDataSetCount(); i++) {
    DataSet<? extends Entry> set=mOriginalData.getDataSetByIndex(i);
    if (maxEntry < set.getEntryCount())     maxEntry=set.getEntryCount();
  }
  float groupSpace=mOriginalData.getGroupSpace();
  mDeltaX+=maxEntry * groupSpace;
}
Program: 26927
Project: 26927
Buggy source:
@Override protected void drawHighlights(){
  BarData bd=(BarData)mOriginalData;
  int setCount=mOriginalData.getDataSetCount();
  for (int i=0; i < mIndicesToHightlight.length; i++) {
    Highlight h=mIndicesToHightlight[i];
    int index=h.getXIndex();
    int dataSetIndex=h.getDataSetIndex();
    BarDataSet ds=(BarDataSet)mCurrentData.getDataSetByIndex(dataSetIndex);
    mHighlightPaint.setColor(ds.getHighLightColor());
    mHighlightPaint.setAlpha(ds.getHighLightAlpha());
    if (index < mCurrentData.getYValCount() && index >= 0 && index < (mDeltaX * mPhaseX) / mOriginalData.getDataSetCount()) {
      Entry e=getEntryByDataSetIndex(index,dataSetIndex);
      if (e == null)       continue;
      float x=index * setCount + dataSetIndex + bd.getGroupSpace() / 2f + bd.getGroupSpace() * index;
      float y=e.getVal();
      prepareBar(x,y,ds.getBarSpace());
      mDrawCanvas.drawRect(mBarRect,mHighlightPaint);
      if (mDrawHighlightArrow) {
        mHighlightPaint.setAlpha(255);
        float offsetY=mDeltaY * 0.07f;
        Path arrow=new Path();
        arrow.moveTo(x + 0.5f,y + offsetY * 0.3f);
        arrow.lineTo(x + 0.2f,y + offsetY);
        arrow.lineTo(x + 0.8f,y + offsetY);
        transformPath(arrow);
        mDrawCanvas.drawPath(arrow,mHighlightPaint);
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void drawHighlights(){
  int setCount=mOriginalData.getDataSetCount();
  for (int i=0; i < mIndicesToHightlight.length; i++) {
    Highlight h=mIndicesToHightlight[i];
    int index=h.getXIndex();
    int dataSetIndex=h.getDataSetIndex();
    BarDataSet ds=(BarDataSet)mCurrentData.getDataSetByIndex(dataSetIndex);
    mHighlightPaint.setColor(ds.getHighLightColor());
    mHighlightPaint.setAlpha(ds.getHighLightAlpha());
    if (index < mCurrentData.getYValCount() && index >= 0 && index < (mDeltaX * mPhaseX) / mOriginalData.getDataSetCount()) {
      Entry e=getEntryByDataSetIndex(index,dataSetIndex);
      if (e == null)       continue;
      float x=index * setCount + dataSetIndex + mOriginalData.getGroupSpace() / 2f + mOriginalData.getGroupSpace() * index;
      float y=e.getVal();
      prepareBar(x,y,ds.getBarSpace());
      mDrawCanvas.drawRect(mBarRect,mHighlightPaint);
      if (mDrawHighlightArrow) {
        mHighlightPaint.setAlpha(255);
        float offsetY=mDeltaY * 0.07f;
        Path arrow=new Path();
        arrow.moveTo(x + 0.5f,y + offsetY * 0.3f);
        arrow.lineTo(x + 0.2f,y + offsetY);
        arrow.lineTo(x + 0.8f,y + offsetY);
        transformPath(arrow);
        mDrawCanvas.drawPath(arrow,mHighlightPaint);
      }
    }
  }
}
Program: 26929
Project: 26929
Buggy source:
@Override protected void drawVerticalGrid(){
  if (!mDrawVerticalGrid || mCurrentData == null)   return;
  float[] position=new float[]{0f,0f};
  BarData bd=(BarData)mCurrentData;
  int step=mCurrentData.getDataSetCount();
  for (int i=0; i < mCurrentData.getXValCount(); i+=mXLabels.mXAxisLabelModulus) {
    position[0]=i * step + i * bd.getGroupSpace();
    transformPointArray(position);
    if (position[0] >= mOffsetLeft && position[0] <= getWidth()) {
      mDrawCanvas.drawLine(position[0],mOffsetTop,position[0],getHeight() - mOffsetBottom,mGridPaint);
    }
  }
}

Fixed version (ground truth):
@Override protected void drawVerticalGrid(){
  if (!mDrawVerticalGrid || mCurrentData == null)   return;
  float[] position=new float[]{0f,0f};
  int step=mCurrentData.getDataSetCount();
  for (int i=0; i < mCurrentData.getXValCount(); i+=mXLabels.mXAxisLabelModulus) {
    position[0]=i * step + i * mOriginalData.getGroupSpace();
    transformPointArray(position);
    if (position[0] >= mOffsetLeft && position[0] <= getWidth()) {
      mDrawCanvas.drawLine(position[0],mOffsetTop,position[0],getHeight() - mOffsetBottom,mGridPaint);
    }
  }
}
Program: 26930
Project: 26930
Buggy source:
/** 
 * returns the filtered ChartData object depending on approximator settings, current scale level and x- and y-axis ratio
 * @return
 */
private ChartData<? extends DataSet<? extends Entry>> getFilteredData(){
  return null;
}

Fixed version (ground truth):
/** 
 * returns the filtered ChartData object depending on approximator settings, current scale level and x- and y-axis ratio
 * @return
 */
private T getFilteredData(){
  return null;
}
Program: 26931
Project: 26931
Buggy source:
/** 
 * Draws the limit lines if there are one.
 */
private void drawLimitLines(){
  ArrayList<LimitLine> limitLines=((BarLineScatterCandleRadarData<? extends DataSet<? extends Entry>>)mOriginalData).getLimitLines();
  if (limitLines == null)   return;
  float[] pts=new float[]{0,0,0,0};
  for (int i=0; i < limitLines.size(); i++) {
    LimitLine l=limitLines.get(i);
    pts[0]=0f;
    pts[1]=l.getLimit();
    pts[2]=mDeltaX;
    pts[3]=l.getLimit();
    transformPointArray(pts);
    mLimitLinePaint.setColor(l.getLineColor());
    mLimitLinePaint.setPathEffect(l.getDashPathEffect());
    mLimitLinePaint.setStrokeWidth(l.getLineWidth());
    mDrawCanvas.drawLine(pts[0],pts[1],pts[2],pts[3],mLimitLinePaint);
  }
}

Fixed version (ground truth):
/** 
 * Draws the limit lines if there are one.
 */
private void drawLimitLines(){
  ArrayList<LimitLine> limitLines=mOriginalData.getLimitLines();
  if (limitLines == null)   return;
  float[] pts=new float[]{0,0,0,0};
  for (int i=0; i < limitLines.size(); i++) {
    LimitLine l=limitLines.get(i);
    pts[0]=0f;
    pts[1]=l.getLimit();
    pts[2]=mDeltaX;
    pts[3]=l.getLimit();
    transformPointArray(pts);
    mLimitLinePaint.setColor(l.getLineColor());
    mLimitLinePaint.setPathEffect(l.getDashPathEffect());
    mLimitLinePaint.setStrokeWidth(l.getLineWidth());
    mDrawCanvas.drawLine(pts[0],pts[1],pts[2],pts[3],mLimitLinePaint);
  }
}
Program: 26932
Project: 26932
Buggy source:
@Override protected void drawData(){
  ArrayList<CandleDataSet> dataSets=((CandleData)mCurrentData).getDataSets();
  float[] shadowPoints=new float[4];
  float[] bodyPoints=new float[4];
  for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
    CandleDataSet dataSet=dataSets.get(i);
    ArrayList<CandleEntry> entries=dataSet.getYVals();
    mRenderPaint.setStrokeWidth(dataSet.getShadowWidth());
    for (int j=0; j < entries.size() * mPhaseX; j++) {
      mRenderPaint.setColor(dataSet.getColor(j));
      CandleEntry e=entries.get(j);
      transformShadow(shadowPoints,e);
      transformBody(bodyPoints,e,dataSet.getBodySpace());
      float xShadow=shadowPoints[0];
      float leftBody=bodyPoints[0];
      float rightBody=bodyPoints[2];
      float high=shadowPoints[1];
      float low=shadowPoints[3];
      float open=bodyPoints[1];
      float close=bodyPoints[3];
      if (isOffContentRight(leftBody))       break;
      if (isOffContentLeft(rightBody) && isOffContentTop(low) && isOffContentBottom(high))       continue;
      mDrawCanvas.drawLine(xShadow,low,xShadow,high,mRenderPaint);
      if (open > close) {
        mRenderPaint.setStyle(Paint.Style.FILL);
        mDrawCanvas.drawRect(leftBody,close,rightBody,open,mRenderPaint);
      }
 else {
        mRenderPaint.setStyle(Paint.Style.STROKE);
        mDrawCanvas.drawRect(leftBody,open,rightBody,close,mRenderPaint);
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void drawData(){
  ArrayList<CandleDataSet> dataSets=mCurrentData.getDataSets();
  float[] shadowPoints=new float[4];
  float[] bodyPoints=new float[4];
  for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
    CandleDataSet dataSet=dataSets.get(i);
    ArrayList<CandleEntry> entries=dataSet.getYVals();
    mRenderPaint.setStrokeWidth(dataSet.getShadowWidth());
    for (int j=0; j < entries.size() * mPhaseX; j++) {
      mRenderPaint.setColor(dataSet.getColor(j));
      CandleEntry e=entries.get(j);
      transformShadow(shadowPoints,e);
      transformBody(bodyPoints,e,dataSet.getBodySpace());
      float xShadow=shadowPoints[0];
      float leftBody=bodyPoints[0];
      float rightBody=bodyPoints[2];
      float high=shadowPoints[1];
      float low=shadowPoints[3];
      float open=bodyPoints[1];
      float close=bodyPoints[3];
      if (isOffContentRight(leftBody))       break;
      if (isOffContentLeft(rightBody) && isOffContentTop(low) && isOffContentBottom(high))       continue;
      mDrawCanvas.drawLine(xShadow,low,xShadow,high,mRenderPaint);
      if (open > close) {
        mRenderPaint.setStyle(Paint.Style.FILL);
        mDrawCanvas.drawRect(leftBody,close,rightBody,open,mRenderPaint);
      }
 else {
        mRenderPaint.setStyle(Paint.Style.STROKE);
        mDrawCanvas.drawRect(leftBody,open,rightBody,close,mRenderPaint);
      }
    }
  }
}
Program: 26933
Project: 26933
Buggy source:
@Override protected void drawHighlights(){
  CandleData cd=(CandleData)mCurrentData;
  for (int i=0; i < mIndicesToHightlight.length; i++) {
    int xIndex=mIndicesToHightlight[i].getXIndex();
    CandleDataSet set=cd.getDataSetByIndex(mIndicesToHightlight[i].getDataSetIndex());
    mHighlightPaint.setColor(set.getHighLightColor());
    CandleEntry e=set.getEntryForXIndex(xIndex);
    if (e == null)     continue;
    float low=e.getLow() * mPhaseY;
    float high=e.getHigh() * mPhaseY;
    float[] vertPts=new float[]{xIndex,mYChartMax,xIndex,mYChartMin,xIndex + 1f,mYChartMax,xIndex + 1f,mYChartMin};
    float[] horPts=new float[]{0,low,mDeltaX,low,0,high,mDeltaX,high};
    transformPointArray(vertPts);
    transformPointArray(horPts);
    mDrawCanvas.drawLines(vertPts,mHighlightPaint);
    mDrawCanvas.drawLines(horPts,mHighlightPaint);
  }
}

Fixed version (ground truth):
@Override protected void drawHighlights(){
  for (int i=0; i < mIndicesToHightlight.length; i++) {
    int xIndex=mIndicesToHightlight[i].getXIndex();
    CandleDataSet set=mOriginalData.getDataSetByIndex(mIndicesToHightlight[i].getDataSetIndex());
    mHighlightPaint.setColor(set.getHighLightColor());
    CandleEntry e=set.getEntryForXIndex(xIndex);
    if (e == null)     continue;
    float low=e.getLow() * mPhaseY;
    float high=e.getHigh() * mPhaseY;
    float[] vertPts=new float[]{xIndex,mYChartMax,xIndex,mYChartMin,xIndex + 1f,mYChartMax,xIndex + 1f,mYChartMin};
    float[] horPts=new float[]{0,low,mDeltaX,low,0,high,mDeltaX,high};
    transformPointArray(vertPts);
    transformPointArray(horPts);
    mDrawCanvas.drawLines(vertPts,mHighlightPaint);
    mDrawCanvas.drawLines(horPts,mHighlightPaint);
  }
}
Program: 26936
Project: 26936
Buggy source:
private void setData(int count,float range){
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < count; i++) {
    xVals.add(mMonths[i % 12]);
  }
  ArrayList<BarEntry> yVals1=new ArrayList<BarEntry>();
  for (int i=0; i < count; i++) {
    float mult=(range + 1);
    float val=(float)(Math.random() * mult) + 3;
    yVals1.add(new BarEntry(val,i));
  }
  BarDataSet set1=new BarDataSet(yVals1,"String_Node_Str");
  set1.setBarSpacePercent(35f);
  ArrayList<BarDataSet> dataSets=new ArrayList<BarDataSet>();
  dataSets.add(set1);
  BarData data=new BarData(xVals,dataSets);
  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(mMonths[i % 12]);
  }
  ArrayList<BarEntry> yVals1=new ArrayList<BarEntry>();
  for (int i=0; i < count; i++) {
    float mult=(range + 1);
    float val=(float)(Math.random() * mult);
    yVals1.add(new BarEntry(val,i));
  }
  BarDataSet set1=new BarDataSet(yVals1,"String_Node_Str");
  set1.setBarSpacePercent(35f);
  ArrayList<BarDataSet> dataSets=new ArrayList<BarDataSet>();
  dataSets.add(set1);
  BarData data=new BarData(xVals,dataSets);
  mChart.setData(data);
}
Program: 26937
Project: 26937
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_linechart);
  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.setProgress(45);
  mSeekBarY.setProgress(100);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setStartAtZero(false);
  mChart.setDrawYValues(false);
  mChart.setDrawBorder(true);
  mChart.setBorderPositions(new BorderPosition[]{BorderPosition.BOTTOM});
  mChart.setDescription("String_Node_Str");
  mChart.setNoDataTextDescription("String_Node_Str");
  mChart.setHighlightEnabled(true);
  mChart.setTouchEnabled(true);
  mChart.setDragScaleEnabled(true);
  mChart.setPinchZoom(true);
  MyMarkerView mv=new MyMarkerView(this,R.layout.custom_marker_view);
  mv.setOffsets(-mv.getMeasuredWidth() / 2,-mv.getMeasuredHeight());
  mChart.setMarkerView(mv);
  mChart.setHighlightIndicatorEnabled(false);
  setData(45,100);
  mChart.animateX(2500);
  Legend l=mChart.getLegend();
  l.setForm(LegendForm.LINE);
  mChart.invalidate();
}

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_linechart);
  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.setProgress(45);
  mSeekBarY.setProgress(100);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setStartAtZero(false);
  mChart.setDrawYValues(false);
  mChart.setDrawBorder(true);
  mChart.setBorderPositions(new BorderPosition[]{BorderPosition.BOTTOM});
  mChart.setDescription("String_Node_Str");
  mChart.setNoDataTextDescription("String_Node_Str");
  mChart.setHighlightEnabled(true);
  mChart.setTouchEnabled(true);
  mChart.setDragScaleEnabled(true);
  mChart.setPinchZoom(true);
  MyMarkerView mv=new MyMarkerView(this,R.layout.custom_marker_view);
  mv.setOffsets(-mv.getMeasuredWidth() / 2,-mv.getMeasuredHeight());
  mChart.setMarkerView(mv);
  mChart.setHighlightIndicatorEnabled(false);
  setData(45,100);
  mChart.animateX(2500);
  Legend l=mChart.getLegend();
  l.setForm(LegendForm.LINE);
}
Program: 26938
Project: 26938
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: 26940
Project: 26940
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);
}