nus-yam/ex-repair huggingface dataset:
Program: 18933
Project: 18933
Buggy source:
@Override public View getView(int position,View convertView,Context c){
  ViewHolder holder=null;
  if (convertView == null) {
    holder=new ViewHolder();
    convertView=LayoutInflater.from(c).inflate(R.layout.list_item_piechart,null);
    holder.chart=(PieChart)convertView.findViewById(R.id.chart);
    convertView.setTag(holder);
  }
 else {
    holder=(ViewHolder)convertView.getTag();
  }
  holder.chart.setValueTypeface(mTf);
  holder.chart.setDescription("String_Node_Str");
  holder.chart.setHoleRadius(60f);
  holder.chart.setTransparentCircleRadius(65f);
  holder.chart.setCenterText("String_Node_Str");
  holder.chart.setCenterTextTypeface(mTf);
  holder.chart.setCenterTextSize(18f);
  holder.chart.setDrawXValues(false);
  holder.chart.setUsePercentValues(true);
  holder.chart.setData(mChartData);
  Legend l=holder.chart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
  holder.chart.animateXY(900,900);
  return convertView;
}

Fixed version (ground truth):
@Override public View getView(int position,View convertView,Context c){
  ViewHolder holder=null;
  if (convertView == null) {
    holder=new ViewHolder();
    convertView=LayoutInflater.from(c).inflate(R.layout.list_item_piechart,null);
    holder.chart=(PieChart)convertView.findViewById(R.id.chart);
    convertView.setTag(holder);
  }
 else {
    holder=(ViewHolder)convertView.getTag();
  }
  holder.chart.setValueTypeface(mTf);
  holder.chart.setDescription("String_Node_Str");
  holder.chart.setHoleRadius(60f);
  holder.chart.setTransparentCircleRadius(65f);
  holder.chart.setCenterText("String_Node_Str");
  holder.chart.setCenterTextTypeface(mTf);
  holder.chart.setCenterTextSize(18f);
  holder.chart.setDrawXValues(false);
  holder.chart.setUsePercentValues(true);
  holder.chart.setData((PieData)mChartData);
  Legend l=holder.chart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
  holder.chart.animateXY(900,900);
  return convertView;
}
Program: 18936
Project: 18936
Buggy source:
/** 
 * Sets a new ChartData object for the chart.
 * @param data
 */
public void setData(ChartData data){
  if (data == null || !data.isValid()) {
    Log.e(LOG_TAG,"String_Node_Str");
    mDataNotSet=true;
    return;
  }
  mDataNotSet=false;
  mOffsetsCalculated=false;
  mCurrentData=data;
  mOriginalData=data;
  prepare();
  Log.i(LOG_TAG,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Sets a new ChartData object for the chart.
 * @param data
 */
protected void setData(ChartData data){
  if (data == null || !data.isValid()) {
    Log.e(LOG_TAG,"String_Node_Str");
    mDataNotSet=true;
    return;
  }
  mDataNotSet=false;
  mOffsetsCalculated=false;
  mCurrentData=data;
  mOriginalData=data;
  prepare();
  Log.i(LOG_TAG,"String_Node_Str");
}
Program: 18937
Project: 18937
Buggy source:
/** 
 * returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch point.
 * @param x
 * @param y
 * @return
 */
public Highlight getHighlightByTouchPoint(float x,float y){
  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);
  Log.i(LOG_TAG,"String_Node_Str" + xTouchVal + "String_Node_Str"+ yTouchVal);
  if ((this instanceof LineChart || this instanceof ScatterChart) && (xTouchVal < 0 || xTouchVal > mDeltaX))   return null;
  if (this instanceof BarChart && (xTouchVal < 0 || xTouchVal > mDeltaX + 1))   return null;
  int xIndex=(int)base;
  int dataSetIndex=0;
  if (this instanceof LineChart || this instanceof ScatterChart) {
    if (xTouchVal - base > 0.5) {
      xIndex=(int)base + 1;
    }
  }
  ArrayList<SelInfo> valsAtIndex=getYValsAtIndex(xIndex);
  dataSetIndex=getClosestDataSetIndex(valsAtIndex,(float)yTouchVal);
  if (dataSetIndex == -1)   return null;
  return new Highlight(xIndex,(float)yTouchVal,dataSetIndex);
}

Fixed version (ground truth):
/** 
 * returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch point.
 * @param x
 * @param y
 * @return
 */
public Highlight getHighlightByTouchPoint(float x,float y){
  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;
  Log.i(LOG_TAG,"String_Node_Str" + xTouchVal + "String_Node_Str"+ yTouchVal+ "String_Node_Str"+ touchOffset);
  if ((this instanceof LineChart || this instanceof ScatterChart) && (xTouchVal < -touchOffset || xTouchVal > mDeltaX + touchOffset))   return null;
  if (this instanceof BarChart && (xTouchVal < 0 || xTouchVal > mDeltaX))   return null;
  if (base < 0)   base=0;
  if (base >= mDeltaX)   base=mDeltaX - 1;
  int xIndex=(int)base;
  int dataSetIndex=0;
  if (this instanceof LineChart || this instanceof ScatterChart) {
    if (xTouchVal - base > 0.5) {
      xIndex=(int)base + 1;
    }
  }
  ArrayList<SelInfo> valsAtIndex=getYValsAtIndex(xIndex);
  dataSetIndex=getClosestDataSetIndex(valsAtIndex,(float)yTouchVal);
  if (dataSetIndex == -1)   return null;
  return new Highlight(xIndex,(float)yTouchVal,dataSetIndex);
}
Program: 18938
Project: 18938
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.setDrawYValues(true);
  mChart.setDrawCenterText(true);
  mChart.setDescription("String_Node_Str");
  mChart.setDrawHoleEnabled(true);
  mChart.setDrawXValues(true);
  mChart.setTouchEnabled(true);
  mChart.setUsePercentValues(true);
  mChart.setOnChartValueSelectedListener(this);
  mSeekBarX.setProgress(4);
  mSeekBarY.setProgress(100);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.BELOW_CHART_LEFT);
  l.setYEntrySpace(3f);
}

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.setDrawXValues(true);
  mChart.setTouchEnabled(true);
  mChart.setUsePercentValues(true);
  mChart.setOnChartValueSelectedListener(this);
  mSeekBarX.setProgress(4);
  mSeekBarY.setProgress(100);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
  l.setXEntrySpace(7f);
  l.setYEntrySpace(5f);
}
Program: 18939
Project: 18939
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_scatterchart);
  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=(ScatterChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setTouchEnabled(true);
  mChart.setHighlightEnabled(true);
  mChart.setDrawYValues(false);
  mChart.setDragEnabled(true);
  mChart.setMaxVisibleValueCount(200);
  mChart.setPinchZoom(true);
  mSeekBarX.setProgress(45);
  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_scatterchart);
  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=(ScatterChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setTouchEnabled(true);
  mChart.setHighlightEnabled(true);
  mChart.setDrawYValues(false);
  mChart.setDragEnabled(true);
  mChart.setMaxVisibleValueCount(200);
  mChart.setPinchZoom(true);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
}
Program: 18940
Project: 18940
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.setDrawYValues(true);
  mChart.setDescription("String_Node_Str");
  mChart.setMaxVisibleValueCount(60);
  mChart.setValueDigits(2);
  mChart.set3DEnabled(false);
  mChart.setPinchZoom(false);
  mChart.setDrawBarShadow(false);
  YLabels yLabels=mChart.getYLabels();
  yLabels.setPosition(YLabelPosition.BOTH_SIDED);
  yLabels.setLabelCount(5);
  XLabels xLabels=mChart.getXLabels();
  xLabels.setPosition(XLabelPosition.TOP);
  xLabels.setCenterXLabelText(true);
  mSeekBarX.setProgress(12);
  mSeekBarY.setProgress(100);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.BELOW_CHART_LEFT);
  l.setFormSize(8f);
  l.setXEntrySpace(4f);
}

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.setDrawYValues(true);
  mChart.setDescription("String_Node_Str");
  mChart.setMaxVisibleValueCount(60);
  mChart.setValueDigits(2);
  mChart.set3DEnabled(false);
  mChart.setPinchZoom(false);
  mChart.setDrawBarShadow(false);
  YLabels yLabels=mChart.getYLabels();
  yLabels.setPosition(YLabelPosition.BOTH_SIDED);
  yLabels.setLabelCount(5);
  XLabels xLabels=mChart.getXLabels();
  xLabels.setPosition(XLabelPosition.TOP);
  xLabels.setCenterXLabelText(true);
  mSeekBarX.setProgress(12);
  mSeekBarY.setProgress(100);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.BELOW_CHART_RIGHT);
  l.setFormSize(8f);
  l.setFormToTextSpace(4f);
  l.setXEntrySpace(6f);
}
Program: 18943
Project: 18943
Buggy source:
/** 
 * returns the maximum length in pixels over all legend labels + their forms
 * @param p the paint object used for rendering the text
 * @return
 */
