nus-yam/ex-repair huggingface dataset:
Program: 18233
Project: 18233
Buggy source:
/** 
 * Draws the provided path in filled mode with the provided color and alpha. Special thanks to Angelo Suzuki (https://github.com/tinsukE) for this.
 * @param c
 * @param filledPath
 * @param fillColor
 * @param fillAlpha
 */
protected void drawFilledPath(Canvas c,Path filledPath,int fillColor,int fillAlpha){
  c.save();
  c.clipPath(filledPath);
  int color=(fillAlpha << 24) | (fillColor & 0xffffff);
  c.drawColor(color);
  c.restore();
}

Fixed version (ground truth):
/** 
 * Draws the provided path in filled mode with the provided color and alpha. Special thanks to Angelo Suzuki (https://github.com/tinsukE) for this.
 * @param c
 * @param filledPath
 * @param fillColor
 * @param fillAlpha
 */
protected void drawFilledPath(Canvas c,Path filledPath,int fillColor,int fillAlpha){
  int color=(fillAlpha << 24) | (fillColor & 0xffffff);
  if (clipPathSupported()) {
    c.save();
    c.clipPath(filledPath);
    c.drawColor(color);
    c.restore();
  }
 else {
    Paint.Style previous=mRenderPaint.getStyle();
    int previousColor=mRenderPaint.getColor();
    mRenderPaint.setStyle(Paint.Style.FILL);
    mRenderPaint.setColor(color);
    c.drawPath(filledPath,mRenderPaint);
    mRenderPaint.setColor(previousColor);
    mRenderPaint.setStyle(previous);
  }
}
Program: 18234
Project: 18234
Buggy source:
public BarLineChartTouchListener(BarLineChartBase<? extends BarLineScatterCandleBubbleData<? extends IBarLineScatterCandleBubbleDataSet<? extends Entry>>> chart,Matrix touchMatrix){
  super(chart);
  this.mMatrix=touchMatrix;
}

Fixed version (ground truth):
public BarLineChartTouchListener(BarLineChartBase<? extends BarLineScatterCandleBubbleData<? extends IBarLineScatterCandleBubbleDataSet<? extends Entry>>> chart,Matrix touchMatrix){
  super(chart);
  this.mMatrix=touchMatrix;
  this.mDragTriggerDist=Utils.convertDpToPixel(3f);
}
Program: 18237
Project: 18237
Buggy source:
public BarLineChartTouchListener(BarLineChartBase<? extends BarLineScatterCandleBubbleData<? extends IBarLineScatterCandleBubbleDataSet<? extends Entry>>> chart,Matrix touchMatrix){
  super(chart);
  this.mMatrix=touchMatrix;
  this.mDragTriggerDist=Utils.convertDpToPixel(3f);
}

Fixed version (ground truth):
public BarLineChartTouchListener(BarLineChartBase<? extends BarLineScatterCandleBubbleData<? extends IBarLineScatterCandleBubbleDataSet<? extends Entry>>> chart,Matrix touchMatrix){
  super(chart);
  this.mMatrix=touchMatrix;
  this.mDragTriggerDist=Utils.convertDpToPixel(3f);
  this.mMinScalePointerDistance=Utils.convertDpToPixel(3.5f);
}
Program: 18238
Project: 18238
Buggy source:
/** 
 * Highlights upon dragging, generates callbacks for the selection-listener.
 * @param e
 */
private void performHighlightDrag(MotionEvent e){
  Highlight h=mChart.getHighlightByTouchPoint(e.getX(),e.getY());
  if (h != null && !h.equalTo(mLastHighlighted)) {
    mLastHighlighted=h;
    mChart.highlightTouch(h);
  }
}

Fixed version (ground truth):
/** 
 * Highlights upon dragging, generates callbacks for the selection-listener.
 * @param e
 */
private void performHighlightDrag(MotionEvent e){
  Highlight h=mChart.getHighlightByTouchPoint(e.getX(),e.getY());
  if (h != null && !h.equalTo(mLastHighlighted)) {
    mLastHighlighted=h;
    mChart.highlightValue(h,true);
  }
}
Program: 18239
Project: 18239
Buggy source:
/** 
 * limits the maximum scale and X translation of the given matrix
 * @param matrix
 */
public void limitTransAndScale(Matrix matrix,RectF content){
  matrix.getValues(matrixBuffer);
  float curTransX=matrixBuffer[Matrix.MTRANS_X];
  float curScaleX=matrixBuffer[Matrix.MSCALE_X];
  float curTransY=matrixBuffer[Matrix.MTRANS_Y];
  float curScaleY=matrixBuffer[Matrix.MSCALE_Y];
  mScaleX=Math.min(Math.max(mMinScaleX,curScaleX),mMaxScaleX);
  mScaleY=Math.min(Math.max(mMinScaleY,curScaleY),mMaxScaleY);
  float width=0f;
  float height=0f;
  if (content != null) {
    width=content.width();
    height=content.height();
  }
  float maxTransX=-width * (mScaleX - 1f);
  float newTransX=Math.min(Math.max(curTransX,maxTransX - mTransOffsetX),mTransOffsetX);
  mTransX=newTransX;
  float maxTransY=height * (mScaleY - 1f);
  float newTransY=Math.max(Math.min(curTransY,maxTransY + mTransOffsetY),-mTransOffsetY);
  mTransY=newTransY;
  matrixBuffer[Matrix.MTRANS_X]=mTransX;
  matrixBuffer[Matrix.MSCALE_X]=mScaleX;
  matrixBuffer[Matrix.MTRANS_Y]=mTransY;
  matrixBuffer[Matrix.MSCALE_Y]=mScaleY;
  matrix.setValues(matrixBuffer);
}

Fixed version (ground truth):
/** 
 * limits the maximum scale and X translation of the given matrix
 * @param matrix
 */
public void limitTransAndScale(Matrix matrix,RectF content){
  matrix.getValues(matrixBuffer);
  float curTransX=matrixBuffer[Matrix.MTRANS_X];
  float curScaleX=matrixBuffer[Matrix.MSCALE_X];
  float curTransY=matrixBuffer[Matrix.MTRANS_Y];
  float curScaleY=matrixBuffer[Matrix.MSCALE_Y];
  mScaleX=Math.min(Math.max(mMinScaleX,curScaleX),mMaxScaleX);
  mScaleY=Math.min(Math.max(mMinScaleY,curScaleY),mMaxScaleY);
  float width=0f;
  float height=0f;
  if (content != null) {
    width=content.width();
    height=content.height();
  }
  float maxTransX=-width * (mScaleX - 1f);
  mTransX=Math.min(Math.max(curTransX,maxTransX - mTransOffsetX),mTransOffsetX);
  float maxTransY=height * (mScaleY - 1f);
  mTransY=Math.max(Math.min(curTransY,maxTransY + mTransOffsetY),-mTransOffsetY);
  matrixBuffer[Matrix.MTRANS_X]=mTransX;
  matrixBuffer[Matrix.MSCALE_X]=mScaleX;
  matrixBuffer[Matrix.MTRANS_Y]=mTransY;
  matrixBuffer[Matrix.MSCALE_Y]=mScaleY;
  matrix.setValues(matrixBuffer);
}
Program: 18243
Project: 18243
Buggy source:
protected void drawValue(Canvas c,String valueText,float x,float y){
  c.drawText(valueText,x,y,mValuePaint);
}

