nus-yam/ex-repair huggingface dataset:
Program: 6401
Project: 6401
Buggy source:
private boolean processMoveEvent(final MotionEvent ev){
  final int x=(int)ev.getX();
  final int y=(int)ev.getY();
  final int rawX=(int)ev.getRawX();
  final int off;
  boolean processed=false;
switch (state) {
case DRAGGING_ITEM:
    dragVelocityTracker.addMovement(ev,false);
  off=x - dragPointX + coordOffsetX;
if (off < 0 && slideLeftListener != null) {
  setState(State.DRAGGING_VIEW_LEFT);
  slideLeftListener.slideLeftStarted(getItemIdAtPosition(dragItemNum));
}
 else {
  dragView(x);
}
processed=true;
break;
case DRAGGING_VIEW_LEFT:
dragVelocityTracker.addMovement(ev,true);
off=dragPointX - rawX;
if (off < 0) {
slideLeft(0);
if (startPreDragging(ev)) setState(State.DRAGGING_ITEM);
 else setState(State.NORMAL);
}
 else {
slideLeft(off);
}
processed=true;
break;
default :
final int deltaXFromDown=x - dragStartX;
final int deltaYFromDown=y - dragStartY;
if (deltaYFromDown >= scaledTouchSlop) scrolling=true;
final int itemnum=pointToPositionWithInvisible(x,y);
if (!scrolling) {
dragVelocityTracker.addMovement(ev,false);
if (state == State.PRESSED_ON_ITEM && itemInBounds(dragItemNum) && deltaXFromDown > scaledTouchSlop && deleteItemListener != null) {
setState(State.DRAGGING_ITEM);
processed=true;
}
 else if (state == State.PRESSED_ON_ITEM && deltaXFromDown < -scaledTouchSlop && slideLeftListener != null && itemnum != AdapterView.INVALID_POSITION) {
setState(State.DRAGGING_VIEW_LEFT);
dragPointX=x;
slideLeftListener.slideLeftStarted(getItemIdAtPosition(itemnum));
processed=true;
}
}
}
return processed;
}

Fixed version (ground truth):
private boolean processMoveEvent(final MotionEvent ev){
  final int x=(int)ev.getX();
  final int y=(int)ev.getY();
  final int rawX=(int)ev.getRawX();
  final int off;
  boolean processed=false;
switch (state) {
case DRAGGING_ITEM:
    dragVelocityTracker.addMovement(ev,false);
  off=x - dragPointX + coordOffsetX;
if (off < 0 && slideLeftListener != null) {
  setState(State.DRAGGING_VIEW_LEFT);
  slideLeftListener.slideLeftStarted(getItemIdAtPosition(dragItemNum));
}
 else {
  dragView(x);
}
processed=true;
break;
case DRAGGING_VIEW_LEFT:
dragVelocityTracker.addMovement(ev,true);
off=dragPointX - rawX;
if (off < 0) {
slideLeft(0);
if (startPreDragging(ev)) setState(State.DRAGGING_ITEM);
 else setState(State.NORMAL);
}
 else {
slideLeft(off);
}
processed=true;
break;
default :
final int deltaXFromDown=x - dragStartX;
final int deltaYFromDown=y - dragStartY;
if (deltaYFromDown >= scaledTouchSlop) scrolling=true;
final int itemnum=pointToPositionWithInvisible(x,y);
if (!scrolling) {
dragVelocityTracker.addMovement(ev,false);
if (state == State.PRESSED_ON_ITEM && itemInBounds(dragItemNum) && deltaXFromDown > scaledTouchSlop && deleteItemListener != null) {
setState(State.DRAGGING_ITEM);
}
 else if (state == State.PRESSED_ON_ITEM && deltaXFromDown < -scaledTouchSlop && slideLeftListener != null && itemnum != AdapterView.INVALID_POSITION) {
setState(State.DRAGGING_VIEW_LEFT);
dragPointX=x;
slideLeftListener.slideLeftStarted(getItemIdAtPosition(itemnum));
}
processed=true;
}
}
return processed;
}
Program: 6402
Project: 6402
Buggy source:
public void slidingFinished(){
  final EditText editText=getEditBodyWidget();
  if (editingItem.caretPos != null) {
    final Editable text=editText.getText();
    Selection.setSelection(text,editingItem.caretPos);
  }
  editText.requestFocus();
}

Fixed version (ground truth):
public void slidingFinished(){
  final EditText editText=getEditBodyWidget();
  if (editingItem.caretPos != null) {
    final Editable text=editText.getText();
    final int savedCaretPos=editingItem.caretPos;
    if (savedCaretPos >= 0 && savedCaretPos < text.length())     Selection.setSelection(text,savedCaretPos);
  }
  editText.requestFocus();
}
Program: 6403
Project: 6403
Buggy source:
private void startEditingItem(final long id){
  editingItem=todoItemsStorage.loadTodoItem(id);
  getEditSummaryWidget().setText(editingItem.summary);
  getEditBodyWidget().setText(editingItem.body);
  if (edititgItemTagsCursor != null)   edititgItemTagsCursor.close();
  edititgItemTagsCursor=tagsStorage.getAllTagsExceptCursor(DBHelper.ALL_TAGS_METATAG_ID);
  startManagingCursor(edititgItemTagsCursor);
  final SimpleCursorAdapter editingItemTagsAdapter=Util.createTagsAdapter(this,edititgItemTagsCursor,android.R.layout.simple_spinner_item);
  editingItemTagsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  final Spinner spinner=getEditItemTagsWidget();
  spinner.setAdapter(editingItemTagsAdapter);
  final int position=Util.getItemPosition(editingItemTagsAdapter,editingItem.tagID);
  if (position != -1)   spinner.setSelection(position);
  getPrioSliderButton().setSelection(editingItem.prio - 1);
  getProgressSliderButton().setSelection(editingItem.getProgress() / 10);
  updateDueDateButton();
  getSlidingView().setSlideListener(new SlidingView.SlideListener(){
    public void slidingFinished(){
      final EditText editText=getEditBodyWidget();
      if (editingItem.caretPos != null) {
        final Editable text=editText.getText();
        Selection.setSelection(text,editingItem.caretPos);
      }
      editText.requestFocus();
    }
  }
);
}

