nus-yam/ex-repair huggingface dataset:
Program: 18866
Project: 18866
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_linechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setStartAtZero(true);
  mChart.setDrawYValues(true);
  mChart.setDrawBorder(true);
  mChart.setBorderPositions(new BorderPosition[]{BorderPosition.BOTTOM});
  mChart.setDescription("String_Node_Str");
  mChart.setInvertYAxisEnabled(true);
  mChart.setHighlightEnabled(true);
  mChart.setTouchEnabled(true);
  mChart.setDragScaleEnabled(false);
  mChart.setPinchZoom(true);
  MyMarkerView mv=new MyMarkerView(this,R.layout.custom_marker_view);
  mv.setOffsets(-mv.getMeasuredWidth() / 2,-mv.getMeasuredHeight());
  mChart.setMarkerView(mv);
  mChart.setHighlightIndicatorEnabled(false);
  XLabels xl=mChart.getXLabels();
  xl.setAvoidFirstLastClipping(true);
  setData(25,50);
  Legend l=mChart.getLegend();
  l.setForm(LegendForm.LINE);
  mChart.invalidate();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_linechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setStartAtZero(true);
  mChart.setDrawYValues(true);
  mChart.setDrawBorder(true);
  mChart.setBorderPositions(new BorderPosition[]{BorderPosition.BOTTOM});
  mChart.setDescription("String_Node_Str");
  mChart.setInvertYAxisEnabled(true);
  mChart.setHighlightEnabled(true);
  mChart.setTouchEnabled(true);
  mChart.setDragScaleEnabled(true);
  mChart.setPinchZoom(true);
  MyMarkerView mv=new MyMarkerView(this,R.layout.custom_marker_view);
  mv.setOffsets(-mv.getMeasuredWidth() / 2,-mv.getMeasuredHeight());
  mChart.setMarkerView(mv);
  mChart.setHighlightIndicatorEnabled(false);
  XLabels xl=mChart.getXLabels();
  xl.setAvoidFirstLastClipping(true);
  setData(25,50);
  Legend l=mChart.getLegend();
  l.setForm(LegendForm.LINE);
  mChart.invalidate();
}
Program: 18867
Project: 18867
Buggy source:
@Override protected void drawHighlights(){
  for (int i=0; i < mIndicesToHightlight.length; i++) {
    Highlight h=mIndicesToHightlight[i];
    int index=h.getXIndex();
    int dataSetIndex=h.getDataSetIndex();
    BarDataSet ds=(BarDataSet)mCurrentData.getDataSetByIndex(dataSetIndex);
    mHighlightPaint.setColor(ds.getHighLightColor());
    mHighlightPaint.setAlpha(ds.getHighLightAlpha());
    if (index < mCurrentData.getYValCount() && index >= 0 && index < mDeltaX * mPhaseX) {
      Entry e=getEntryByDataSetIndex(index,dataSetIndex);
      float x=index * mOriginalData.getDataSetCount() + dataSetIndex;
      prepareBar(x,e.getVal(),ds.getBarSpace());
      mDrawCanvas.drawRect(mBarRect,mHighlightPaint);
      if (mDrawHighlightArrow) {
        mHighlightPaint.setAlpha(255);
        float offsetY=mDeltaY * 0.07f;
        float y=e.getVal();
        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(){
  for (int i=0; i < mIndicesToHightlight.length; i++) {
    Highlight h=mIndicesToHightlight[i];
    int index=h.getXIndex();
    int dataSetIndex=h.getDataSetIndex();
    BarDataSet ds=(BarDataSet)mCurrentData.getDataSetByIndex(dataSetIndex);
    mHighlightPaint.setColor(ds.getHighLightColor());
    mHighlightPaint.setAlpha(ds.getHighLightAlpha());
    if (index < mCurrentData.getYValCount() && index >= 0 && index < (mDeltaX * mPhaseX) / mOriginalData.getDataSetCount()) {
      Entry e=getEntryByDataSetIndex(index,dataSetIndex);
      float x=index * mOriginalData.getDataSetCount() + dataSetIndex;
      float y=e.getVal();
      prepareBar(x,y,ds.getBarSpace());
      mDrawCanvas.drawRect(mBarRect,mHighlightPaint);
      if (mDrawHighlightArrow) {
        mHighlightPaint.setAlpha(255);
        float offsetY=mDeltaY * 0.07f;
        Path arrow=new Path();
        arrow.moveTo(x + 0.5f,y + offsetY * 0.3f);
        arrow.lineTo(x + 0.2f,y + offsetY);
        arrow.lineTo(x + 0.8f,y + offsetY);
        transformPath(arrow);
        mDrawCanvas.drawPath(arrow,mHighlightPaint);
      }
    }
  }
}
Program: 18868
Project: 18868
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 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);
  }
}

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 barspace the space between bars
 */
private void prepareBar(float x,float y,float barspace){
  float spaceHalf=barspace / 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: 18870
Project: 18870
Buggy source:
/** 
 * draws the x-labels on the specified y-position
 * @param yPos
 */
private void drawXLabels(float yPos){
  float[] position=new float[]{0f,0f};
  int step=mCurrentData.getDataSetCount();
  for (int i=0; i < mCurrentData.getXValCount(); i+=mXLabels.mXAxisLabelModulus) {
    position[0]=i * step;
    if (mXLabels.isCenterXLabelsEnabled())     position[0]+=(step / 2f);
    transformPointArray(position);
    if (position[0] >= mOffsetLeft && position[0] <= getWidth() - mOffsetRight) {
      String label=mCurrentData.getXVals().get(i);
      if (mXLabels.isAvoidFirstLastClippingEnabled()) {
        if (i == mCurrentData.getXValCount() - 1) {
          float width=Utils.calcTextWidth(mXLabelPaint,label);
          if (width > getOffsetRight() * 2 && position[0] + width > getWidth())           position[0]-=width / 2;
        }
 else         if (i == 0) {
          float width=Utils.calcTextWidth(mXLabelPaint,label);
          position[0]+=width / 2;
        }
      }
      mDrawCanvas.drawText(label,position[0],yPos,mXLabelPaint);
    }
  }
}

Fixed version (ground truth):
/** 
 * draws the x-labels on the specified y-position
 * @param yPos
 */
private void drawXLabels(float yPos){
  float[] position=new float[]{0f,0f};
  int step=1;
  if (this instanceof BarChart)   step=mCurrentData.getDataSetCount();
  for (int i=0; i < mCurrentData.getXValCount(); i+=mXLabels.mXAxisLabelModulus) {
    position[0]=i * step;
    if (mXLabels.isCenterXLabelsEnabled())     position[0]+=(step / 2f);
    transformPointArray(position);
    if (position[0] >= mOffsetLeft && position[0] <= getWidth() - mOffsetRight) {
      String label=mCurrentData.getXVals().get(i);
      if (mXLabels.isAvoidFirstLastClippingEnabled()) {
        if (i == mCurrentData.getXValCount() - 1) {
          float width=Utils.calcTextWidth(mXLabelPaint,label);
          if (width > getOffsetRight() * 2 && position[0] + width > getWidth())           position[0]-=width / 2;
        }
 else         if (i == 0) {
          float width=Utils.calcTextWidth(mXLabelPaint,label);
          position[0]+=width / 2;
        }
      }
      mDrawCanvas.drawText(label,position[0],yPos,mXLabelPaint);
    }
  }
}
Program: 18871
Project: 18871
Buggy source:
/** 
 * draws the vertical grid
 */
protected void drawVerticalGrid(){
  if (!mDrawVerticalGrid || mCurrentData == null)   return;
  float[] position=new float[]{0f,0f};
  int step=mCurrentData.getDataSetCount();
  for (int i=0; i < mCurrentData.getXValCount(); i+=mXLabels.mXAxisLabelModulus) {
    position[0]=i * step;
    transformPointArray(position);
    if (position[0] >= mOffsetLeft && position[0] <= getWidth()) {
      mDrawCanvas.drawLine(position[0],mOffsetTop,position[0],getHeight() - mOffsetBottom,mGridPaint);
    }
  }
}

Fixed version (ground truth):
/** 
 * draws the vertical grid
 */
protected void drawVerticalGrid(){
  if (!mDrawVerticalGrid || mCurrentData == null)   return;
  float[] position=new float[]{0f,0f};
  int step=1;
  if (this instanceof BarChart)   step=mCurrentData.getDataSetCount();
  for (int i=0; i < mCurrentData.getXValCount(); i+=mXLabels.mXAxisLabelModulus) {
    position[0]=i * step;
    transformPointArray(position);
    if (position[0] >= mOffsetLeft && position[0] <= getWidth()) {
      mDrawCanvas.drawLine(position[0],mOffsetTop,position[0],getHeight() - mOffsetBottom,mGridPaint);
    }
  }
}
Program: 18872
Project: 18872
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_piechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(PieChart)findViewById(R.id.chart1);
  Typeface tf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  mChart.setValueTypeface(tf);
  mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(),"String_Node_Str"));
  mChart.setHoleRadius(60f);
  mChart.setDescription("String_Node_Str");
  mChart.setDrawYValues(true);
  mChart.setDrawCenterText(true);
  mChart.setDrawHoleEnabled(true);
  mChart.setDrawXValues(true);
  mChart.setRotationEnabled(true);
  mChart.setUsePercentValues(true);
  mChart.setOnChartValueSelectedListener(this);
  mSeekBarX.setProgress(3);
  mSeekBarY.setProgress(100);
  mChart.animateXY(1500,1500);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
  l.setXEntrySpace(7f);
  l.setYEntrySpace(5f);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_piechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(PieChart)findViewById(R.id.chart1);
  Typeface tf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  mChart.setValueTypeface(tf);
  mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(),"String_Node_Str"));
  mChart.setHoleRadius(60f);
  mChart.setDescription("String_Node_Str");
  mChart.setDrawYValues(true);
  mChart.setDrawCenterText(true);
  mChart.setDrawHoleEnabled(true);
  mChart.setRotationAngle(0);
  mChart.setDrawXValues(true);
  mChart.setRotationEnabled(true);
  mChart.setUsePercentValues(true);
  mChart.setOnChartValueSelectedListener(this);
  mSeekBarX.setProgress(3);
  mSeekBarY.setProgress(100);
  mChart.animateXY(1500,1500);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
  l.setXEntrySpace(7f);
  l.setYEntrySpace(5f);
}
Program: 18873
Project: 18873
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_radarchart);
  mChart=(RadarChart)findViewById(R.id.chart1);
  Typeface tf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  mChart.setValueTypeface(tf);
  mChart.setDescription("String_Node_Str");
  mChart.setWebLineWidth(2f);
  mChart.setWebLineWidthInner(0.75f);
  setData();
  mChart.animateXY(1500,1500);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
  l.setXEntrySpace(7f);
  l.setYEntrySpace(5f);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_radarchart);
  mChart=(RadarChart)findViewById(R.id.chart1);
  Typeface tf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  mChart.setValueTypeface(tf);
  mChart.setDescription("String_Node_Str");
  mChart.setWebLineWidth(2f);
  mChart.setWebLineWidthInner(0.75f);
  setData();
  YLabels yl=mChart.getYLabels();
  yl.setTypeface(tf);
  yl.setLabelCount(5);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
  l.setTypeface(tf);
  l.setXEntrySpace(7f);
  l.setYEntrySpace(5f);
}
Program: 18874
Project: 18874
Buggy source:
public void setData(){
  float mult=100;
  ArrayList<Entry> yVals1=new ArrayList<Entry>();
  ArrayList<Entry> yVals2=new ArrayList<Entry>();
  for (int i=0; i < 6; i++) {
    yVals1.add(new Entry((float)(Math.random() * mult) + mult / 2,i));
  }
  for (int i=0; i < 6; i++) {
    yVals2.add(new Entry((float)(Math.random() * mult) + mult / 2,i));
  }
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < 6; i++)   xVals.add(mParties[i % mParties.length]);
  RadarDataSet set1=new RadarDataSet(yVals1,"String_Node_Str");
  set1.setColor(getResources().getColor(R.color.vordiplom_1));
  set1.setLineWidth(2f);
  RadarDataSet set2=new RadarDataSet(yVals2,"String_Node_Str");
  set2.setColor(getResources().getColor(R.color.vordiplom_5));
  set2.setLineWidth(2f);
  ArrayList<RadarDataSet> sets=new ArrayList<RadarDataSet>();
  sets.add(set1);
  sets.add(set2);
  RadarData data=new RadarData(xVals,sets);
  mChart.setData(data);
  mChart.highlightValues(null);
  mChart.invalidate();
}