Fixed version (ground truth):
protected void drawValue(Canvas c,String valueText,float x,float y,int color){
  mValuePaint.setColor(color);
  c.drawText(valueText,x,y,mValuePaint);
}
Program: 18245
Project: 18245
Buggy source:
@Override public void calcMinMax(int start,int end){
  if (mYVals == null)   return;
  if (mYVals.size() == 0)   return;
  int endValue;
  if (end == 0 || end >= mYVals.size())   endValue=mYVals.size() - 1;
 else   endValue=end;
  mYMin=yMin(mYVals.get(start));
  mYMax=yMax(mYVals.get(start));
  for (int i=start; i < endValue; i++) {
    final BubbleEntry entry=mYVals.get(i);
    final float ymin=yMin(entry);
    final float ymax=yMax(entry);
    if (ymin < mYMin) {
      mYMin=ymin;
    }
    if (ymax > mYMax) {
      mYMax=ymax;
    }
    final float xmin=xMin(entry);
    final float xmax=xMax(entry);
    if (xmin < mXMin) {
      mXMin=xmin;
    }
    if (xmax > mXMax) {
      mXMax=xmax;
    }
    final float size=largestSize(entry);
    if (size > mMaxSize) {
      mMaxSize=size;
    }
  }
}

Fixed version (ground truth):
@Override public void calcMinMax(int start,int end){
  if (mYVals == null)   return;
  if (mYVals.size() == 0)   return;
  int endValue;
  if (end == 0 || end >= mYVals.size())   endValue=mYVals.size() - 1;
 else   endValue=end;
  mYMin=yMin(mYVals.get(start));
  mYMax=yMax(mYVals.get(start));
  for (int i=start; i <= endValue; i++) {
    final BubbleEntry entry=mYVals.get(i);
    float ymin=yMin(entry);
    float ymax=yMax(entry);
    if (ymin < mYMin) {
      mYMin=ymin;
    }
    if (ymax > mYMax) {
      mYMax=ymax;
    }
    final float xmin=xMin(entry);
    final float xmax=xMax(entry);
    if (xmin < mXMin) {
      mXMin=xmin;
    }
    if (xmax > mXMax) {
      mXMax=xmax;
    }
    final float size=largestSize(entry);
    if (size > mMaxSize) {
      mMaxSize=size;
    }
  }
}
Program: 18246
Project: 18246
Buggy source:
/** 
 * sets the color that is used for filling the line surface
 * @param color
 */
public void setFillColor(int color){
  mFillColor=color;
}

Fixed version (ground truth):
/** 
 * sets the color that is used for filling the line surface
 * @param color
 */
public void setFillColor(int color){
  mFillColor=color;
  mFillDrawable=null;
}
Program: 18247
Project: 18247
Buggy source:
protected void drawDataSet(Canvas c,IRadarDataSet dataSet){
  float sliceangle=mChart.getSliceAngle();
  float factor=mChart.getFactor();
  PointF center=mChart.getCenterOffsets();
  Path surface=new Path();
  boolean hasMovedToPoint=false;
  for (int j=0; j < dataSet.getEntryCount(); j++) {
    mRenderPaint.setColor(dataSet.getColor(j));
    Entry e=dataSet.getEntryForIndex(j);
    PointF p=Utils.getPosition(center,(e.getVal() - mChart.getYChartMin()) * factor,sliceangle * j + mChart.getRotationAngle());
    if (Float.isNaN(p.x))     continue;
    if (!hasMovedToPoint) {
      surface.moveTo(p.x,p.y);
      hasMovedToPoint=true;
    }
 else     surface.lineTo(p.x,p.y);
  }
  surface.close();
  mRenderPaint.setStrokeWidth(dataSet.getLineWidth());
  mRenderPaint.setStyle(Paint.Style.STROKE);
  if (!dataSet.isDrawFilledEnabled() || dataSet.getFillAlpha() < 255)   c.drawPath(surface,mRenderPaint);
  final Drawable drawable=dataSet.getFillDrawable();
  if (drawable != null) {
    drawFilledPath(c,surface,drawable);
  }
 else {
    drawFilledPath(c,surface,dataSet.getFillColor(),dataSet.getFillAlpha());
  }
}

Fixed version (ground truth):
protected void drawDataSet(Canvas c,IRadarDataSet dataSet){
  float sliceangle=mChart.getSliceAngle();
  float factor=mChart.getFactor();
  PointF center=mChart.getCenterOffsets();
  Path surface=new Path();
  boolean hasMovedToPoint=false;
  for (int j=0; j < dataSet.getEntryCount(); j++) {
    mRenderPaint.setColor(dataSet.getColor(j));
    Entry e=dataSet.getEntryForIndex(j);
    PointF p=Utils.getPosition(center,(e.getVal() - mChart.getYChartMin()) * factor,sliceangle * j + mChart.getRotationAngle());
    if (Float.isNaN(p.x))     continue;
    if (!hasMovedToPoint) {
      surface.moveTo(p.x,p.y);
      hasMovedToPoint=true;
    }
 else     surface.lineTo(p.x,p.y);
  }
  surface.close();
  final Drawable drawable=dataSet.getFillDrawable();
  if (drawable != null) {
    drawFilledPath(c,surface,drawable);
  }
 else {
    drawFilledPath(c,surface,dataSet.getFillColor(),dataSet.getFillAlpha());
  }
  mRenderPaint.setStrokeWidth(dataSet.getLineWidth());
  mRenderPaint.setStyle(Paint.Style.STROKE);
  if (!dataSet.isDrawFilledEnabled() || dataSet.getFillAlpha() < 255)   c.drawPath(surface,mRenderPaint);
}
Program: 18248
Project: 18248
Buggy source:
@Override public boolean onDoubleTap(MotionEvent e){
  mLastGesture=ChartGesture.DOUBLE_TAP;
  OnChartGestureListener l=mChart.getOnChartGestureListener();
  if (l != null) {
    l.onChartDoubleTapped(e);
    return super.onDoubleTap(e);
  }
  if (mChart.isDoubleTapToZoomEnabled()) {
    PointF trans=getTrans(e.getX(),e.getY());
    mChart.zoom(mChart.isScaleXEnabled() ? 1.4f : 1f,mChart.isScaleYEnabled() ? 1.4f : 1f,trans.x,trans.y);
    if (mChart.isLogEnabled())     Log.i("String_Node_Str","String_Node_Str" + trans.x + "String_Node_Str"+ trans.y);
  }
  return super.onDoubleTap(e);
}