Fixed version (ground truth):
private void startEditingItem(final long id){
  editingItem=todoItemsStorage.loadTodoItem(id);
  getEditSummaryWidget().setText(editingItem.summary);
  getEditBodyWidget().setText(editingItem.body);
  if (edititgItemTagsCursor != null)   edititgItemTagsCursor.close();
  edititgItemTagsCursor=tagsStorage.getAllTagsExceptCursor(DBHelper.ALL_TAGS_METATAG_ID);
  startManagingCursor(edititgItemTagsCursor);
  final SimpleCursorAdapter editingItemTagsAdapter=Util.createTagsAdapter(this,edititgItemTagsCursor,android.R.layout.simple_spinner_item);
  editingItemTagsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  final Spinner spinner=getEditItemTagsWidget();
  spinner.setAdapter(editingItemTagsAdapter);
  final int position=Util.getItemPosition(editingItemTagsAdapter,editingItem.tagID);
  if (position != -1)   spinner.setSelection(position);
  getPrioSliderButton().setSelection(editingItem.prio - 1);
  getProgressSliderButton().setSelection(editingItem.getProgress() / 10);
  updateDueDateButton();
  getSlidingView().setSlideListener(new SlidingView.SlideListener(){
    public void slidingFinished(){
      final EditText editText=getEditBodyWidget();
      if (editingItem.caretPos != null) {
        final Editable text=editText.getText();
        final int savedCaretPos=editingItem.caretPos;
        if (savedCaretPos >= 0 && savedCaretPos < text.length())         Selection.setSelection(text,savedCaretPos);
      }
      editText.requestFocus();
    }
  }
);
}
Program: 6404
Project: 6404
Buggy source:
@Override public boolean onTouchEvent(final MotionEvent ev){
  if (replaying || deleteItemListener == null)   return super.onTouchEvent(ev);
  boolean processed=false;
switch (ev.getAction()) {
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
    processed=processUpEvent();
  break;
case MotionEvent.ACTION_DOWN:
if (scrolling) break;
processed=processDownEvent(ev);
break;
case MotionEvent.ACTION_MOVE:
if (scrolling) break;
processed=processMoveEvent(ev);
break;
}
if (processed) {
if (!(state == State.DRAGGING_ITEM)) intercepted.add(ev);
return true;
}
 else if (intercepted.size() > 0) {
replaying=true;
try {
for (final MotionEvent event : intercepted) {
super.dispatchTouchEvent(event);
}
}
 catch (Exception e) {
}
replaying=false;
intercepted.clear();
}
return super.onTouchEvent(ev);
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(final MotionEvent ev){
  if (replaying || deleteItemListener == null)   return super.onTouchEvent(ev);
  boolean processed=false;
switch (ev.getAction()) {
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
    processed=processUpEvent();
  break;
case MotionEvent.ACTION_DOWN:
if (scrolling) break;
processed=processDownEvent(ev);
break;
case MotionEvent.ACTION_MOVE:
if (scrolling) break;
processed=processMoveEvent(ev);
break;
}
if (processed) {
if (!(state == State.DRAGGING_ITEM)) intercepted.add(ev);
return true;
}
 else if (intercepted.size() > 0) {
replaying=true;
try {
for (final MotionEvent event : intercepted) {
super.dispatchTouchEvent(event);
}
return super.onTouchEvent(ev);
}
 catch (Exception e) {
}
 finally {
replaying=false;
intercepted.clear();
}
return true;
}
 else return super.onTouchEvent(ev);
}
Program: 6405
Project: 6405
Buggy source:
@Override public boolean onTouchEvent(final MotionEvent ev){
  if (replaying || deleteItemListener == null)   return super.onTouchEvent(ev);
  boolean processed=false;
switch (ev.getAction()) {
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
    processed=processUpEvent();
  break;
case MotionEvent.ACTION_DOWN:
if (scrolling) break;
processed=processDownEvent(ev);
break;
case MotionEvent.ACTION_MOVE:
if (scrolling) break;
processed=processMoveEvent(ev);
break;
}
if (processed) {
if (!(state == State.DRAGGING_ITEM)) intercepted.add(ev);
return true;
}
 else if (intercepted.size() > 0) {
replaying=true;
for (final MotionEvent event : intercepted) {
try {
super.dispatchTouchEvent(event);
}
 catch (ArrayIndexOutOfBoundsException e) {
}
}
replaying=false;
intercepted.clear();
}
return super.onTouchEvent(ev);
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(final MotionEvent ev){
  if (replaying || deleteItemListener == null)   return super.onTouchEvent(ev);
  boolean processed=false;
switch (ev.getAction()) {
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
    processed=processUpEvent();
  break;
case MotionEvent.ACTION_DOWN:
if (scrolling) break;
processed=processDownEvent(ev);
break;
case MotionEvent.ACTION_MOVE:
if (scrolling) break;
processed=processMoveEvent(ev);
break;
}
if (processed) {
if (!(state == State.DRAGGING_ITEM)) intercepted.add(ev);
return true;
}
 else if (intercepted.size() > 0) {
replaying=true;
try {
for (final MotionEvent event : intercepted) {
super.dispatchTouchEvent(event);
}
}
 catch (Exception e) {
}
replaying=false;
intercepted.clear();
}
return super.onTouchEvent(ev);
}
Program: 6406
Project: 6406
Buggy source:
@Override public boolean handleLongClick(){
  if (!mEditorView.scaleDetectorActive()) {
    mTweetFlow.addServiceRequest(mEditorView.getLastTouchX(),mEditorView.getLastTouchY());
    mEditorView.redraw();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean handleLongClick(){
  if (!mEditorView.scaleDetectorActive()) {
    mTweetFlow.addServiceRequest(mEditorView.scaledLastX(),mEditorView.scaledLastY());
    mEditorView.redraw();
  }
  return true;
}
Program: 6407
Project: 6407
Buggy source:
public void checkMaybeConnections(AbstractElement candidate){
  final int offX=getMiddleX() - candidate.getMiddleX();
  if (Math.abs(offX) < TweetFlow.DISTANCE_FOR_AUTO_CONNECTION_X) {
    if (mClosedSequenceNext == null && candidate.mClosedSequencePrev == null) {
      final int offY=candidate.getTopY() - getBotY();
      if (offY > 0 && offY < TweetFlow.DISTANCE_FOR_AUTO_CONNECTION_Y) {
        mClosedSequenceMaybeNext=candidate;
      }
    }
    if (candidate.mClosedSequenceNext == null && mClosedSequencePrev == null) {
      final int offY=getTopY() - candidate.getBotY();
      if (offY > 0 && offY < TweetFlow.DISTANCE_FOR_AUTO_CONNECTION_Y) {
        candidate.mClosedSequenceMaybeNext=this;
      }
    }
  }
}

Fixed version (ground truth):
public void checkMaybeConnections(AbstractElement candidate){
  final int offX=getMiddleX() - candidate.getMiddleX();
  if (Math.abs(offX) < TweetFlow.DISTANCE_FOR_AUTO_CONNECTION_X) {
    if (mClosedSequenceNext == null && candidate.mClosedSequencePrev == null) {
      final int offY=candidate.getTopY() - getBotY();
      if (offY > 0 && offY < TweetFlow.DISTANCE_FOR_AUTO_CONNECTION_Y && mClosedSequenceMaybeNext == null) {
        mClosedSequenceMaybeNext=candidate;
        candidate.mClosedSequenceMaybePrev=this;
      }
    }
    if (candidate.mClosedSequenceNext == null && mClosedSequencePrev == null) {
      final int offY=getTopY() - candidate.getBotY();
      if (offY > 0 && offY < TweetFlow.DISTANCE_FOR_AUTO_CONNECTION_Y && mClosedSequenceMaybePrev == null) {
        mClosedSequenceMaybePrev=candidate;
        candidate.mClosedSequenceMaybeNext=this;
      }
    }
  }
}
Program: 6408
Project: 6408
Buggy source:
public void setClosedSequencePrev(AbstractElement mClosedSequencePrev){
  this.mClosedSequencePrev=mClosedSequencePrev;
}

Fixed version (ground truth):
public void setClosedSequencePrev(AbstractElement closedSequencePrev){
  if (closedSequencePrev != null) {
    mClosedSequencePrev=closedSequencePrev;
    closedSequencePrev.mClosedSequenceNext=this;
  }
}
Program: 6409
Project: 6409
Buggy source:
public void resetMaybeConnections(){
  mClosedSequenceMaybeNext=null;
}

Fixed version (ground truth):
public void resetMaybeConnections(){
  mClosedSequenceMaybeNext=null;
  mClosedSequenceMaybePrev=null;
}
Program: 6410
Project: 6410
Buggy source:
public ArrayList<Integer> createRasterLines(){
  ArrayList<Integer> gridLines=new ArrayList<Integer>();
  for (int i=0; i < horizontalRasterCT; i++) {
    gridLines.add((Integer)(i * RASTER_HORIZONTAL_WIDTH - RASTER_HORIZONTAL_WIDTH / 2 + mOffsetX % RASTER_HORIZONTAL_WIDTH - mOffsetX));
  }
  return gridLines;
}

Fixed version (ground truth):
public ArrayList<Integer> createRasterLines(){
  float scale=editorView.getmScaleFactor();
  ArrayList<Integer> gridLines=new ArrayList<Integer>();
  for (int i=0; i < horizontalRasterCT / scale; i++) {
    gridLines.add((Integer)(i * RASTER_HORIZONTAL_WIDTH - RASTER_HORIZONTAL_WIDTH / 2 + mOffsetX % RASTER_HORIZONTAL_WIDTH - mOffsetX));
  }
  return gridLines;
}
Program: 6411
Project: 6411
Buggy source:
private void prepareListView(){
  ListView lv=(ListView)findViewById(R.id.home_file_list);
  LayoutInflater inflator=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View emptyView=inflator.inflate(R.layout.filelist_empty,null);
  ((ViewGroup)lv.getParent()).addView(emptyView);
  lv.setEmptyView(emptyView);
  lv.setAdapter(mFileListAdapter);
  lv.setOnItemClickListener(new OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      final File file=(File)parent.getItemAtPosition(position);
      Intent i=new Intent(Home.this,Editor.class);
      i.putExtra(Editor.OPEN_FILE,file.getName());
      Home.this.startActivity(i);
    }
  }
);
  lv.setOnItemLongClickListener(new OnItemLongClickListener(){
    @Override public boolean onItemLongClick(    AdapterView<?> parent,    View view,    int position,    long id){
      final File file=(File)parent.getItemAtPosition(position);
      Toast.makeText(Home.this,"String_Node_Str" + file.getName(),Toast.LENGTH_SHORT).show();
      return true;
    }
  }
);
}

Fixed version (ground truth):
private void prepareListView(){
  ListView lv=(ListView)findViewById(R.id.home_file_list);
  LayoutInflater inflator=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View emptyView=inflator.inflate(R.layout.filelist_empty,null);
  ((ViewGroup)lv.getParent()).addView(emptyView);
  lv.setEmptyView(emptyView);
  lv.setAdapter(mFileListAdapter);
  lv.setOnItemClickListener(new OnItemClickListener(){
    public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      final File file=(File)parent.getItemAtPosition(position);
      Intent i=new Intent(Home.this,Editor.class);
      i.putExtra(Editor.OPEN_FILE,file.getName());
      Home.this.startActivity(i);
    }
  }
);
  lv.setOnItemLongClickListener(new OnItemLongClickListener(){
    public boolean onItemLongClick(    AdapterView<?> parent,    View view,    int position,    long id){
      final File file=(File)parent.getItemAtPosition(position);
      Toast.makeText(Home.this,"String_Node_Str" + file.getName(),Toast.LENGTH_SHORT).show();
      return true;
    }
  }
);
}
Program: 6412
Project: 6412
Buggy source:
@Override public boolean onItemLongClick(AdapterView<?> parent,View view,int position,long id){
  final File file=(File)parent.getItemAtPosition(position);
  Toast.makeText(Home.this,"String_Node_Str" + file.getName(),Toast.LENGTH_SHORT).show();
  return true;
}

Fixed version (ground truth):
public boolean onItemLongClick(AdapterView<?> parent,View view,int position,long id){
  final File file=(File)parent.getItemAtPosition(position);
  Toast.makeText(Home.this,"String_Node_Str" + file.getName(),Toast.LENGTH_SHORT).show();
  return true;
}
Program: 6413
Project: 6413
Buggy source:
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  final File file=(File)parent.getItemAtPosition(position);
  Intent i=new Intent(Home.this,Editor.class);
  i.putExtra(Editor.OPEN_FILE,file.getName());
  Home.this.startActivity(i);
}

