nus-yam/ex-repair huggingface dataset:
Program: 27012
Project: 27012
Buggy source:
/** 
 * Prepares a bar for drawing on the specified x-index and y-position. Also prepares the shadow-bar if enabled.
 * @param x the x-position
 * @param y the y-position
 * @param space the space between bars
 */
private void prepareBar(float x,float y,float space){
  float left=x + space / 2f;
  float right=x + 1f - space / 2f;
  float top=(y >= 0 ? y : 0) * mPhaseY;
  float bottom=(y <= 0 ? y : 0) * mPhaseY;
  mBarRect.set(left,top,right,bottom);
  transformRect(mBarRect);
  if (mDrawBarShadow) {
    mBarShadow.set(mBarRect.left,mOffsetTop,mBarRect.right,getHeight() - mOffsetBottom);
  }
}

Fixed version (ground truth):
/** 
 * Prepares a bar for drawing on the specified x-index and y-position. Also prepares the shadow-bar if enabled.
 * @param x the x-position
 * @param y the y-position
 * @param space the space between bars
 */
private void prepareBar(float x,float y,float space){
  float spaceHalf=space / 2f;
  float left=x + spaceHalf;
  float right=x + 1f - spaceHalf;
  float top=y >= 0 ? y : 0;
  float bottom=y <= 0 ? y : 0;
  mBarRect.set(left,top,right,bottom);
  transformRectWithPhase(mBarRect);
  if (mDrawBarShadow) {
    mBarShadow.set(mBarRect.left,mOffsetTop,mBarRect.right,getHeight() - mOffsetBottom);
  }
}
Program: 27013
Project: 27013
Buggy source:
/** 
 * draws the y-labels on the specified x-position
 * @param xPos
 * @param positions
 */
private void drawYLabels(float xPos,float[] positions){
  for (int i=0; i < mYLabels.mEntryCount; i++) {
    String text=Utils.formatNumber(mYLabels.mEntries[i],mYLabels.mDecimals,mSeparateTousands);
    if (!mYLabels.isDrawTopYLabelEntryEnabled() && i >= mYLabels.mEntryCount - 1)     return;
    if (mYLabels.isDrawUnitsInYLabelEnabled()) {
      mDrawCanvas.drawText(text + mUnit,xPos,positions[i * 2 + 1],mYLabelPaint);
    }
 else {
      mDrawCanvas.drawText(text,xPos,positions[i * 2 + 1],mYLabelPaint);
    }
  }
}

Fixed version (ground truth):
/** 
 * draws the y-labels on the specified x-position
 * @param xPos
 * @param positions
 */
private void drawYLabels(float xPos,float[] positions,float yOffset){
  for (int i=0; i < mYLabels.mEntryCount; i++) {
    String text=Utils.formatNumber(mYLabels.mEntries[i],mYLabels.mDecimals,mSeparateTousands);
    if (!mYLabels.isDrawTopYLabelEntryEnabled() && i >= mYLabels.mEntryCount - 1)     return;
    if (mYLabels.isDrawUnitsInYLabelEnabled()) {
      mDrawCanvas.drawText(text + mUnit,xPos,positions[i * 2 + 1] + yOffset,mYLabelPaint);
    }
 else {
      mDrawCanvas.drawText(text,xPos,positions[i * 2 + 1] + yOffset,mYLabelPaint);
    }
  }
}
Program: 27014
Project: 27014
Buggy source:
@Override protected void calcMinMax(boolean fixedValues){
  super.calcMinMax(fixedValues);
  float space=mDeltaY / 100f * 15f;
  if (mStartAtZero) {
    mYChartMin=0;
  }
 else {
    mYChartMin=mYChartMin - space;
  }
  mYChartMax=mYChartMax + space;
  mDeltaY=Math.abs(mYChartMax - mYChartMin);
}

Fixed version (ground truth):
@Override protected void calcMinMax(boolean fixedValues){
  super.calcMinMax(fixedValues);
  float space=Math.abs(mDeltaY / 100f * 15f);
  if (mStartAtZero) {
    if (mYChartMax < 0) {
      mYChartMax=0;
      mYChartMin=mYChartMin - space;
    }
 else {
      mYChartMin=0;
      mYChartMax=mYChartMax + space;
    }
  }
 else {
    mYChartMin=mYChartMin - space / 2f;
    mYChartMax=mYChartMax + space / 2f;
  }
  mDeltaY=Math.abs(mYChartMax - mYChartMin);
}
Program: 27015
Project: 27015
Buggy source:
private Path generateFilledPath(ArrayList<Entry> entries){
  Path filled=new Path();
  filled.moveTo(entries.get(0).getXIndex(),entries.get(0).getVal() * mPhaseY);
  for (int x=1; x < entries.size() * mPhaseX; x++) {
    Entry e=entries.get(x);
    filled.lineTo(e.getXIndex(),e.getVal() * mPhaseY);
  }
  filled.lineTo(entries.get((int)((entries.size() - 1) * mPhaseX)).getXIndex(),mYChartMin);
  filled.lineTo(entries.get(0).getXIndex(),mYChartMin);
  filled.close();
  return filled;
}

Fixed version (ground truth):
/** 
 * Generates the path that is used for filled drawing.
 * @param entries
 * @return
 */
