nus-yam/ex-repair huggingface dataset:
Program: 31851
Project: 31851
Buggy source:
/** 
 * Process a click on one of our selectors.
 * @param v   The view that was clicked
 * @return    true if we need to update the graph
 */
public boolean processClick(View v){
  SharedPreferences sharedPref=this.getPreferences(Context.MODE_PRIVATE);
  SharedPreferences.Editor editor=sharedPref.edit();
  String value=((TextView)v).getText().toString();
switch (v.getId()) {
case R.id.button_recording:
    bSaveWav=value.equals("String_Node_Str");
  SelectorText st=(SelectorText)findViewById(R.id.run);
if (bSaveWav && !st.getText().toString().equals("String_Node_Str")) {
  st.nextValue();
}
return true;
case R.id.run:
boolean pause=value.equals("String_Node_Str");
if (samplingThread != null && samplingThread.getPause() != pause) {
samplingThread.setPause(pause);
}
return false;
case R.id.graph_view_mode:
isMeasure=!value.equals("String_Node_Str");
return false;
case R.id.dbA:
isAWeighting=!value.equals("String_Node_Str");
if (samplingThread != null && samplingThread.stft != null) {
samplingThread.stft.setAWeighting(isAWeighting);
}
editor.putBoolean("String_Node_Str",isAWeighting);
editor.commit();
return false;
case R.id.spectrum_spectrogram_mode:
if (value.equals("String_Node_Str")) {
graphView.switch2Spectrum();
}
 else {
graphView.switch2Spectrogram(sampleRate,fftLen);
}
editor.putBoolean("String_Node_Str",value.equals("String_Node_Str"));
editor.commit();
return false;
default :
return true;
}
}

Fixed version (ground truth):
/** 
 * Process a click on one of our selectors.
 * @param v   The view that was clicked
 * @return    true if we need to update the graph
 */
public boolean processClick(View v){
  SharedPreferences sharedPref=this.getPreferences(Context.MODE_PRIVATE);
  SharedPreferences.Editor editor=sharedPref.edit();
  String value=((TextView)v).getText().toString();
switch (v.getId()) {
case R.id.button_recording:
    bSaveWav=value.equals("String_Node_Str");
  SelectorText st=(SelectorText)findViewById(R.id.run);
if (bSaveWav && !st.getText().toString().equals("String_Node_Str")) {
  st.nextValue();
  if (samplingThread != null) {
    samplingThread.setPause(true);
  }
}
return true;
case R.id.run:
boolean pause=value.equals("String_Node_Str");
if (samplingThread != null && samplingThread.getPause() != pause) {
samplingThread.setPause(pause);
}
return false;
case R.id.graph_view_mode:
isMeasure=!value.equals("String_Node_Str");
return false;
case R.id.dbA:
isAWeighting=!value.equals("String_Node_Str");
if (samplingThread != null && samplingThread.stft != null) {
samplingThread.stft.setAWeighting(isAWeighting);
}
editor.putBoolean("String_Node_Str",isAWeighting);
editor.commit();
return false;
case R.id.spectrum_spectrogram_mode:
if (value.equals("String_Node_Str")) {
graphView.switch2Spectrum();
}
 else {
graphView.switch2Spectrogram(sampleRate,fftLen);
}
editor.putBoolean("String_Node_Str",value.equals("String_Node_Str"));
editor.commit();
return false;
default :
return true;
}
}
Program: 31852
Project: 31852
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  this.mDetector.onTouchEvent(event);
  if (isMeasure) {
    measureEvent(event);
  }
 else {
    scaleEvent(event);
  }
  long t=SystemClock.uptimeMillis();
  long frameTime;
  if (graphView.getShowMode() != 0) {
    frameTime=200;
  }
 else {
    frameTime=50;
  }
  if (t >= timeToUpdate) {
    timeToUpdate+=frameTime;
    if (timeToUpdate < t) {
      timeToUpdate=t + frameTime;
    }
    graphView.invalidate();
  }
  return super.onTouchEvent(event);
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  this.mDetector.onTouchEvent(event);
  if (isMeasure) {
    measureEvent(event);
  }
 else {
    scaleEvent(event);
  }
  invalidateGraphView();
  return super.onTouchEvent(event);
}
Program: 31853
Project: 31853
Buggy source:
private void scaleEvent(MotionEvent event){
  if (event.getAction() != MotionEvent.ACTION_MOVE) {
    xShift0=INIT;
    yShift0=INIT;
    isPinching=false;
    return;
  }
switch (event.getPointerCount()) {
case 2:
    if (isPinching) {
      graphView.setShiftScale(event.getX(0),event.getY(0),event.getX(1),event.getY(1));
      updateAllLabels();
    }
 else {
      graphView.setShiftScaleBegin(event.getX(0),event.getY(0),event.getX(1),event.getY(1));
    }
  isPinching=true;
break;
case 1:
float x=event.getX(0);
float y=event.getY(0);
graphView.getLocationInWindow(windowLocation);
if (isPinching || xShift0 == INIT) {
xShift0=graphView.getXShift();
x0=x;
yShift0=graphView.getYShift();
y0=y;
}
 else {
if (x0 < windowLocation[0] + 50) {
graphView.setYShift(yShift0 + (y0 - y) / graphView.getYZoom());
}
 else if (y0 < windowLocation[1] + 50) {
graphView.setXShift(xShift0 + (x0 - x) / graphView.getXZoom());
}
 else {
graphView.setXShift(xShift0 + (x0 - x) / graphView.getXZoom());
graphView.setYShift(yShift0 + (y0 - y) / graphView.getYZoom());
}
updateAllLabels();
}
isPinching=false;
break;
default :
Log.v(TAG,"String_Node_Str");
break;
}
}

Fixed version (ground truth):
private void scaleEvent(MotionEvent event){
  if (event.getAction() != MotionEvent.ACTION_MOVE) {
    xShift0=INIT;
    yShift0=INIT;
    isPinching=false;
    return;
  }
switch (event.getPointerCount()) {
case 2:
    if (isPinching) {
      graphView.setShiftScale(event.getX(0),event.getY(0),event.getX(1),event.getY(1));
    }
 else {
      graphView.setShiftScaleBegin(event.getX(0),event.getY(0),event.getX(1),event.getY(1));
    }
  isPinching=true;
break;
case 1:
float x=event.getX(0);
float y=event.getY(0);
graphView.getLocationInWindow(windowLocation);
if (isPinching || xShift0 == INIT) {
xShift0=graphView.getXShift();
x0=x;
yShift0=graphView.getYShift();
y0=y;
}
 else {
if (x0 < windowLocation[0] + 50) {
graphView.setYShift(yShift0 + (y0 - y) / graphView.getYZoom());
}
 else if (y0 < windowLocation[1] + 50) {
graphView.setXShift(xShift0 + (x0 - x) / graphView.getXZoom());
}
 else {
graphView.setXShift(xShift0 + (x0 - x) / graphView.getXZoom());
graphView.setYShift(yShift0 + (y0 - y) / graphView.getYZoom());
}
}
isPinching=false;
break;
default :
Log.v(TAG,"String_Node_Str");
break;
}
}
Program: 31854
Project: 31854
Buggy source:
private void update(final double[] data){
synchronized (oblock) {
    textRMS.setLength(0);
    textRMS.append("String_Node_Str");
    SBNumFormat.fillInNumFixedWidth(textRMS,20 * Math.log10(dtRMSFromFT),3,1);
    textRMS.getChars(0,Math.min(textRMS.length(),textRMSChar.length),textRMSChar,0);
  }
synchronized (oblock) {
    textPeak.setLength(0);
    textPeak.append("String_Node_Str");
    SBNumFormat.fillInNumFixedWidthPositive(textPeak,maxAmpFreq,5,1);
    textPeak.append("String_Node_Str");
    freq2Cent(textPeak,maxAmpFreq,"String_Node_Str");
    textPeak.append("String_Node_Str");
    SBNumFormat.fillInNumFixedWidth(textPeak,maxAmpDB,3,1);
    textPeak.append("String_Node_Str");
    textPeak.getChars(0,Math.min(textPeak.length(),textPeakChar.length),textPeakChar,0);
  }
  if (graphView.getShowMode() == 1) {
    graphView.pushRawSpectrum(spectrumDBcopy);
  }
  AnalyzeActivity.this.runOnUiThread(new Runnable(){
    @Override public void run(){
      AnalyzeActivity.this.rePlot();
    }
  }
);
}