Fixed version (ground truth):
public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  final File file=(File)parent.getItemAtPosition(position);
  Intent i=new Intent(Home.this,Editor.class);
  i.putExtra(Editor.OPEN_FILE,file.getName());
  Home.this.startActivity(i);
}
Program: 6414
Project: 6414
Buggy source:
public void draw(Canvas canvas){
  if (rasterOn) {
    horizontalRasterCT=(canvas.getWidth() / RASTER_HORIZONTAL_WIDTH) + 3;
    Paint paint=new Paint();
    paint.setPathEffect(new DashPathEffect(new float[]{10,3,6,3},1));
    if ((snapMode == SnapMode.NOTHING) || (snapMode == SnapMode.RASTER)) {
      paint.setColor(Color.BLUE);
      ArrayList<Integer> gridLines=createRasterLines();
      for (int i=0; i < gridLines.size(); i++) {
        canvas.drawLine(gridLines.get(i),0 - mOffsetY,gridLines.get(i),canvas.getHeight() - mOffsetY,paint);
      }
    }
    if (snapMode == SnapMode.GRID) {
      paint.setColor(Color.RED);
      for (      AbstractElement e : tweetFlow.getmElements().values()) {
        if (e instanceof ServiceRequest) {
          canvas.drawLine(e.getMiddleX(),0 - mOffsetY,e.getMiddleX(),canvas.getHeight() - mOffsetY,paint);
        }
      }
    }
  }
}