Fixed version (ground truth):
@Override public boolean onDoubleTap(MotionEvent e){
  mLastGesture=ChartGesture.DOUBLE_TAP;
  OnChartGestureListener l=mChart.getOnChartGestureListener();
  if (l != null) {
    l.onChartDoubleTapped(e);
  }
  if (mChart.isDoubleTapToZoomEnabled()) {
    PointF trans=getTrans(e.getX(),e.getY());
    mChart.zoom(mChart.isScaleXEnabled() ? 1.4f : 1f,mChart.isScaleYEnabled() ? 1.4f : 1f,trans.x,trans.y);
    if (mChart.isLogEnabled())     Log.i("String_Node_Str","String_Node_Str" + trans.x + "String_Node_Str"+ trans.y);
  }
  return super.onDoubleTap(e);
}
Program: 18249
Project: 18249
Buggy source:
public void setFloatValue(Float value){
  this.floatValue=value;
}

Fixed version (ground truth):
public void setFloatValue(float value){
  this.floatValue=value;
}
Program: 18250
Project: 18250
Buggy source:
protected void drawDataSet(Canvas c,BarDataSet dataSet,int index){
  Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
  mShadowPaint.setColor(dataSet.getBarShadowColor());
  float phaseX=mAnimator.getPhaseX();
  float phaseY=mAnimator.getPhaseY();
  List<BarEntry> entries=dataSet.getYVals();
  BarBuffer buffer=mBarBuffers[index];
  buffer.setPhases(phaseX,phaseY);
  buffer.setBarSpace(dataSet.getBarSpace());
  buffer.setDataSet(index);
  buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency()));
  buffer.feed(dataSet);
  trans.pointValuesToPixel(buffer.buffer);
  for (int j=0; j < buffer.size(); j+=4) {
    if (!mViewPortHandler.isInBoundsTop(buffer.buffer[j + 3]))     break;
    if (!mViewPortHandler.isInBoundsBottom(buffer.buffer[j + 1]))     continue;
    if (mChart.isDrawBarShadowEnabled()) {
      c.drawRect(mViewPortHandler.contentLeft(),buffer.buffer[j + 1],mViewPortHandler.contentRight(),buffer.buffer[j + 3],mShadowPaint);
    }
    mRenderPaint.setColor(dataSet.getColor(j / 4));
    c.drawRect(buffer.buffer[j],buffer.buffer[j + 1],buffer.buffer[j + 2],buffer.buffer[j + 3],mRenderPaint);
  }
}

Fixed version (ground truth):
@Override protected void drawDataSet(Canvas c,IBarDataSet dataSet,int index){
  Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
  mShadowPaint.setColor(dataSet.getBarShadowColor());
  float phaseX=mAnimator.getPhaseX();
  float phaseY=mAnimator.getPhaseY();
  BarBuffer buffer=mBarBuffers[index];
  buffer.setPhases(phaseX,phaseY);
  buffer.setBarSpace(dataSet.getBarSpace());
  buffer.setDataSet(index);
  buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency()));
  buffer.feed(dataSet);
  trans.pointValuesToPixel(buffer.buffer);
  for (int j=0; j < buffer.size(); j+=4) {
    if (!mViewPortHandler.isInBoundsTop(buffer.buffer[j + 3]))     break;
    if (!mViewPortHandler.isInBoundsBottom(buffer.buffer[j + 1]))     continue;
    if (mChart.isDrawBarShadowEnabled()) {
      c.drawRect(mViewPortHandler.contentLeft(),buffer.buffer[j + 1],mViewPortHandler.contentRight(),buffer.buffer[j + 3],mShadowPaint);
    }
    mRenderPaint.setColor(dataSet.getColor(j / 4));
    c.drawRect(buffer.buffer[j],buffer.buffer[j + 1],buffer.buffer[j + 2],buffer.buffer[j + 3],mRenderPaint);
  }
}
Program: 18252
Project: 18252
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_bubblechart_noseekbar);
  mChart=(BubbleChart)findViewById(R.id.chart1);
  setup(mChart);
  mChart.getXAxis().setDrawGridLines(false);
}

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_bubblechart_noseekbar);
  mChart=(BubbleChart)findViewById(R.id.chart1);
  setup(mChart);
  mChart.getXAxis().setDrawGridLines(false);
  mChart.getAxisLeft().setDrawGridLines(false);
  mChart.setPinchZoom(true);
}
Program: 18253
Project: 18253
Buggy source:
private void setData(){
  RealmResults<RealmDemoData> result=mRealm.allObjects(RealmDemoData.class);
  RealmBubbleDataSet<RealmDemoData> set=new RealmBubbleDataSet<RealmDemoData>(result,"String_Node_Str","String_Node_Str","String_Node_Str");
  set.setLabel("String_Node_Str");
  set.setColors(ColorTemplate.COLORFUL_COLORS);
  ArrayList<IBubbleDataSet> dataSets=new ArrayList<IBubbleDataSet>();
  dataSets.add(set);
  BubbleData data=new BubbleData(result,"String_Node_Str",dataSets);
  styleData(data);
  mChart.setData(data);
  mChart.animateY(1400,Easing.EasingOption.EaseInOutQuart);
}

Fixed version (ground truth):
private void setData(){
  RealmResults<RealmDemoData> result=mRealm.allObjects(RealmDemoData.class);
  RealmBubbleDataSet<RealmDemoData> set=new RealmBubbleDataSet<RealmDemoData>(result,"String_Node_Str","String_Node_Str","String_Node_Str");
  set.setLabel("String_Node_Str");
  set.setColors(ColorTemplate.COLORFUL_COLORS,110);
  ArrayList<IBubbleDataSet> dataSets=new ArrayList<IBubbleDataSet>();
  dataSets.add(set);
  BubbleData data=new BubbleData(result,"String_Node_Str",dataSets);
  styleData(data);
  mChart.setData(data);
  mChart.animateY(1400,Easing.EasingOption.EaseInOutQuart);
}
Program: 18254
Project: 18254
Buggy source:
@Override protected void onResume(){
  super.onResume();
  writeToDBBubble(12);
  setData();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  writeToDBBubble(10);
  setData();
}
Program: 18255
Project: 18255
Buggy source:
@Override public void calcMinMax(int start,int end){
  if (mYVals == null)   return;
  if (mYVals.size() == 0)   return;
  int endValue;
  if (end == 0)   endValue=mYVals.size() - 1;
 else   endValue=end;
  mYMin=yMin(mYVals.get(start));
  mYMax=yMax(mYVals.get(start));
  for (int i=start; i < endValue; i++) {
    final BubbleEntry entry=mYVals.get(i);
    final float ymin=yMin(entry);
    final float ymax=yMax(entry);
    if (ymin < mYMin) {
      mYMin=ymin;
    }
    if (ymax > mYMax) {
      mYMax=ymax;
    }
    final float xmin=xMin(entry);
    final float xmax=xMax(entry);
    if (xmin < mXMin) {
      mXMin=xmin;
    }
    if (xmax > mXMax) {
      mXMax=xmax;
    }
    final float size=largestSize(entry);
    if (size > mMaxSize) {
      mMaxSize=size;
    }
  }
}