Fixed version (ground truth):
private void update(final double[] data){
synchronized (oblock) {
    textRMS.setLength(0);
    textRMS.append("String_Node_Str");
    SBNumFormat.fillInNumFixedWidth(textRMS,20 * Math.log10(dtRMSFromFT),3,1);
    textRMS.getChars(0,Math.min(textRMS.length(),textRMSChar.length),textRMSChar,0);
  }
synchronized (oblock) {
    textPeak.setLength(0);
    textPeak.append("String_Node_Str");
    SBNumFormat.fillInNumFixedWidthPositive(textPeak,maxAmpFreq,5,1);
    textPeak.append("String_Node_Str");
    freq2Cent(textPeak,maxAmpFreq,"String_Node_Str");
    textPeak.append("String_Node_Str");
    SBNumFormat.fillInNumFixedWidth(textPeak,maxAmpDB,3,1);
    textPeak.append("String_Node_Str");
    textPeak.getChars(0,Math.min(textPeak.length(),textPeakChar.length),textPeakChar,0);
  }
  if (graphView.getShowMode() == 1) {
    graphView.pushRawSpectrum(spectrumDBcopy);
  }
  AnalyzeActivity.this.runOnUiThread(new Runnable(){
    @Override public void run(){
      if (graphView.getShowMode() == 0) {
        graphView.replotRawSpectrum(spectrumDBcopy,1,spectrumDBcopy.length,showLines);
      }
      AnalyzeActivity.this.invalidateGraphView();
    }
  }
);
}
Program: 31855
Project: 31855
Buggy source:
/** 
 * The graph view size has been determined - update the labels accordingly.
 */
@Override public void ready(){
  updateAllLabels();
}

Fixed version (ground truth):
/** 
 * The graph view size has been determined - update the labels accordingly.
 */
@Override public void ready(){
}
Program: 31856
Project: 31856
Buggy source:
/** 
 * Manage cursor for measurement
 */
private void measureEvent(MotionEvent event){
switch (event.getPointerCount()) {
case 1:
    if (graphView.setCursor(event.getX(),event.getY())) {
      updateAllLabels();
    }
  break;
case 2:
if (isInGraphView(event.getX(0),event.getY(0)) && isInGraphView(event.getX(1),event.getY(1))) {
  isMeasure=!isMeasure;
  SelectorText st=(SelectorText)findViewById(R.id.graph_view_mode);
  st.performClick();
}
}
}

Fixed version (ground truth):
/** 
 * Manage cursor for measurement
 */
private void measureEvent(MotionEvent event){
switch (event.getPointerCount()) {
case 1:
    graphView.setCursor(event.getX(),event.getY());
  break;
case 2:
if (isInGraphView(event.getX(0),event.getY(0)) && isInGraphView(event.getX(1),event.getY(1))) {
  isMeasure=!isMeasure;
  SelectorText st=(SelectorText)findViewById(R.id.graph_view_mode);
  st.performClick();
}
}
}
Program: 31857
Project: 31857
Buggy source:
@Override public void onItemClick(AdapterView<?> parent,View v,int position,long id){
  String selectedItemTag=((TextView)v).getTag().toString();
  if (selectedItemTag.equals("String_Node_Str")) {
    return;
  }
  String selectedItemText=((TextView)v).getText().toString();
  int buttonId=Integer.parseInt((parent.getTag().toString()));
  Button buttonView=(Button)findViewById(buttonId);
  buttonView.setText(selectedItemText);
  boolean b_need_restart_audio;
  SharedPreferences sharedPref=this.getPreferences(Context.MODE_PRIVATE);
  SharedPreferences.Editor editor=sharedPref.edit();
switch (buttonId) {
case R.id.button_sample_rate:
    popupMenuSampleRate.dismiss();
  sampleRate=Integer.parseInt(selectedItemTag);
b_need_restart_audio=true;
editor.putInt("String_Node_Str",sampleRate);
break;
case R.id.button_fftlen:
popupMenuFFTLen.dismiss();
fftLen=Integer.parseInt(selectedItemTag);
b_need_restart_audio=true;
editor.putInt("String_Node_Str",fftLen);
break;
case R.id.button_average:
popupMenuAverage.dismiss();
nFFTAverage=Integer.parseInt(selectedItemTag);
if (graphView != null) {
graphView.setTimeMultiplier(nFFTAverage);
}
b_need_restart_audio=false;
editor.putInt("String_Node_Str",nFFTAverage);
break;
default :
Log.w(TAG,"String_Node_Str");
b_need_restart_audio=false;
}
editor.commit();
if (b_need_restart_audio) {
reRecur();
updateAllLabels();
}
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> parent,View v,int position,long id){
  String selectedItemTag=((TextView)v).getTag().toString();
  if (selectedItemTag.equals("String_Node_Str")) {
    return;
  }
  String selectedItemText=((TextView)v).getText().toString();
  int buttonId=Integer.parseInt((parent.getTag().toString()));
  Button buttonView=(Button)findViewById(buttonId);
  buttonView.setText(selectedItemText);
  boolean b_need_restart_audio;
  SharedPreferences sharedPref=this.getPreferences(Context.MODE_PRIVATE);
  SharedPreferences.Editor editor=sharedPref.edit();
switch (buttonId) {
case R.id.button_sample_rate:
    popupMenuSampleRate.dismiss();
  sampleRate=Integer.parseInt(selectedItemTag);
b_need_restart_audio=true;
editor.putInt("String_Node_Str",sampleRate);
break;
case R.id.button_fftlen:
popupMenuFFTLen.dismiss();
fftLen=Integer.parseInt(selectedItemTag);
b_need_restart_audio=true;
editor.putInt("String_Node_Str",fftLen);
break;
case R.id.button_average:
popupMenuAverage.dismiss();
nFFTAverage=Integer.parseInt(selectedItemTag);
if (graphView != null) {
graphView.setTimeMultiplier(nFFTAverage);
}
b_need_restart_audio=false;
editor.putInt("String_Node_Str",nFFTAverage);
break;
default :
Log.w(TAG,"String_Node_Str");
b_need_restart_audio=false;
}
editor.commit();
if (b_need_restart_audio) {
reRecur();
}
}
Program: 31858
Project: 31858
Buggy source:
public Looper(){
  double fq0=Double.parseDouble(getString(R.string.test_signal_1_freq1));
  double amp0=Math.pow(10,1 / 20.0 * Double.parseDouble(getString(R.string.test_signal_1_db1)));
  double fq1=Double.parseDouble(getString(R.string.test_signal_2_freq1));
  double fq2=Double.parseDouble(getString(R.string.test_signal_2_freq2));
  double amp1=Math.pow(10,1 / 20.0 * Double.parseDouble(getString(R.string.test_signal_2_db1)));
  double amp2=Math.pow(10,1 / 20.0 * Double.parseDouble(getString(R.string.test_signal_2_db2)));
  if (audioSourceId == 1000) {
    sineGen1=new DoubleSineGen(fq0,sampleRate,SAMPLE_VALUE_MAX * amp0);
  }
 else {
    sineGen1=new DoubleSineGen(fq1,sampleRate,SAMPLE_VALUE_MAX * amp1);
  }
  sineGen2=new DoubleSineGen(fq2,sampleRate,SAMPLE_VALUE_MAX * amp2);
}