private Path generateFilledPath(ArrayList<Entry> entries){
  Path filled=new Path();
  filled.moveTo(entries.get(0).getXIndex(),entries.get(0).getVal() * mPhaseY);
  for (int x=1; x < entries.size() * mPhaseX; x++) {
    Entry e=entries.get(x);
    filled.lineTo(e.getXIndex(),e.getVal() * mPhaseY);
  }
  filled.lineTo(entries.get((int)((entries.size() - 1) * mPhaseX)).getXIndex(),mYChartMin);
  filled.lineTo(entries.get(0).getXIndex(),mYChartMin);
  filled.close();
  return filled;
}
Program: 27016
Project: 27016
Buggy source:
@Override protected void drawValues(){
  if (mDrawYValues && mCurrentData.getYValCount() < mMaxVisibleCount * mScaleX) {
    ArrayList<ScatterDataSet> dataSets=(ArrayList<ScatterDataSet>)mCurrentData.getDataSets();
    for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
      ScatterDataSet dataSet=dataSets.get(i);
      ArrayList<Entry> entries=dataSet.getYVals();
      float[] positions=generateTransformedValues(entries,0f);
      float shapeSize=dataSet.getScatterShapeSize();
      for (int j=0; j < positions.length; j+=2) {
        if (isOffContentRight(positions[j]))         break;
        if (isOffContentLeft(positions[j]) || isOffContentTop(positions[j + 1]) || isOffContentBottom(positions[j + 1]))         continue;
        float val=entries.get(j / 2).getVal();
        if (mDrawUnitInChart) {
          mDrawCanvas.drawText(mFormatValue.format(val) + mUnit,positions[j],positions[j + 1] - shapeSize,mValuePaint);
        }
 else {
          mDrawCanvas.drawText(mFormatValue.format(val),positions[j],positions[j + 1] - shapeSize,mValuePaint);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void drawValues(){
  if (mDrawYValues && mCurrentData.getYValCount() < mMaxVisibleCount * mScaleX) {
    ArrayList<ScatterDataSet> dataSets=(ArrayList<ScatterDataSet>)mCurrentData.getDataSets();
    for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
      ScatterDataSet dataSet=dataSets.get(i);
      ArrayList<Entry> entries=dataSet.getYVals();
      float[] positions=generateTransformedValues(entries,0f);
      float shapeSize=dataSet.getScatterShapeSize();
      for (int j=0; j < positions.length * mPhaseX; j+=2) {
        if (isOffContentRight(positions[j]))         break;
        if (isOffContentLeft(positions[j]) || isOffContentTop(positions[j + 1]) || isOffContentBottom(positions[j + 1]))         continue;
        float val=entries.get(j / 2).getVal();
        if (mDrawUnitInChart) {
          mDrawCanvas.drawText(mFormatValue.format(val) + mUnit,positions[j],positions[j + 1] - shapeSize,mValuePaint);
        }
 else {
          mDrawCanvas.drawText(mFormatValue.format(val),positions[j],positions[j + 1] - shapeSize,mValuePaint);
        }
      }
    }
  }
}
Program: 27017
Project: 27017
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: 27018
Project: 27018
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: 27019
Project: 27019
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: 27020
Project: 27020
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: 27023
Project: 27023
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: 27024
Project: 27024
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: 27027
Project: 27027
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: 27028
Project: 27028
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: 27030
Project: 27030
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: 27031
Project: 27031
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: 27032
Project: 27032
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: 27033
Project: 27033
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: 27034
Project: 27034
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: 27035
Project: 27035
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: 27036
Project: 27036
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: 27037
Project: 27037
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: 27039
Project: 27039
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: 27040
Project: 27040
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: 27041
Project: 27041
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: 27042
Project: 27042
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: 27043
Project: 27043
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: 27044
Project: 27044
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: 27045
Project: 27045
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: 27046
Project: 27046
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: 27047
Project: 27047
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: 27048
Project: 27048
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: 27049
Project: 27049
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: 27050
Project: 27050
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: 27051
Project: 27051
Buggy source:
@Override public void notifyDataSetChanged(){
  calcMinMax(mFixedYValues);
}

Fixed version (ground truth):
@Override public void notifyDataSetChanged(){
  if (!mFixedYValues) {
    prepare();
  }
 else {
    calcMinMax(mFixedYValues);
  }
}
Program: 27052
Project: 27052
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: 27053
Project: 27053
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);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setDrawYValues(false);
  mChart.setLineWidth(5f);
  mChart.setCircleSize(5f);
  mChart.setYLegendCount(6);
  mChart.setTouchEnabled(true);
  mChart.setHighlightEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setTouchEnabled(true);
  TextView textView=new TextView(this);
  textView.setVisibility(View.VISIBLE);
  textView.setBackgroundColor(Color.WHITE);
  textView.setPadding(15,15,15,15);
  textView.setText("String_Node_Str");
  mChart.setDrawMarkerView(true);
  mChart.setMarkerView(textView);
  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_linechart);
  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=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setDrawYValues(false);
  mChart.setLineWidth(5f);
  mChart.setCircleSize(5f);
  mChart.setYLegendCount(6);
  mChart.setTouchEnabled(true);
  mChart.setHighlightEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setTouchEnabled(true);
  TextView textView=new TextView(this);
  textView.setVisibility(View.VISIBLE);
  textView.setBackgroundColor(Color.WHITE);
  textView.setPadding(15,15,15,15);
  textView.setText("String_Node_Str");
  mChart.setDrawMarkerView(true);
  mChart.setMarkerView(textView);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
}