Fixed version (ground truth):
public void setData(){
  float mult=150;
  ArrayList<Entry> yVals1=new ArrayList<Entry>();
  ArrayList<Entry> yVals2=new ArrayList<Entry>();
  for (int i=0; i < 6; i++) {
    yVals1.add(new Entry((float)(Math.random() * mult) + mult / 2,i));
  }
  for (int i=0; i < 6; i++) {
    yVals2.add(new Entry((float)(Math.random() * mult) + mult / 2,i));
  }
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < 6; i++)   xVals.add(mParties[i % mParties.length]);
  RadarDataSet set1=new RadarDataSet(yVals1,"String_Node_Str");
  set1.setColor(getResources().getColor(R.color.vordiplom_1));
  set1.setLineWidth(2f);
  RadarDataSet set2=new RadarDataSet(yVals2,"String_Node_Str");
  set2.setColor(getResources().getColor(R.color.vordiplom_5));
  set2.setLineWidth(2f);
  ArrayList<RadarDataSet> sets=new ArrayList<RadarDataSet>();
  sets.add(set1);
  sets.add(set2);
  RadarData data=new RadarData(xVals,sets);
  mChart.setData(data);
  mChart.highlightValues(null);
  mChart.invalidate();
}
Program: 18875
Project: 18875
Buggy source:
@Override protected void init(){
  super.init();
  mListener=new BarLineChartTouchListener(this,mMatrixTouch);
  mXLabelPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mXLabelPaint.setColor(Color.BLACK);
  mXLabelPaint.setTextAlign(Align.CENTER);
  mXLabelPaint.setTextSize(Utils.convertDpToPixel(10f));
  mYLabelPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mYLabelPaint.setColor(Color.BLACK);
  mYLabelPaint.setTextSize(Utils.convertDpToPixel(10f));
  mGridPaint=new Paint();
  mGridPaint.setColor(Color.GRAY);
  mGridPaint.setStrokeWidth(mGridWidth);
  mGridPaint.setStyle(Style.STROKE);
  mGridPaint.setAlpha(90);
  mBorderPaint=new Paint();
  mBorderPaint.setColor(Color.BLACK);
  mBorderPaint.setStrokeWidth(mGridWidth * 2f);
  mBorderPaint.setStyle(Style.STROKE);
  mGridBackgroundPaint=new Paint();
  mGridBackgroundPaint.setStyle(Style.FILL);
  mGridBackgroundPaint.setColor(Color.rgb(240,240,240));
  mHighlightPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mHighlightPaint.setStyle(Paint.Style.STROKE);
  mHighlightPaint.setStrokeWidth(2f);
  mHighlightPaint.setColor(Color.rgb(255,187,115));
  mLimitLinePaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mLimitLinePaint.setStyle(Paint.Style.STROKE);
}