Fixed version (ground truth):
public Looper(){
  isPaused1=((SelectorText)findViewById(R.id.run)).getText().toString().equals("String_Node_Str");
  double fq0=Double.parseDouble(getString(R.string.test_signal_1_freq1));
  double amp0=Math.pow(10,1 / 20.0 * Double.parseDouble(getString(R.string.test_signal_1_db1)));
  double fq1=Double.parseDouble(getString(R.string.test_signal_2_freq1));
  double fq2=Double.parseDouble(getString(R.string.test_signal_2_freq2));
  double amp1=Math.pow(10,1 / 20.0 * Double.parseDouble(getString(R.string.test_signal_2_db1)));
  double amp2=Math.pow(10,1 / 20.0 * Double.parseDouble(getString(R.string.test_signal_2_db2)));
  if (audioSourceId == 1000) {
    sineGen1=new DoubleSineGen(fq0,sampleRate,SAMPLE_VALUE_MAX * amp0);
  }
 else {
    sineGen1=new DoubleSineGen(fq1,sampleRate,SAMPLE_VALUE_MAX * amp1);
  }
  sineGen2=new DoubleSineGen(fq2,sampleRate,SAMPLE_VALUE_MAX * amp2);
}
Program: 31859
Project: 31859
Buggy source:
public void setYShift(float offset){
  yShift=clampYShift(offset);
  computeMatrix();
  invalidate();
}

Fixed version (ground truth):
public void setYShift(float offset){
  yShift=clampYShift(offset);
  computeMatrix();
}
Program: 31860
Project: 31860
Buggy source:
private void computeMatrix(){
  matrix.reset();
  matrix.setTranslate(-xShift,-yShift);
  matrix.postScale(xZoom,yZoom);
  matrix0.reset();
  matrix0.setTranslate(0f,0f);
  matrix0.postScale(1f,1f);
}

Fixed version (ground truth):
private void computeMatrix(){
  matrix.reset();
  matrix.setTranslate(-xShift,-yShift);
  matrix.postScale(xZoom,yZoom);
}
Program: 31861
Project: 31861
Buggy source:
public void setShiftScale(float x1,float y1,float x2,float y2){
  if (canvasWidth * 0.13f < xDiffOld) {
    xZoom=clamp(xZoomOld * Math.abs(x1 - x2) / xDiffOld,1f,axisBounds.width() / 200f);
  }
  xShift=clampXShift(xShiftOld + xMidOld / xZoomOld - (x1 + x2) / 2f / xZoom);
  if (canvasHeight * 0.13f < yDiffOld) {
    yZoom=clamp(yZoomOld * Math.abs(y1 - y2) / yDiffOld,1f,-axisBounds.height() / 6f);
  }
  yShift=clampYShift(yShiftOld + yMidOld / yZoomOld - (y1 + y2) / 2f / yZoom);
  computeMatrix();
  invalidate();
}

Fixed version (ground truth):
public void setShiftScale(float x1,float y1,float x2,float y2){
  if (canvasWidth * 0.13f < xDiffOld) {
    xZoom=clamp(xZoomOld * Math.abs(x1 - x2) / xDiffOld,1f,axisBounds.width() / 200f);
  }
  xShift=clampXShift(xShiftOld + xMidOld / xZoomOld - (x1 + x2) / 2f / xZoom);
  if (canvasHeight * 0.13f < yDiffOld) {
    yZoom=clamp(yZoomOld * Math.abs(y1 - y2) / yDiffOld,1f,-axisBounds.height() / 6f);
  }
  yShift=clampYShift(yShiftOld + yMidOld / yZoomOld - (y1 + y2) / 2f / yZoom);
  computeMatrix();
}
Program: 31862
Project: 31862
Buggy source:
public void setScale(float s){
  xZoom=Math.max(s,1f);
  xShift=clamp(xShift,0f,(xZoom - 1f) * canvasWidth);
  computeMatrix();
  invalidate();
}

Fixed version (ground truth):
public void setScale(float s){
  xZoom=Math.max(s,1f);
  xShift=clamp(xShift,0f,(xZoom - 1f) * canvasWidth);
  computeMatrix();
}
Program: 31863
Project: 31863
Buggy source:
public void setXShift(float offset){
  xShift=clampXShift(offset);
  computeMatrix();
  invalidate();
}