Fixed version (ground truth):
public void draw(Canvas canvas){
  if (rasterOn) {
    horizontalRasterCT=(canvas.getWidth() / RASTER_HORIZONTAL_WIDTH) + 3;
    Paint paint=new Paint();
    paint.setPathEffect(new DashPathEffect(new float[]{10,3,6,3},1));
    float scale=editorView.getmScaleFactor();
    if ((snapMode == SnapMode.NOTHING) || (snapMode == SnapMode.RASTER)) {
      paint.setColor(Color.BLUE);
      ArrayList<Integer> gridLines=createRasterLines();
      for (int i=0; i < gridLines.size(); i++) {
        canvas.drawLine(gridLines.get(i),(int)((0 - mOffsetY) / scale),gridLines.get(i),(int)((canvas.getHeight() - mOffsetY) / scale),paint);
      }
    }
    if (snapMode == SnapMode.GRID) {
      paint.setColor(Color.RED);
      for (      AbstractElement e : tweetFlow.getmElements().values()) {
        if (e instanceof ServiceRequest) {
          canvas.drawLine(e.getMiddleX(),(int)((0 - mOffsetY) / scale),e.getMiddleX(),(int)((canvas.getHeight() - mOffsetY) / scale),paint);
        }
      }
    }
  }
}
Program: 6415
Project: 6415
Buggy source:
public boolean isThereGridHorizontal(){
  int x=tweetFlow.getTouchElement().getMiddleX();
  int xDiff=Integer.MAX_VALUE;
  for (  AbstractElement e : tweetFlow.getmElements().values()) {
    if (e instanceof ServiceRequest) {
      if (tweetFlow.getTouchElement().getId() != e.getId()) {
        if ((Math.abs(x - e.getMiddleX())) < xDiff) {
          xDiff=Math.abs(x - e.getMiddleX());
        }
      }
    }
  }
  if (xDiff < 15)   return true;
  return false;
}

Fixed version (ground truth):
public boolean isThereGridHorizontal(){
  int x=tweetFlow.getTouchElement().getMiddleX();
  int xDiff=Integer.MAX_VALUE;
  for (  AbstractElement e : tweetFlow.getmElements().values()) {
    if (e instanceof ServiceRequest) {
      if (tweetFlow.getTouchElement().getId() != e.getId()) {
        if ((Math.abs(x - e.getMiddleX())) < xDiff) {
          xDiff=Math.abs(x - e.getMiddleX());
        }
      }
    }
  }
  if (xDiff < 30)   return true;
  return false;
}
Program: 6416
Project: 6416
Buggy source:
public RasterGridHelper(TweetFlow tweetFlow,Integer mOffsetX,Integer mOffsetY){
  this.mOffsetX=mOffsetX;
  this.mOffsetY=mOffsetY;
  this.tweetFlow=tweetFlow;
}

Fixed version (ground truth):
public RasterGridHelper(TweetFlow tweetFlow,Integer mOffsetX,Integer mOffsetY,EditorView editorView){
  this.mOffsetX=mOffsetX;
  this.mOffsetY=mOffsetY;
  this.tweetFlow=tweetFlow;
  this.editorView=editorView;
}
Program: 6417
Project: 6417
Buggy source:
public void onActionDown(MotionEvent event){
  super.onActionDown(event);
  final int x=(int)event.getX();
  final int y=(int)event.getY();
  if (mTweetFlow.elementAt(mEditorView.scaledX(x),mEditorView.scaledY(y))) {
    mTweetFlow.setTouchElementModeMarked();
    mEditorView.setState(EDITOR_STATE.TOUCH_ELEMENT);
    mEditorView.redraw();
  }
 else   if (rasterGridHelper.getRasterOn() && rasterGridHelper.getSnapMode() == SnapMode.GRID && rasterGridHelper.isTouchOnGrid(x)) {
    mEditorView.setState(EDITOR_STATE.MOVE_GRID);
    mEditorView.redraw();
  }
 else {
    mEditorView.setState(EDITOR_STATE.TOUCH_VOID);
  }
  mEditorView.setLastTouch(x,y);
}

Fixed version (ground truth):
public void onActionDown(MotionEvent event){
  super.onActionDown(event);
  final int x=(int)event.getX();
  final int y=(int)event.getY();
  if (mTweetFlow.elementAt(mEditorView.scaledX(x),mEditorView.scaledY(y))) {
    mTweetFlow.setTouchElementModeMarked();
    mEditorView.setState(EDITOR_STATE.TOUCH_ELEMENT);
    mEditorView.redraw();
  }
 else   if (rasterGridHelper.getRasterOn() && rasterGridHelper.getSnapMode() == SnapMode.GRID && rasterGridHelper.isTouchOnGrid(mEditorView.scaledX(x))) {
    mEditorView.setState(EDITOR_STATE.MOVE_GRID);
    mEditorView.redraw();
  }
 else {
    mEditorView.setState(EDITOR_STATE.TOUCH_VOID);
  }
  mEditorView.setLastTouch(x,y);
}
Program: 6418
Project: 6418
Buggy source:
public void onActionMove(MotionEvent event){
  final int pointerIndex=event.findPointerIndex(mEditorView.getActivePointerId());
  final int x=(int)event.getX(pointerIndex);
  final int y=(int)event.getY(pointerIndex);
  if (!mEditorView.scaleDetectorActive()) {
    final int offX=x - mEditorView.getLastTouchX();
    final int offY=y - mEditorView.getLastTouchY();
    mTweetFlow.moveTouchElement(offX,offY);
    mEditorView.redraw();
  }
  mEditorView.setLastTouch(x,y);
}

Fixed version (ground truth):
public void onActionMove(MotionEvent event){
  final int pointerIndex=event.findPointerIndex(mEditorView.getActivePointerId());
  final int x=(int)event.getX(pointerIndex);
  final int y=(int)event.getY(pointerIndex);
  if (!mEditorView.scaleDetectorActive()) {
    final int offX=x - mEditorView.getLastTouchX();
    final int offY=y - mEditorView.getLastTouchY();
    float scale=mEditorView.getmScaleFactor();
    mTweetFlow.moveTouchElement((int)(offX / scale),(int)(offY / scale));
    mEditorView.redraw();
  }
  mEditorView.setLastTouch(x,y);
}
Program: 6419
Project: 6419
Buggy source:
public void onActionMove(MotionEvent event){
  final int pointerIndex=event.findPointerIndex(mEditorView.getActivePointerId());
  final int x=(int)event.getX(pointerIndex);
  final int y=(int)event.getY(pointerIndex);
  if (!isRunning) {
    int xGrid=rasterGridHelper.getTouchOnGrid(mEditorView.getLastTouchX());
    gridElements=rasterGridHelper.getElementsOnGrid(xGrid);
    isRunning=true;
  }
  if (!mEditorView.scaleDetectorActive()) {
    final int offX=x - mEditorView.getLastTouchX();
    final int offY=y - mEditorView.getLastTouchY();
    mTweetFlow.moveGridElements(gridElements,offX,offY);
    mEditorView.redraw();
  }
  mEditorView.setLastTouch(x,y);
}