Fixed version (ground truth):
@Override protected void init(){
  super.init();
  mListener=new BarLineChartTouchListener(this,mMatrixTouch);
  mXLabelPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mXLabelPaint.setColor(Color.BLACK);
  mXLabelPaint.setTextAlign(Align.CENTER);
  mXLabelPaint.setTextSize(Utils.convertDpToPixel(10f));
  mYLabelPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mYLabelPaint.setColor(Color.BLACK);
  mYLabelPaint.setTextSize(Utils.convertDpToPixel(10f));
  mGridPaint=new Paint();
  mGridPaint.setColor(Color.GRAY);
  mGridPaint.setStrokeWidth(mGridWidth);
  mGridPaint.setStyle(Style.STROKE);
  mGridPaint.setAlpha(90);
  mBorderPaint=new Paint();
  mBorderPaint.setColor(Color.BLACK);
  mBorderPaint.setStrokeWidth(mGridWidth * 2f);
  mBorderPaint.setStyle(Style.STROKE);
  mGridBackgroundPaint=new Paint();
  mGridBackgroundPaint.setStyle(Style.FILL);
  mGridBackgroundPaint.setColor(Color.rgb(240,240,240));
  mLimitLinePaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mLimitLinePaint.setStyle(Paint.Style.STROKE);
}
Program: 18876
Project: 18876
Buggy source:
/** 
 * Draws the limit lines if there are one.
 */