Fixed version (ground truth):
public void setXShift(float offset){
  xShift=clampXShift(offset);
  computeMatrix();
}
Program: 31864
Project: 31864
Buggy source:
public boolean setCursor(float x,float y){
  if (intersects(x,y)) {
    float current=getXShift();
    if (x <= 3 && xShift > 0f) {
      setXShift(current - 10f);
    }
 else     if (x >= canvasWidth - 3) {
      setXShift(current + 10f);
    }
 else {
      cursorX=xShift + (x - myLocation[0]) / xZoom;
      cursorY=yShift + (y - myLocation[1]) / yZoom;
    }
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
public boolean setCursor(float x,float y){
  if (intersects(x,y)) {
    float current=getXShift();
    if (x <= 3 && xShift > 0f) {
      setXShift(current - 10f);
    }
 else     if (x >= canvasWidth - 3) {
      setXShift(current + 10f);
    }
 else {
      cursorX=xShift + (x - myLocation[0]) / xZoom;
      cursorY=yShift + (y - myLocation[1]) / yZoom;
      cursorX=axisBounds.width() * cursorX / canvasWidth;
      cursorY=axisBounds.height() * cursorY / canvasHeight;
    }
    return true;
  }
 else {
    return false;
  }
}
Program: 31865
Project: 31865
Buggy source:
private void drawCursor(Canvas c){
  if (xShift < cursorX && cursorX <= xShift + canvasWidth / xZoom) {
    c.drawLine(cursorX,yShift,cursorX,yShift + canvasHeight / yZoom,cursorPaint);
  }
  if (yShift < cursorY && cursorY <= yShift + canvasHeight / yZoom) {
    c.drawLine(xShift,cursorY,xShift + canvasWidth / xZoom,cursorY,cursorPaint);
  }
}

Fixed version (ground truth):
private void drawCursor(Canvas c){
  float cX=cursorX / axisBounds.width() * canvasWidth;
  float cY=cursorY / axisBounds.height() * canvasHeight;
  if (xShift < cX && cX <= xShift + canvasWidth / xZoom) {
    c.drawLine(cX,yShift,cX,yShift + canvasHeight / yZoom,cursorPaint);
  }
  if (yShift < cY && cY <= yShift + canvasHeight / yZoom) {
    c.drawLine(xShift,cY,xShift + canvasWidth / xZoom,cY,cursorPaint);
  }
}
Program: 31866
Project: 31866
Buggy source:
public void resetViewScale(){
  xShift=0;
  xZoom=1;
  yShift=0;
  yZoom=1;
  computeMatrix();
  invalidate();
}

Fixed version (ground truth):
public void resetViewScale(){
  xShift=0;
  xZoom=1;
  yShift=0;
  yZoom=1;
  computeMatrix();
}
Program: 31867
Project: 31867
Buggy source:
public float getCursorY(){
  return canvasHeight == 0 ? 0 : axisBounds.height() * cursorY / canvasHeight;
}

Fixed version (ground truth):
public float getCursorY(){
  return canvasHeight == 0 ? 0 : cursorY;
}
Program: 31868
Project: 31868
Buggy source:
public float getCursorX(){
  return canvasWidth == 0 ? 0 : axisBounds.width() * cursorX / canvasWidth;
}

Fixed version (ground truth):
public float getCursorX(){
  return canvasWidth == 0 ? 0 : cursorX;
}
Program: 31869
Project: 31869
Buggy source:
private void setup(AttributeSet attrs,Context context){
  Log.v(TAG,"String_Node_Str");
  path=new Path();
  linePaint=new Paint();
  linePaint.setColor(Color.RED);
  linePaint.setStyle(Paint.Style.STROKE);
  linePaint.setStrokeWidth(0);
  cursorPaint=new Paint(linePaint);
  cursorPaint.setColor(Color.BLUE);
  gridPaint=new Paint(linePaint);
  gridPaint.setColor(Color.DKGRAY);
  rulerBrightPaint=new Paint(linePaint);
  rulerBrightPaint.setColor(Color.rgb(99,99,99));
  labelPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  labelPaint.setColor(Color.GRAY);
  labelPaint.setTextSize(14.0f);
  labelPaint.setTypeface(Typeface.MONOSPACE);
  backgroundPaint=new Paint();
  backgroundPaint.setColor(Color.BLACK);
  cursorX=cursorY=0f;
  xZoom=1f;
  xShift=0f;
  yZoom=1f;
  yShift=0f;
  canvasWidth=canvasHeight=0;
  axisBounds=new RectF(0.0f,0.0f,8000.0f,-120.0f);
  gridDensity=1 / 85f;
  Resources res=getResources();
  minDB=Float.parseFloat(res.getString(R.string.max_DB_range));
  sharedPref=PreferenceManager.getDefaultSharedPreferences(context);
  dBLowerBound=Double.parseDouble(sharedPref.getString("String_Node_Str",Double.toString(dBLowerBound)));
  axisBounds.bottom=Float.parseFloat(sharedPref.getString("String_Node_Str",Double.toString(axisBounds.bottom)));
}

Fixed version (ground truth):
private void setup(AttributeSet attrs,Context context){
  Log.v(TAG,"String_Node_Str");
  matrix0.reset();
  matrix0.setTranslate(0f,0f);
  matrix0.postScale(1f,1f);
  path=new Path();
  linePaint=new Paint();
  linePaint.setColor(Color.RED);
  linePaint.setStyle(Paint.Style.STROKE);
  linePaint.setStrokeWidth(0);
  cursorPaint=new Paint(linePaint);
  cursorPaint.setColor(Color.BLUE);
  gridPaint=new Paint(linePaint);
  gridPaint.setColor(Color.DKGRAY);
  rulerBrightPaint=new Paint(linePaint);
  rulerBrightPaint.setColor(Color.rgb(99,99,99));
  labelPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  labelPaint.setColor(Color.GRAY);
  labelPaint.setTextSize(14.0f);
  labelPaint.setTypeface(Typeface.MONOSPACE);
  backgroundPaint=new Paint();
  backgroundPaint.setColor(Color.BLACK);
  cursorX=cursorY=0f;
  xZoom=1f;
  xShift=0f;
  yZoom=1f;
  yShift=0f;
  canvasWidth=canvasHeight=0;
  axisBounds=new RectF(0.0f,0.0f,8000.0f,-120.0f);
  gridDensity=1 / 85f;
  Resources res=getResources();
  minDB=Float.parseFloat(res.getString(R.string.max_DB_range));
  sharedPref=PreferenceManager.getDefaultSharedPreferences(context);
  dBLowerBound=Double.parseDouble(sharedPref.getString("String_Node_Str",Double.toString(dBLowerBound)));
  axisBounds.bottom=Float.parseFloat(sharedPref.getString("String_Node_Str",Double.toString(axisBounds.bottom)));
}
Program: 31870
Project: 31870
Buggy source:
@Override public void onRestoreInstanceState(Bundle bundle){
  super.onRestoreInstanceState(bundle);
}

Fixed version (ground truth):
@Override public void onRestoreInstanceState(Bundle savedInstanceState){
  super.onRestoreInstanceState(savedInstanceState);
  dtRMS=savedInstanceState.getDouble("String_Node_Str");
  dtRMSFromFT=savedInstanceState.getDouble("String_Node_Str");
  maxAmpDB=savedInstanceState.getDouble("String_Node_Str");
  maxAmpFreq=savedInstanceState.getDouble("String_Node_Str");
}
Program: 31871
Project: 31871
Buggy source:
private void update(final double[] data){
synchronized (oblock) {
    textRMS.setLength(0);
    textRMS.append("String_Node_Str");
    SBNumFormat.fillInNumFixedWidth(textRMS,20 * Math.log10(dtRMSFromFT),3,1);
    textRMS.getChars(0,Math.min(textRMS.length(),textRMSChar.length),textRMSChar,0);
  }
synchronized (oblock) {
    textPeak.setLength(0);
    textPeak.append("String_Node_Str");
    SBNumFormat.fillInNumFixedWidthPositive(textPeak,maxAmpFreq,5,1);
    textPeak.append("String_Node_Str");
    freq2Cent(textPeak,maxAmpFreq,"String_Node_Str");
    textPeak.append("String_Node_Str");
    SBNumFormat.fillInNumFixedWidth(textPeak,maxAmpDB,3,1);
    textPeak.append("String_Node_Str");
    textPeak.getChars(0,Math.min(textPeak.length(),textPeakChar.length),textPeakChar,0);
  }
  if (graphView.getShowMode() == 1) {
    graphView.pushRawSpectrum(spectrumDBcopy);
  }
  AnalyzeActivity.this.runOnUiThread(new Runnable(){
    @Override public void run(){
      if (graphView.getShowMode() == 0) {
        graphView.replotRawSpectrum(spectrumDBcopy);
      }
      AnalyzeActivity.this.invalidateGraphView();
    }
  }
);
}

Fixed version (ground truth):
private void update(final double[] data){
  if (graphView.getShowMode() == 1) {
    graphView.pushRawSpectrum(spectrumDBcopy);
  }
  AnalyzeActivity.this.runOnUiThread(new Runnable(){
    @Override public void run(){
      if (graphView.getShowMode() == 0) {
        graphView.replotRawSpectrum(spectrumDBcopy);
      }
      AnalyzeActivity.this.invalidateGraphView();
    }
  }
);
}
Program: 31872
Project: 31872
Buggy source:
/** 
 * The graph view size has been determined - update the labels accordingly.
 */
@Override public void ready(){
  Log.v(TAG,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * The graph view size has been determined - update the labels accordingly.
 */
@Override public void ready(){
  Log.v(TAG,"String_Node_Str");
  invalidateGraphView();
}
Program: 31873
Project: 31873
Buggy source:
public void invalidateGraphView(int viewMask){
  if (isInvalidating) {
    return;
  }
  isInvalidating=true;
  long frameTime;
  if (graphView.getShowMode() != 0) {
    frameTime=1000 / 8;
  }
 else {
    frameTime=1000 / 20;
  }
  long t=SystemClock.uptimeMillis();
  if (t >= timeToUpdate) {
    timeToUpdate+=frameTime;
    if (timeToUpdate < t) {
      timeToUpdate=t + frameTime;
    }
    idPaddingInvalidate=false;
    if ((viewMask & VIEW_MASK_graphView) != 0)     graphView.invalidate();
    TextView tv;
    if ((viewMask & VIEW_MASK_textview_RMS) != 0) synchronized (oblock) {
      tv=(TextView)findViewById(R.id.textview_RMS);
      tv.setText(textRMSChar,0,textRMSChar.length);
      tv.invalidate();
    }
    if ((viewMask & VIEW_MASK_textview_peak) != 0) synchronized (oblock) {
      tv=(TextView)findViewById(R.id.textview_peak);
      tv.setText(textPeakChar,0,textPeakChar.length);
      tv.invalidate();
    }
    if ((viewMask & VIEW_MASK_CursorLabel) != 0)     refreshCursorLabel();
    if ((viewMask & VIEW_MASK_RecTimeLable) != 0)     refreshRecTimeLable();
  }
 else {
    if (idPaddingInvalidate == false) {
      idPaddingInvalidate=true;
      paddingViewMask=viewMask;
      paddingInvalidateHandler.postDelayed(paddingInvalidateRunnable,timeToUpdate - t + 1);
    }
 else {
      paddingViewMask|=viewMask;
    }
  }
  isInvalidating=false;
}

Fixed version (ground truth):
public void invalidateGraphView(int viewMask){
  if (isInvalidating) {
    return;
  }
  isInvalidating=true;
  long frameTime;
  if (graphView.getShowMode() != 0) {
    frameTime=1000 / 8;
  }
 else {
    frameTime=1000 / 20;
  }
  long t=SystemClock.uptimeMillis();
  if (t >= timeToUpdate) {
    timeToUpdate+=frameTime;
    if (timeToUpdate < t) {
      timeToUpdate=t + frameTime;
    }
    idPaddingInvalidate=false;
    if ((viewMask & VIEW_MASK_graphView) != 0)     graphView.invalidate();
    if ((viewMask & VIEW_MASK_textview_RMS) != 0)     refreshRMSLabel();
    if ((viewMask & VIEW_MASK_textview_peak) != 0)     refreshPeakLabel();
    if ((viewMask & VIEW_MASK_CursorLabel) != 0)     refreshCursorLabel();
    if ((viewMask & VIEW_MASK_RecTimeLable) != 0)     refreshRecTimeLable();
  }
 else {
    if (idPaddingInvalidate == false) {
      idPaddingInvalidate=true;
      paddingViewMask=viewMask;
      paddingInvalidateHandler.postDelayed(paddingInvalidateRunnable,timeToUpdate - t + 1);
    }
 else {
      paddingViewMask|=viewMask;
    }
  }
  isInvalidating=false;
}
Program: 31874
Project: 31874
Buggy source:
@Override public void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
}

Fixed version (ground truth):
@Override public void onSaveInstanceState(Bundle savedInstanceState){
  savedInstanceState.putDouble("String_Node_Str",dtRMS);
  savedInstanceState.putDouble("String_Node_Str",dtRMSFromFT);
  savedInstanceState.putDouble("String_Node_Str",maxAmpDB);
  savedInstanceState.putDouble("String_Node_Str",maxAmpFreq);
  super.onSaveInstanceState(savedInstanceState);
}
Program: 31875
Project: 31875
Buggy source:
@Override public void run(){
  AnalyzeActivity.this.rePlot();
  TextView tv=(TextView)findViewById(R.id.textview_RMS);
  tv.setText("String_Node_Str" + dfDB.format(20 * Math.log10(dtRMSFromFT)));
  tv.invalidate();
  freq2Cent(sCent,maxAmpFreq,"String_Node_Str");
  tv=(TextView)findViewById(R.id.textview_peak);
  tv.setText("String_Node_Str" + dfFreq.format(maxAmpFreq) + "String_Node_Str"+ sCent+ "String_Node_Str"+ dfDB.format(maxAmpDB)+ "String_Node_Str");
  tv.invalidate();
}

Fixed version (ground truth):
@Override public void run(){
  AnalyzeActivity.this.rePlot();
  TextView tv=(TextView)findViewById(R.id.textview_RMS);
  tv.setText(textRMSChar,0,Math.min(textRMS.length(),textRMSChar.length));
  tv.invalidate();
  tv=(TextView)findViewById(R.id.textview_peak);
  tv.setText(textPeakChar,0,Math.min(textPeak.length(),textPeakChar.length));
  tv.invalidate();
}
Program: 31876
Project: 31876
Buggy source:
public void freq2Cent(StringBuilder a,double f,String sFill){
  a.setLength(0);
  if (f <= 0 || Double.isNaN(f) || Double.isInfinite(f)) {
    a.append("String_Node_Str");
    return;
  }
  double p=69 + 12 * Math.log(f / 440.0) / Math.log(2);
  int pi=(int)Math.round(p);
  int po=(int)Math.floor(pi / 12.0);
  a.append(LP[pi - po * 12]);
  a.append(po - 1);
  if (p - pi > 0) {
    a.append('+');
  }
  a.append(Math.round(100 * (p - pi)));
  while (a.length() < 6 && sFill != null && sFill.length() > 0) {
    a.append(sFill);
  }
}

Fixed version (ground truth):
public void freq2Cent(StringBuilder a,double f,String sFill){
  if (f <= 0 || Double.isNaN(f) || Double.isInfinite(f)) {
    a.append("String_Node_Str");
    return;
  }
  int len0=a.length();
  double p=69 + 12 * Math.log(f / 440.0) / Math.log(2);
  int pi=(int)Math.round(p);
  int po=(int)Math.floor(pi / 12.0);
  int pm=pi - po * 12;
  a.append(LP[pm]);
  SBNumFormat.fillInInt(a,po - 1);
  if (LP[pm].length() == 1) {
    a.append(' ');
  }
  SBNumFormat.fillInNumFixedWidthSignedFirst(a,Math.round(100 * (p - pi)),2,0);
  while (a.length() - len0 < 6 && sFill != null && sFill.length() > 0) {
    a.append(sFill);
  }
}
Program: 31877
Project: 31877
Buggy source:
private void update(final double[] data){
  if (graphView.getShowMode() == 1) {
    graphView.pushRawSpectrum(spectrumDBcopy);
  }
  AnalyzeActivity.this.runOnUiThread(new Runnable(){
    @Override public void run(){
      AnalyzeActivity.this.rePlot();
      TextView tv=(TextView)findViewById(R.id.textview_RMS);
      tv.setText("String_Node_Str" + dfDB.format(20 * Math.log10(dtRMSFromFT)));
      tv.invalidate();
      freq2Cent(sCent,maxAmpFreq,"String_Node_Str");
      tv=(TextView)findViewById(R.id.textview_peak);
      tv.setText("String_Node_Str" + dfFreq.format(maxAmpFreq) + "String_Node_Str"+ sCent+ "String_Node_Str"+ dfDB.format(maxAmpDB)+ "String_Node_Str");
      tv.invalidate();
    }
  }
);
}

Fixed version (ground truth):
private void update(final double[] data){
  textRMS.setLength(0);
  textRMS.append("String_Node_Str");
  SBNumFormat.fillInNumFixedWidth(textRMS,20 * Math.log10(dtRMSFromFT),3,1);
  textRMS.getChars(0,Math.min(textRMS.length(),textRMSChar.length),textRMSChar,0);
  textPeak.setLength(0);
  textPeak.append("String_Node_Str");
  SBNumFormat.fillInNumFixedWidthPositive(textPeak,maxAmpFreq,5,1);
  textPeak.append("String_Node_Str");
  freq2Cent(textPeak,maxAmpFreq,"String_Node_Str");
  textPeak.append("String_Node_Str");
  SBNumFormat.fillInNumFixedWidth(textPeak,maxAmpDB,3,1);
  textPeak.append("String_Node_Str");
  textPeak.getChars(0,Math.min(textPeak.length(),textPeakChar.length),textPeakChar,0);
  if (graphView.getShowMode() == 1) {
    graphView.pushRawSpectrum(spectrumDBcopy);
  }
  AnalyzeActivity.this.runOnUiThread(new Runnable(){
    @Override public void run(){
      AnalyzeActivity.this.rePlot();
      TextView tv=(TextView)findViewById(R.id.textview_RMS);
      tv.setText(textRMSChar,0,Math.min(textRMS.length(),textRMSChar.length));
      tv.invalidate();
      tv=(TextView)findViewById(R.id.textview_peak);
      tv.setText(textPeakChar,0,Math.min(textPeak.length(),textPeakChar.length));
      tv.invalidate();
    }
  }
);
}
Program: 31878
Project: 31878
Buggy source:
private void refreshCursorLabel(){
  double f1=graphView.getCursorX();
  freq2Cent(sCent,f1,"String_Node_Str");
  ((TextView)findViewById(R.id.textview_cur)).setText("String_Node_Str" + dfFreq.format(f1) + "String_Node_Str"+ sCent+ "String_Node_Str"+ dfDB.format(graphView.getCursorY())+ "String_Node_Str");
}

Fixed version (ground truth):
private void refreshCursorLabel(){
  double f1=graphView.getCursorX();
  textCur.setLength(0);
  textCur.append("String_Node_Str");
  SBNumFormat.fillInNumFixedWidthPositive(textCur,f1,5,1);
  textCur.append("String_Node_Str");
  freq2Cent(textCur,f1,"String_Node_Str");
  textCur.append("String_Node_Str");
  SBNumFormat.fillInNumFixedWidth(textCur,graphView.getCursorY(),3,1);
  textCur.append("String_Node_Str");
  textCur.getChars(0,Math.min(textCur.length(),textCurChar.length),textCurChar,0);
  ((TextView)findViewById(R.id.textview_cur)).setText(textCurChar,0,Math.min(textCur.length(),textCurChar.length));
}
Program: 31880
Project: 31880
Buggy source:
private void setupView(){
  RectF bounds=graphView.getBounds();
  bounds.right=sampleRate / 2;
  graphView.setBounds(bounds);
  graphView.setupSpectrogram(sampleRate,fftLen);
}

Fixed version (ground truth):
private void setupView(){
  RectF bounds=graphView.getBounds();
  bounds.right=sampleRate / 2;
  graphView.setBounds(bounds);
  graphView.setupSpectrogram(sampleRate,fftLen);
  graphView.setTimeMultiplier(nFFTAverage);
}
Program: 31881
Project: 31881
Buggy source:
@Override public void onItemClick(AdapterView<?> parent,View v,int position,long id){
  String selectedItemTag=((TextView)v).getTag().toString();
  if (selectedItemTag.equals("String_Node_Str")) {
    return;
  }
  String selectedItemText=((TextView)v).getText().toString();
  int buttonId=Integer.parseInt((parent.getTag().toString()));
  Button buttonView=(Button)findViewById(buttonId);
  buttonView.setText(selectedItemText);
  boolean b_need_restart_audio;
  SharedPreferences sharedPref=this.getPreferences(Context.MODE_PRIVATE);
  SharedPreferences.Editor editor=sharedPref.edit();
switch (buttonId) {
case R.id.button_sample_rate:
    popupMenuSampleRate.dismiss();
  sampleRate=Integer.parseInt(selectedItemTag);
b_need_restart_audio=true;
editor.putInt("String_Node_Str",sampleRate);
break;
case R.id.button_fftlen:
popupMenuFFTLen.dismiss();
fftLen=Integer.parseInt(selectedItemTag);
b_need_restart_audio=true;
editor.putInt("String_Node_Str",fftLen);
break;
case R.id.button_average:
popupMenuAverage.dismiss();
nFFTAverage=Integer.parseInt(selectedItemTag);
b_need_restart_audio=false;
editor.putInt("String_Node_Str",nFFTAverage);
break;
default :
Log.w(TAG,"String_Node_Str");
b_need_restart_audio=false;
}
editor.commit();
if (b_need_restart_audio) {
reRecur();
updateAllLabels();
}
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> parent,View v,int position,long id){
  String selectedItemTag=((TextView)v).getTag().toString();
  if (selectedItemTag.equals("String_Node_Str")) {
    return;
  }
  String selectedItemText=((TextView)v).getText().toString();
  int buttonId=Integer.parseInt((parent.getTag().toString()));
  Button buttonView=(Button)findViewById(buttonId);
  buttonView.setText(selectedItemText);
  boolean b_need_restart_audio;
  SharedPreferences sharedPref=this.getPreferences(Context.MODE_PRIVATE);
  SharedPreferences.Editor editor=sharedPref.edit();
switch (buttonId) {
case R.id.button_sample_rate:
    popupMenuSampleRate.dismiss();
  sampleRate=Integer.parseInt(selectedItemTag);
b_need_restart_audio=true;
editor.putInt("String_Node_Str",sampleRate);
break;
case R.id.button_fftlen:
popupMenuFFTLen.dismiss();
fftLen=Integer.parseInt(selectedItemTag);
b_need_restart_audio=true;
editor.putInt("String_Node_Str",fftLen);
break;
case R.id.button_average:
popupMenuAverage.dismiss();
nFFTAverage=Integer.parseInt(selectedItemTag);
if (graphView != null) {
graphView.setTimeMultiplier(nFFTAverage);
}
b_need_restart_audio=false;
editor.putInt("String_Node_Str",nFFTAverage);
break;
default :
Log.w(TAG,"String_Node_Str");
b_need_restart_audio=false;
}
editor.commit();
if (b_need_restart_audio) {
reRecur();
updateAllLabels();
}
}
Program: 31883
Project: 31883
Buggy source:
@Override public void run(){
  AnalyzeActivity.this.recompute(data);
  TextView tv=(TextView)findViewById(R.id.textview_RMS);
  tv.setText("String_Node_Str" + dfDB.format(20 * Math.log10(dtRMSFromFT)));
  tv.invalidate();
  freq2Cent(sCent,maxAmpFreq,"String_Node_Str");
  tv=(TextView)findViewById(R.id.textview_peak);
  tv.setText("String_Node_Str" + dfFreq.format(maxAmpFreq) + "String_Node_Str"+ sCent+ "String_Node_Str"+ dfDB.format(maxAmpDB)+ "String_Node_Str");
  tv.invalidate();
}

Fixed version (ground truth):
@Override public void run(){
  AnalyzeActivity.this.rePlot();
  TextView tv=(TextView)findViewById(R.id.textview_RMS);
  tv.setText("String_Node_Str" + dfDB.format(20 * Math.log10(dtRMSFromFT)));
  tv.invalidate();
  freq2Cent(sCent,maxAmpFreq,"String_Node_Str");
  tv=(TextView)findViewById(R.id.textview_peak);
  tv.setText("String_Node_Str" + dfFreq.format(maxAmpFreq) + "String_Node_Str"+ sCent+ "String_Node_Str"+ dfDB.format(maxAmpDB)+ "String_Node_Str");
  tv.invalidate();
}
Program: 31884
Project: 31884
Buggy source:
private void update(final double[] data){
  AnalyzeActivity.this.runOnUiThread(new Runnable(){
    @Override public void run(){
      AnalyzeActivity.this.recompute(data);
      TextView tv=(TextView)findViewById(R.id.textview_RMS);
      tv.setText("String_Node_Str" + dfDB.format(20 * Math.log10(dtRMSFromFT)));
      tv.invalidate();
      freq2Cent(sCent,maxAmpFreq,"String_Node_Str");
      tv=(TextView)findViewById(R.id.textview_peak);
      tv.setText("String_Node_Str" + dfFreq.format(maxAmpFreq) + "String_Node_Str"+ sCent+ "String_Node_Str"+ dfDB.format(maxAmpDB)+ "String_Node_Str");
      tv.invalidate();
    }
  }
);
}

Fixed version (ground truth):
private void update(final double[] data){
  graphView.replotRawSpectrum(spectrumDBcopy,1,spectrumDBcopy.length,showLines);
  AnalyzeActivity.this.runOnUiThread(new Runnable(){
    @Override public void run(){
      AnalyzeActivity.this.rePlot();
      TextView tv=(TextView)findViewById(R.id.textview_RMS);
      tv.setText("String_Node_Str" + dfDB.format(20 * Math.log10(dtRMSFromFT)));
      tv.invalidate();
      freq2Cent(sCent,maxAmpFreq,"String_Node_Str");
      tv=(TextView)findViewById(R.id.textview_peak);
      tv.setText("String_Node_Str" + dfFreq.format(maxAmpFreq) + "String_Node_Str"+ sCent+ "String_Node_Str"+ dfDB.format(maxAmpDB)+ "String_Node_Str");
      tv.invalidate();
    }
  }
);
}
Program: 31885
Project: 31885
Buggy source:
/** 
 * recompute the spectra "chart"
 * @param data    The normalized FFT output
 */
public void recompute(double[] data){
  if (graphView.isBusy() == true) {
    Log.d(TAG,"String_Node_Str");
  }
  graphView.replotRawSpectrum(data,1,data.length,showLines);
  graphView.invalidate();
}

Fixed version (ground truth):
public void recompute(double[] data){
  if (graphView.isBusy() == true) {
    Log.d(TAG,"String_Node_Str");
  }
  graphView.replotRawSpectrum(data,1,data.length,showLines);
  graphView.invalidate();
}
Program: 31886
Project: 31886
Buggy source:
public void add2Spectrogram(double[] db){
  for (int i=1; i < db.length; i++) {
    spectrogramColors[spectrogramColorsPt * nFreqPoints - 1 + i]=colorFromDB(db[i]);
  }
  spectrogramColorsPt++;
  if (spectrogramColorsPt >= nTimePoints) {
    spectrogramColorsPt=0;
  }
}

Fixed version (ground truth):
public void add2Spectrogram(double[] db){
  System.arraycopy(spectrogramColors,nFreqPoints,spectrogramColors,0,spectrogramColors.length - nFreqPoints);
  for (int i=1; i < db.length; i++) {
    spectrogramColors[spectrogramColors.length - nFreqPoints - 1 + i]=colorFromDB(db[i]);
  }
}
Program: 31887
Project: 31887
Buggy source:
/** 
 * Re-plot the spectrum
 */
public void replotRawSpectrum(double[] db,int start,int end,boolean bars){
  if (canvasHeight < 1) {
    return;
  }
  isBusy=true;
  float minYcanvas=canvasY4axis(minDB);
  path.reset();
  if (bars) {
    for (int i=start; i < end; i++) {
      float x=(float)i / db.length * canvasWidth;
      float y=canvasY4axis(clampDB((float)db[i]));
      if (y != canvasHeight) {
        path.moveTo(x,minYcanvas);
        path.lineTo(x,y);
      }
    }
  }
 else {
    path.moveTo((float)start / db.length * canvasWidth,canvasY4axis(clampDB((float)db[start])));
    for (int i=start + 1; i < end; i++) {
      float x=(float)i / db.length * canvasWidth;
      float y=canvasY4axis(clampDB((float)db[i]));
      path.lineTo(x,y);
    }
  }
  add2Spectrogram(db);
  isBusy=false;
}

Fixed version (ground truth):
/** 
 * Re-plot the spectrum
 */
public void replotRawSpectrum(double[] db,int start,int end,boolean bars){
  if (canvasHeight < 1) {
    return;
  }
  isBusy=true;
  float minYcanvas=canvasY4axis(minDB);
  path.reset();
  if (bars) {
    for (int i=start; i < end; i++) {
      float x=(float)i / (db.length - 1) * canvasWidth;
      float y=canvasY4axis(clampDB((float)db[i]));
      if (y != canvasHeight) {
        path.moveTo(x,minYcanvas);
        path.lineTo(x,y);
      }
    }
  }
 else {
    path.moveTo((float)start / (db.length - 1) * canvasWidth,canvasY4axis(clampDB((float)db[start])));
    for (int i=start + 1; i < end; i++) {
      float x=(float)i / (db.length - 1) * canvasWidth;
      float y=canvasY4axis(clampDB((float)db[i]));
      path.lineTo(x,y);
    }
  }
  add2Spectrogram(db);
  isBusy=false;
}
Program: 31888
Project: 31888
Buggy source:
@Override protected void onDraw(Canvas c){
  isBusy=true;
  c.concat(matrix0);
  c.save();
  drawGridLines(c,canvasWidth * gridDensity,canvasHeight * gridDensity);
  c.concat(matrix);
  c.drawPath(path,linePaint);
  if (xShift <= cursorX && cursorX <= xShift + canvasWidth / xZoom) {
    c.drawLine(cursorX,yShift,cursorX,yShift + canvasHeight / yZoom,cursorPaint);
  }
  if (yShift <= cursorY && cursorY <= yShift + canvasHeight / yZoom) {
    c.drawLine(xShift,cursorY,xShift + canvasWidth / xZoom,cursorY,cursorPaint);
  }
  if (mark > 0f) {
    c.drawLine(mark - 3,0,mark,25,cursorPaint);
    c.drawLine(mark + 3,0,mark,25,cursorPaint);
  }
  c.restore();
  drawGridLabels(c);
  float x=0;
  float y=canvasHeight - spectrogramColorsPt;
  if (spectrogramColorsPt > 0) {
    c.drawBitmap(spectrogramColors,0,nFreqPoints,x,y,nFreqPoints,spectrogramColorsPt,false,null);
  }
  y=canvasHeight - nTimePoints;
  c.drawBitmap(spectrogramColors,spectrogramColorsPt * nFreqPoints,nFreqPoints,x,y,nFreqPoints,nTimePoints - spectrogramColorsPt,false,null);
  isBusy=false;
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas c){
  isBusy=true;
  c.concat(matrix0);
  c.save();
  drawGridLines(c,canvasWidth * gridDensity,canvasHeight * gridDensity);
  c.concat(matrix);
  c.drawPath(path,linePaint);
  if (xShift <= cursorX && cursorX <= xShift + canvasWidth / xZoom) {
    c.drawLine(cursorX,yShift,cursorX,yShift + canvasHeight / yZoom,cursorPaint);
  }
  if (yShift <= cursorY && cursorY <= yShift + canvasHeight / yZoom) {
    c.drawLine(xShift,cursorY,xShift + canvasWidth / xZoom,cursorY,cursorPaint);
  }
  if (mark > 0f) {
    c.drawLine(mark - 3,0,mark,25,cursorPaint);
    c.drawLine(mark + 3,0,mark,25,cursorPaint);
  }
  c.restore();
  drawGridLabels(c);
  matrixSpectrogram.reset();
  matrixSpectrogram.postScale((float)canvasWidth / nFreqPoints,1);
  c.concat(matrixSpectrogram);
  float x=0;
  float y=canvasHeight - nTimePoints;
  c.drawBitmap(spectrogramColors,0,nFreqPoints,x,y,nFreqPoints,nTimePoints,false,null);
  isBusy=false;
}
Program: 31889
Project: 31889
Buggy source:
public void switch2Spectrogram(double timeWatch,int sampleRate,int fftLen){
  showMode=1;
  nFreqPoints=fftLen / 2 + 1;
  timeInc=fftLen / 2.0 / sampleRate;
  nTimePoints=(int)Math.round(timeWatch / timeInc);
  spectrogramColorsPt=0;
  if (spectrogramColors == null || spectrogramColors.length != nFreqPoints * nTimePoints) {
    spectrogramColors=new int[nFreqPoints * nTimePoints];
    Arrays.fill(spectrogramColors,0);
  }
  for (int i=0; i < spectrogramColors.length; i++) {
    spectrogramColors[i]=(int)(Math.random() * 0xFFFFFF);
  }
}

Fixed version (ground truth):
public void switch2Spectrogram(double timeWatch,int sampleRate,int fftLen){
  showMode=1;
  nFreqPoints=fftLen / 2;
  timeInc=fftLen / 2.0 / sampleRate;
  nTimePoints=(int)Math.round(timeWatch / timeInc);
  spectrogramColorsPt=0;
  if (spectrogramColors == null || spectrogramColors.length != nFreqPoints * nTimePoints) {
    spectrogramColors=new int[nFreqPoints * nTimePoints];
    Arrays.fill(spectrogramColors,0);
  }
}
Program: 31890
Project: 31890
Buggy source:
private void SleepWithoutInterrupt(long millis){
  try {
    Thread.sleep(100);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void SleepWithoutInterrupt(long millis){
  try {
    Thread.sleep(millis);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}
Program: 31891
Project: 31891
Buggy source:
/** 
 * TODO: add button-specific help on longclick
 */
@Override public boolean onLongClick(View view){
  vibrate(300);
  Log.i(TAG,"String_Node_Str" + view.toString());
  return true;
}

Fixed version (ground truth):
/** 
 * TODO: add button-specific help on long click
 */
@Override public boolean onLongClick(View view){
  vibrate(300);
  Log.i(TAG,"String_Node_Str" + view.toString());
  return true;
}
Program: 31892
Project: 31892
Buggy source:
/** 
 * recompute the spectra "chart"
 * @param data    The normalized FFT output
 */
public void recompute(double[] data){
  if (graphView.isBusy() == true) {
    Log.d(TAG,"String_Node_Str");
  }
  graphView.recompute(data,1,data.length,showLines);
  graphView.invalidate();
}

Fixed version (ground truth):
/** 
 * recompute the spectra "chart"
 * @param data    The normalized FFT output
 */
public void recompute(double[] data){
  if (graphView.isBusy() == true) {
    Log.d(TAG,"String_Node_Str");
  }
  graphView.replotRawSpectrum(data,1,data.length,showLines);
  graphView.invalidate();
}
Program: 31893
Project: 31893
Buggy source:
private void scaleEvent(MotionEvent event){
  if (event.getAction() != MotionEvent.ACTION_MOVE) {
    start=INIT;
    isPinching=false;
    return;
  }
switch (event.getPointerCount()) {
case 2:
    float delta=Math.abs(event.getX(0) - event.getX(1));
  if (isPinching) {
    float scale=initScale * delta / start;
    graphView.setScale(Math.min(10f,scale));
    updateAllLabels();
  }
 else {
    start=delta;
    initScale=graphView.getScale();
  }
isPinching=true;
break;
case 1:
float x=event.getX(0);
if (isPinching || start == INIT) {
start=graphView.getXlate();
x0=x;
}
 else {
graphView.setXlate(start + (x0 - x) / graphView.getScale());
updateAllLabels();
}
isPinching=false;
break;
default :
Log.i(TAG,"String_Node_Str");
break;
}
}

Fixed version (ground truth):
private void scaleEvent(MotionEvent event){
  if (event.getAction() != MotionEvent.ACTION_MOVE) {
    start=INIT;
    isPinching=false;
    return;
  }
switch (event.getPointerCount()) {
case 2:
    float delta=Math.abs(event.getX(0) - event.getX(1));
  if (isPinching) {
    float scale=initScale * delta / start;
    graphView.setScale(Math.min(10f,scale));
    updateAllLabels();
  }
 else {
    start=delta;
    initScale=graphView.getXZoom();
  }
isPinching=true;
break;
case 1:
float x=event.getX(0);
if (isPinching || start == INIT) {
start=graphView.getXlate();
x0=x;
}
 else {
graphView.setXlate(start + (x0 - x) / graphView.getXZoom());
updateAllLabels();
}
isPinching=false;
break;
default :
Log.i(TAG,"String_Node_Str");
break;
}
}
Program: 31895
Project: 31895
Buggy source:
@Override protected void onDraw(Canvas c){
  isBusy=true;
  c.concat(matrix0);
  c.save();
  drawGridLines(c,3,5);
  c.concat(matrix);
  c.drawPath(path,linePaint);
  if (cursorX > 0) {
    c.drawLine(cursorX,0,cursorX,canvasHeight,cursorPaint);
  }
  if (cursorY > 0) {
    c.drawLine(0,cursorY,canvasWidth,cursorY,cursorPaint);
  }
  if (mark > 0f) {
    c.drawLine(mark - 3,0,mark,25,cursorPaint);
    c.drawLine(mark + 3,0,mark,25,cursorPaint);
  }
  c.restore();
  drawGridLabels(c);
  isBusy=false;
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas c){
  isBusy=true;
  c.concat(matrix0);
  c.save();
  drawGridLines(c,canvasWidth / 80f,canvasHeight / 90f);
  c.concat(matrix);
  c.drawPath(path,linePaint);
  if (cursorX > 0) {
    c.drawLine(cursorX,0,cursorX,canvasHeight,cursorPaint);
  }
  if (cursorY > 0) {
    c.drawLine(0,cursorY,canvasWidth,cursorY,cursorPaint);
  }
  if (mark > 0f) {
    c.drawLine(mark - 3,0,mark,25,cursorPaint);
    c.drawLine(mark + 3,0,mark,25,cursorPaint);
  }
  c.restore();
  drawGridLabels(c);
  isBusy=false;
}