Fixed version (ground truth):
public void onActionMove(MotionEvent event){
  final int pointerIndex=event.findPointerIndex(mEditorView.getActivePointerId());
  final int x=(int)event.getX(pointerIndex);
  final int y=(int)event.getY(pointerIndex);
  if (!isRunning) {
    int xGrid=rasterGridHelper.getTouchOnGrid(mEditorView.scaledX(mEditorView.getLastTouchX()));
    gridElements=rasterGridHelper.getElementsOnGrid(xGrid);
    isRunning=true;
  }
  if (!mEditorView.scaleDetectorActive()) {
    final int offX=x - mEditorView.getLastTouchX();
    final int offY=y - mEditorView.getLastTouchY();
    float scale=mEditorView.getmScaleFactor();
    mTweetFlow.moveGridElements(gridElements,(int)(offX / scale),(int)(offY / scale));
    mEditorView.redraw();
  }
  mEditorView.setLastTouch(x,y);
}
Program: 6420
Project: 6420
Buggy source:
public void onActionMove(MotionEvent event){
  final int pointerIndex=event.findPointerIndex(mEditorView.getActivePointerId());
  final int x=(int)event.getX(pointerIndex);
  final int y=(int)event.getY(pointerIndex);
  if (!mEditorView.scaleDetectorActive()) {
    final int offX=x - mEditorView.getLastTouchX();
    final int offY=y - mEditorView.getLastTouchY();
    mTweetFlow.moveSelected(offX,offY);
    mEditorView.redraw();
  }
  mEditorView.setLastTouch(x,y);
}

Fixed version (ground truth):
public void onActionMove(MotionEvent event){
  final int pointerIndex=event.findPointerIndex(mEditorView.getActivePointerId());
  final int x=(int)event.getX(pointerIndex);
  final int y=(int)event.getY(pointerIndex);
  if (!mEditorView.scaleDetectorActive()) {
    final int offX=x - mEditorView.getLastTouchX();
    final int offY=y - mEditorView.getLastTouchY();
    float scale=mEditorView.getmScaleFactor();
    mTweetFlow.moveSelected((int)(offX / scale),(int)(offY / scale));
    mEditorView.redraw();
  }
  mEditorView.setLastTouch(x,y);
}
Program: 6421
Project: 6421
Buggy source:
public void onActionDown(MotionEvent event){
  super.onActionDown(event);
  final int xGrid;
  final int x=(int)event.getX();
  final int y=(int)event.getY();
  if (mTweetFlow.elementAt(mEditorView.scaledX(x),mEditorView.scaledY(y))) {
    mTweetFlow.setTouchElementModeMarked();
    mEditorView.setState(EDITOR_STATE.TOUCH_ELEMENT);
    mEditorView.redraw();
  }
 else   if (rasterGridHelper.getRasterOn() && rasterGridHelper.getSnapMode() == SnapMode.GRID && rasterGridHelper.isTouchOnGrid(x)) {
    mEditorView.setState(EDITOR_STATE.MOVE_GRID);
    mEditorView.redraw();
  }
 else {
    mEditorView.setState(EDITOR_STATE.TOUCH_VOID);
  }
  mEditorView.setLastTouch(x,y);
}

Fixed version (ground truth):
public void onActionDown(MotionEvent event){
  super.onActionDown(event);
  final int x=(int)event.getX();
  final int y=(int)event.getY();
  if (mTweetFlow.elementAt(mEditorView.scaledX(x),mEditorView.scaledY(y))) {
    mTweetFlow.setTouchElementModeMarked();
    mEditorView.setState(EDITOR_STATE.TOUCH_ELEMENT);
    mEditorView.redraw();
  }
 else   if (rasterGridHelper.getRasterOn() && rasterGridHelper.getSnapMode() == SnapMode.GRID && rasterGridHelper.isTouchOnGrid(mEditorView.scaledX(x))) {
    mEditorView.setState(EDITOR_STATE.MOVE_GRID);
    mEditorView.redraw();
  }
 else {
    mEditorView.setState(EDITOR_STATE.TOUCH_VOID);
  }
  mEditorView.setLastTouch(x,y);
}
Program: 6422
Project: 6422
Buggy source:
public EditorView(Context context,AttributeSet attrs){
  super(context,attrs);
  mTweetFlow=new TweetFlow(getContext());
  mTweetFlow.fillElements();
  setOnLongClickListener(mOnLongClickListener);
  mScaleDetector=new ScaleGestureDetector(context,new ScaleListener());
  mTapDetector=new GestureDetector(context,new DoubleTapListener());
  rasterGridHelper=new RasterGridHelper(mTweetFlow,mOffsetX,mOffsetY);
  prepareStates();
}

Fixed version (ground truth):
public EditorView(Context context,AttributeSet attrs){
  super(context,attrs);
  mTweetFlow=new TweetFlow(getContext());
  mTweetFlow.fillElements();
  setOnLongClickListener(mOnLongClickListener);
  mScaleDetector=new ScaleGestureDetector(context,new ScaleListener());
  mTapDetector=new GestureDetector(context,new DoubleTapListener());
  rasterGridHelper=new RasterGridHelper(mTweetFlow,mOffsetX,mOffsetY,this);
  prepareStates();
}
Program: 6423
Project: 6423
Buggy source:
public boolean onOptionsItemSelected(MenuItem menuItem){
  super.onOptionsItemSelected(menuItem);
switch (menuItem.getItemId()) {
case R.id.send_tweetflow:
    Toast.makeText(this,TweeterParser.parseTweetFlow(mTweetFlow.getmElementsAsList()),Toast.LENGTH_SHORT).show();
  break;
case R.id.deselect:
mTweetFlow.deselectAll();
mEditorView.redraw();
break;
case R.id.raster_add:
mEditorView.setRasterOn(true);
mEditorView.redraw();
break;
case R.id.raster_remove:
mEditorView.setRasterOn(false);
mEditorView.redraw();
break;
case R.id.snapping:
break;
case R.id.snapping_nothing:
menuItem.setChecked(true);
mEditorView.setSnapMode(SnapMode.NOTHING);
mEditorView.redraw();
break;
case R.id.snapping_raster:
menuItem.setChecked(true);
mEditorView.setSnapMode(SnapMode.RASTER);
mEditorView.redraw();
break;
case R.id.snapping_grid:
menuItem.setChecked(true);
mEditorView.setSnapMode(SnapMode.GRID);
mEditorView.redraw();
break;
case R.id.add_open_sequence:
mTweetFlow.addOpenSequence();
mEditorView.redraw();
break;
case R.id.create_bigloop:
mEditorView.setState(EDITOR_STATE.CREATE_LOOP);
break;
default :
Toast.makeText(this,menuItem.getTitle(),Toast.LENGTH_SHORT).show();
}
return true;
}