public int getMaximumEntryLength(Paint p){
  int max=0;
  for (int i=0; i < mLegendLabels.length; i++) {
    if (mLegendLabels[i] != null) {
      int length=Utils.calcTextWidth(p,mLegendLabels[i]);
      if (length > max)       max=length;
    }
  }
  return max + (int)mFormSize * 4;
}

Fixed version (ground truth):
/** 
 * returns the maximum length in pixels over all legend labels + their forms
 * @param p the paint object used for rendering the text
 * @return
 */
public int getMaximumEntryLength(Paint p){
  int max=0;
  for (int i=0; i < mLegendLabels.length; i++) {
    if (mLegendLabels[i] != null) {
      int length=Utils.calcTextWidth(p,mLegendLabels[i]);
      if (length > max)       max=length;
    }
  }
  return max + (int)mFormSize;
}
Program: 18944
Project: 18944
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View v=inflater.inflate(R.layout.frag_simple_pie,container,false);
  mChart=(PieChart)v.findViewById(R.id.pieChart1);
  mChart.setDescription("String_Node_Str");
  Typeface tf=Typeface.createFromAsset(getActivity().getAssets(),"String_Node_Str");
  mChart.setValueTypeface(tf);
  mChart.setCenterTextTypeface(Typeface.createFromAsset(getActivity().getAssets(),"String_Node_Str"));
  mChart.setUsePercentValues(true);
  mChart.setCenterText("String_Node_Str");
  mChart.setCenterTextSize(23f);
  mChart.setHoleRadius(45f);
  mChart.setTransparentCircleRadius(50f);
  mChart.setData(generateLessData());
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
  return v;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View v=inflater.inflate(R.layout.frag_simple_pie,container,false);
  mChart=(PieChart)v.findViewById(R.id.pieChart1);
  mChart.setDescription("String_Node_Str");
  Typeface tf=Typeface.createFromAsset(getActivity().getAssets(),"String_Node_Str");
  mChart.setValueTypeface(tf);
  mChart.setCenterTextTypeface(Typeface.createFromAsset(getActivity().getAssets(),"String_Node_Str"));
  mChart.setUsePercentValues(true);
  mChart.setCenterText("String_Node_Str");
  mChart.setCenterTextSize(22f);
  mChart.setHoleRadius(45f);
  mChart.setTransparentCircleRadius(50f);
  mChart.setData(generateLessData());
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
  return v;
}
Program: 18947
Project: 18947
Buggy source:
/** 
 * draws the description text in the center of the pie chart makes most sense when center-hole is enabled
 */
private void drawCenterText(){
  if (mDrawCenterText) {
    PointF c=getCenterCircleBox();
    String[] lines=mCenterText.split("String_Node_Str");
    float lineHeight=Utils.calcTextHeight(mCenterTextPaint,lines[0]) * 1.2f;
    float totalheight=lineHeight * lines.length;
    int cnt=lines.length;
    for (int i=0; i < lines.length; i++) {
      String line=lines[lines.length - i - 1];
      mDrawCanvas.drawText(line,c.x,c.y + lineHeight * cnt - lineHeight / 2 - totalheight * 0.45f,mCenterTextPaint);
      cnt--;
    }
  }
}