private void drawLimitLines(){
  ArrayList<LimitLine> limitLines=((BarLineScatterCandleData)mOriginalData).getLimitLines();
  if (limitLines == null)   return;
  float[] pts=new float[]{0,0,0,0};
  for (int i=0; i < limitLines.size(); i++) {
    LimitLine l=limitLines.get(i);
    pts[0]=0f;
    pts[1]=l.getLimit();
    pts[2]=mDeltaX;
    pts[3]=l.getLimit();
    transformPointArray(pts);
    mLimitLinePaint.setColor(l.getLineColor());
    mLimitLinePaint.setPathEffect(l.getDashPathEffect());
    mLimitLinePaint.setStrokeWidth(l.getLineWidth());
    mDrawCanvas.drawLine(pts[0],pts[1],pts[2],pts[3],mLimitLinePaint);
  }
}

Fixed version (ground truth):
/** 
 * Draws the limit lines if there are one.
 */
private void drawLimitLines(){
  ArrayList<LimitLine> limitLines=((BarLineScatterCandleRadarData)mOriginalData).getLimitLines();
  if (limitLines == null)   return;
  float[] pts=new float[]{0,0,0,0};
  for (int i=0; i < limitLines.size(); i++) {
    LimitLine l=limitLines.get(i);
    pts[0]=0f;
    pts[1]=l.getLimit();
    pts[2]=mDeltaX;
    pts[3]=l.getLimit();
    transformPointArray(pts);
    mLimitLinePaint.setColor(l.getLineColor());
    mLimitLinePaint.setPathEffect(l.getDashPathEffect());
    mLimitLinePaint.setStrokeWidth(l.getLineWidth());
    mDrawCanvas.drawLine(pts[0],pts[1],pts[2],pts[3],mLimitLinePaint);
  }
}
Program: 18877
Project: 18877
Buggy source:
/** 
 * initialize all paints and stuff
 */
protected void init(){
  Utils.init(getContext().getResources());
  mOffsetBottom=(int)Utils.convertDpToPixel(mOffsetBottom);
  mOffsetLeft=(int)Utils.convertDpToPixel(mOffsetLeft);
  mOffsetRight=(int)Utils.convertDpToPixel(mOffsetRight);
  mOffsetTop=(int)Utils.convertDpToPixel(mOffsetTop);
  mRenderPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mRenderPaint.setStyle(Style.FILL);
  mDrawPaint=new Paint();
  mDescPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mDescPaint.setColor(Color.BLACK);
  mDescPaint.setTextAlign(Align.RIGHT);
  mDescPaint.setTextSize(Utils.convertDpToPixel(9f));
  mInfoPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mInfoPaint.setColor(Color.rgb(247,189,51));
  mInfoPaint.setTextAlign(Align.CENTER);
  mInfoPaint.setTextSize(Utils.convertDpToPixel(12f));
  mValuePaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mValuePaint.setColor(Color.rgb(63,63,63));
  mValuePaint.setTextAlign(Align.CENTER);
  mValuePaint.setTextSize(Utils.convertDpToPixel(9f));
  mLegendFormPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mLegendFormPaint.setStyle(Paint.Style.FILL);
  mLegendFormPaint.setStrokeWidth(3f);
  mLegendLabelPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mLegendLabelPaint.setTextSize(Utils.convertDpToPixel(9f));
}

Fixed version (ground truth):
/** 
 * initialize all paints and stuff
 */
protected void init(){
  Utils.init(getContext().getResources());
  mOffsetBottom=(int)Utils.convertDpToPixel(mOffsetBottom);
  mOffsetLeft=(int)Utils.convertDpToPixel(mOffsetLeft);
  mOffsetRight=(int)Utils.convertDpToPixel(mOffsetRight);
  mOffsetTop=(int)Utils.convertDpToPixel(mOffsetTop);
  mRenderPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mRenderPaint.setStyle(Style.FILL);
  mDrawPaint=new Paint();
  mDescPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mDescPaint.setColor(Color.BLACK);
  mDescPaint.setTextAlign(Align.RIGHT);
  mDescPaint.setTextSize(Utils.convertDpToPixel(9f));
  mInfoPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mInfoPaint.setColor(Color.rgb(247,189,51));
  mInfoPaint.setTextAlign(Align.CENTER);
  mInfoPaint.setTextSize(Utils.convertDpToPixel(12f));
  mValuePaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mValuePaint.setColor(Color.rgb(63,63,63));
  mValuePaint.setTextAlign(Align.CENTER);
  mValuePaint.setTextSize(Utils.convertDpToPixel(9f));
  mLegendFormPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mLegendFormPaint.setStyle(Paint.Style.FILL);
  mLegendFormPaint.setStrokeWidth(3f);
  mLegendLabelPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mLegendLabelPaint.setTextSize(Utils.convertDpToPixel(9f));
  mHighlightPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mHighlightPaint.setStyle(Paint.Style.STROKE);
  mHighlightPaint.setStrokeWidth(2f);
  mHighlightPaint.setColor(Color.rgb(255,187,115));
}
Program: 18878
Project: 18878
Buggy source:
/** 
 * Returns the rectangle that defines the borders of the chart-value surface (into which the actual values are drawn).
 * @return
 */
public Rect getContentRect(){
  return mContentRect;
}

Fixed version (ground truth):
/** 
 * Returns the rectangle that defines the borders of the chart-value surface (into which the actual values are drawn).
 * @return
 */