Fixed version (ground truth):
public boolean onOptionsItemSelected(MenuItem menuItem){
  super.onOptionsItemSelected(menuItem);
switch (menuItem.getItemId()) {
case R.id.send_tweetflow:
    Toast.makeText(this,TweeterParser.parseTweetFlow(mTweetFlow),Toast.LENGTH_SHORT).show();
  break;
case R.id.deselect:
mTweetFlow.deselectAll();
mEditorView.redraw();
break;
case R.id.raster_add:
mEditorView.setRasterOn(true);
mEditorView.redraw();
break;
case R.id.raster_remove:
mEditorView.setRasterOn(false);
mEditorView.redraw();
break;
case R.id.snapping:
break;
case R.id.snapping_nothing:
menuItem.setChecked(true);
mEditorView.setSnapMode(SnapMode.NOTHING);
mEditorView.redraw();
break;
case R.id.snapping_raster:
menuItem.setChecked(true);
mEditorView.setSnapMode(SnapMode.RASTER);
mEditorView.redraw();
break;
case R.id.snapping_grid:
menuItem.setChecked(true);
mEditorView.setSnapMode(SnapMode.GRID);
mEditorView.redraw();
break;
case R.id.add_open_sequence:
mTweetFlow.addOpenSequence();
mEditorView.redraw();
break;
case R.id.create_bigloop:
mEditorView.setState(EDITOR_STATE.CREATE_LOOP);
break;
default :
Toast.makeText(this,menuItem.getTitle(),Toast.LENGTH_SHORT).show();
}
return true;
}
Program: 6424
Project: 6424
Buggy source:
private static String createOpenSequence(AbstractElement element){
  String elementString="String_Node_Str";
  if (element instanceof ServiceRequest) {
    elementString="String_Node_Str" + ((ServiceRequest)element).getUser() + "String_Node_Str"+ ((ServiceRequest)element).getOperation()+ "String_Node_Str"+ ((ServiceRequest)element).getService();
    if (((ServiceRequest)element).getInputdata().length() > 0)     elementString+="String_Node_Str" + ((ServiceRequest)element).getInputdata();
    if (((ServiceRequest)element).getCondition().length() > 0)     elementString+="String_Node_Str" + ((ServiceRequest)element).getCondition() + "String_Node_Str";
  }
  if (element instanceof OpenSequence) {
    elementString=element.getId() + "String_Node_Str";
  }
  return elementString;
}

Fixed version (ground truth):
private static String createOpenSequence(TweetFlow tweetFlow,OpenSequence e){
  List<AbstractElement> list=tweetFlow.getElementsInOpenSequence(e);
  String elementString="String_Node_Str";
  if (list.size() > 0) {
    elementString+="String_Node_Str";
    for (    AbstractElement element : list) {
      if ((element.getClosedSequenceNext() == null) && (element.getClosedSequencePrev() == null)) {
        elementString+=createOpenSequenceRequest(element);
        elementString+="String_Node_Str";
      }
 else       if (element.getClosedSequencePrev() != null) {
        continue;
      }
 else       if (element.getClosedSequenceNext() != null) {
        elementString+=createClosedSequence(element);
        elementString+="String_Node_Str";
      }
    }
    elementString+="String_Node_Str";
  }
  return elementString;
}
Program: 6425
Project: 6425
Buggy source:
public static String parseTweetFlow(ArrayList<AbstractElement> elements){
  String tweetFlowString="String_Node_Str";
  for (  AbstractElement element : elements) {
    if ((element.getClosedSequenceNext() == null) && (element.getClosedSequencePrev() == null)) {
      tweetFlowString+=createOpenSequence(element);
      tweetFlowString+="String_Node_Str";
    }
 else     if (element.getClosedSequencePrev() != null) {
      continue;
    }
 else     if (element.getClosedSequenceNext() != null) {
      tweetFlowString+=createClosedSequence(element);
      tweetFlowString+="String_Node_Str";
    }
  }
  tweetFlowString+="String_Node_Str";
  return tweetFlowString;
}

Fixed version (ground truth):
public static String parseTweetFlow(TweetFlow tweetFlow){
  List<AbstractElement> elements=tweetFlow.getmElementsAsList();
  String tweetFlowString="String_Node_Str";
  for (  AbstractElement element : elements) {
    if (element instanceof OpenSequence) {
      String cos=createOpenSequence(tweetFlow,(OpenSequence)element);
      tweetFlowString+=cos;
      if (cos.length() > 0) {
        tweetFlowString+="String_Node_Str";
      }
      continue;
    }
    if (tweetFlow.isInOpenSequence(element)) {
      continue;
    }
    if ((element.getClosedSequenceNext() == null) && (element.getClosedSequencePrev() == null)) {
      tweetFlowString+=createOpenSequenceRequest(element);
      tweetFlowString+="String_Node_Str";
      continue;
    }
 else     if (element.getClosedSequencePrev() != null) {
      continue;
    }
 else     if (element.getClosedSequenceNext() != null) {
      tweetFlowString+=createClosedSequence(element);
      tweetFlowString+="String_Node_Str";
      continue;
    }
  }
  tweetFlowString+="String_Node_Str";
  return tweetFlowString;
}
Program: 6426
Project: 6426
Buggy source:
private void saveData(){
  element.setUser(user.getText().toString());
  element.setOperation(operation.getText().toString());
  element.setService(service.getText().toString());
  element.setInputdata(inputdata.getText().toString());
  element.setCondition(condition.getText().toString());
  element.setSelfLoopCondition(selfLoopCondition.getText().toString());
  if (element.getmLoop() != null)   element.setClosedLoopCondition(closedLoopCondition.getText().toString());
  if (selfLoopCondition.getText().toString() != "String_Node_Str") {
    Toast.makeText(getContext(),selfLoopCondition.getText().toString(),Toast.LENGTH_SHORT).show();
    element.setSelfLoop(true);
  }
  editorView.redraw();
}

Fixed version (ground truth):
private void saveData(){
  element.setUser(user.getText().toString());
  element.setOperation(operation.getText().toString());
  element.setService(service.getText().toString());
  element.setInputdata(inputdata.getText().toString());
  element.setCondition(condition.getText().toString());
  element.setSelfLoopCondition(selfLoopCondition.getText().toString());
  if (element.getmLoop() != null)   element.setClosedLoopCondition(closedLoopCondition.getText().toString());
  if (selfLoopCondition.getText().toString().length() > 0) {
    element.setSelfLoop(true);
  }
 else {
    element.setSelfLoop(false);
  }
  editorView.redraw();
}
Program: 6427
Project: 6427
Buggy source:
public void onClick(View v){
  view.getTweetFlow().deleteElement(mId);
  qa.dismiss();
}