Fixed version (ground truth):
/** 
 * draws the description text in the center of the pie chart makes most sense when center-hole is enabled
 */
private void drawCenterText(){
  if (mDrawCenterText) {
    PointF c=getCenterCircleBox();
    String[] lines=mCenterText.split("String_Node_Str");
    float lineHeight=Utils.calcTextHeight(mCenterTextPaint,lines[0]);
    float linespacing=lineHeight * 0.2f;
    float totalheight=lineHeight * lines.length - linespacing * (lines.length - 1);
    int cnt=lines.length;
    float y=c.y;
    for (int i=0; i < lines.length; i++) {
      String line=lines[lines.length - i - 1];
      mDrawCanvas.drawText(line,c.x,y + lineHeight * cnt - totalheight / 2f,mCenterTextPaint);
      cnt--;
      y-=linespacing;
    }
  }
}
Program: 18948
Project: 18948
Buggy source:
@Override public void calculateOffsets(){
  if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART) {
    mLegendLabelPaint.setTextAlign(Align.LEFT);
  }
 else   if (mLegend.getPosition() == LegendPosition.BELOW_CHART_LEFT || mLegend.getPosition() == LegendPosition.BELOW_CHART_RIGHT) {
    mOffsetBottom=(int)(mLegendLabelPaint.getTextSize() * 3.5f);
  }
  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 public void calculateOffsets(){
  if (mLegend.getPosition() == LegendPosition.RIGHT_OF_CHART) {
    mLegendLabelPaint.setTextAlign(Align.LEFT);
    mOffsetTop=(int)(mLegendLabelPaint.getTextSize() * 3.5f);
  }
 else   if (mLegend.getPosition() == LegendPosition.BELOW_CHART_LEFT || mLegend.getPosition() == LegendPosition.BELOW_CHART_RIGHT) {
    mOffsetBottom=(int)(mLegendLabelPaint.getTextSize() * 3.5f);
  }
  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: 18950
Project: 18950
Buggy source:
/** 
 * Loads a DataSet from a textfile from the sd-card. Textfile syntax is: labelstring<linebreak>500.99#0<linebreak>350.80#1<linebreak>and so on...
 * @param path the name of the file on the sd card (path if needed)
 * @return
 */
public static DataSet dataSetFromFile(String path){
  File sdcard=Environment.getExternalStorageDirectory();
  File file=new File(sdcard,path);
  ArrayList<Entry> entries=new ArrayList<Entry>();
  String label="String_Node_Str";
  try {
    @SuppressWarnings("String_Node_Str") BufferedReader br=new BufferedReader(new FileReader(file));
    String line=br.readLine();
    label=line;
    while ((line=br.readLine()) != null) {
      String[] split=line.split("String_Node_Str");
      entries.add(new Entry(Float.valueOf(split[0]),Integer.valueOf(split[1])));
    }
  }
 catch (  IOException e) {
    Log.e(LOG,e.toString());
  }
  DataSet ds=new DataSet(entries,label);
  return ds;
}

Fixed version (ground truth):
/** 
 * Loads a DataSet from a textfile from the sd-card. Textfile syntax is: labelstring<linebreak>500.99#0<linebreak>350.80#1<linebreak>and so on...
 * @param path the name of the file on the sd card (path if needed)
 * @return
 */
public static DataSet dataSetFromFile(String path){
  File sdcard=Environment.getExternalStorageDirectory();
  File file=new File(sdcard,path);
  ArrayList<Entry> entries=new ArrayList<Entry>();
  String label="String_Node_Str";
  try {
    @SuppressWarnings("String_Node_Str") BufferedReader br=new BufferedReader(new FileReader(file));
    String line=br.readLine();
    label=line;
    while ((line=br.readLine()) != null) {
      String[] split=line.split("String_Node_Str");
      entries.add(new Entry(Float.parseFloat(split[0]),Integer.parseInt(split[1])));
    }
  }
 catch (  IOException e) {
    Log.e(LOG,e.toString());
  }
  DataSet ds=new DataSet(entries,label);
  return ds;
}
Program: 18951
Project: 18951
Buggy source:
@Override public void run(){
  float indicesInView=mDeltaX / mScaleX;
  float valsInView=mDeltaY / mScaleY;
  float[] pts=new float[]{xIndex - indicesInView / 2f,yVal + valsInView / 2f};
  Matrix save=new Matrix();
  save.set(mMatrixTouch);
  transformPointArray(pts);
  final float x=-pts[0] + getOffsetLeft();
  final float y=-pts[1] - getOffsetTop();
  save.postTranslate(x,y);
  refreshTouchNoInvalidate(save);
}

Fixed version (ground truth):
@Override public void run(){
  float indicesInView=mDeltaX / mScaleX;
  float valsInView=mDeltaY / mScaleY;
  float[] pts=new float[]{xIndex - indicesInView / 2f,yVal + valsInView / 2f};
  Matrix save=new Matrix();
  save.set(mMatrixTouch);
  transformPointArray(pts);
  final float x=-pts[0] + getOffsetLeft();
  final float y=-pts[1] - getOffsetTop();
  save.postTranslate(x,y);
  refreshTouch(save);
}
Program: 18952
Project: 18952
Buggy source:
/** 
 * Centers the viewport around the specified x-index and the specified y-value in the chart. Centering the viewport outside the bounds of the chart is not possible. Makes most sense in combination with the setScaleMinima(...) method. SHOULD BE CALLED AFTER setting data for the chart.
 * @param xIndex the index on the x-axis to center to
 * @param yVal the value ont he y-axis to center to
 */
public synchronized void centerViewPort(final int xIndex,final float yVal){
  post(new Runnable(){
    @Override public void run(){
      float indicesInView=mDeltaX / mScaleX;
      float valsInView=mDeltaY / mScaleY;
      float[] pts=new float[]{xIndex - indicesInView / 2f,yVal + valsInView / 2f};
      Matrix save=new Matrix();
      save.set(mMatrixTouch);
      transformPointArray(pts);
      final float x=-pts[0] + getOffsetLeft();
      final float y=-pts[1] - getOffsetTop();
      save.postTranslate(x,y);
      refreshTouchNoInvalidate(save);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Centers the viewport around the specified x-index and the specified y-value in the chart. Centering the viewport outside the bounds of the chart is not possible. Makes most sense in combination with the setScaleMinima(...) method. First set the scale minima, then center the viewport. SHOULD BE CALLED AFTER setting data for the chart.
 * @param xIndex the index on the x-axis to center to
 * @param yVal the value ont he y-axis to center to
 */
public synchronized void centerViewPort(final int xIndex,final float yVal){
  post(new Runnable(){
    @Override public void run(){
      float indicesInView=mDeltaX / mScaleX;
      float valsInView=mDeltaY / mScaleY;
      float[] pts=new float[]{xIndex - indicesInView / 2f,yVal + valsInView / 2f};
      Matrix save=new Matrix();
      save.set(mMatrixTouch);
      transformPointArray(pts);
      final float x=-pts[0] + getOffsetLeft();
      final float y=-pts[1] - getOffsetTop();
      save.postTranslate(x,y);
      refreshTouch(save);
    }
  }
);
}
Program: 18953
Project: 18953
Buggy source:
private boolean alreadyCounted(ArrayList<String> countedLabels,String label){
  for (int i=0; i < countedLabels.size(); i++) {
    if (countedLabels.get(i).equals(label))     return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean alreadyCounted(ArrayList<String> countedLabels,String label){
  if (label == null)   return true;
  for (int i=0; i < countedLabels.size(); i++) {
    if (countedLabels.get(i).equals(label))     return true;
  }
  return false;
}
Program: 18954
Project: 18954
Buggy source:
/** 
 * Does all necessary calculations, if the underlying data has changed
 */
private void doCalculations(){
  calcTypes();
  calcMinMax();
  calcYValueSum();
}

Fixed version (ground truth):
/** 
 * Does all necessary calculations, if the underlying data has changed
 */
private void doCalculations(){
  calcMinMax();
  calcYValueSum();
}
Program: 18955
Project: 18955
Buggy source:
private void init(ArrayList<String> xVals,ArrayList<DataSet> dataSets){
  this.mXVals=xVals;
  this.mDataSets=dataSets;
  calcTypes();
  calcMinMax();
  calcYValueSum();
  for (int i=0; i < mDataSets.size(); i++) {
    if (mDataSets.get(i).getYVals().size() > xVals.size()) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
private void init(ArrayList<String> xVals,ArrayList<DataSet> dataSets){
  this.mXVals=xVals;
  this.mDataSets=dataSets;
  calcMinMax();
  calcYValueSum();
  for (int i=0; i < mDataSets.size(); i++) {
    if (mDataSets.get(i).getYVals().size() > xVals.size()) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
}
Program: 18956
Project: 18956
Buggy source:
/** 
 * Call this method to create a new drawing DataSet
 * @param type the type of the new DataSet
 */
public void createNewDrawingDataSet(ChartData chartData){
  if (mCurrentDrawingDataSet != null && mCurrentDrawingEntries != null) {
    finishNewDrawingEntry(chartData);
  }
  if (!chartData.getLabels().contains(mLastDrawnDataSetIndex)) {
    chartData.getLabels().add("String_Node_Str" + mLastDrawnDataSetIndex);
  }
  mCurrentDrawingEntries=new ArrayList<Entry>();
  this.mCurrentDrawingDataSet=new DataSet(mCurrentDrawingEntries,"String_Node_Str" + mLastDrawnDataSetIndex);
  chartData.getDataSets().add(mCurrentDrawingDataSet);
}

Fixed version (ground truth):
/** 
 * Call this method to create a new drawing DataSet
 * @param type the type of the new DataSet
 */
public void createNewDrawingDataSet(ChartData chartData){
  if (mCurrentDrawingDataSet != null && mCurrentDrawingEntries != null) {
    finishNewDrawingEntry(chartData);
  }
  mCurrentDrawingEntries=new ArrayList<Entry>();
  this.mCurrentDrawingDataSet=new DataSet(mCurrentDrawingEntries,"String_Node_Str" + mLastDrawnDataSetIndex);
  chartData.getDataSets().add(mCurrentDrawingDataSet);
}
Program: 18957
Project: 18957
Buggy source:
/** 
 * calculates the approximate width of a text, depending on a demo text avoid repeated calls (e.g. inside drawing methods)
 * @param paint
 * @param demoText
 * @return
 */
public static int calcTextWidth(Paint paint,String demoText){
  Rect r=new Rect();
  paint.getTextBounds(demoText,0,demoText.length(),r);
  return r.width();
}

Fixed version (ground truth):
/** 
 * calculates the approximate width of a text, depending on a demo text avoid repeated calls (e.g. inside drawing methods)
 * @param paint
 * @param demoText
 * @return
 */
public static int calcTextWidth(Paint paint,String demoText){
  return (int)paint.measureText(demoText);
}
Program: 18959
Project: 18959
Buggy source:
@Override public void run(){
  float indicesInView=mDeltaX / mScaleX;
  float valsInView=mDeltaY / mScaleY;
  float[] pts=new float[]{xIndex - indicesInView / 2f,yVal + valsInView / 2f};
  Matrix save=new Matrix();
  save.set(mMatrixTouch);
  transformPointArray(pts);
  final float x=-pts[0] + getOffsetLeft();
  final float y=-pts[1] + getOffsetBottom();
  save.postTranslate(x,y);
  refreshTouchNoInvalidate(save);
}

Fixed version (ground truth):
@Override public void run(){
  float indicesInView=mDeltaX / mScaleX;
  float valsInView=mDeltaY / mScaleY;
  float[] pts=new float[]{xIndex - indicesInView / 2f,yVal + valsInView / 2f};
  Matrix save=new Matrix();
  save.set(mMatrixTouch);
  transformPointArray(pts);
  final float x=-pts[0] + getOffsetLeft();
  final float y=-pts[1] - getOffsetTop();
  save.postTranslate(x,y);
  refreshTouchNoInvalidate(save);
}
Program: 18960
Project: 18960
Buggy source:
/** 
 * Centers the viewport around the specified x-index and the specified y-value in the chart. Centering the viewport outside the bounds of the chart is not possible. Makes most sense in combination with the setScaleMinima(...) method. SHOULD BE CALLED AFTER setting data for the chart.
 * @param xIndex the index on the x-axis to center to
 * @param yVal the value ont he y-axis to center to
 */
public synchronized void centerViewPort(final int xIndex,final float yVal){
  post(new Runnable(){
    @Override public void run(){
      float indicesInView=mDeltaX / mScaleX;
      float valsInView=mDeltaY / mScaleY;
      float[] pts=new float[]{xIndex - indicesInView / 2f,yVal + valsInView / 2f};
      Matrix save=new Matrix();
      save.set(mMatrixTouch);
      transformPointArray(pts);
      final float x=-pts[0] + getOffsetLeft();
      final float y=-pts[1] + getOffsetBottom();
      save.postTranslate(x,y);
      refreshTouchNoInvalidate(save);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Centers the viewport around the specified x-index and the specified y-value in the chart. Centering the viewport outside the bounds of the chart is not possible. Makes most sense in combination with the setScaleMinima(...) method. SHOULD BE CALLED AFTER setting data for the chart.
 * @param xIndex the index on the x-axis to center to
 * @param yVal the value ont he y-axis to center to
 */
public synchronized void centerViewPort(final int xIndex,final float yVal){
  post(new Runnable(){
    @Override public void run(){
      float indicesInView=mDeltaX / mScaleX;
      float valsInView=mDeltaY / mScaleY;
      float[] pts=new float[]{xIndex - indicesInView / 2f,yVal + valsInView / 2f};
      Matrix save=new Matrix();
      save.set(mMatrixTouch);
      transformPointArray(pts);
      final float x=-pts[0] + getOffsetLeft();
      final float y=-pts[1] - getOffsetTop();
      save.postTranslate(x,y);
      refreshTouchNoInvalidate(save);
    }
  }
);
}
Program: 18961
Project: 18961
Buggy source:
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  super.onLayout(changed,left,top,right,bottom);
  prepareContentRect();
  Log.i(LOG_TAG,"String_Node_Str" + mContentRect.width() + "String_Node_Str"+ mContentRect.height());
  if (this instanceof BarLineChartBase) {
    if (!((BarLineChartBase)this).hasFixedYValues())     prepareMatrix();
  }
 else {
    prepareMatrix();
  }
}

Fixed version (ground truth):
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  super.onLayout(changed,left,top,right,bottom);
  prepareContentRect();
  Log.i(LOG_TAG,"String_Node_Str" + mContentRect.width() + "String_Node_Str"+ mContentRect.height());
  if (this instanceof BarLineChartBase) {
    BarLineChartBase b=(BarLineChartBase)this;
    if (!b.hasFixedYValues() && !mMatrixOnLayoutPrepared) {
      prepareMatrix();
      mMatrixOnLayoutPrepared=true;
    }
  }
 else {
    prepareMatrix();
  }
}
Program: 18962
Project: 18962
Buggy source:
/** 
 * setup all the matrices that will be used for scaling the coordinates to the display
 */
protected void prepareMatrix(){
  float scaleX=(float)((getWidth() - mOffsetLeft - mOffsetRight) / mDeltaX);
  float scaleY=(float)((getHeight() - mOffsetBottom - mOffsetTop) / mDeltaY);
  mMatrixValueToPx.reset();
  mMatrixValueToPx.postTranslate(0,-mYChartMin);
  mMatrixValueToPx.postScale(scaleX,-scaleY);
  mMatrixOffset.reset();
  mMatrixOffset.postTranslate(mOffsetLeft,getHeight() - mOffsetBottom);
}

Fixed version (ground truth):
/** 
 * setup all the matrices that will be used for scaling the coordinates to the display
 */
protected void prepareMatrix(){
  float scaleX=(float)((getWidth() - mOffsetLeft - mOffsetRight) / mDeltaX);
  float scaleY=(float)((getHeight() - mOffsetBottom - mOffsetTop) / mDeltaY);
  mMatrixValueToPx.reset();
  mMatrixValueToPx.postTranslate(0,-mYChartMin);
  mMatrixValueToPx.postScale(scaleX,-scaleY);
  mMatrixOffset.reset();
  mMatrixOffset.postTranslate(mOffsetLeft,getHeight() - mOffsetBottom);
  Log.i(LOG_TAG,"String_Node_Str");
}
Program: 18963
Project: 18963
Buggy source:
@Override protected void calcMinMax(boolean fixedValues){
  super.calcMinMax(fixedValues);
  mDeltaX++;
}

Fixed version (ground truth):
@Override protected void calcMinMax(boolean fixedValues){
  super.calcMinMax(fixedValues);
  if (!mStartAtZero && getYMin() >= 0f) {
    mYChartMin=getYMin();
    mDeltaY=Math.abs(mYChartMax - mYChartMin);
  }
  mDeltaX++;
}
Program: 18964
Project: 18964
Buggy source:
@Override protected void calcMinMax(boolean fixedValues){
  super.calcMinMax(fixedValues);
  float spaceTop=(mData.getYMax() - mYChartMin) / 100f * 10f;
  if (mStartAtZero) {
    mYChartMin=0;
  }
 else {
    float spaceBottom=(mData.getYMax() - mYChartMin) / 100f * 10f;
    mYChartMin=mYChartMin - spaceBottom;
  }
  mDeltaY=(mData.getYMax() + spaceTop) - mYChartMin;
  mYChartMax=mYChartMin + mDeltaY;
  Log.i(LOG_TAG,"String_Node_Str" + mDeltaX + "String_Node_Str"+ mDeltaY);
}

Fixed version (ground truth):
@Override protected void calcMinMax(boolean fixedValues){
  super.calcMinMax(fixedValues);
  float space=mDeltaY / 100f * 10f;
  if (mStartAtZero) {
    mYChartMin=0;
  }
 else {
    mYChartMin=mYChartMin - space;
  }
  mYChartMax=mYChartMax + space;
  mDeltaY=Math.abs(mYChartMax - mYChartMin);
}
Program: 18965
Project: 18965
Buggy source:
/** 
 * setup the Y legend
 */
protected void prepareYLegend(){
  ArrayList<Float> yLegend=new ArrayList<Float>();
  if (mRoundedYLegend) {
    float interval=(mDeltaY) / (mYLegendCount - 1);
    double log10=Math.log10(interval);
    int exp=(int)Math.floor(log10);
    double tenPowExp=POW_10[exp + 5];
    double multi=Math.round(interval / tenPowExp);
    if (multi >= 1) {
      if (multi > 2 && multi < 5) {
        multi=5;
      }
 else       if (multi > 5 && multi < 10) {
        multi=10;
      }
    }
    float step=(float)(multi * tenPowExp);
    float val=0;
    if (step >= 1f)     val=(int)(mYChartMin / step) * step;
 else {
      val=mYChartMin;
    }
    while (val <= mDeltaY + step + mYChartMin) {
      yLegend.add(val);
      val=val + step;
    }
    if (step >= 1f)     mYChartMin=(int)(mYChartMin / step) * step;
    mDeltaY=val - step - mYChartMin;
    mYChartMax=yLegend.get(yLegend.size() - 1);
  }
 else {
    float interval=(mDeltaY) / (mYLegendCount - 1);
    yLegend.add(mYChartMin);
    for (int i=1; i < mYLegendCount - 1; i++) {
      yLegend.add(mYChartMin + ((float)i * interval));
    }
    yLegend.add(mDeltaY + mYChartMin);
  }
  mYLegend=yLegend.toArray(new Float[0]);
}

Fixed version (ground truth):
/** 
 * setup the Y legend
 */
protected void prepareYLegend(){
  ArrayList<Float> yLegend=new ArrayList<Float>();
  if (mRoundedYLegend) {
    float interval=(mDeltaY) / (mYLegendCount - 1);
    double log10=Math.log10(interval);
    int exp=(int)Math.floor(log10);
    double tenPowExp=POW_10[exp + 5];
    double multi=Math.round(interval / tenPowExp);
    if (multi >= 1) {
      if (multi > 2 && multi < 5) {
        multi=5;
      }
 else       if (multi > 5 && multi < 10) {
        multi=10;
      }
    }
    float step=(float)(multi * tenPowExp);
    float min=mYChartMin;
    float val=0;
    if (step >= 1f) {
      val=(int)(mYChartMin / step) - step;
      mYChartMin=val;
    }
 else {
      val=mYChartMin;
    }
    if (mStartAtZero) {
      val=0;
      mYChartMin=0;
    }
 else {
      if (getYMin() >= 0 && this instanceof BarChart) {
        val=0;
        mYChartMin=0;
      }
    }
    while (val <= mDeltaY + step + min) {
      yLegend.add(val);
      val=val + step;
    }
    mDeltaY=val - step - mYChartMin;
  }
 else {
    float interval=(mDeltaY) / (mYLegendCount - 1);
    yLegend.add(mYChartMin);
    for (int i=1; i < mYLegendCount - 1; i++) {
      yLegend.add(mYChartMin + ((float)i * interval));
    }
    yLegend.add(mDeltaY + mYChartMin);
  }
  mYChartMax=yLegend.get(yLegend.size() - 1);
  mYLegend=yLegend.toArray(new Float[0]);
  Log.i(LOG_TAG,"String_Node_Str" + mDeltaX + "String_Node_Str"+ mDeltaY);
  Log.i(LOG_TAG,"String_Node_Str" + mYChartMax + "String_Node_Str"+ mYChartMin);
  Log.i(LOG_TAG,"String_Node_Str" + getYMax() + "String_Node_Str"+ getYMin());
}
Program: 18966
Project: 18966
Buggy source:
/** 
 * calcualtes the y-min and y-max value and the y-delta and x-delta value
 */
protected void calcMinMax(boolean fixedValues){
  if (!fixedValues) {
    mYChartMin=mData.getYMin();
    mYChartMax=mYChartMin + mData.getYMax();
  }
  mDeltaY=mData.getYMax() - mYChartMin;
  mDeltaX=mData.getXVals().size() - 1;
}

Fixed version (ground truth):
/** 
 * calcualtes the y-min and y-max value and the y-delta and x-delta value
 */
protected void calcMinMax(boolean fixedValues){
  if (!fixedValues) {
    mYChartMin=mData.getYMin();
    mYChartMax=mData.getYMax();
  }
  mDeltaY=Math.abs(mData.getYMax() - mData.getYMin());
  mDeltaX=mData.getXVals().size() - 1;
}
Program: 18967
Project: 18967
Buggy source:
/** 
 * does all necessary preparations, needed when data is changed or flags that effect the data are changed
 */
@Override protected void prepare(){
  if (mDataNotSet)   return;
  calcMinMax();
  prepareXLegend();
  prepareYLegend();
  calcFormats();
  prepareMatrix();
}

Fixed version (ground truth):
/** 
 * does all necessary preparations, needed when data is changed or flags that effect the data are changed
 */
@Override public void prepare(){
  if (mDataNotSet)   return;
  calcMinMax();
  prepareXLegend();
  prepareYLegend();
  calcFormats();
  prepareMatrix();
}
Program: 18968
Project: 18968
Buggy source:
/** 
 * calcualtes the y-min and y-max value and the y-delta and x-delta value
 */
protected void calcMinMax(boolean fixedValues){
  if (fixedValues) {
    mYChartMin=mData.getYMin();
    mYChartMax=mYChartMin + mData.getYMax();
  }
  mDeltaY=mData.getYMax() - mYChartMin;
  mDeltaX=mData.getXVals().size() - 1;
}

Fixed version (ground truth):
/** 
 * calcualtes the y-min and y-max value and the y-delta and x-delta value
 */
protected void calcMinMax(boolean fixedValues){
  if (!fixedValues) {
    mYChartMin=mData.getYMin();
    mYChartMax=mYChartMin + mData.getYMax();
  }
  mDeltaY=mData.getYMax() - mYChartMin;
  mDeltaX=mData.getXVals().size() - 1;
}
Program: 18969
Project: 18969
Buggy source:
private void initWithDummyData(){
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < 25; i++) {
    xVals.add((i) + "String_Node_Str");
  }
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  DataSet set1=new DataSet(yVals,0);
  ArrayList<DataSet> dataSets=new ArrayList<DataSet>();
  dataSets.add(set1);
  ChartData data=new ChartData(xVals,dataSets);
  mChart.setData(data);
  mChart.invalidate();
}

Fixed version (ground truth):
private void initWithDummyData(){
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < 25; i++) {
    xVals.add((i) + "String_Node_Str");
  }
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  DataSet set1=new DataSet(yVals,0);
  ArrayList<DataSet> dataSets=new ArrayList<DataSet>();
  dataSets.add(set1);
  ChartData data=new ChartData(xVals,dataSets);
  mChart.setData(data);
  mChart.setYRange(10,40,0);
  mChart.invalidate();
}
Program: 18970
Project: 18970
Buggy source:
private void initWithDummyData(){
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < 148; i++) {
    xVals.add((i) + "String_Node_Str");
  }
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  DataSet set1=new DataSet(yVals,0);
  ArrayList<DataSet> dataSets=new ArrayList<DataSet>();
  dataSets.add(set1);
  ChartData data=new ChartData(xVals,dataSets);
  mChart.setData(data);
  mChart.setYRange(10f,40f);
  mChart.invalidate();
}

Fixed version (ground truth):
private void initWithDummyData(){
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < 148; i++) {
    xVals.add((i) + "String_Node_Str");
  }
  ArrayList<Entry> yVals=new ArrayList<Entry>();
  DataSet set1=new DataSet(yVals,0);
  ArrayList<DataSet> dataSets=new ArrayList<DataSet>();
  dataSets.add(set1);
  ChartData data=new ChartData(xVals,dataSets);
  mChart.setData(data);
  mChart.setYRangeFixed(false);
  mChart.setYRange(-40f,40f);
  mChart.invalidate();
}
Program: 18971
Project: 18971
Buggy source:
@Override public void notifyDataSetChanged(){
  calcMinMax(mFixedYValues);
}

Fixed version (ground truth):
@Override public void notifyDataSetChanged(){
  if (!mFixedYValues) {
    prepare();
  }
 else {
    calcMinMax(mFixedYValues);
  }
}
Program: 18972
Project: 18972
Buggy source:
/** 
 * sets the effective range of y-values the chart can display
 * @param minY
 * @param maxY
 */
public void setYRange(float minY,float maxY){
  mFixedYValues=true;
  mYChartMin=minY;
  mYChartMax=maxY;
  mDeltaY=mYChartMax - mYChartMin;
  calcFormats();
  prepareMatrix();
  invalidate();
}

Fixed version (ground truth):
/** 
 * sets the effective range of y-values the chart can display
 * @param minY
 * @param maxY
 */
public void setYRange(float minY,float maxY){
  mYChartMin=minY;
  mYChartMax=maxY;
  if (minY < 0) {
    mStartAtZero=false;
  }
  mDeltaY=mYChartMax - mYChartMin;
  calcFormats();
  prepareMatrix();
  invalidate();
}
Program: 18973
Project: 18973
Buggy source:
@Override public void onProgressChanged(SeekBar seekBar,int progress,boolean fromUser){
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < mSeekBarX.getProgress(); i++) {
    xVals.add((i) + "String_Node_Str");
  }
  ArrayList<Series> yVals=new ArrayList<Series>();
  for (int i=0; i < mSeekBarX.getProgress(); i++) {
    float mult=(mSeekBarY.getProgress() + 1);
    float val=(float)(Math.random() * mult * 0.1) + 3;
    yVals.add(new Series(val,i));
  }
  tvX.setText("String_Node_Str" + (mSeekBarX.getProgress() + 1));
  tvY.setText("String_Node_Str" + (mSeekBarY.getProgress() / 10));
  DataSet set=new DataSet(yVals,0);
  ArrayList<DataSet> dataSets=new ArrayList<DataSet>();
  dataSets.add(set);
  ChartData data=new ChartData(xVals,dataSets);
  mChart.setData(data);
  mChart.invalidate();
}

Fixed version (ground truth):
@Override public void onProgressChanged(SeekBar seekBar,int progress,boolean fromUser){
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < mSeekBarX.getProgress(); i++) {
    xVals.add((i) + "String_Node_Str");
  }
  ArrayList<Series> yVals1=new ArrayList<Series>();
  for (int i=0; i < mSeekBarX.getProgress(); i++) {
    float mult=(mSeekBarY.getProgress() + 1);
    float val=(float)(Math.random() * mult * 0.1) + 3;
    yVals1.add(new Series(val,i));
  }
  tvX.setText("String_Node_Str" + (mSeekBarX.getProgress() + 1));
  tvY.setText("String_Node_Str" + (mSeekBarY.getProgress() / 10));
  DataSet set1=new DataSet(yVals1,0);
  ArrayList<DataSet> dataSets=new ArrayList<DataSet>();
  dataSets.add(set1);
  ChartData data=new ChartData(xVals,dataSets);
  mChart.setData(data);
  mChart.invalidate();
}
Program: 18975
Project: 18975
Buggy source:
@Override protected void drawHighlights(){
  if (mHighlightEnabled && valuesToHighlight()) {
    float offsetY=mDeltaY * 0.04f;
    for (int i=0; i < mIndicesToHightlight.length; i++) {
      int index=mIndicesToHightlight[i].getXIndex();
      if (index < mData.getYValCount() && index >= 0) {
        mHighlightPaint.setAlpha(120);
        float y=getYValue(index);
        float left=index + mBarSpace / 2f;
        float right=index + 1f - mBarSpace / 2f;
        float top=y >= 0 ? y : 0;
        float bottom=y <= 0 ? y : 0;
        RectF highlight=new RectF(left,top,right,bottom);
        transformRect(highlight);
        mDrawCanvas.drawRect(highlight,mHighlightPaint);
        if (mDrawHighlightArrow) {
          mHighlightPaint.setAlpha(200);
          Path arrow=new Path();
          arrow.moveTo(index + 0.5f,y + offsetY * 0.3f);
          arrow.lineTo(index + 0.2f,y + offsetY);
          arrow.lineTo(index + 0.8f,y + offsetY);
          transformPath(arrow);
          mDrawCanvas.drawPath(arrow,mHighlightPaint);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void drawHighlights(){
  if (mHighlightEnabled && valuesToHighlight()) {
    float offsetY=mDeltaY * 0.04f;
    for (int i=0; i < mIndicesToHightlight.length; i++) {
      int index=mIndicesToHightlight[i].getXIndex();
      if (index < mData.getYValCount() && index >= 0) {
        mHighlightPaint.setAlpha(120);
        float y=getYValueByDataSetIndex(index,mIndicesToHightlight[i].getDataSetIndex());
        float left=index + mBarSpace / 2f;
        float right=index + 1f - mBarSpace / 2f;
        float top=y >= 0 ? y : 0;
        float bottom=y <= 0 ? y : 0;
        RectF highlight=new RectF(left,top,right,bottom);
        transformRect(highlight);
        mDrawCanvas.drawRect(highlight,mHighlightPaint);
        if (mDrawHighlightArrow) {
          mHighlightPaint.setAlpha(200);
          Path arrow=new Path();
          arrow.moveTo(index + 0.5f,y + offsetY * 0.3f);
          arrow.lineTo(index + 0.2f,y + offsetY);
          arrow.lineTo(index + 0.8f,y + offsetY);
          transformPath(arrow);
          mDrawCanvas.drawPath(arrow,mHighlightPaint);
        }
      }
    }
  }
}
Program: 18976
Project: 18976
Buggy source:
/** 
 * returns the Highlight object (x index and DataSet index) of the selected value at the given touch point
 * @param x
 * @param y
 * @return
 */
public Highlight getIndexByTouchPoint(float x,float y){
  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);
  Log.i(LOG_TAG,"String_Node_Str" + xTouchVal + "String_Node_Str"+ yTouchVal);
  if (this instanceof LineChart && (xTouchVal < 0 || xTouchVal > mDeltaX))   return null;
  if (this instanceof BarChart && (xTouchVal < 0 || xTouchVal > mDeltaX + 1))   return null;
  int xIndex=(int)base;
  int yIndex=0;
  if (this instanceof LineChart) {
    if (xTouchVal - base > 0.5) {
      xIndex=(int)base + 1;
    }
  }
  ArrayList<Float> valsAtIndex=getYValsAtIndex(xIndex);
  yIndex=getClosestDataSetIndex(valsAtIndex,(float)yTouchVal);
  if (yIndex == -1)   return null;
  return new Highlight(xIndex,yIndex);
}

Fixed version (ground truth):
/** 
 * returns the Highlight object (x index and DataSet index) of the selected value at the given touch point
 * @param x
 * @param y
 * @return
 */
public Highlight getIndexByTouchPoint(float x,float y){
  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);
  Log.i(LOG_TAG,"String_Node_Str" + xTouchVal + "String_Node_Str"+ yTouchVal);
  if (this instanceof LineChart && (xTouchVal < 0 || xTouchVal > mDeltaX))   return null;
  if (this instanceof BarChart && (xTouchVal < 0 || xTouchVal > mDeltaX + 1))   return null;
  int xIndex=(int)base;
  int yIndex=0;
  if (this instanceof LineChart) {
    if (xTouchVal - base > 0.5) {
      xIndex=(int)base + 1;
    }
  }
  ArrayList<SelInfo> valsAtIndex=getYValsAtIndex(xIndex);
  yIndex=getClosestDataSetIndex(valsAtIndex,(float)yTouchVal);
  if (yIndex == -1)   return null;
  return new Highlight(xIndex,yIndex);
}
Program: 18977
Project: 18977
Buggy source:
/** 
 * returns the index DataSet that contains the closest value    
 * @param valsAtIndex
 * @return
 */
private int getClosestDataSetIndex(ArrayList<Float> valsAtIndex,float val){
  int index=-1;
  float distance=Float.MAX_VALUE;
  for (int c=0; c < valsAtIndex.size(); c++) {
    float cdistance=Math.abs((float)valsAtIndex.get(c) - val);
    if (cdistance < distance) {
      index=c;
      distance=cdistance;
    }
  }
  Log.i(LOG_TAG,"String_Node_Str" + index);
  return index;
}

Fixed version (ground truth):
/** 
 * returns the index DataSet that contains the closest value    
 * @param valsAtIndex
 * @return
 */
private int getClosestDataSetIndex(ArrayList<SelInfo> valsAtIndex,float val){
  int index=-1;
  float distance=Float.MAX_VALUE;
  for (int i=0; i < valsAtIndex.size(); i++) {
    float cdistance=Math.abs((float)valsAtIndex.get(i).val - val);
    if (cdistance < distance) {
      index=valsAtIndex.get(i).dataSetIndex;
      distance=cdistance;
    }
  }
  Log.i(LOG_TAG,"String_Node_Str" + index);
  return index;
}