public RectF getContentRect(){
  return mContentRect;
}
Program: 18879
Project: 18879
Buggy source:
/** 
 * draws all MarkerViews on the highlighted positions
 */
protected void drawMarkers(){
  if (mMarkerView == null || !mDrawMarkerViews || !valuesToHighlight())   return;
  for (int i=0; i < mIndicesToHightlight.length; i++) {
    int xIndex=mIndicesToHightlight[i].getXIndex();
    if (xIndex <= mDeltaX && xIndex <= mDeltaX * mPhaseX)     drawMarkerView(xIndex,mIndicesToHightlight[i].getDataSetIndex());
  }
}

Fixed version (ground truth):
/** 
 * draws all MarkerViews on the highlighted positions
 */
protected void drawMarkers(){
  if (mMarkerView == null || !mDrawMarkerViews || !valuesToHighlight())   return;
  for (int i=0; i < mIndicesToHightlight.length; i++) {
    int xIndex=mIndicesToHightlight[i].getXIndex();
    int dataSetIndex=mIndicesToHightlight[i].getDataSetIndex();
    if (xIndex <= mDeltaX && xIndex <= mDeltaX * mPhaseX) {
      Entry e=getEntryByDataSetIndex(xIndex,dataSetIndex);
      if (e == null)       continue;
      float[] pos=getMarkerPosition(e,dataSetIndex);
      mMarkerView.refreshContent(e,dataSetIndex);
      mMarkerView.draw(mDrawCanvas,pos[0],pos[1]);
    }
  }
}
Program: 18880
Project: 18880
Buggy source:
/** 
 * returns the center point of the chart in pixels
 * @return
 */
public PointF getCenter(){
  return new PointF(getWidth() / 2,getHeight() / 2);
}

Fixed version (ground truth):
/** 
 * returns the center point of the chart in pixels
 * @return
 */
public PointF getCenter(){
  return new PointF(getWidth() / 2f,getHeight() / 2f);
}
Program: 18881
Project: 18881
Buggy source:
@Override protected void init(){
  super.init();
  mFilledPaint=new Paint();
  mFilledPaint.setStyle(Paint.Style.FILL);
  mFilledPaint.setColor(mColorDarkBlue);
  mFilledPaint.setAlpha(130);
  mCirclePaintInner=new Paint(Paint.ANTI_ALIAS_FLAG);
  mCirclePaintInner.setStyle(Paint.Style.FILL);
  mCirclePaintInner.setColor(Color.WHITE);
  mHighlightPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mHighlightPaint.setStyle(Paint.Style.STROKE);
  mHighlightPaint.setStrokeWidth(2f);
  mHighlightPaint.setColor(Color.rgb(255,187,115));
}

Fixed version (ground truth):
@Override protected void init(){
  super.init();
  mCirclePaintInner=new Paint(Paint.ANTI_ALIAS_FLAG);
  mCirclePaintInner.setStyle(Paint.Style.FILL);
  mCirclePaintInner.setColor(Color.WHITE);
  mHighlightPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mHighlightPaint.setStyle(Paint.Style.STROKE);
  mHighlightPaint.setStrokeWidth(2f);
  mHighlightPaint.setColor(Color.rgb(255,187,115));
}
Program: 18883
Project: 18883
Buggy source:
@Override protected void prepareContentRect(){
  super.prepareContentRect();
  float width=mContentRect.width() + mOffsetLeft + mOffsetRight;
  float height=mContentRect.height() + mOffsetTop + mOffsetBottom;
  float diameter=getDiameter();
  float shift=((PieData)mCurrentData).getDataSet().getSelectionShift();
  mCircleBox.set(width / 2 - diameter / 2 + shift,height / 2 - diameter / 2 + shift,width / 2 + diameter / 2 - shift,height / 2 + diameter / 2 - shift);
}

Fixed version (ground truth):
@Override protected void prepareContentRect(){
  super.prepareContentRect();
  if (mDataNotSet)   return;
  float width=mContentRect.width() + mOffsetLeft + mOffsetRight;
  float height=mContentRect.height() + mOffsetTop + mOffsetBottom;
  float diameter=getDiameter();
  float shift=((PieData)mCurrentData).getDataSet().getSelectionShift();
  mCircleBox.set(width / 2 - diameter / 2 + shift,height / 2 - diameter / 2 + shift,width / 2 + diameter / 2 - shift,height / 2 + diameter / 2 - shift);
}
Program: 18884
Project: 18884
Buggy source:
/** 
 * draws the circle value indicators
 */