Fixed version (ground truth):
public void onClick(View v){
  for (int i=0; i < view.getTweetFlow().getmElementsAsList().size(); i++) {
    if (view.getTweetFlow().getmElementsAsList().get(i).getmLoop() == view.getTweetFlow().getmElements().get(mId)) {
      view.getTweetFlow().getmElementsAsList().get(i).setmLoop(null);
    }
  }
  view.getTweetFlow().deleteElement(mId);
  qa.dismiss();
}
Program: 6428
Project: 6428
Buggy source:
protected final void fillCommonQuickactionItems(final QuickAction qa,final EditorView view){
  final Resources res=mContext.getResources();
  ActionItem delete=new ActionItem();
  delete.setTitle("String_Node_Str");
  delete.setIcon(res.getDrawable(R.drawable.chart));
  delete.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      view.getTweetFlow().deleteElement(mId);
      qa.dismiss();
    }
  }
);
  qa.addActionItem(delete);
}

Fixed version (ground truth):
protected final void fillCommonQuickactionItems(final QuickAction qa,final EditorView view){
  final Resources res=mContext.getResources();
  ActionItem delete=new ActionItem();
  delete.setTitle("String_Node_Str");
  delete.setIcon(res.getDrawable(R.drawable.chart));
  delete.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      for (int i=0; i < view.getTweetFlow().getmElementsAsList().size(); i++) {
        if (view.getTweetFlow().getmElementsAsList().get(i).getmLoop() == view.getTweetFlow().getmElements().get(mId)) {
          view.getTweetFlow().getmElementsAsList().get(i).setmLoop(null);
        }
      }
      view.getTweetFlow().deleteElement(mId);
      qa.dismiss();
    }
  }
);
  qa.addActionItem(delete);
}
Program: 6429
Project: 6429
Buggy source:
public void onClick(View v){
  view.setCreateLoopState(mId);
  qa.dismiss();
}

Fixed version (ground truth):
public void onClick(View v){
  mLoop=null;
  qa.dismiss();
}
Program: 6430
Project: 6430
Buggy source:
@Override void fillQuickActionMenu(final QuickAction qa,final EditorView view){
  ActionItem changeData=new ActionItem();
  changeData.setTitle("String_Node_Str");
  changeData.setIcon(mContext.getResources().getDrawable(R.drawable.production));
  changeData.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      ChangeDataDialogServiceRequest changeDataDialog=new ChangeDataDialogServiceRequest(mContext,view,ServiceRequest.this);
      changeDataDialog.show();
      qa.dismiss();
    }
  }
);
  qa.addActionItem(changeData);
  ActionItem bigLoop=new ActionItem();
  bigLoop.setTitle("String_Node_Str");
  bigLoop.setIcon(mContext.getResources().getDrawable(R.drawable.production));
  bigLoop.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      view.setCreateLoopState(mId);
      qa.dismiss();
    }
  }
);
  qa.addActionItem(bigLoop);
  fillCommonQuickactionItems(qa,view);
}

Fixed version (ground truth):
@Override void fillQuickActionMenu(final QuickAction qa,final EditorView view){
  ActionItem changeData=new ActionItem();
  changeData.setTitle("String_Node_Str");
  changeData.setIcon(mContext.getResources().getDrawable(R.drawable.production));
  changeData.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      ChangeDataDialogServiceRequest changeDataDialog=new ChangeDataDialogServiceRequest(mContext,view,ServiceRequest.this);
      changeDataDialog.show();
      qa.dismiss();
    }
  }
);
  qa.addActionItem(changeData);
  if (mLoop == null) {
    ActionItem bigLoop=new ActionItem();
    bigLoop.setTitle("String_Node_Str");
    bigLoop.setIcon(mContext.getResources().getDrawable(R.drawable.production));
    bigLoop.setOnClickListener(new OnClickListener(){
      public void onClick(      View v){
        view.setCreateLoopState(mId);
        qa.dismiss();
      }
    }
);
    qa.addActionItem(bigLoop);
  }
 else {
    ActionItem bigLoop=new ActionItem();
    bigLoop.setTitle("String_Node_Str");
    bigLoop.setIcon(mContext.getResources().getDrawable(R.drawable.production));
    bigLoop.setOnClickListener(new OnClickListener(){
      public void onClick(      View v){
        mLoop=null;
        qa.dismiss();
      }
    }
);
  }
  fillCommonQuickactionItems(qa,view);
}
Program: 6431
Project: 6431
Buggy source:
protected void onActionDown(MotionEvent event){
}

Fixed version (ground truth):
protected void onActionDown(MotionEvent event){
  mEditorView.setActivePointerId(event.getPointerId(0));
}
Program: 6432
Project: 6432
Buggy source:
public void onActionDown(MotionEvent event){
  final int x=(int)event.getX();
  final int y=(int)event.getY();
  if (mTweetFlow.elementAt(mEditorView.scaledX(x),mEditorView.scaledY(y))) {
    mTweetFlow.setTouchElementModeMarked();
    mEditorView.setState(EDITOR_STATE.TOUCH_ELEMENT);
    mEditorView.redraw();
  }
 else {
    mEditorView.setState(EDITOR_STATE.TOUCH_VOID);
  }
  mEditorView.setLastTouch(x,y);
  mEditorView.setActivePointerId(event.getPointerId(0));
}

Fixed version (ground truth):
public void onActionDown(MotionEvent event){
  super.onActionDown(event);
  final int x=(int)event.getX();
  final int y=(int)event.getY();
  if (mTweetFlow.elementAt(mEditorView.scaledX(x),mEditorView.scaledY(y))) {
    mTweetFlow.setTouchElementModeMarked();
    mEditorView.setState(EDITOR_STATE.TOUCH_ELEMENT);
    mEditorView.redraw();
  }
 else {
    mEditorView.setState(EDITOR_STATE.TOUCH_VOID);
  }
  mEditorView.setLastTouch(x,y);
}
Program: 6433
Project: 6433
Buggy source:
public void onActionDown(MotionEvent event){
  final int xGrid;
  final int x=(int)event.getX();
  final int y=(int)event.getY();
  if (mTweetFlow.elementAt(mEditorView.scaledX(x),mEditorView.scaledY(y))) {
    mTweetFlow.setTouchElementModeMarked();
    mEditorView.setState(EDITOR_STATE.TOUCH_ELEMENT);
    mEditorView.redraw();
  }
 else {
    mEditorView.setState(EDITOR_STATE.TOUCH_VOID);
  }
  mEditorView.setLastTouch(x,y);
}

