nus-yam/ex-repair huggingface dataset:
Program: 26942
Project: 26942
Buggy source:
/** 
 * Generates the path that is used for filled drawing.
 * @param entries
 * @return
 */
private Path generateFilledPath(ArrayList<? extends Entry> entries){
  Path filled=new Path();
  filled.moveTo(entries.get(0).getXIndex(),entries.get(0).getVal() * mPhaseY);
  for (int x=1; x < entries.size() * mPhaseX; x++) {
    Entry e=entries.get(x);
    filled.lineTo(e.getXIndex(),e.getVal() * mPhaseY);
  }
  filled.lineTo(entries.get((int)((entries.size() - 1) * mPhaseX)).getXIndex(),mYChartMin);
  filled.lineTo(entries.get(0).getXIndex(),mYChartMin);
  filled.close();
  return filled;
}

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

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

Fixed version (ground truth):
/** 
 * This method converts dp unit to equivalent pixels, depending on device density. NEEDS UTILS TO BE INITIALIZED BEFORE USAGE.
 * @param dp A value in dp (density independent pixels) unit. Which we needto convert into pixels
 * @return A float value to represent px equivalent to dp depending ondevice density
 */
public static float convertDpToPixel(float dp){
  if (mRes == null) {
    Log.e("String_Node_Str","String_Node_Str");
    return dp;
  }
  DisplayMetrics metrics=mRes.getDisplayMetrics();
  float px=dp * (metrics.densityDpi / 160f);
  return px;
}
Program: 26945
Project: 26945
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: 26946
Project: 26946
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: 26947
Project: 26947
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: 26949
Project: 26949
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: 26950
Project: 26950
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: 26951
Project: 26951
Buggy source:
/** 
 * Returns the first Entry object found at the given xIndex with binary search. Returns null if no Entry object at that index. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @param xIndex
 * @return
 */
public Entry getEntryForXIndex(int x){
  int low=0;
  int high=mYVals.size();
  while (low <= high) {
    int m=(high + low) / 2;
    if (x == mYVals.get(m).getXIndex()) {
      return mYVals.get(m);
    }
    if (x > mYVals.get(m).getXIndex())     low=m + 1;
 else     high=m - 1;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the first Entry object found at the given xIndex with binary search. Returns null if no Entry object at that index. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @param xIndex
 * @return
 */
public Entry getEntryForXIndex(int x){
  int low=0;
  int high=mYVals.size() - 1;
  while (low <= high) {
    int m=(high + low) / 2;
    if (x == mYVals.get(m).getXIndex()) {
      return mYVals.get(m);
    }
    if (x > mYVals.get(m).getXIndex())     low=m + 1;
 else     high=m - 1;
  }
  return null;
}
Program: 26952
Project: 26952
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: 26953
Project: 26953
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: 26954
Project: 26954
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: 26955
Project: 26955
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: 26956
Project: 26956
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: 26957
Project: 26957
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: 26958
Project: 26958
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: 26959
Project: 26959
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: 26960
Project: 26960
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: 26961
Project: 26961
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: 26962
Project: 26962
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: 26963
Project: 26963
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: 26964
Project: 26964
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: 26965
Project: 26965
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);
}
Program: 26966
Project: 26966
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);
  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_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.setDragScaleEnabled(true);
  mChart.setMaxVisibleValueCount(200);
  mChart.setPinchZoom(true);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
  Legend l=mChart.getLegend();
  l.setPosition(LegendPosition.RIGHT_OF_CHART);
}
Program: 26967
Project: 26967
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);
  double touchOffset=mDeltaX * 0.025;
  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;
    }
  }
  if (mDataNotSet) {
    Log.i(LOG_TAG,"String_Node_Str");
    return null;
  }
  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;
  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;
    }
  }
  if (mDataNotSet) {
    Log.i(LOG_TAG,"String_Node_Str");
    return null;
  }
  ArrayList<SelInfo> valsAtIndex=getYValsAtIndex(xIndex);
  dataSetIndex=getClosestDataSetIndex(valsAtIndex,(float)yTouchVal);
  if (dataSetIndex == -1)   return null;
  return new Highlight(xIndex,dataSetIndex);
}
Program: 26968
Project: 26968
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 < mCurrentData.getXVals().size() && 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();
    if (xIndex <= mDeltaX && xIndex <= mDeltaX * mPhaseX)     drawMarkerView(xIndex,mIndicesToHightlight[i].getDataSetIndex());
  }
}
Program: 26969
Project: 26969
Buggy source:
/** 
 * Draws the view that is displayed when a value is highlighted.
 * @param xIndex the selected x-index
 * @param dataSetIndex the index of the selected DataSet
 */
private void drawMarkerView(int xIndex,int dataSetIndex){
  Entry e=getEntryByDataSetIndex(xIndex,dataSetIndex);
  if (e == null)   return;
  float xPos=(float)xIndex;
  if (this instanceof BarChart || this instanceof CandleStickChart)   xPos+=0.5f;
  float[] pts=new float[]{xPos,e.getVal() * mPhaseY};
  transformPointArray(pts);
  float posX=pts[0];
  float posY=pts[1];
  mMarkerView.refreshContent(e,dataSetIndex);
  mMarkerView.draw(mDrawCanvas,posX,posY);
}

Fixed version (ground truth):
/** 
 * Draws the view that is displayed when a value is highlighted.
 * @param xIndex the selected x-index
 * @param dataSetIndex the index of the selected DataSet
 */
private void drawMarkerView(int xIndex,int dataSetIndex){
  Entry e=getEntryByDataSetIndex(xIndex,dataSetIndex);
  if (e == null) {
    return;
  }
  float xPos=(float)xIndex;
  if (this instanceof BarChart || this instanceof CandleStickChart)   xPos+=0.5f;
  float[] pts=new float[]{xPos,e.getVal() * mPhaseY};
  transformPointArray(pts);
  float posX=pts[0];
  float posY=pts[1];
  mMarkerView.refreshContent(e,dataSetIndex);
  mMarkerView.draw(mDrawCanvas,posX,posY);
}
Program: 26970
Project: 26970
Buggy source:
/** 
 * Returns the first Entry object found at the given xIndex. Returns null if no Entry object at that index. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @param xIndex
 * @return
 */
public Entry getEntryForXIndex(int xIndex){
  for (int i=0; i < mYVals.size(); i++) {
    if (xIndex == mYVals.get(i).getXIndex())     return mYVals.get(i);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the first Entry object found at the given xIndex with binary search. Returns null if no Entry object at that index. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @param xIndex
 * @return
 */
public Entry getEntryForXIndex(int x){
  int low=0;
  int high=mYVals.size();
  while (low <= high) {
    int m=(high + low) / 2;
    if (x == mYVals.get(m).getXIndex()) {
      return mYVals.get(m);
    }
    if (x > mYVals.get(m).getXIndex())     low=m + 1;
 else     high=m - 1;
  }
  return null;
}