Fixed version (ground truth):
@Override public void calcMinMax(int start,int end){
  if (mYVals == null)   return;
  if (mYVals.size() == 0)   return;
  int endValue;
  if (end == 0 || end >= mYVals.size())   endValue=mYVals.size() - 1;
 else   endValue=end;
  mYMin=yMin(mYVals.get(start));
  mYMax=yMax(mYVals.get(start));
  for (int i=start; i < endValue; i++) {
    final BubbleEntry entry=mYVals.get(i);
    final float ymin=yMin(entry);
    final float ymax=yMax(entry);
    if (ymin < mYMin) {
      mYMin=ymin;
    }
    if (ymax > mYMax) {
      mYMax=ymax;
    }
    final float xmin=xMin(entry);
    final float xmax=xMax(entry);
    if (xmin < mXMin) {
      mXMin=xmin;
    }
    if (xmax > mXMax) {
      mXMax=xmax;
    }
    final float size=largestSize(entry);
    if (size > mMaxSize) {
      mMaxSize=size;
    }
  }
}
Program: 18256
Project: 18256
Buggy source:
@Override public void calcMinMax(int start,int end){
  if (mValues == null)   return;
  if (mValues.size() == 0)   return;
  int endValue;
  if (end == 0)   endValue=mValues.size() - 1;
 else   endValue=end;
  mYMin=yMin(mValues.get(start));
  mYMax=yMax(mValues.get(start));
  for (int i=start; i < endValue; i++) {
    final BubbleEntry entry=mValues.get(i);
    final float ymin=yMin(entry);
    final float ymax=yMax(entry);
    if (ymin < mYMin) {
      mYMin=ymin;
    }
    if (ymax > mYMax) {
      mYMax=ymax;
    }
    final float xmin=xMin(entry);
    final float xmax=xMax(entry);
    if (xmin < mXMin) {
      mXMin=xmin;
    }
    if (xmax > mXMax) {
      mXMax=xmax;
    }
    final float size=largestSize(entry);
    if (size > mMaxSize) {
      mMaxSize=size;
    }
  }
}

Fixed version (ground truth):
@Override public void calcMinMax(int start,int end){
  if (mValues == null)   return;
  if (mValues.size() == 0)   return;
  int endValue;
  if (end == 0 || end >= mValues.size())   endValue=mValues.size() - 1;
 else   endValue=end;
  mYMin=yMin(mValues.get(start));
  mYMax=yMax(mValues.get(start));
  for (int i=start; i < endValue; i++) {
    final BubbleEntry entry=mValues.get(i);
    final float ymin=yMin(entry);
    final float ymax=yMax(entry);
    if (ymin < mYMin) {
      mYMin=ymin;
    }
    if (ymax > mYMax) {
      mYMax=ymax;
    }
    final float xmin=xMin(entry);
    final float xmax=xMax(entry);
    if (xmin < mXMin) {
      mXMin=xmin;
    }
    if (xmax > mXMax) {
      mXMax=xmax;
    }
    final float size=largestSize(entry);
    if (size > mMaxSize) {
      mMaxSize=size;
    }
  }
}
Program: 18257
Project: 18257
Buggy source:
/** 
 * performs all kinds of initialization calculations, such as min-max and value count and sum
 */
protected void init(){
  checkLegal();
  calcMinMax(mLastStart,mLastEnd);
  calcYValueSum();
  calcYValueCount();
  calcXValAverageLength();
}

Fixed version (ground truth):
/** 
 * performs all kinds of initialization calculations, such as min-max and value count and sum
 */
protected void init(){
  checkLegal();
  calcMinMax(mLastStart,mLastEnd);
  calcYValueCount();
  calcXValAverageLength();
}
Program: 18258
Project: 18258
Buggy source:
/** 
 * Adds an Entry to the DataSet at the specified index. Entries are added to the end of the list.
 * @param e
 * @param dataSetIndex
 */