Fixed version (ground truth):
public void onActionDown(MotionEvent event){
  super.onActionDown(event);
  final int xGrid;
  final int x=(int)event.getX();
  final int y=(int)event.getY();
  if (mTweetFlow.elementAt(mEditorView.scaledX(x),mEditorView.scaledY(y))) {
    mTweetFlow.setTouchElementModeMarked();
    mEditorView.setState(EDITOR_STATE.TOUCH_ELEMENT);
    mEditorView.redraw();
  }
 else {
    mEditorView.setState(EDITOR_STATE.TOUCH_VOID);
  }
  mEditorView.setLastTouch(x,y);
}
Program: 6434
Project: 6434
Buggy source:
@Override public boolean handleLongClick(){
  if (!mEditorView.scaleDetectorActive()) {
    mTweetFlow.addRectangle(mEditorView.getLastTouchX(),mEditorView.getLastTouchY());
    mEditorView.redraw();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean handleLongClick(){
  if (!mEditorView.scaleDetectorActive()) {
    mTweetFlow.addServiceRequest(mEditorView.getLastTouchX(),mEditorView.getLastTouchY());
    mEditorView.redraw();
  }
  return true;
}
Program: 6435
Project: 6435
Buggy source:
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  canvas.drawText(mCurrState.toString(),10,10,new Paint(Color.BLACK));
  canvas.save();
  canvas.translate(mOffsetX,mOffsetY);
  canvas.scale(mScaleFactor,mScaleFactor);
  mTweetFlow.draw(canvas);
  canvas.restore();
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  canvas.drawText(mCurrState.toString(),10,10,new Paint(Color.BLACK));
  canvas.save();
  canvas.translate(mOffsetX,mOffsetY);
  canvas.scale(mScaleFactor,mScaleFactor);
  rasterGridHelper.draw(canvas);
  mTweetFlow.draw(canvas);
  canvas.restore();
}
Program: 6436
Project: 6436
Buggy source:
public EditorView(Context context,AttributeSet attrs){
  super(context,attrs);
  mTweetFlow=new TweetFlow(getContext());
  mTweetFlow.fillElements();
  setOnLongClickListener(mOnLongClickListener);
  mScaleDetector=new ScaleGestureDetector(context,new ScaleListener());
  prepareStates();
}

Fixed version (ground truth):
public EditorView(Context context,AttributeSet attrs){
  super(context,attrs);
  mTweetFlow=new TweetFlow(getContext());
  mTweetFlow.fillElements();
  setOnLongClickListener(mOnLongClickListener);
  mScaleDetector=new ScaleGestureDetector(context,new ScaleListener());
  prepareStates();
  rasterGridHelper=new RasterGridHelper(mTweetFlow.getmElements(),mTweetFlow.getTouchElement(),mOffsetX,mOffsetY);
}
Program: 6437
Project: 6437
Buggy source:
public boolean onOptionsItemSelected(MenuItem menuItem){
  super.onOptionsItemSelected(menuItem);
switch (menuItem.getItemId()) {
case R.id.deselect:
    editorView.delesectAll();
  editorView.redraw();
break;
case R.id.raster_add:
editorView.setRasterOn(true);
editorView.redraw();
break;
case R.id.raster_remove:
editorView.setRasterOn(false);
editorView.redraw();
break;
case R.id.snapping:
break;
case R.id.snapping_nothing:
menuItem.setChecked(true);
editorView.setSnapMode(SnapMode.NOTHING);
editorView.redraw();
break;
case R.id.snapping_raster:
menuItem.setChecked(true);
editorView.setSnapMode(SnapMode.RASTER);
editorView.redraw();
break;
case R.id.snapping_grid:
menuItem.setChecked(true);
editorView.setSnapMode(SnapMode.GRID);
editorView.redraw();
break;
default :
Toast.makeText(this,menuItem.getTitle(),Toast.LENGTH_SHORT).show();
}
return true;
}

Fixed version (ground truth):
public boolean onOptionsItemSelected(MenuItem menuItem){
  super.onOptionsItemSelected(menuItem);
switch (menuItem.getItemId()) {
case R.id.deselect:
    editorView.delesectAll();
  editorView.redraw();
break;
case R.id.raster_add:
editorView.setRasterOn(true);
editorView.redraw();
break;
case R.id.raster_remove:
editorView.setRasterOn(false);
editorView.redraw();
break;
case R.id.snapping:
break;
case R.id.snapping_nothing:
menuItem.setChecked(true);
editorView.setSnapMode(SnapMode.NOTHING);
editorView.redraw();
break;
case R.id.snapping_raster:
menuItem.setChecked(true);
editorView.setSnapMode(SnapMode.RASTER);
editorView.redraw();
break;
case R.id.snapping_grid:
menuItem.setChecked(true);
editorView.setSnapMode(SnapMode.GRID);
editorView.redraw();
break;
case R.id.undo:
editorView.undo();
break;
case R.id.redo:
editorView.redo();
break;
default :
Toast.makeText(this,menuItem.getTitle(),Toast.LENGTH_SHORT).show();
}
return true;
}
Program: 6438
Project: 6438
Buggy source:
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  canvas.drawColor(Color.WHITE);
  if (rasterOn) {
    if (!setRaster) {
      setRaster=true;
      horizontalRasterCT=(canvas.getWidth() / RASTER_HORIZONTAL_WIDTH) + 3;
    }
    Paint paint=new Paint();
    paint.setPathEffect(new DashPathEffect(new float[]{10,3,6,3},1));
    if ((snapMode == SnapMode.NOTHING) || (snapMode == SnapMode.RASTER)) {
      paint.setColor(Color.BLUE);
      for (int i=0; i < horizontalRasterCT; i++) {
        int x=(i * RASTER_HORIZONTAL_WIDTH) + (RASTER_HORIZONTAL_WIDTH / 2) - RASTER_HORIZONTAL_WIDTH + (xGlobalOffset % RASTER_HORIZONTAL_WIDTH);
        canvas.drawLine(x,0,x,canvas.getHeight(),paint);
      }
    }
    if (snapMode == SnapMode.GRID) {
      paint.setColor(Color.RED);
      for (      AbstractElement e : mElements.values()) {
        if (e instanceof Rectangle) {
          canvas.drawLine(e.getMiddleX(),0,e.getMiddleX(),canvas.getHeight(),paint);
        }
      }
    }
  }
  for (  AbstractElement elem : mElements.values()) {
    elem.draw(canvas);
  }
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  canvas.drawColor(Color.WHITE);
  if (rasterOn) {
    if (!setRaster) {
      setRaster=true;
      horizontalRasterCT=(canvas.getWidth() / RASTER_HORIZONTAL_WIDTH) + 3;
    }
    Paint paint=new Paint();
    paint.setPathEffect(new DashPathEffect(new float[]{10,3,6,3},1));
    if ((snapMode == SnapMode.NOTHING) || (snapMode == SnapMode.RASTER)) {
      paint.setColor(Color.BLUE);
      ArrayList<Integer> gridLines=createRasterLines();
      for (int i=0; i < gridLines.size(); i++) {
        canvas.drawLine(gridLines.get(i),0,gridLines.get(i),canvas.getHeight(),paint);
      }
    }
    if (snapMode == SnapMode.GRID) {
      paint.setColor(Color.RED);
      for (      AbstractElement e : mElements.values()) {
        if (e instanceof Rectangle) {
          canvas.drawLine(e.getMiddleX(),0,e.getMiddleX(),canvas.getHeight(),paint);
        }
      }
    }
  }
  for (  AbstractElement elem : mElements.values()) {
    elem.draw(canvas);
  }
}