@Override protected void drawAdditional(){
  mRenderPaint.setStyle(Paint.Style.FILL);
  ArrayList<LineDataSet> dataSets=(ArrayList<LineDataSet>)mCurrentData.getDataSets();
  for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
    LineDataSet dataSet=dataSets.get(i);
    if (dataSet.isDrawCirclesEnabled()) {
      ArrayList<? extends Entry> entries=dataSet.getYVals();
      float[] positions=generateTransformedValues(entries,0f);
      for (int j=0; j < positions.length * mPhaseX; j+=2) {
        mRenderPaint.setColor(dataSet.getCircleColor(j));
        if (isOffContentRight(positions[j]))         break;
        if (isOffContentLeft(positions[j]) || isOffContentTop(positions[j + 1]) || isOffContentBottom(positions[j + 1]))         continue;
        mDrawCanvas.drawCircle(positions[j],positions[j + 1],dataSet.getCircleSize(),mRenderPaint);
        mDrawCanvas.drawCircle(positions[j],positions[j + 1],dataSet.getCircleSize() / 2,mCirclePaintInner);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * draws the circle value indicators
 */
@Override protected void drawAdditional(){
  mRenderPaint.setStyle(Paint.Style.FILL);
  ArrayList<LineDataSet> dataSets=(ArrayList<LineDataSet>)mCurrentData.getDataSets();
  for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
    LineDataSet dataSet=dataSets.get(i);
    if (dataSet.isDrawCirclesEnabled()) {
      ArrayList<? extends Entry> entries=dataSet.getYVals();
      float[] positions=generateTransformedValues(entries,0f);
      for (int j=0; j < positions.length * mPhaseX; j+=2) {
        mRenderPaint.setColor(dataSet.getCircleColor(j / 2));
        if (isOffContentRight(positions[j]))         break;
        if (isOffContentLeft(positions[j]) || isOffContentTop(positions[j + 1]) || isOffContentBottom(positions[j + 1]))         continue;
        mDrawCanvas.drawCircle(positions[j],positions[j + 1],dataSet.getCircleSize(),mRenderPaint);
        mDrawCanvas.drawCircle(positions[j],positions[j + 1],dataSet.getCircleSize() / 2,mCirclePaintInner);
      }
    }
  }
}
Program: 18885
Project: 18885
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_candlechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(CandleStickChart)findViewById(R.id.chart1);
  mChart.setDrawYValues(false);
  mChart.setUnit("String_Node_Str");
  mChart.setDescription("String_Node_Str");
  mChart.setMaxVisibleValueCount(60);
  mChart.setPinchZoom(false);
  mChart.setDrawVerticalGrid(false);
  mChart.setDrawHorizontalGrid(false);
  mChart.setDrawGridBackground(false);
  XLabels xLabels=mChart.getXLabels();
  xLabels.setPosition(XLabelPosition.BOTTOM);
  xLabels.setCenterXLabelText(true);
  xLabels.setSpaceBetweenLabels(0);
  mChart.setDrawYLabels(false);
  mChart.setDrawLegend(false);
  mSeekBarX.setProgress(10);
  mSeekBarY.setProgress(100);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_candlechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(CandleStickChart)findViewById(R.id.chart1);
  mChart.setDrawYValues(false);
  mChart.setUnit("String_Node_Str");
  mChart.setDescription("String_Node_Str");
  mChart.setMaxVisibleValueCount(60);
  mChart.setPinchZoom(false);
  mChart.setDrawVerticalGrid(false);
  mChart.setDrawGridBackground(false);
  XLabels xLabels=mChart.getXLabels();
  xLabels.setPosition(XLabelPosition.BOTTOM);
  xLabels.setCenterXLabelText(true);
  xLabels.setSpaceBetweenLabels(2);
  mChart.setDrawYLabels(true);
  mChart.setDrawLegend(false);
  mSeekBarX.setProgress(30);
  mSeekBarY.setProgress(100);
}
Program: 18886
Project: 18886
Buggy source:
@Override public void onProgressChanged(SeekBar seekBar,int progress,boolean fromUser){
  tvX.setText("String_Node_Str" + (mSeekBarX.getProgress() + 1));
  tvY.setText("String_Node_Str" + (mSeekBarY.getProgress()));
  ArrayList<CandleEntry> yVals1=new ArrayList<CandleEntry>();
  for (int i=0; i < mSeekBarX.getProgress() + 1; i++) {
    float mult=(mSeekBarY.getProgress() + 1);
    float val=(float)(Math.sin(i) * mult) + 100f;
    yVals1.add(new CandleEntry(i,val + 7,val - 7,val + 4,val - 4));
  }
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < mSeekBarX.getProgress() + 1; i++) {
    xVals.add((int)yVals1.get(i).getVal() + "String_Node_Str" + mChart.getUnit());
  }
  CandleDataSet set1=new CandleDataSet(yVals1,"String_Node_Str");
  set1.setColors(ColorTemplate.createColors(getApplicationContext(),ColorTemplate.VORDIPLOM_COLORS));
  CandleData data=new CandleData(xVals,set1);
  mChart.setData(data);
  mChart.invalidate();
}

Fixed version (ground truth):
@Override public void onProgressChanged(SeekBar seekBar,int progress,boolean fromUser){
  tvX.setText("String_Node_Str" + (mSeekBarX.getProgress() + 1));
  tvY.setText("String_Node_Str" + (mSeekBarY.getProgress()));
  ArrayList<CandleEntry> yVals1=new ArrayList<CandleEntry>();
  for (int i=0; i < mSeekBarX.getProgress() + 1; i++) {
    float mult=(mSeekBarY.getProgress() + 1);
    float val=(float)(Math.sin(i) * mult) + 400f;
    boolean even=i % 2 == 0;
    yVals1.add(new CandleEntry(i,even ? val + 10 : val - 10,even ? val - 10 : val + 10,even ? val + 5 : val - 5,even ? val - 5 : val + 5));
  }
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < mSeekBarX.getProgress() + 1; i++) {
    xVals.add("String_Node_Str" + (i + 1));
  }
  CandleDataSet set1=new CandleDataSet(yVals1,"String_Node_Str");
  set1.setColors(ColorTemplate.createColors(getApplicationContext(),ColorTemplate.VORDIPLOM_COLORS));
  CandleData data=new CandleData(xVals,set1);
  mChart.setData(data);
  mChart.invalidate();
}
Program: 18887
Project: 18887
Buggy source:
/** 
 * setup the x-axis labels
 */