public void addEntry(Entry e,int dataSetIndex){
  if (mDataSets.size() > dataSetIndex && dataSetIndex >= 0) {
    float val=e.getVal();
    T set=mDataSets.get(dataSetIndex);
    if (mYValCount == 0) {
      mYMin=val;
      mYMax=val;
      if (set.getAxisDependency() == AxisDependency.LEFT) {
        mLeftAxisMax=e.getVal();
        mLeftAxisMin=e.getVal();
      }
 else {
        mRightAxisMax=e.getVal();
        mRightAxisMin=e.getVal();
      }
    }
 else {
      if (mYMax < val)       mYMax=val;
      if (mYMin > val)       mYMin=val;
      if (set.getAxisDependency() == AxisDependency.LEFT) {
        if (mLeftAxisMax < e.getVal())         mLeftAxisMax=e.getVal();
        if (mLeftAxisMin > e.getVal())         mLeftAxisMin=e.getVal();
      }
 else {
        if (mRightAxisMax < e.getVal())         mRightAxisMax=e.getVal();
        if (mRightAxisMin > e.getVal())         mRightAxisMin=e.getVal();
      }
    }
    mYValCount+=1;
    mYValueSum+=val;
    handleEmptyAxis(getFirstLeft(),getFirstRight());
    set.addEntry(e);
  }
 else {
    Log.e("String_Node_Str","String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Adds an Entry to the DataSet at the specified index. Entries are added to the end of the list.
 * @param e
 * @param dataSetIndex
 */
public void addEntry(Entry e,int dataSetIndex){
  if (mDataSets.size() > dataSetIndex && dataSetIndex >= 0) {
    float val=e.getVal();
    T set=mDataSets.get(dataSetIndex);
    if (mYValCount == 0) {
      mYMin=val;
      mYMax=val;
      if (set.getAxisDependency() == AxisDependency.LEFT) {
        mLeftAxisMax=e.getVal();
        mLeftAxisMin=e.getVal();
      }
 else {
        mRightAxisMax=e.getVal();
        mRightAxisMin=e.getVal();
      }
    }
 else {
      if (mYMax < val)       mYMax=val;
      if (mYMin > val)       mYMin=val;
      if (set.getAxisDependency() == AxisDependency.LEFT) {
        if (mLeftAxisMax < e.getVal())         mLeftAxisMax=e.getVal();
        if (mLeftAxisMin > e.getVal())         mLeftAxisMin=e.getVal();
      }
 else {
        if (mRightAxisMax < e.getVal())         mRightAxisMax=e.getVal();
        if (mRightAxisMin > e.getVal())         mRightAxisMin=e.getVal();
      }
    }
    mYValCount+=1;
    handleEmptyAxis(getFirstLeft(),getFirstRight());
    set.addEntry(e);
  }
 else {
    Log.e("String_Node_Str","String_Node_Str");
  }
}
Program: 18259
Project: 18259
Buggy source:
/** 
 * Adds a DataSet dynamically.
 * @param d
 */
public void addDataSet(T d){
  if (d == null)   return;
  mYValCount+=d.getEntryCount();
  mYValueSum+=d.getYValueSum();
  if (mDataSets.size() <= 0) {
    mYMax=d.getYMax();
    mYMin=d.getYMin();
    if (d.getAxisDependency() == AxisDependency.LEFT) {
      mLeftAxisMax=d.getYMax();
      mLeftAxisMin=d.getYMin();
    }
 else {
      mRightAxisMax=d.getYMax();
      mRightAxisMin=d.getYMin();
    }
  }
 else {
    if (mYMax < d.getYMax())     mYMax=d.getYMax();
    if (mYMin > d.getYMin())     mYMin=d.getYMin();
    if (d.getAxisDependency() == AxisDependency.LEFT) {
      if (mLeftAxisMax < d.getYMax())       mLeftAxisMax=d.getYMax();
      if (mLeftAxisMin > d.getYMin())       mLeftAxisMin=d.getYMin();
    }
 else {
      if (mRightAxisMax < d.getYMax())       mRightAxisMax=d.getYMax();
      if (mRightAxisMin > d.getYMin())       mRightAxisMin=d.getYMin();
    }
  }
  mDataSets.add(d);
  handleEmptyAxis(getFirstLeft(),getFirstRight());
}

Fixed version (ground truth):
/** 
 * Adds a DataSet dynamically.
 * @param d
 */
public void addDataSet(T d){
  if (d == null)   return;
  mYValCount+=d.getEntryCount();
  if (mDataSets.size() <= 0) {
    mYMax=d.getYMax();
    mYMin=d.getYMin();
    if (d.getAxisDependency() == AxisDependency.LEFT) {
      mLeftAxisMax=d.getYMax();
      mLeftAxisMin=d.getYMin();
    }
 else {
      mRightAxisMax=d.getYMax();
      mRightAxisMin=d.getYMin();
    }
  }
 else {
    if (mYMax < d.getYMax())     mYMax=d.getYMax();
    if (mYMin > d.getYMin())     mYMin=d.getYMin();
    if (d.getAxisDependency() == AxisDependency.LEFT) {
      if (mLeftAxisMax < d.getYMax())       mLeftAxisMax=d.getYMax();
      if (mLeftAxisMin > d.getYMin())       mLeftAxisMin=d.getYMin();
    }
 else {
      if (mRightAxisMax < d.getYMax())       mRightAxisMax=d.getYMax();
      if (mRightAxisMin > d.getYMin())       mRightAxisMin=d.getYMin();
    }
  }
  mDataSets.add(d);
  handleEmptyAxis(getFirstLeft(),getFirstRight());
}
Program: 18260
Project: 18260
Buggy source:
/** 
 * Creates a new DataSet object with the given values it represents. Also, a label that describes the DataSet can be specified. The label can also be used to retrieve the DataSet from a ChartData object.
 * @param yVals
 * @param label
 */
public DataSet(List<T> yVals,String label){
  this.mLabel=label;
  this.mYVals=yVals;
  if (mYVals == null)   mYVals=new ArrayList<T>();
  mColors=new ArrayList<Integer>();
  mColors.add(Color.rgb(140,234,255));
  calcMinMax(mLastStart,mLastEnd);
  calcYValueSum();
}

Fixed version (ground truth):
/** 
 * Creates a new DataSet object with the given values it represents. Also, a label that describes the DataSet can be specified. The label can also be used to retrieve the DataSet from a ChartData object.
 * @param yVals
 * @param label
 */
public DataSet(List<T> yVals,String label){
  this.mLabel=label;
  this.mYVals=yVals;
  if (mYVals == null)   mYVals=new ArrayList<T>();
  mColors=new ArrayList<Integer>();
  mColors.add(Color.rgb(140,234,255));
  calcMinMax(mLastStart,mLastEnd);
}
Program: 18261
Project: 18261
Buggy source:
/** 
 * Removes the first Entry (at index 0) of this DataSet from the entries array. Returns true if successful, false if not.
 * @return
 */
public boolean removeFirst(){
  T entry=mYVals.remove(0);
  boolean removed=entry != null;
  if (removed) {
    float val=entry.getVal();
    mYValueSum-=val;
    calcMinMax(mLastStart,mLastEnd);
  }
  return removed;
}

Fixed version (ground truth):
/** 
 * Removes the first Entry (at index 0) of this DataSet from the entries array. Returns true if successful, false if not.
 * @return
 */
public boolean removeFirst(){
  T entry=mYVals.remove(0);
  boolean removed=entry != null;
  if (removed) {
    float val=entry.getVal();
    calcMinMax(mLastStart,mLastEnd);
  }
  return removed;
}
Program: 18262
Project: 18262
Buggy source:
/** 
 * Use this method to tell the data set that the underlying data has changed
 */
public void notifyDataSetChanged(){
  calcMinMax(mLastStart,mLastEnd);
  calcYValueSum();
}

Fixed version (ground truth):
/** 
 * Use this method to tell the data set that the underlying data has changed
 */
public void notifyDataSetChanged(){
  calcMinMax(mLastStart,mLastEnd);
}
Program: 18263
Project: 18263
Buggy source:
/** 
 * Adds an Entry to the DataSet dynamically. Entries are added to the end of the list. This will also recalculate the current minimum and maximum values of the DataSet and the value-sum.
 * @param e
 */
@SuppressWarnings("String_Node_Str") public void addEntry(Entry e){
  if (e == null)   return;
  float val=e.getVal();
  if (mYVals == null) {
    mYVals=new ArrayList<T>();
  }
  if (mYVals.size() == 0) {
    mYMax=val;
    mYMin=val;
  }
 else {
    if (mYMax < val)     mYMax=val;
    if (mYMin > val)     mYMin=val;
  }
  mYValueSum+=val;
  mYVals.add((T)e);
}

Fixed version (ground truth):
/** 
 * Adds an Entry to the DataSet dynamically. Entries are added to the end of the list. This will also recalculate the current minimum and maximum values of the DataSet and the value-sum.
 * @param e
 */
@SuppressWarnings("String_Node_Str") public void addEntry(Entry e){
  if (e == null)   return;
  float val=e.getVal();
  if (mYVals == null) {
    mYVals=new ArrayList<T>();
  }
  if (mYVals.size() == 0) {
    mYMax=val;
    mYMin=val;
  }
 else {
    if (mYMax < val)     mYMax=val;
    if (mYMin > val)     mYMin=val;
  }
  mYVals.add((T)e);
}
Program: 18264
Project: 18264
Buggy source:
/** 
 * Removes the last Entry (at index size-1) of this DataSet from the entries array. Returns true if successful, false if not.
 * @return
 */
public boolean removeLast(){
  if (mYVals.size() <= 0)   return false;
  T entry=mYVals.remove(mYVals.size() - 1);
  boolean removed=entry != null;
  if (removed) {
    float val=entry.getVal();
    mYValueSum-=val;
    calcMinMax(mLastStart,mLastEnd);
  }
  return removed;
}

Fixed version (ground truth):
/** 
 * Removes the last Entry (at index size-1) of this DataSet from the entries array. Returns true if successful, false if not.
 * @return
 */
public boolean removeLast(){
  if (mYVals.size() <= 0)   return false;
  T entry=mYVals.remove(mYVals.size() - 1);
  boolean removed=entry != null;
  if (removed) {
    float val=entry.getVal();
    calcMinMax(mLastStart,mLastEnd);
  }
  return removed;
}
Program: 18265
Project: 18265
Buggy source:
/** 
 * Adds an Entry to the DataSet dynamically. Entries are added to their appropriate index respective to it's x-index. This will also recalculate the current minimum and maximum values of the DataSet and the value-sum.
 * @param e
 */
@SuppressWarnings("String_Node_Str") public void addEntryOrdered(Entry e){
  if (e == null)   return;
  float val=e.getVal();
  if (mYVals == null) {
    mYVals=new ArrayList<T>();
  }
  if (mYVals.size() == 0) {
    mYMax=val;
    mYMin=val;
  }
 else {
    if (mYMax < val)     mYMax=val;
    if (mYMin > val)     mYMin=val;
  }
  mYValueSum+=val;
  if (mYVals.size() > 0 && mYVals.get(mYVals.size() - 1).getXIndex() > e.getXIndex()) {
    int closestIndex=getEntryIndex(e.getXIndex(),Rounding.UP);
    mYVals.add(closestIndex,(T)e);
    return;
  }
  mYVals.add((T)e);
}

Fixed version (ground truth):
/** 
 * Adds an Entry to the DataSet dynamically. Entries are added to their appropriate index respective to it's x-index. This will also recalculate the current minimum and maximum values of the DataSet and the value-sum.
 * @param e
 */
@SuppressWarnings("String_Node_Str") public void addEntryOrdered(Entry e){
  if (e == null)   return;
  float val=e.getVal();
  if (mYVals == null) {
    mYVals=new ArrayList<T>();
  }
  if (mYVals.size() == 0) {
    mYMax=val;
    mYMin=val;
  }
 else {
    if (mYMax < val)     mYMax=val;
    if (mYMin > val)     mYMin=val;
  }
  if (mYVals.size() > 0 && mYVals.get(mYVals.size() - 1).getXIndex() > e.getXIndex()) {
    int closestIndex=getEntryIndex(e.getXIndex(),Rounding.UP);
    mYVals.add(closestIndex,(T)e);
    return;
  }
  mYVals.add((T)e);
}
Program: 18266
Project: 18266
Buggy source:
private void setData(){
  RealmResults<RealmDemoData> result=mRealm.allObjects(RealmDemoData.class);
  RealmBarDataSet<RealmDemoData> set=new RealmBarDataSet<RealmDemoData>(result,"String_Node_Str","String_Node_Str");
  System.out.println("String_Node_Str" + set.getStackSize());
  set.setValueTextSize(9f);
  set.setColors(getColors(set.getStackSize()));
  set.setLabel("String_Node_Str");
  set.setStackLabels(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  System.out.println("String_Node_Str" + set.getStackSize());
  ArrayList<IBarDataSet> dataSets=new ArrayList<IBarDataSet>();
  dataSets.add(set);
  BarData data=new BarData(result,"String_Node_Str",dataSets);
  mChart.setData(data);
  mChart.animateY(1400,Easing.EasingOption.EaseInOutQuart);
}

Fixed version (ground truth):
private void setData(){
  RealmResults<RealmDemoData> result=mRealm.allObjects(RealmDemoData.class);
  RealmBarDataSet<RealmDemoData> set=new RealmBarDataSet<RealmDemoData>(result,"String_Node_Str","String_Node_Str","String_Node_Str");
  set.setValueTextSize(9f);
  set.setColors(getColors(set.getStackSize()));
  set.setLabel("String_Node_Str");
  set.setStackLabels(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  ArrayList<IBarDataSet> dataSets=new ArrayList<IBarDataSet>();
  dataSets.add(set);
  BarData data=new BarData(result,"String_Node_Str",dataSets);
  mChart.setData(data);
  mChart.animateY(1400,Easing.EasingOption.EaseInOutQuart);
}
Program: 18267
Project: 18267
Buggy source:
@Override protected void onResume(){
  super.onResume();
  writeToDBStack(4);
  setData();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  writeToDBStack(200);
  setData();
}
Program: 18268
Project: 18268
Buggy source:
public RealmFloat(float value){
  this.value=value;
}

Fixed version (ground truth):
public RealmFloat(float floatValue){
  this.floatValue=floatValue;
}
Program: 18269
Project: 18269
Buggy source:
public RealmBarDataSet(RealmResults<T> results,String yValuesField,String xIndexField){
  super(results,yValuesField,xIndexField);
  mHighLightColor=Color.rgb(0,0,0);
  calcStackSize();
}

Fixed version (ground truth):
/** 
 * Constructor for supporting stacked values.
 * @param results
 * @param yValuesField
 * @param xIndexField
 * @param stackValueFieldName
 */
public RealmBarDataSet(RealmResults<T> results,String yValuesField,String xIndexField,String stackValueFieldName){
  super(results,yValuesField,xIndexField);
  this.mStackValueFieldName=stackValueFieldName;
  mHighLightColor=Color.rgb(0,0,0);
  buildData(this.results);
}
Program: 18270
Project: 18270
Buggy source:
@Override public void build(RealmResults<T> results){
  for (  T realmObject : results) {
    DynamicRealmObject dynamicObject=new DynamicRealmObject(realmObject);
    try {
      float value=dynamicObject.getFloat(mValuesField);
      mValues.add(new BarEntry(value,dynamicObject.getInt(mIndexField)));
    }
 catch (    IllegalArgumentException e) {
      DynamicRealmList list=dynamicObject.getList(mValuesField);
      float[] values=new float[list.size()];
      int i=0;
      for (      DynamicRealmObject o : list) {
        values[i]=o.getFloat("String_Node_Str");
        i++;
      }
      mValues.add(new BarEntry(values,dynamicObject.getInt(mIndexField)));
    }
  }
  calcStackSize();
}

Fixed version (ground truth):
@Override public void build(RealmResults<T> results){
}
Program: 18271
Project: 18271
Buggy source:
/** 
 * Returns the lowest x-index (value on the x-axis) that is still visible on the chart.
 * @return
 */
@Override public int getLowestVisibleXIndex(){
  float[] pts=new float[]{mViewPortHandler.contentLeft(),mViewPortHandler.contentBottom()};
  getTransformer(AxisDependency.LEFT).pixelsToValue(pts);
  return (pts[0] <= 0) ? 0 : (int)(pts[0] + 1);
}

Fixed version (ground truth):
/** 
 * Returns the lowest x-index (value on the x-axis) that is still visible on the chart.
 * @return
 */
@Override public int getLowestVisibleXIndex(){
  float[] pts=new float[]{mViewPortHandler.contentLeft(),mViewPortHandler.contentBottom()};
  getTransformer(AxisDependency.LEFT).pixelsToValue(pts);
  return (pts[0] <= 0) ? 0 : (int)Math.round(pts[0] + 1.0f);
}
Program: 18272
Project: 18272
Buggy source:
/** 
 * Returns the highest x-index (value on the x-axis) that is still visible on the chart.
 * @return
 */
@Override public int getHighestVisibleXIndex(){
  float[] pts=new float[]{mViewPortHandler.contentRight(),mViewPortHandler.contentBottom()};
  getTransformer(AxisDependency.LEFT).pixelsToValue(pts);
  return (pts[0] >= mData.getXValCount()) ? mData.getXValCount() - 1 : (int)pts[0];
}

Fixed version (ground truth):
/** 
 * Returns the highest x-index (value on the x-axis) that is still visible on the chart.
 * @return
 */
@Override public int getHighestVisibleXIndex(){
  float[] pts=new float[]{mViewPortHandler.contentRight(),mViewPortHandler.contentBottom()};
  getTransformer(AxisDependency.LEFT).pixelsToValue(pts);
  return (Math.round(pts[0]) >= mData.getXValCount()) ? mData.getXValCount() - 1 : (int)Math.round(pts[0]);
}
Program: 18273
Project: 18273
Buggy source:
@Override public void calcMinMax(int start,int end){
  if (mYVals == null)   return;
  if (mYVals.size() == 0)   return;
  int endValue;
  if (end == 0)   endValue=mYVals.size() - 1;
 else   endValue=end;
  mYMin=yMin(mYVals.get(start));
  mYMax=yMax(mYVals.get(start));
  for (int i=start; i <= endValue; i++) {
    final BubbleEntry entry=mYVals.get(i);
    final float ymin=yMin(entry);
    final float ymax=yMax(entry);
    if (ymin < mYMin) {
      mYMin=ymin;
    }
    if (ymax > mYMax) {
      mYMax=ymax;
    }
    final float xmin=xMin(entry);
    final float xmax=xMax(entry);
    if (xmin < mXMin) {
      mXMin=xmin;
    }
    if (xmax > mXMax) {
      mXMax=xmax;
    }
    final float size=largestSize(entry);
    if (size > mMaxSize) {
      mMaxSize=size;
    }
  }
}

Fixed version (ground truth):
@Override public void calcMinMax(int start,int end){
  if (mYVals == null)   return;
  if (mYVals.size() == 0)   return;
  int endValue;
  if (end == 0)   endValue=mYVals.size() - 1;
 else   endValue=end;
  mYMin=yMin(mYVals.get(start));
  mYMax=yMax(mYVals.get(start));
  for (int i=start; i < endValue; i++) {
    final BubbleEntry entry=mYVals.get(i);
    final float ymin=yMin(entry);
    final float ymax=yMax(entry);
    if (ymin < mYMin) {
      mYMin=ymin;
    }
    if (ymax > mYMax) {
      mYMax=ymax;
    }
    final float xmin=xMin(entry);
    final float xmax=xMax(entry);
    if (xmin < mXMin) {
      mXMin=xmin;
    }
    if (xmax > mXMax) {
      mXMax=xmax;
    }
    final float size=largestSize(entry);
    if (size > mMaxSize) {
      mMaxSize=size;
    }
  }
}
Program: 18274
Project: 18274
Buggy source:
/** 
 * Returns the first Entry index found at the given xIndex with binary search. If the no Entry at the specified x-index is found, this method returns the index at the closest x-index. Returns -1 if no Entry object at that index. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @param x
 * @return
 */
public int getEntryIndex(int x){
  int low=0;
  int high=mYVals.size() - 1;
  int closest=-1;
  while (low <= high) {
    int m=(high + low) / 2;
    if (x == mYVals.get(m).getXIndex()) {
      while (m > 0 && mYVals.get(m - 1).getXIndex() == x)       m--;
      return m;
    }
    if (x > mYVals.get(m).getXIndex())     low=m + 1;
 else     high=m - 1;
    closest=m;
  }
  return closest;
}

Fixed version (ground truth):
/** 
 * Returns the first Entry index found at the given xIndex with binary search. If the no Entry at the specified x-index is found, this method returns the index as determined by the given rounding mode. Returns -1 if no Entry object at that index. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @param x
 * @return
 */
public int getEntryIndex(int x,Rounding rounding){
  int low=0;
  int high=mYVals.size() - 1;
  int closest=-1;
  while (low <= high) {
    int m=(high + low) / 2;
    if (x == mYVals.get(m).getXIndex()) {
      while (m > 0 && mYVals.get(m - 1).getXIndex() == x)       m--;
      return m;
    }
    if (x > mYVals.get(m).getXIndex())     low=m + 1;
 else     high=m - 1;
    closest=m;
  }
  if (closest != -1) {
    int closestXIndex=mYVals.get(closest).getXIndex();
    if (rounding == Rounding.UP) {
      if (closestXIndex < x && closest < mYVals.size() - 1) {
        ++closest;
      }
    }
 else     if (rounding == Rounding.DOWN) {
      if (closestXIndex > x && closest > 0) {
        --closest;
      }
    }
  }
  return closest;
}
Program: 18275
Project: 18275
Buggy source:
/** 
 * Returns the first Entry object found at the given xIndex with binary search. If the no Entry at the specified x-index is found, this method returns the index at the closest x-index. 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 x
 * @return
 */
public T getEntryForXIndex(int x){
  int index=getEntryIndex(x);
  if (index > -1)   return mYVals.get(index);
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the first Entry object found at the given xIndex with binary search. If the no Entry at the specified x-index is found, this method returns the index as determined by the given rounding mode. 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 x
 * @return
 */
public T getEntryForXIndex(int x,Rounding rounding){
  int index=getEntryIndex(x,rounding);
  if (index > -1)   return mYVals.get(index);
  return null;
}
Program: 18276
Project: 18276
Buggy source:
/** 
 * Adds an Entry to the DataSet dynamically. Entries are added to their appropriate index respective to it's x-index. This will also recalculate the current minimum and maximum values of the DataSet and the value-sum.
 * @param e
 */
@SuppressWarnings("String_Node_Str") public void addEntryOrdered(Entry e){
  if (e == null)   return;
  float val=e.getVal();
  if (mYVals == null) {
    mYVals=new ArrayList<T>();
  }
  if (mYVals.size() == 0) {
    mYMax=val;
    mYMin=val;
  }
 else {
    if (mYMax < val)     mYMax=val;
    if (mYMin > val)     mYMin=val;
  }
  mYValueSum+=val;
  if (mYVals.size() > 0 && mYVals.get(mYVals.size() - 1).getXIndex() > e.getXIndex()) {
    int closestIndex=getEntryIndex(e.getXIndex());
    if (mYVals.get(closestIndex).getXIndex() < e.getXIndex())     closestIndex++;
    mYVals.add(closestIndex,(T)e);
    return;
  }
  mYVals.add((T)e);
}

Fixed version (ground truth):
/** 
 * Adds an Entry to the DataSet dynamically. Entries are added to their appropriate index respective to it's x-index. This will also recalculate the current minimum and maximum values of the DataSet and the value-sum.
 * @param e
 */
@SuppressWarnings("String_Node_Str") public void addEntryOrdered(Entry e){
  if (e == null)   return;
  float val=e.getVal();
  if (mYVals == null) {
    mYVals=new ArrayList<T>();
  }
  if (mYVals.size() == 0) {
    mYMax=val;
    mYMin=val;
  }
 else {
    if (mYMax < val)     mYMax=val;
    if (mYMin > val)     mYMin=val;
  }
  mYValueSum+=val;
  if (mYVals.size() > 0 && mYVals.get(mYVals.size() - 1).getXIndex() > e.getXIndex()) {
    int closestIndex=getEntryIndex(e.getXIndex(),Rounding.UP);
    mYVals.add(closestIndex,(T)e);
    return;
  }
  mYVals.add((T)e);
}
Program: 18281
Project: 18281
Buggy source:
/** 
 * Returns the index of the DataSet this x-index belongs to.
 * @param xIndex
 * @return
 */
public int getDataSetIndexForIndex(int xIndex){
  List<? extends DataSet<? extends Entry>> dataSets=mData.getDataSets();
  for (int i=0; i < dataSets.size(); i++) {
    if (dataSets.get(i).getEntryForXIndex(xIndex) != null)     return i;
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * Returns the index of the DataSet this x-index belongs to.
 * @param xIndex
 * @return
 */
public int getDataSetIndexForIndex(int xIndex){
  List<IPieDataSet> dataSets=mData.getDataSets();
  for (int i=0; i < dataSets.size(); i++) {
    if (dataSets.get(i).getEntryForXIndex(xIndex) != null)     return i;
  }
  return -1;
}
Program: 18282
Project: 18282
Buggy source:
/** 
 * calculates the needed angles for the chart slices
 */
private void calcAngles(){
  mDrawAngles=new float[mData.getYValCount()];
  mAbsoluteAngles=new float[mData.getYValCount()];
  List<PieDataSet> dataSets=mData.getDataSets();
  int cnt=0;
  for (int i=0; i < mData.getDataSetCount(); i++) {
    PieDataSet set=dataSets.get(i);
    List<Entry> entries=set.getYVals();
    for (int j=0; j < entries.size(); j++) {
      mDrawAngles[cnt]=calcAngle(Math.abs(entries.get(j).getVal()));
      if (cnt == 0) {
        mAbsoluteAngles[cnt]=mDrawAngles[cnt];
      }
 else {
        mAbsoluteAngles[cnt]=mAbsoluteAngles[cnt - 1] + mDrawAngles[cnt];
      }
      cnt++;
    }
  }
}

Fixed version (ground truth):
/** 
 * calculates the needed angles for the chart slices
 */
private void calcAngles(){
  mDrawAngles=new float[mData.getYValCount()];
  mAbsoluteAngles=new float[mData.getYValCount()];
  List<IPieDataSet> dataSets=mData.getDataSets();
  int cnt=0;
  for (int i=0; i < mData.getDataSetCount(); i++) {
    IPieDataSet set=dataSets.get(i);
    List<Entry> entries=set.getYVals();
    for (int j=0; j < entries.size(); j++) {
      mDrawAngles[cnt]=calcAngle(Math.abs(entries.get(j).getVal()));
      if (cnt == 0) {
        mAbsoluteAngles[cnt]=mDrawAngles[cnt];
      }
 else {
        mAbsoluteAngles[cnt]=mAbsoluteAngles[cnt - 1] + mDrawAngles[cnt];
      }
      cnt++;
    }
  }
}
Program: 18283
Project: 18283
Buggy source:
/** 
 * Returns an array of SelectionDetail objects for the given x-index. The SelectionDetail objects give information about the value at the selected index and the DataSet it belongs to. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @return
 */
public List<SelectionDetail> getSelectionDetailsAtIndex(int xIndex){
  List<SelectionDetail> vals=new ArrayList<SelectionDetail>();
  for (int i=0; i < mData.getDataSetCount(); i++) {
    DataSet<?> dataSet=mData.getDataSetByIndex(i);
    final float yVal=dataSet.getYValForXIndex(xIndex);
    if (yVal == Float.NaN)     continue;
    vals.add(new SelectionDetail(yVal,i,dataSet));
  }
  return vals;
}

Fixed version (ground truth):
/** 
 * Returns an array of SelectionDetail objects for the given x-index. The SelectionDetail objects give information about the value at the selected index and the DataSet it belongs to. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @return
 */
public List<SelectionDetail> getSelectionDetailsAtIndex(int xIndex){
  List<SelectionDetail> vals=new ArrayList<SelectionDetail>();
  for (int i=0; i < mData.getDataSetCount(); i++) {
    IDataSet<?> dataSet=mData.getDataSetByIndex(i);
    final float yVal=dataSet.getYValForXIndex(xIndex);
    if (yVal == Float.NaN)     continue;
    vals.add(new SelectionDetail(yVal,i,dataSet));
  }
  return vals;
}
Program: 18284
Project: 18284
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.actionToggleValues:
{
      for (      DataSet<?> set : mChart.getData().getDataSets())       set.setDrawValues(!set.isDrawValuesEnabled());
      mChart.invalidate();
      break;
    }
case R.id.actionToggleHole:
{
    if (mChart.isDrawHoleEnabled())     mChart.setDrawHoleEnabled(false);
 else     mChart.setDrawHoleEnabled(true);
    mChart.invalidate();
    break;
  }
case R.id.actionDrawCenter:
{
  if (mChart.isDrawCenterTextEnabled())   mChart.setDrawCenterText(false);
 else   mChart.setDrawCenterText(true);
  mChart.invalidate();
  break;
}
case R.id.actionToggleXVals:
{
mChart.setDrawSliceText(!mChart.isDrawSliceTextEnabled());
mChart.invalidate();
break;
}
case R.id.actionSave:
{
mChart.saveToPath("String_Node_Str" + System.currentTimeMillis(),"String_Node_Str");
break;
}
case R.id.actionTogglePercent:
mChart.setUsePercentValues(!mChart.isUsePercentValuesEnabled());
mChart.invalidate();
break;
case R.id.animateX:
{
mChart.animateX(1400);
break;
}
case R.id.animateY:
{
mChart.animateY(1400);
break;
}
case R.id.animateXY:
{
mChart.animateXY(1400,1400);
break;
}
}
return true;
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.actionToggleValues:
{
      for (      IDataSet<?> set : mChart.getData().getDataSets())       set.setDrawValues(!set.isDrawValuesEnabled());
      mChart.invalidate();
      break;
    }
case R.id.actionToggleHole:
{
    if (mChart.isDrawHoleEnabled())     mChart.setDrawHoleEnabled(false);
 else     mChart.setDrawHoleEnabled(true);
    mChart.invalidate();
    break;
  }
case R.id.actionDrawCenter:
{
  if (mChart.isDrawCenterTextEnabled())   mChart.setDrawCenterText(false);
 else   mChart.setDrawCenterText(true);
  mChart.invalidate();
  break;
}
case R.id.actionToggleXVals:
{
mChart.setDrawSliceText(!mChart.isDrawSliceTextEnabled());
mChart.invalidate();
break;
}
case R.id.actionSave:
{
mChart.saveToPath("String_Node_Str" + System.currentTimeMillis(),"String_Node_Str");
break;
}
case R.id.actionTogglePercent:
mChart.setUsePercentValues(!mChart.isUsePercentValuesEnabled());
mChart.invalidate();
break;
case R.id.animateX:
{
mChart.animateX(1400);
break;
}
case R.id.animateY:
{
mChart.animateY(1400);
break;
}
case R.id.animateXY:
{
mChart.animateXY(1400,1400);
break;
}
}
return true;
}