nus-yam/ex-repair huggingface dataset:
Program: 26310
Project: 26310
Buggy source:
@Override protected void onSizeChanged(int w,int h,int oldw,int oldh){
  float[] pts=new float[2];
  if (mKeepPositionOnRotation) {
    pts[0]=mViewPortHandler.contentLeft();
    pts[1]=mViewPortHandler.contentTop();
    getTransformer(AxisDependency.LEFT).pixelsToValue(pts);
  }
  super.onSizeChanged(w,h,oldw,oldh);
  if (mKeepPositionOnRotation) {
    getTransformer(AxisDependency.LEFT).pointValuesToPixel(pts);
    mViewPortHandler.centerViewPort(pts,this);
  }
}

Fixed version (ground truth):
@Override protected void onSizeChanged(int w,int h,int oldw,int oldh){
  float[] pts=new float[2];
  if (mKeepPositionOnRotation) {
    pts[0]=mViewPortHandler.contentLeft();
    pts[1]=mViewPortHandler.contentTop();
    getTransformer(AxisDependency.LEFT).pixelsToValue(pts);
  }
  super.onSizeChanged(w,h,oldw,oldh);
  if (mKeepPositionOnRotation) {
    getTransformer(AxisDependency.LEFT).pointValuesToPixel(pts);
    mViewPortHandler.centerViewPort(pts,this);
  }
 else {
    mViewPortHandler.refresh(mViewPortHandler.getMatrixTouch(),this,true);
  }
}
Program: 26311
Project: 26311
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: 26312
Project: 26312
Buggy source:
@Override protected void calcMinMax(){
  super.calcMinMax();
  calcAngles();
}

Fixed version (ground truth):
@Override protected void calcMinMax(){
  calcAngles();
}
Program: 26313
Project: 26313
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.setViewPortOffsets(0,20,0,0);
  mChart.setBackgroundColor(Color.rgb(104,241,175));
  mChart.setDescription("String_Node_Str");
  mChart.setTouchEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setScaleEnabled(true);
  mChart.setPinchZoom(false);
  mChart.setDrawGridBackground(false);
  tf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  XAxis x=mChart.getXAxis();
  x.setEnabled(false);
  YAxis y=mChart.getAxisLeft();
  y.setTypeface(tf);
  y.setLabelCount(6,false);
  y.setTextColor(Color.WHITE);
  y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
  y.setDrawGridLines(false);
  y.setAxisLineColor(Color.WHITE);
  mChart.getAxisRight().setEnabled(false);
  setData(45,100);
  mChart.getLegend().setEnabled(false);
  mChart.animateXY(2000,2000);
  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.setViewPortOffsets(0,0,0,0);
  mChart.setBackgroundColor(Color.rgb(104,241,175));
  mChart.setDescription("String_Node_Str");
  mChart.setTouchEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setScaleEnabled(true);
  mChart.setPinchZoom(false);
  mChart.setDrawGridBackground(false);
  tf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  XAxis x=mChart.getXAxis();
  x.setEnabled(false);
  YAxis y=mChart.getAxisLeft();
  y.setTypeface(tf);
  y.setLabelCount(6,false);
  y.setTextColor(Color.WHITE);
  y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
  y.setDrawGridLines(false);
  y.setAxisLineColor(Color.WHITE);
  mChart.getAxisRight().setEnabled(false);
  setData(45,100);
  mChart.getLegend().setEnabled(false);
  mChart.animateXY(2000,2000);
  mChart.invalidate();
}
Program: 26317
Project: 26317
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: 26318
Project: 26318
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: 26319
Project: 26319
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: 26320
Project: 26320
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: 26323
Project: 26323
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: 26325
Project: 26325
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: 26326
Project: 26326
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: 26327
Project: 26327
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: 26328
Project: 26328
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: 26329
Project: 26329
Buggy source:
public void setFloatValue(Float value){
  this.floatValue=value;
}

Fixed version (ground truth):
public void setFloatValue(float value){
  this.floatValue=value;
}
Program: 26330
Project: 26330
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: 26332
Project: 26332
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: 26333
Project: 26333
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: 26334
Project: 26334
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: 26335
Project: 26335
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: 26336
Project: 26336
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: 26337
Project: 26337
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: 26338
Project: 26338
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: 26339
Project: 26339
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: 26340
Project: 26340
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: 26341
Project: 26341
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: 26342
Project: 26342
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: 26343
Project: 26343
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: 26344
Project: 26344
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: 26345
Project: 26345
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: 26346
Project: 26346
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: 26347
Project: 26347
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: 26348
Project: 26348
Buggy source:
public RealmFloat(float value){
  this.value=value;
}

Fixed version (ground truth):
public RealmFloat(float floatValue){
  this.floatValue=floatValue;
}
Program: 26349
Project: 26349
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: 26350
Project: 26350
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: 26351
Project: 26351
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: 26352
Project: 26352
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: 26353
Project: 26353
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: 26354
Project: 26354
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: 26355
Project: 26355
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: 26356
Project: 26356
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: 26361
Project: 26361
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_noseekbar);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setDrawGridBackground(false);
  mChart.setDescription("String_Node_Str");
  mChart.setNoDataTextDescription("String_Node_Str");
  mChart.setTouchEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setScaleEnabled(true);
  mChart.setPinchZoom(false);
  Typeface tf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  YAxis leftAxis=mChart.getAxisLeft();
  leftAxis.removeAllLimitLines();
  leftAxis.setAxisMaxValue(220f);
  leftAxis.setAxisMinValue(-50f);
  leftAxis.setStartAtZero(false);
  leftAxis.setTypeface(tf);
  mChart.getXAxis().setTypeface(tf);
  mChart.getAxisRight().setEnabled(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_barchart);
  mChart=(BarChart)findViewById(R.id.chart1);
  mChart.setDrawGridBackground(false);
  mChart.setDescription("String_Node_Str");
  mChart.setNoDataTextDescription("String_Node_Str");
  mChart.setTouchEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setScaleEnabled(true);
  mChart.setPinchZoom(false);
  Typeface tf=Typeface.createFromAsset(getAssets(),"String_Node_Str");
  YAxis leftAxis=mChart.getAxisLeft();
  leftAxis.removeAllLimitLines();
  leftAxis.setAxisMaxValue(220f);
  leftAxis.setAxisMinValue(-50f);
  leftAxis.setStartAtZero(false);
  leftAxis.setTypeface(tf);
  mChart.getXAxis().setTypeface(tf);
  mChart.getAxisRight().setEnabled(false);
}