protected void prepareXLabels(){
  StringBuffer a=new StringBuffer();
  for (int i=0; i < mCurrentData.getXValAverageLength() + mXLabels.getSpaceBetweenLabels(); i++) {
    a.append("String_Node_Str");
  }
  mXLabels.mXLabelWidth=Utils.calcTextWidth(mXLabelPaint,a.toString());
  mXLabels.mXLabelHeight=Utils.calcTextWidth(mXLabelPaint,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * setup the x-axis labels
 */
protected void prepareXLabels(){
  StringBuffer a=new StringBuffer();
  int max=(int)Math.round(mCurrentData.getXValAverageLength() + mXLabels.getSpaceBetweenLabels());
  for (int i=0; i < max; i++) {
    a.append("String_Node_Str");
  }
  mXLabels.mLabelWidth=Utils.calcTextWidth(mXLabelPaint,a.toString());
  mXLabels.mLabelHeight=Utils.calcTextWidth(mXLabelPaint,"String_Node_Str");
}
Program: 18888
Project: 18888
Buggy source:
/** 
 * calculates the modulus for x-labels and grid
 */
protected void calcModulus(){
  float[] values=new float[9];
  mMatrixTouch.getValues(values);
  mXLabels.mXAxisLabelModulus=(int)Math.ceil((mCurrentData.getXValCount() * mXLabels.mXLabelWidth) / (mContentRect.width() * values[Matrix.MSCALE_X]));
}

Fixed version (ground truth):
/** 
 * calculates the modulus for x-labels and grid
 */
protected void calcModulus(){
  float[] values=new float[9];
  mMatrixTouch.getValues(values);
  mXLabels.mXAxisLabelModulus=(int)Math.ceil((mCurrentData.getXValCount() * mXLabels.mLabelWidth) / (mContentRect.width() * values[Matrix.MSCALE_X]));
}
Program: 18889
Project: 18889
Buggy source:
@Override protected void drawData(){
  ArrayList<CandleDataSet> dataSets=(ArrayList<CandleDataSet>)mCurrentData.getDataSets();
  mRenderPaint.setStyle(Paint.Style.FILL);
  for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
    CandleDataSet dataSet=dataSets.get(i);
    ArrayList<CandleEntry> entries=(ArrayList<CandleEntry>)dataSet.getYVals();
    mRenderPaint.setStrokeWidth(dataSet.getShadowWidth());
    float[] shadowPoints=new float[4];
    float[] bodyPoints=new float[4];
    for (int j=0; j < entries.size() * mPhaseX; j++) {
      mRenderPaint.setColor(dataSet.getColor(j));
      CandleEntry e=entries.get(j);
      transformShadow(shadowPoints,e);
      transformBody(bodyPoints,e,dataSet.getBodySpace());
      float xShadow=shadowPoints[0];
      float leftBody=bodyPoints[0];
      float rightBody=bodyPoints[2];
      float high=shadowPoints[1];
      float low=shadowPoints[3];
      float open=bodyPoints[1];
      float close=bodyPoints[3];
      if (isOffContentRight(leftBody))       break;
      if (isOffContentLeft(rightBody) && isOffContentTop(low) && isOffContentBottom(high))       continue;
      mDrawCanvas.drawLine(xShadow,low,xShadow,high,mRenderPaint);
      mDrawCanvas.drawRect(leftBody,open,rightBody,close,mRenderPaint);
    }
  }
}

Fixed version (ground truth):
@Override protected void drawData(){
  ArrayList<CandleDataSet> dataSets=(ArrayList<CandleDataSet>)mCurrentData.getDataSets();
  for (int i=0; i < mCurrentData.getDataSetCount(); i++) {
    CandleDataSet dataSet=dataSets.get(i);
    ArrayList<CandleEntry> entries=(ArrayList<CandleEntry>)dataSet.getYVals();
    mRenderPaint.setStrokeWidth(dataSet.getShadowWidth());
    float[] shadowPoints=new float[4];
    float[] bodyPoints=new float[4];
    for (int j=0; j < entries.size() * mPhaseX; j++) {
      mRenderPaint.setColor(dataSet.getColor(j));
      CandleEntry e=entries.get(j);
      transformShadow(shadowPoints,e);
      transformBody(bodyPoints,e,dataSet.getBodySpace());
      float xShadow=shadowPoints[0];
      float leftBody=bodyPoints[0];
      float rightBody=bodyPoints[2];
      float high=shadowPoints[1];
      float low=shadowPoints[3];
      float open=bodyPoints[1];
      float close=bodyPoints[3];
      if (isOffContentRight(leftBody))       break;
      if (isOffContentLeft(rightBody) && isOffContentTop(low) && isOffContentBottom(high))       continue;
      mDrawCanvas.drawLine(xShadow,low,xShadow,high,mRenderPaint);
      if (open > close)       mRenderPaint.setStyle(Paint.Style.FILL);
 else       mRenderPaint.setStyle(Paint.Style.STROKE);
      mDrawCanvas.drawRect(leftBody,open,rightBody,close,mRenderPaint);
    }
  }
}
Program: 18890
Project: 18890
Buggy source:
/** 
 * calculates the average length (in characters) across all x-value strings
 */
private void calcXValAverageLength(){
  if (mXVals.size() == 0) {
    mXValAverageLength=1;
    return;
  }
  int sum=0;
  for (int i=0; i < mXVals.size(); i++) {
    sum+=mXVals.get(i).length();
  }
  mXValAverageLength=sum / mXVals.size();
}

Fixed version (ground truth):
/** 
 * calculates the average length (in characters) across all x-value strings
 */
private void calcXValAverageLength(){
  if (mXVals.size() == 0) {
    mXValAverageLength=1;
    return;
  }
  float sum=0f;
  for (int i=0; i < mXVals.size(); i++) {
    sum+=mXVals.get(i).length();
  }
  mXValAverageLength=sum / (float)mXVals.size();
}
Program: 18891
Project: 18891
Buggy source:
/** 
 * returns the average length (in characters) across all values in the x-vals array
 * @return
 */
public int getXValAverageLength(){
  return mXValAverageLength;
}

Fixed version (ground truth):
/** 
 * returns the average length (in characters) across all values in the x-vals array
 * @return
 */
public float getXValAverageLength(){
  return mXValAverageLength;
}
Program: 18892
Project: 18892
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_draw_chart);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setOnDrawListener(this);
  mChart.setDrawingEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setDrawYValues(false);
  mChart.setHighlightEnabled(true);
  mChart.setAutoFinish(false);
  mChart.setDrawLegend(false);
  initWithDummyData();
  mChart.setYRange(-40f,40f,true);
}

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_draw_chart);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setOnDrawListener(this);
  mChart.setDrawingEnabled(true);
  mChart.setDragScaleEnabled(true);
  mChart.setDrawYValues(false);
  mChart.setHighlightEnabled(true);
  mChart.setAutoFinish(false);
  mChart.setDrawLegend(false);
  initWithDummyData();
  mChart.setYRange(-40f,40f,true);
}
Program: 18893
Project: 18893
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_linechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setStartAtZero(true);
  mChart.setDrawYValues(true);
  mChart.setDrawBorder(true);
  mChart.setBorderPositions(new BorderPosition[]{BorderPosition.BOTTOM});
  mChart.setDescription("String_Node_Str");
  mChart.setInvertYAxisEnabled(true);
  mChart.setHighlightEnabled(true);
  mChart.setTouchEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setPinchZoom(true);
  MyMarkerView mv=new MyMarkerView(this,R.layout.custom_marker_view);
  mv.setOffsets(-mv.getMeasuredWidth() / 2,-mv.getMeasuredHeight());
  mChart.setMarkerView(mv);
  mChart.setHighlightIndicatorEnabled(false);
  XLabels xl=mChart.getXLabels();
  xl.setAvoidFirstLastClipping(true);
  setData(25,50);
  Legend l=mChart.getLegend();
  l.setForm(LegendForm.LINE);
  mChart.invalidate();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_linechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setStartAtZero(true);
  mChart.setDrawYValues(true);
  mChart.setDrawBorder(true);
  mChart.setBorderPositions(new BorderPosition[]{BorderPosition.BOTTOM});
  mChart.setDescription("String_Node_Str");
  mChart.setInvertYAxisEnabled(true);
  mChart.setHighlightEnabled(true);
  mChart.setTouchEnabled(true);
  mChart.setDragScaleEnabled(false);
  mChart.setPinchZoom(true);
  MyMarkerView mv=new MyMarkerView(this,R.layout.custom_marker_view);
  mv.setOffsets(-mv.getMeasuredWidth() / 2,-mv.getMeasuredHeight());
  mChart.setMarkerView(mv);
  mChart.setHighlightIndicatorEnabled(false);
  XLabels xl=mChart.getXLabels();
  xl.setAvoidFirstLastClipping(true);
  setData(25,50);
  Legend l=mChart.getLegend();
  l.setForm(LegendForm.LINE);
  mChart.invalidate();
}
Program: 18894
Project: 18894
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_linechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setStartAtZero(false);
  mChart.setDrawYValues(false);
  mChart.setDrawBorder(true);
  mChart.setBorderPositions(new BorderPosition[]{BorderPosition.BOTTOM});
  mChart.setDescription("String_Node_Str");
  mChart.setNoDataTextDescription("String_Node_Str");
  mChart.setHighlightEnabled(true);
  mChart.setTouchEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setPinchZoom(true);
  MyMarkerView mv=new MyMarkerView(this,R.layout.custom_marker_view);
  mv.setOffsets(-mv.getMeasuredWidth() / 2,-mv.getMeasuredHeight());
  mChart.setMarkerView(mv);
  mChart.setHighlightIndicatorEnabled(false);
  setData(45,100);
  mChart.animateX(2500);
  Legend l=mChart.getLegend();
  l.setForm(LegendForm.LINE);
  mChart.invalidate();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_linechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setStartAtZero(false);
  mChart.setDrawYValues(false);
  mChart.setDrawBorder(true);
  mChart.setBorderPositions(new BorderPosition[]{BorderPosition.BOTTOM});
  mChart.setDescription("String_Node_Str");
  mChart.setNoDataTextDescription("String_Node_Str");
  mChart.setHighlightEnabled(true);
  mChart.setTouchEnabled(true);
  mChart.setDragScaleEnabled(true);
  mChart.setPinchZoom(true);
  MyMarkerView mv=new MyMarkerView(this,R.layout.custom_marker_view);
  mv.setOffsets(-mv.getMeasuredWidth() / 2,-mv.getMeasuredHeight());
  mChart.setMarkerView(mv);
  mChart.setHighlightIndicatorEnabled(false);
  setData(45,100);
  mChart.animateX(2500);
  Legend l=mChart.getLegend();
  l.setForm(LegendForm.LINE);
  mChart.invalidate();
}
Program: 18895
Project: 18895
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.setOnChartValueSelectedListener(this);
  mChart.setDrawYValues(false);
  mChart.setHighlightEnabled(true);
  mChart.setTouchEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setPinchZoom(false);
  mSeekBarX.setProgress(20);
  mSeekBarY.setProgress(100);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
}

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.setHighlightEnabled(true);
  mChart.setTouchEnabled(true);
  mChart.setDragScaleEnabled(true);
  mChart.setPinchZoom(false);
  mSeekBarX.setProgress(20);
  mSeekBarY.setProgress(100);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
}