nus-yam/ex-repair huggingface dataset:
Program: 95314
Project: 95314
Buggy source:
@Override public void onResume(){
  Log.d("String_Node_Str","String_Node_Str");
  if (this.drone == null) {
    this.drone=((SuperActivity)this.context).drone;
    if (this.drone == null)     Log.d("String_Node_Str","String_Node_Str");
 else     Log.d("String_Node_Str","String_Node_Str");
  }
  super.onResume();
}

Fixed version (ground truth):
@Override public void onResume(){
  Log.d("String_Node_Str","String_Node_Str");
  this.drone=((SuperActivity)this.context).drone;
  sysLink=new CheckListSysLink(this.drone);
  if (this.drone == null) {
    this.drone=((SuperActivity)this.context).drone;
    if (this.drone == null)     Log.d("String_Node_Str","String_Node_Str");
 else     Log.d("String_Node_Str","String_Node_Str");
  }
  super.onResume();
}
Program: 95315
Project: 95315
Buggy source:
@Override public void onAttach(Activity activity){
  Log.d("String_Node_Str","String_Node_Str");
  this.context=activity;
  this.drone=((SuperActivity)activity).drone;
  sysLink=new CheckListSysLink(this.drone);
  if (this.context == null)   Log.d("String_Node_Str","String_Node_Str");
  if (this.drone == null)   Log.d("String_Node_Str","String_Node_Str");
  loadXMLChecklist();
  prepareListData();
  super.onAttach(activity);
}

Fixed version (ground truth):
@Override public void onAttach(Activity activity){
  Log.d("String_Node_Str","String_Node_Str");
  this.context=activity;
  if (this.context == null)   Log.d("String_Node_Str","String_Node_Str");
  if (this.drone == null)   Log.d("String_Node_Str","String_Node_Str");
  loadXMLChecklist();
  prepareListData();
  super.onAttach(activity);
}
Program: 95316
Project: 95316
Buggy source:
public ChecklistFragment(){
  Log.d("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public ChecklistFragment(){
}
Program: 95317
Project: 95317
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_flight);
  fragmentManager=getFragmentManager();
  modeInfoPanel=fragmentManager.findFragmentById(R.id.modeInfoPanel);
  failsafeTextView=findViewById(R.id.failsafeTextView);
  drone.state.addFlightStateListner(this);
  drone.state.addModeChangedListener(this);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_flight);
  fragmentManager=getFragmentManager();
  modeInfoPanel=fragmentManager.findFragmentById(R.id.modeInfoPanel);
  failsafeTextView=findViewById(R.id.failsafeTextView);
}
Program: 95318
Project: 95318
Buggy source:
@Override protected void onResume(){
  super.onResume();
  onModeChanged();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  drone.state.addFlightStateListner(this);
  drone.state.addModeChangedListener(this);
  onModeChanged();
}
Program: 95319
Project: 95319
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_flight);
  fragmentManager=getFragmentManager();
  modeInfoPanel=fragmentManager.findFragmentById(R.id.modeInfoPanel);
  failsafeTextView=findViewById(R.id.failsafeTextView);
  drone.state.addFlightStateListner(this);
  drone.state.addModeChangedListener(this);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_flight);
  fragmentManager=getFragmentManager();
  modeInfoPanel=fragmentManager.findFragmentById(R.id.modeInfoPanel);
  failsafeTextView=findViewById(R.id.failsafeTextView);
}
Program: 95320
Project: 95320
Buggy source:
@Override protected void onResume(){
  super.onResume();
  onModeChanged();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  drone.state.addFlightStateListner(this);
  drone.state.addModeChangedListener(this);
  onModeChanged();
}
Program: 95321
Project: 95321
Buggy source:
public msg_mission_item packMavlink(){
  msg_mission_item mavMsg=new msg_mission_item();
  mavMsg.autocontinue=1;
  mavMsg.current=1;
  mavMsg.target_component=1;
  mavMsg.target_system=1;
  if (isValid()) {
    mavMsg.x=(float)getCoord().longitude;
    mavMsg.y=(float)getCoord().latitude;
    mavMsg.z=(float)getAltitude().valueInMeters();
  }
  return mavMsg;
}

Fixed version (ground truth):
public msg_mission_item packMavlink(){
  msg_mission_item mavMsg=new msg_mission_item();
  mavMsg.autocontinue=1;
  mavMsg.current=1;
  mavMsg.target_component=1;
  mavMsg.target_system=1;
  if (isValid()) {
    mavMsg.x=(float)getCoord().latitude;
    mavMsg.y=(float)getCoord().longitude;
    mavMsg.z=(float)getAltitude().valueInMeters();
  }
  return mavMsg;
}
Program: 95322
Project: 95322
Buggy source:
/** 
 * Write a list of waypoints to the MAV. The callback will return the status of this operation
 * @param data waypoints to be written
 */
public void writeWaypoints(List<msg_mission_item> data){
  if ((mission != null)) {
    mission.clear();
    mission.addAll(data);
    writeIndex=0;
    state=waypointStates.WRITTING_WP;
    MavLinkWaypoint.sendWaypointCount(myDrone,mission.size());
  }
}

Fixed version (ground truth):
/** 
 * Write a list of waypoints to the MAV. The callback will return the status of this operation
 * @param data waypoints to be written
 */
public void writeWaypoints(List<msg_mission_item> data){
  if ((mission != null)) {
    updateMsgIndexes(data);
    mission.clear();
    mission.addAll(data);
    writeIndex=0;
    state=waypointStates.WRITTING_WP;
    MavLinkWaypoint.sendWaypointCount(myDrone,mission.size());
  }
}
Program: 95323
Project: 95323
Buggy source:
@Override public msg_mission_item packMissionItem(){
  msg_mission_item mavMsg=new msg_mission_item();
  mavMsg.autocontinue=1;
  mavMsg.target_component=1;
  mavMsg.target_system=1;
  mavMsg.x=(float)getCoordinate().longitude;
  mavMsg.y=(float)getCoordinate().latitude;
  mavMsg.z=(float)getAltitude().valueInMeters();
  return mavMsg;
}

Fixed version (ground truth):
@Override public msg_mission_item packMissionItem(){
  msg_mission_item mavMsg=new msg_mission_item();
  mavMsg.autocontinue=1;
  mavMsg.target_component=1;
  mavMsg.target_system=1;
  mavMsg.x=(float)getCoordinate().latitude;
  mavMsg.y=(float)getCoordinate().longitude;
  mavMsg.z=(float)getAltitude().valueInMeters();
  return mavMsg;
}
Program: 95324
Project: 95324
Buggy source:
@Override protected void openConnection() throws UnknownHostException, IOException {
  Log.d(BLUE,"String_Node_Str");
  BluetoothDevice device=findBluetoothDevice();
  bluetoothSocket=device.createInsecureRfcommSocketToServiceRecord(UUID.fromString(UUID_SPP_DEVICE));
  mBluetoothAdapter.cancelDiscovery();
  bluetoothSocket.connect();
  out=bluetoothSocket.getOutputStream();
  in=bluetoothSocket.getInputStream();
}

Fixed version (ground truth):
@Override protected void openConnection() throws UnknownHostException, IOException {
  Log.d(BLUE,"String_Node_Str");
  BluetoothDevice device=findBluetoothDevice();
  if (Build.VERSION.SDK_INT < 9) {
    try {
      bluetoothSocket=device.createRfcommSocketToServiceRecord(UUID.fromString(UUID_SPP_DEVICE));
    }
 catch (    IOException e1) {
      e1.printStackTrace();
    }
  }
 else {
    Method BTSocketMethod=null;
    try {
      BTSocketMethod=device.getClass().getMethod("String_Node_Str",new Class[]{UUID.class});
    }
 catch (    NoSuchMethodException e) {
      e.printStackTrace();
    }
    try {
      bluetoothSocket=(BluetoothSocket)BTSocketMethod.invoke(device,(UUID)UUID.fromString(UUID_SPP_DEVICE));
    }
 catch (    IllegalAccessException e) {
      e.printStackTrace();
    }
catch (    InvocationTargetException e) {
      e.printStackTrace();
    }
  }
  mBluetoothAdapter.cancelDiscovery();
  bluetoothSocket.connect();
  Log.d(BLUE,"String_Node_Str");
  out=bluetoothSocket.getOutputStream();
  in=bluetoothSocket.getInputStream();
}
Program: 95325
Project: 95325
Buggy source:
@SuppressLint("String_Node_Str") private BluetoothDevice findBluetoothDevice() throws UnknownHostException {
  Set<BluetoothDevice> pairedDevices=mBluetoothAdapter.getBondedDevices();
  if (pairedDevices.size() > 0) {
    for (    BluetoothDevice device : pairedDevices) {
      Log.d(BLUE,device.getName() + "String_Node_Str" + device.getAddress()+ "String_Node_Str");
      for (      ParcelUuid id : device.getUuids()) {
        Log.d(BLUE,"String_Node_Str" + id.toString());
        if (id.toString().equalsIgnoreCase(UUID_SPP_DEVICE)) {
          return device;
        }
      }
    }
  }
  throw new UnknownHostException("String_Node_Str");
}

Fixed version (ground truth):
@SuppressLint("String_Node_Str") private BluetoothDevice findBluetoothDevice() throws UnknownHostException {
  Set<BluetoothDevice> pairedDevices=mBluetoothAdapter.getBondedDevices();
  if (pairedDevices.size() > 0) {
    for (    BluetoothDevice device : pairedDevices) {
      Log.d(BLUE,device.getName() + "String_Node_Str" + device.getAddress()+ "String_Node_Str");
      for (      ParcelUuid id : device.getUuids()) {
        Log.d(BLUE,"String_Node_Str" + id.toString());
        if (id.toString().equalsIgnoreCase(UUID_SPP_DEVICE)) {
          Log.d(BLUE,"String_Node_Str" + device.getName() + "String_Node_Str"+ id.toString());
          return device;
        }
      }
    }
  }
  throw new UnknownHostException("String_Node_Str");
}
Program: 95326
Project: 95326
Buggy source:
@Override protected void closeConnection() throws IOException {
  bluetoothSocket.close();
}

Fixed version (ground truth):
@Override protected void closeConnection() throws IOException {
  bluetoothSocket.close();
  Log.d(BLUE,"String_Node_Str");
}
Program: 95327
Project: 95327
Buggy source:
public void addWaypoint(LatLng point,Double alt){
  waypoints.add(new Waypoint(point,alt));
}

Fixed version (ground truth):
public void addWaypoint(LatLng point,Double alt){
  waypoints.add(new Waypoint(point,alt));
  onMissionUpdate();
}
Program: 95328
Project: 95328
Buggy source:
public void addWaypointsWithDefaultAltitude(List<LatLng> points){
  for (  LatLng point : points) {
    addWaypoint(point,defaultAlt);
  }
}

Fixed version (ground truth):
public void addWaypointsWithDefaultAltitude(List<LatLng> points){
  for (  LatLng point : points) {
    waypoints.add(new Waypoint(point,defaultAlt));
  }
  onMissionUpdate();
}
Program: 95329
Project: 95329
Buggy source:
@Override public boolean onMarkerClick(GenericWaypoint wp){
  DialogMissionFactory.getDialog(wp,this,mission);
  return true;
}

Fixed version (ground truth):
@Override public boolean onMarkerClick(GenericWaypoint wp){
  return true;
}
Program: 95330
Project: 95330
Buggy source:
public void onModeChanged(){
  if (drone.state.getMode() != ApmModes.ROTOR_GUIDED) {
    if (drone.guidedPoint.isCoordValid()) {
      markers.clear();
      drone.guidedPoint.invalidateCoord();
    }
  }
}

Fixed version (ground truth):
public void onModeChanged(){
  if (drone.state.getMode() != ApmModes.ROTOR_GUIDED) {
    if (drone.guidedPoint.isCoordValid()) {
      markers.clean();
      drone.guidedPoint.invalidateCoord();
    }
  }
}
Program: 95331
Project: 95331
Buggy source:
private void checkForWaypointMarkerMoving(MarkerSource source,Marker marker,boolean dragging){
  if (GenericWaypoint.class.isInstance(source)) {
    LatLng position=marker.getPosition();
    GenericWaypoint waypoint=(GenericWaypoint)source;
    waypoint.setCoord(position);
    if (dragging)     waypoint.updateDistanceFromPrevPoint();
 else     waypoint.setPrevPoint(mission.getWaypoints());
    updateInfoWindow(waypoint,marker);
    missionPath.update(mission);
    mListener.onMovingWaypoint(waypoint,position);
  }
}

Fixed version (ground truth):
private void checkForWaypointMarkerMoving(MarkerSource source,Marker marker,boolean dragging){
  if (GenericWaypoint.class.isInstance(source)) {
    LatLng position=marker.getPosition();
    GenericWaypoint waypoint=(GenericWaypoint)source;
    waypoint.setCoordinate(position);
    missionPath.update(mission);
    mListener.onMovingWaypoint(waypoint,position);
  }
}
Program: 95332
Project: 95332
Buggy source:
public void update(){
  markers.clear();
  markers.updateMarker(drone.home.getHome(),false,context);
  markers.updateMarkers(mission.getMarkers(),true,context);
  missionPath.update(mission);
}

Fixed version (ground truth):
public void update(){
  markers.clean();
  Home home=drone.home.getHome();
  if (home.isValid()) {
    markers.updateMarker(home,false,context);
  }
  markers.updateMarkers(mission.getMarkers(),true,context);
  missionPath.update(mission);
}
Program: 95333
Project: 95333
Buggy source:
public static MarkerOptions build(Home home){
  return new MarkerOptions().position(home.getCoord()).visible(home.isValid()).title("String_Node_Str").snippet(String.format(Locale.ENGLISH,"String_Node_Str",home.getHeight())).anchor((float)0.5,(float)0.5).icon(BitmapDescriptorFactory.fromResource(drawable.ic_menu_home)).title("String_Node_Str");
}

Fixed version (ground truth):
public static MarkerOptions build(Home home){
  return new MarkerOptions().position(home.getCoord()).visible(home.isValid()).title("String_Node_Str").snippet(home.getAltitude().toString()).anchor((float)0.5,(float)0.5).icon(BitmapDescriptorFactory.fromResource(drawable.ic_menu_home)).title("String_Node_Str");
}
Program: 95334
Project: 95334
Buggy source:
public static void update(Marker marker,Home home){
  marker.setVisible(home.isValid());
  marker.setPosition(home.getCoord());
  marker.setSnippet("String_Node_Str" + home.getHeight());
}

Fixed version (ground truth):
public static void update(Marker marker,Home home){
  marker.setVisible(home.isValid());
  marker.setPosition(home.getCoord());
  marker.setSnippet("String_Node_Str" + home.getAltitude());
}
Program: 95335
Project: 95335
Buggy source:
protected View buildView(){
  super.buildView();
  loiterCCW=(CheckBox)view.findViewById(R.string.loiter_ccw);
  if (wp.getRadius() < 0) {
    loiterCCW.setChecked(true);
  }
 else {
    loiterCCW.setChecked(false);
  }
  loiterCCW.setOnCheckedChangeListener(this);
  loiterRadiusSeekBar=(SeekBarWithText)view.findViewById(R.id.loiterRadius);
  loiterRadiusSeekBar.setOnChangedListner(this);
  loiterRadiusSeekBar.setAbsValue(wp.getRadius());
  yawSeekBar=(SeekBarWithText)view.findViewById(R.id.waypointAngle);
  yawSeekBar.setValue(wp.getAngle());
  yawSeekBar.setOnChangedListner(this);
  return view;
}

Fixed version (ground truth):
protected View buildView(){
  super.buildView();
  item=(LoiterInfinite)wp;
  loiterCCW=(CheckBox)view.findViewById(R.string.loiter_ccw);
  if (item.getRadius() < 0) {
    loiterCCW.setChecked(true);
  }
 else {
    loiterCCW.setChecked(false);
  }
  loiterCCW.setOnCheckedChangeListener(this);
  loiterRadiusSeekBar=(SeekBarWithText)view.findViewById(R.id.loiterRadius);
  loiterRadiusSeekBar.setOnChangedListner(this);
  loiterRadiusSeekBar.setAbsValue(item.getRadius());
  yawSeekBar=(SeekBarWithText)view.findViewById(R.id.waypointAngle);
  yawSeekBar.setValue(item.getAngle());
  yawSeekBar.setOnChangedListner(this);
  return view;
}
Program: 95336
Project: 95336
Buggy source:
@Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
  wp.setRadius(loiterRadiusSeekBar.getValue());
  if (loiterCCW.isChecked()) {
    wp.setRadius(wp.getRadius() * -1.0);
  }
}

Fixed version (ground truth):
@Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
  item.setRadius(loiterRadiusSeekBar.getValue());
  if (loiterCCW.isChecked()) {
    item.setRadius(item.getRadius() * -1.0);
  }
}
Program: 95337
Project: 95337
Buggy source:
@Override public void onSeekBarChanged(){
  wp.setRadius(loiterRadiusSeekBar.getValue());
  if (loiterCCW.isChecked()) {
    wp.setRadius(wp.getRadius() * -1.0);
  }
  wp.setAngle(yawSeekBar.getValue());
}

Fixed version (ground truth):
@Override public void onSeekBarChanged(){
  item.setRadius(loiterRadiusSeekBar.getValue());
  if (loiterCCW.isChecked()) {
    item.setRadius(item.getRadius() * -1.0);
  }
  item.setAngle(yawSeekBar.getValue());
}
Program: 95338
Project: 95338
Buggy source:
protected View buildView(){
  super.buildView();
  loiterCCW=(CheckBox)view.findViewById(R.string.loiter_ccw);
  if (wp.getRadius() < 0) {
    loiterCCW.setChecked(true);
  }
 else {
    loiterCCW.setChecked(false);
  }
  loiterCCW.setOnCheckedChangeListener(this);
  altitudeSeekBar=(SeekBarWithText)view.findViewById(R.id.altitudeView);
  altitudeSeekBar.setValue(wp.getAltitude().valueInMeters());
  altitudeSeekBar.setOnChangedListner(this);
  loiterTurnSeekBar=(SeekBarWithText)view.findViewById(R.id.loiterTurn);
  loiterTurnSeekBar.setOnChangedListner(this);
  loiterTurnSeekBar.setValue(wp.getTurns());
  loiterRadiusSeekBar=(SeekBarWithText)view.findViewById(R.id.loiterRadius);
  loiterRadiusSeekBar.setAbsValue(wp.getRadius());
  loiterRadiusSeekBar.setOnChangedListner(this);
  yawSeekBar=(SeekBarWithText)view.findViewById(R.id.waypointAngle);
  yawSeekBar.setValue(wp.getAngle());
  yawSeekBar.setOnChangedListner(this);
  return view;
}

Fixed version (ground truth):
protected View buildView(){
  super.buildView();
  item=(LoiterTurns)wp;
  loiterCCW=(CheckBox)view.findViewById(R.string.loiter_ccw);
  if (item.getRadius() < 0) {
    loiterCCW.setChecked(true);
  }
 else {
    loiterCCW.setChecked(false);
  }
  loiterCCW.setOnCheckedChangeListener(this);
  altitudeSeekBar=(SeekBarWithText)view.findViewById(R.id.altitudeView);
  altitudeSeekBar.setValue(item.getAltitude().valueInMeters());
  altitudeSeekBar.setOnChangedListner(this);
  loiterTurnSeekBar=(SeekBarWithText)view.findViewById(R.id.loiterTurn);
  loiterTurnSeekBar.setOnChangedListner(this);
  loiterTurnSeekBar.setValue(item.getTurns());
  loiterRadiusSeekBar=(SeekBarWithText)view.findViewById(R.id.loiterRadius);
  loiterRadiusSeekBar.setAbsValue(item.getRadius());
  loiterRadiusSeekBar.setOnChangedListner(this);
  yawSeekBar=(SeekBarWithText)view.findViewById(R.id.waypointAngle);
  yawSeekBar.setValue(item.getAngle());
  yawSeekBar.setOnChangedListner(this);
  return view;
}
Program: 95339
Project: 95339
Buggy source:
@Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
  wp.setRadius(loiterRadiusSeekBar.getValue());
  if (loiterCCW.isChecked()) {
    wp.setRadius(wp.getRadius() * -1.0);
  }
}

Fixed version (ground truth):
@Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
  item.setRadius(loiterRadiusSeekBar.getValue());
  if (loiterCCW.isChecked()) {
    item.setRadius(item.getRadius() * -1.0);
  }
}
Program: 95340
Project: 95340
Buggy source:
@Override public void onSeekBarChanged(){
  wp.getAltitude().set(altitudeSeekBar.getValue());
  wp.setTurns((int)loiterTurnSeekBar.getValue());
  wp.setRadius(loiterRadiusSeekBar.getValue());
  if (loiterCCW.isChecked()) {
    wp.setRadius(wp.getRadius() * -1.0);
  }
  wp.setAngle(yawSeekBar.getValue());
}

Fixed version (ground truth):
@Override public void onSeekBarChanged(){
  item.getAltitude().set(altitudeSeekBar.getValue());
  item.setTurns((int)loiterTurnSeekBar.getValue());
  item.setRadius(loiterRadiusSeekBar.getValue());
  if (loiterCCW.isChecked()) {
    item.setRadius(item.getRadius() * -1.0);
  }
  item.setAngle(yawSeekBar.getValue());
}
Program: 95341
Project: 95341
Buggy source:
protected View buildView(){
  super.buildView();
  loiterCCW=(CheckBox)view.findViewById(R.string.loiter_ccw);
  if (wp.getRadius() < 0) {
    loiterCCW.setChecked(true);
  }
 else {
    loiterCCW.setChecked(false);
  }
  loiterCCW.setOnCheckedChangeListener(this);
  altitudeSeekBar=(SeekBarWithText)view.findViewById(R.id.altitudeView);
  altitudeSeekBar.setValue(wp.getAltitude().valueInMeters());
  altitudeSeekBar.setOnChangedListner(this);
  loiterTimeSeekBar=(SeekBarWithText)view.findViewById(R.id.loiterTime);
  loiterTimeSeekBar.setOnChangedListner(this);
  loiterTimeSeekBar.setValue(wp.getTime());
  loiterRadiusSeekBar=(SeekBarWithText)view.findViewById(R.id.loiterRadius);
  loiterRadiusSeekBar.setAbsValue(wp.getRadius());
  loiterRadiusSeekBar.setOnChangedListner(this);
  yawSeekBar=(SeekBarWithText)view.findViewById(R.id.waypointAngle);
  yawSeekBar.setValue(wp.getAngle());
  yawSeekBar.setOnChangedListner(this);
  return view;
}

Fixed version (ground truth):
protected View buildView(){
  super.buildView();
  item=(LoiterTime)wp;
  loiterCCW=(CheckBox)view.findViewById(R.string.loiter_ccw);
  if (item.getRadius() < 0) {
    loiterCCW.setChecked(true);
  }
 else {
    loiterCCW.setChecked(false);
  }
  loiterCCW.setOnCheckedChangeListener(this);
  altitudeSeekBar=(SeekBarWithText)view.findViewById(R.id.altitudeView);
  altitudeSeekBar.setValue(item.getAltitude().valueInMeters());
  altitudeSeekBar.setOnChangedListner(this);
  loiterTimeSeekBar=(SeekBarWithText)view.findViewById(R.id.loiterTime);
  loiterTimeSeekBar.setOnChangedListner(this);
  loiterTimeSeekBar.setValue(item.getTime());
  loiterRadiusSeekBar=(SeekBarWithText)view.findViewById(R.id.loiterRadius);
  loiterRadiusSeekBar.setAbsValue(item.getRadius());
  loiterRadiusSeekBar.setOnChangedListner(this);
  yawSeekBar=(SeekBarWithText)view.findViewById(R.id.waypointAngle);
  yawSeekBar.setValue(item.getAngle());
  yawSeekBar.setOnChangedListner(this);
  return view;
}
Program: 95342
Project: 95342
Buggy source:
@Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
  wp.setRadius(loiterRadiusSeekBar.getValue());
  if (loiterCCW.isChecked()) {
    wp.setRadius(wp.getRadius() * -1.0);
  }
}

Fixed version (ground truth):
@Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
  item.setRadius(loiterRadiusSeekBar.getValue());
  if (loiterCCW.isChecked()) {
    item.setRadius(item.getRadius() * -1.0);
  }
}
Program: 95343
Project: 95343
Buggy source:
@Override public void onSeekBarChanged(){
  wp.getAltitude().set(altitudeSeekBar.getValue());
  wp.setTime(loiterTimeSeekBar.getValue());
  wp.setRadius(loiterRadiusSeekBar.getValue());
  if (loiterCCW.isChecked()) {
    wp.setRadius(wp.getRadius() * -1.0);
  }
  wp.setAngle(yawSeekBar.getValue());
}

Fixed version (ground truth):
@Override public void onSeekBarChanged(){
  item.getAltitude().set(altitudeSeekBar.getValue());
  item.setTime(loiterTimeSeekBar.getValue());
  item.setRadius(loiterRadiusSeekBar.getValue());
  if (loiterCCW.isChecked()) {
    item.setRadius(item.getRadius() * -1.0);
  }
  item.setAngle(yawSeekBar.getValue());
}
Program: 95344
Project: 95344
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  screenOrientation.unlock();
  app.conectionListner=this;
  drone.MavClient.queryConnectionState();
  infoMenu=new InfoMenu(drone);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  screenOrientation.unlock();
  infoMenu=new InfoMenu(drone);
}
Program: 95345
Project: 95345
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_new_editor);
  ActionBar actionBar=getActionBar();
  actionBar.setDisplayHomeAsUpEnabled(true);
  planningMapFragment=((PlanningMapFragment)getFragmentManager().findFragmentById(R.id.mapFragment));
  gestureMapFragment=((GestureMapFragment)getFragmentManager().findFragmentById(R.id.gestureMapFragment));
  missionFragment=(MissionFragment)getFragmentManager().findFragmentById(R.id.missionFragment1);
  editorToolsFragment=(EditorToolsFragment)getFragmentManager().findFragmentById(R.id.editorToolsFragment);
  mission=drone.mission;
  gestureMapFragment.setOnPathFinishedListner(this);
  missionFragment.setMission(mission);
  planningMapFragment.setMission(mission);
  mission.addOnWaypointsChangedListner(missionFragment);
  mission.addOnWaypointsChangedListner(planningMapFragment);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_new_editor);
  ActionBar actionBar=getActionBar();
  actionBar.setDisplayHomeAsUpEnabled(true);
  planningMapFragment=((PlanningMapFragment)getFragmentManager().findFragmentById(R.id.mapFragment));
  gestureMapFragment=((GestureMapFragment)getFragmentManager().findFragmentById(R.id.gestureMapFragment));
  missionFragment=(MissionFragment)getFragmentManager().findFragmentById(R.id.missionFragment1);
  editorToolsFragment=(EditorToolsFragment)getFragmentManager().findFragmentById(R.id.editorToolsFragment);
  mission=drone.mission;
  gestureMapFragment.setOnPathFinishedListner(this);
  missionFragment.setMission(mission);
  planningMapFragment.setMission(mission);
  mission.addOnWaypointsChangedListner(missionFragment);
  mission.addOnWaypointsChangedListner(planningMapFragment);
  mission.onWaypointsUpdate();
}
Program: 95346
Project: 95346
Buggy source:
@Override public void onWaypointsUpdate(){
  for (  OnWaypointChangedListner listner : missionListner) {
    listner.onWaypointsUpdate();
  }
}

Fixed version (ground truth):
@Override public void onWaypointsUpdate(){
  for (  OnWaypointChangedListner listner : missionListner) {
    if (listner != null) {
      listner.onWaypointsUpdate();
    }
  }
}
Program: 95347
Project: 95347
Buggy source:
private void addOneFootprint(LatLng latLng,SurveyData surveyData){
  double diag=Math.hypot(surveyData.getLateralFootPrint().valueInMeters(),surveyData.getLongitudinalFootPrint().valueInMeters());
  cameraOverlays.add(mMap.addPolygon(new PolygonOptions().add(GeoTools.newCoordFromBearingAndDistance(latLng,surveyData.getAngle() + 45,diag),GeoTools.newCoordFromBearingAndDistance(latLng,surveyData.getAngle() + 90 + 45,diag),GeoTools.newCoordFromBearingAndDistance(latLng,surveyData.getAngle() + 180 + 45,diag),GeoTools.newCoordFromBearingAndDistance(latLng,surveyData.getAngle() + 270 + 45,diag)).fillColor(Color.argb(40,0,0,127)).strokeWidth(0)));
}

Fixed version (ground truth):
private void addOneFootprint(LatLng latLng,SurveyData surveyData){
  double lng=surveyData.getLateralFootPrint().valueInMeters();
  double lateral=surveyData.getLongitudinalFootPrint().valueInMeters();
  double halfDiag=Math.hypot(lng,lateral) / 2;
  double angle=Math.toDegrees(Math.tan(lng / lateral));
  cameraOverlays.add(mMap.addPolygon(new PolygonOptions().add(GeoTools.newCoordFromBearingAndDistance(latLng,surveyData.getAngle() - angle,halfDiag),GeoTools.newCoordFromBearingAndDistance(latLng,surveyData.getAngle() + angle,halfDiag),GeoTools.newCoordFromBearingAndDistance(latLng,surveyData.getAngle() + 180 - angle,halfDiag),GeoTools.newCoordFromBearingAndDistance(latLng,surveyData.getAngle() + 180 + angle,halfDiag)).fillColor(Color.argb(40,0,0,127)).strokeWidth(1).strokeColor(Color.argb(127,0,0,255))));
}
Program: 95348
Project: 95348
Buggy source:
/** 
 * Copied from: http://stackoverflow.com/questions/18335642/how-to-draw-text-in-default-marker-of-google-map-v2?lq=1
 */
private static Bitmap drawTextToBitmap(Context gContext,int gResId,String gText){
  Resources resources=gContext.getResources();
  float scale=resources.getDisplayMetrics().density;
  Bitmap bitmap=BitmapFactory.decodeResource(resources,gResId);
  android.graphics.Bitmap.Config bitmapConfig=bitmap.getConfig();
  if (bitmapConfig == null) {
    bitmapConfig=android.graphics.Bitmap.Config.ARGB_8888;
  }
  bitmap=bitmap.copy(bitmapConfig,true);
  Canvas canvas=new Canvas(bitmap);
  Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG);
  paint.setColor(Color.BLACK);
  paint.setTextSize((int)(15 * scale));
  paint.setShadowLayer(1f,0f,1f,Color.WHITE);
  Rect bounds=new Rect();
  paint.getTextBounds(gText,0,gText.length(),bounds);
  int x=(bitmap.getWidth() - bounds.width()) / 2;
  int y=(bitmap.getHeight() + bounds.height()) / 2;
  canvas.drawText(gText,x * scale,y * scale,paint);
  return bitmap;
}

Fixed version (ground truth):
/** 
 * Copied from: http://stackoverflow.com/questions/18335642/how-to-draw-text-in-default-marker-of-google-map-v2?lq=1
 */
private static Bitmap drawTextToBitmap(Context gContext,int gResId,String gText){
  Resources resources=gContext.getResources();
  float scale=resources.getDisplayMetrics().density;
  Bitmap bitmap=BitmapFactory.decodeResource(resources,gResId);
  android.graphics.Bitmap.Config bitmapConfig=bitmap.getConfig();
  if (bitmapConfig == null) {
    bitmapConfig=android.graphics.Bitmap.Config.ARGB_8888;
  }
  bitmap=bitmap.copy(bitmapConfig,true);
  Canvas canvas=new Canvas(bitmap);
  Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG);
  paint.setColor(Color.BLACK);
  paint.setTextSize((int)(15 * scale));
  paint.setShadowLayer(1f,0f,1f,Color.WHITE);
  Rect bounds=new Rect();
  paint.getTextBounds(gText,0,gText.length(),bounds);
  int x=(bitmap.getWidth() - bounds.width()) / 2;
  int y=(bitmap.getHeight() + bounds.height()) * 5 / 12;
  canvas.drawText(gText,x,y,paint);
  return bitmap;
}
Program: 95349
Project: 95349
Buggy source:
private void checkIfPolygonIsValid(Polygon polygon) throws Exception {
  throw new Exception("String_Node_Str");
}

Fixed version (ground truth):
private void checkIfPolygonIsValid(Polygon polygon) throws Exception {
  if (!polygon.isValid()) {
    throw new Exception("String_Node_Str");
  }
}
Program: 95350
Project: 95350
Buggy source:
@Override public void onSpinnerItemSelected(Spinner spinner,int position,String text){
  CameraInfo cameraInfo;
  try {
    cameraInfo=avaliableCameras.openFile(text);
  }
 catch (  Exception e) {
    Toast.makeText(context,context.getString(R.string.error_when_opening_file),Toast.LENGTH_SHORT).show();
    cameraInfo=CameraInfoReader.getNewMockCameraInfo();
  }
  surveyData.setCameraInfo(cameraInfo);
  updateSeekBarsValues();
  updateViews();
}

Fixed version (ground truth):
@Override public void onSpinnerItemSelected(Spinner spinner,int position,String text){
  CameraInfo cameraInfo;
  try {
    cameraInfo=avaliableCameras.openFile(text);
  }
 catch (  Exception e) {
    Toast.makeText(context,context.getString(R.string.error_when_opening_file),Toast.LENGTH_SHORT).show();
    cameraInfo=CameraInfoReader.getNewMockCameraInfo();
  }
  surveyData.setCameraInfo(cameraInfo);
  updateSeekBarsValues();
  onSeekBarChanged();
}
Program: 95351
Project: 95351
Buggy source:
private void updateViews(){
  footprintTextView.setText(context.getString(R.string.footprint) + "String_Node_Str" + ((Double)surveyData.getLateralFootPrint()).intValue()+ "String_Node_Str"+ ((Double)surveyData.getLongitudinalFootPrint()).intValue()+ "String_Node_Str");
  groundResolutionTextView.setText(String.format("String_Node_Str",context.getString(R.string.ground_resolution),surveyData.getGroundResolution()));
  distanceTextView.setText(context.getString(R.string.distance_between_pictures) + "String_Node_Str" + surveyData.getLongitudinalPictureDistance().intValue()+ "String_Node_Str");
  distanceBetweenLinesTextView.setText(context.getString(R.string.distance_between_lines) + "String_Node_Str" + surveyData.getLateralPictureDistance().intValue()+ "String_Node_Str");
  areaTextView.setText(context.getString(R.string.area) + "String_Node_Str" + polygon.getArea().intValue()+ "String_Node_Str");
  lengthView.setText(context.getString(R.string.mission_length) + "String_Node_Str" + grid.getLength()+ "String_Node_Str");
  numberOfPicturesView.setText(context.getString(R.string.pictures) + "String_Node_Str" + grid.getLength() / surveyData.getLongitudinalPictureDistance());
  numberOfStripsView.setText(context.getString(R.string.number_of_strips) + "String_Node_Str" + grid.getNumberOfLines());
}

Fixed version (ground truth):
private void updateViews(){
  footprintTextView.setText(context.getString(R.string.footprint) + "String_Node_Str" + ((Double)surveyData.getLateralFootPrint()).intValue()+ "String_Node_Str"+ ((Double)surveyData.getLongitudinalFootPrint()).intValue()+ "String_Node_Str");
  groundResolutionTextView.setText(String.format("String_Node_Str",context.getString(R.string.ground_resolution),surveyData.getGroundResolution()));
  distanceTextView.setText(context.getString(R.string.distance_between_pictures) + "String_Node_Str" + surveyData.getLongitudinalPictureDistance().intValue()+ "String_Node_Str");
  distanceBetweenLinesTextView.setText(context.getString(R.string.distance_between_lines) + "String_Node_Str" + surveyData.getLateralPictureDistance().intValue()+ "String_Node_Str");
  areaTextView.setText(context.getString(R.string.area) + "String_Node_Str" + polygon.getArea().intValue()+ "String_Node_Str");
  lengthView.setText(context.getString(R.string.mission_length) + "String_Node_Str" + (int)grid.getLength()+ "String_Node_Str");
  numberOfPicturesView.setText(context.getString(R.string.pictures) + "String_Node_Str" + (int)(grid.getLength() / surveyData.getLongitudinalPictureDistance()));
  numberOfStripsView.setText(context.getString(R.string.number_of_strips) + "String_Node_Str" + grid.getNumberOfLines());
}
Program: 95352
Project: 95352
Buggy source:
@Override public void onSeekBarChanged(){
  surveyData.update(angleView.getValue(),altitudeView.getValue(),overlapView.getValue(),sidelapView.getValue());
  grid=gridBuilder.generate();
  updateViews();
}

Fixed version (ground truth):
@Override public void onSeekBarChanged(){
  surveyData.update(angleView.getValue(),altitudeView.getValue(),overlapView.getValue(),sidelapView.getValue());
  GridBuilder gridBuilder=new GridBuilder(polygon,surveyData,originPoint);
  grid=gridBuilder.generate();
  updateViews();
}
Program: 95353
Project: 95353
Buggy source:
@Override public void onClick(DialogInterface arg0,int which){
  if (which == Dialog.BUTTON_POSITIVE) {
    GridBuilder grid=new GridBuilder(polygon,angleView.getValue(),distanceView.getValue(),originPoint);
    onPolygonGenerated(grid.generate().getWaypoints(altitudeView.getValue()));
  }
}

Fixed version (ground truth):
@Override public void onClick(DialogInterface arg0,int which){
  if (which == Dialog.BUTTON_POSITIVE) {
    GridBuilder grid=new GridBuilder(polygon,angleView.getValue(),distanceView.getValue(),originPoint);
    try {
      onPolygonGenerated(grid.generate().getWaypoints(altitudeView.getValue()));
    }
 catch (    Exception e) {
      Toast.makeText(context,e.getMessage(),Toast.LENGTH_SHORT).show();
    }
  }
}
Program: 95354
Project: 95354
Buggy source:
public void generatePolygon(double defaultHatchAngle,double defaultHatchDistance,Polygon polygon,LatLng originPoint,double altitude,Context context){
  this.polygon=polygon;
  this.originPoint=originPoint;
  if (!polygon.isValid()) {
    Toast.makeText(context,"String_Node_Str",Toast.LENGTH_SHORT).show();
    return;
  }
  AlertDialog dialog=buildDialog(context);
  distanceView.setValue(defaultHatchDistance);
  angleView.setValue(defaultHatchAngle);
  altitudeView.setValue(altitude);
  dialog.show();
}

Fixed version (ground truth):
public void generatePolygon(double defaultHatchAngle,double defaultHatchDistance,Polygon polygon,LatLng originPoint,double altitude,Context context){
  this.context=context;
  this.polygon=polygon;
  this.originPoint=originPoint;
  if (!polygon.isValid()) {
    Toast.makeText(context,"String_Node_Str",Toast.LENGTH_SHORT).show();
    return;
  }
  AlertDialog dialog=buildDialog(context);
  distanceView.setValue(defaultHatchDistance);
  angleView.setValue(defaultHatchAngle);
  altitudeView.setValue(altitude);
  dialog.show();
}
Program: 95355
Project: 95355
Buggy source:
@Override public void onSeekBarChanged(){
  surveyData.update(views.angleView.getValue(),views.altitudeView.getValue(),views.overlapView.getValue(),views.sidelapView.getValue());
  GridBuilder gridBuilder=new GridBuilder(polygon,surveyData,originPoint);
  grid=gridBuilder.generate();
  views.updateViews(surveyData,grid,0.0);
}

Fixed version (ground truth):
@Override public void onSeekBarChanged(){
  surveyData.update(views.angleView.getValue(),views.altitudeView.getValue(),views.overlapView.getValue(),views.sidelapView.getValue());
  GridBuilder gridBuilder=new GridBuilder(polygon,surveyData,originPoint);
  try {
    grid=gridBuilder.generate();
    views.updateViews(surveyData,grid,0.0);
  }
 catch (  Exception e) {
    Toast.makeText(context,e.getMessage(),Toast.LENGTH_SHORT).show();
    views.blank();
  }
}
Program: 95356
Project: 95356
Buggy source:
public void generateSurveyDialog(Polygon polygon,double defaultHatchAngle,LatLng lastPoint,double defaultAltitude,Context context) throws Exception {
  this.polygon=polygon;
  this.originPoint=lastPoint;
  checkIfPolygonIsValid(polygon);
  views=new SurveyDialogViews(context);
  avaliableCameras=new CameraInfoLoader(this.views.context);
  surveyData=new SurveyData(Math.floor(defaultHatchAngle),defaultAltitude);
  AlertDialog dialog=views.buildDialog(this);
  views.updateCameraSpinner(avaliableCameras.getCameraInfoList());
  dialog.show();
}

Fixed version (ground truth):
public void generateSurveyDialog(Polygon polygon,double defaultHatchAngle,LatLng lastPoint,double defaultAltitude,Context context) throws Exception {
  this.context=context;
  this.polygon=polygon;
  this.originPoint=lastPoint;
  checkIfPolygonIsValid(polygon);
  views=new SurveyDialogViews(context);
  avaliableCameras=new CameraInfoLoader(this.views.context);
  surveyData=new SurveyData(Math.floor(defaultHatchAngle),defaultAltitude);
  AlertDialog dialog=views.buildDialog(this);
  views.updateCameraSpinner(avaliableCameras.getCameraInfoList());
  dialog.show();
}
Program: 95357
Project: 95357
Buggy source:
private void drawGrid(Double lineDist){
  int lines=0;
  LatLng startPoint=gridLowerLeft;
  while (lines * lineDist < extrapolatedDiag) {
    LatLng endPoint=GeoTools.newCoordFromBearingAndDistance(startPoint,angle,extrapolatedDiag);
    LineLatLng line=new LineLatLng(startPoint,endPoint);
    grid.add(line);
    startPoint=GeoTools.newCoordFromBearingAndDistance(startPoint,angle + 90,lineDist);
    lines++;
  }
}

Fixed version (ground truth):
private void drawGrid(Double lineDist) throws Exception {
  int lines=0;
  LatLng startPoint=gridLowerLeft;
  while (lines * lineDist < extrapolatedDiag) {
    LatLng endPoint=GeoTools.newCoordFromBearingAndDistance(startPoint,angle,extrapolatedDiag);
    LineLatLng line=new LineLatLng(startPoint,endPoint);
    grid.add(line);
    startPoint=GeoTools.newCoordFromBearingAndDistance(startPoint,angle + 90,lineDist);
    lines++;
    if (lines > MAX_NUMBER_OF_LINES) {
      throw new Exception("String_Node_Str");
    }
  }
}
Program: 95358
Project: 95358
Buggy source:
public CircumscribedGrid(List<LatLng> polygonPoints,Double angle,Double lineDist){
  this.angle=angle;
  findPolygonBounds(polygonPoints);
  drawGrid(lineDist);
}

Fixed version (ground truth):
public CircumscribedGrid(List<LatLng> polygonPoints,Double angle,Double lineDist) throws Exception {
  this.angle=angle;
  findPolygonBounds(polygonPoints);
  drawGrid(lineDist);
}
Program: 95359
Project: 95359
Buggy source:
public Grid generate(){
  List<LatLng> polygonPoints=poly.getLatLngList();
  List<LineLatLng> circumscribedGrid=new CircumscribedGrid(polygonPoints,angle,lineDist).getGrid();
  List<LineLatLng> trimedGrid=new Trimmer(circumscribedGrid,poly.getLines()).getTrimmedGrid();
  EndpointSorter gridSorter=new EndpointSorter(trimedGrid,wpDistance);
  gridSorter.sortGrid(origin,innerWPs);
  grid=new Grid(gridSorter.getSortedGrid());
  return grid;
}

Fixed version (ground truth):
public Grid generate() throws Exception {
  List<LatLng> polygonPoints=poly.getLatLngList();
  List<LineLatLng> circumscribedGrid=new CircumscribedGrid(polygonPoints,angle,lineDist).getGrid();
  List<LineLatLng> trimedGrid=new Trimmer(circumscribedGrid,poly.getLines()).getTrimmedGrid();
  EndpointSorter gridSorter=new EndpointSorter(trimedGrid,wpDistance);
  gridSorter.sortGrid(origin,innerWPs);
  grid=new Grid(gridSorter.getSortedGrid());
  return grid;
}
Program: 95360
Project: 95360
Buggy source:
/** 
 * Finds the intersection of two lines http://stackoverflow.com/questions/ 1119451/how-to-tell-if-a-line-intersects -a-polygon-in-c
 */
public static LatLng FindLineIntersection(LineLatLng first,LineLatLng second){
  double denom=((first.p2.longitude - first.p1.longitude) * (second.p2.latitude - second.p1.latitude)) - ((first.p2.latitude - first.p1.latitude) * (second.p2.longitude - second.p1.longitude));
  if (denom == 0)   return null;
  double numer=((first.p1.latitude - second.p1.latitude) * (second.p2.longitude - second.p1.longitude)) - ((first.p1.longitude - second.p1.longitude) * (second.p2.latitude - second.p1.latitude));
  double r=numer / denom;
  double numer2=((first.p1.latitude - second.p1.latitude) * (first.p2.longitude - first.p1.longitude)) - ((first.p1.longitude - second.p1.longitude) * (first.p2.latitude - first.p1.latitude));
  double s=numer2 / denom;
  if ((r < 0 || r > 1) || (s < 0 || s > 1))   return null;
  double longitude=first.p1.longitude + (r * (first.p2.longitude - first.p1.longitude));
  double latitude=first.p1.latitude + (r * (first.p2.latitude - first.p1.latitude));
  return (new LatLng(latitude,longitude));
}

Fixed version (ground truth):
/** 
 * Finds the intersection of two lines http://stackoverflow.com/questions/ 1119451/how-to-tell-if-a-line-intersects -a-polygon-in-c
 * @throws Exception 
 */
public static LatLng FindLineIntersection(LineLatLng first,LineLatLng second) throws Exception {
  double denom=((first.p2.longitude - first.p1.longitude) * (second.p2.latitude - second.p1.latitude)) - ((first.p2.latitude - first.p1.latitude) * (second.p2.longitude - second.p1.longitude));
  if (denom == 0)   throw new Exception("String_Node_Str");
  double numer=((first.p1.latitude - second.p1.latitude) * (second.p2.longitude - second.p1.longitude)) - ((first.p1.longitude - second.p1.longitude) * (second.p2.latitude - second.p1.latitude));
  double r=numer / denom;
  double numer2=((first.p1.latitude - second.p1.latitude) * (first.p2.longitude - first.p1.longitude)) - ((first.p1.longitude - second.p1.longitude) * (first.p2.latitude - first.p1.latitude));
  double s=numer2 / denom;
  if ((r < 0 || r > 1) || (s < 0 || s > 1))   throw new Exception("String_Node_Str");
  double longitude=first.p1.longitude + (r * (first.p2.longitude - first.p1.longitude));
  double latitude=first.p1.latitude + (r * (first.p2.latitude - first.p1.latitude));
  return (new LatLng(latitude,longitude));
}
Program: 95361
Project: 95361
Buggy source:
private void findPolygonBounds(List<LatLng> polygonPoints){
  PolyBounds bounds=new PolyBounds(polygonPoints);
  LatLng middlePoint=bounds.getMidlePoint();
  gridLowerLeft=GeoTools.newCoordFromBearingAndDistance(middlePoint,angle - 135,bounds.getDiag());
  extrapolatedDiag=bounds.getDiag() * 1.5;
}

Fixed version (ground truth):
private void findPolygonBounds(List<LatLng> polygonPoints){
  PolyBounds bounds=new PolyBounds(polygonPoints);
  LatLng middlePoint=bounds.getMiddle();
  gridLowerLeft=GeoTools.newCoordFromBearingAndDistance(middlePoint,angle - 135,bounds.getDiag());
  extrapolatedDiag=bounds.getDiag() * 1.5;
}
Program: 95362
Project: 95362
Buggy source:
private void processCrossings(int crosses){
switch (crosses) {
case 0:
case 1:
    break;
default :
case 2:
  trimedGrid.add(new LineLatLng(closestPoint,farestPoint));
break;
}
}

Fixed version (ground truth):
private void processCrossings(ArrayList<LatLng> crosses,LineLatLng gridLine){
switch (crosses.size()) {
case 0:
case 1:
    break;
case 2:
  trimedGrid.add(new LineLatLng(crosses.get(0),crosses.get(1)));
break;
default :
trimedGrid.add(new LineLatLng(findExternalPoints(crosses)));
}
}
Program: 95363
Project: 95363
Buggy source:
private int findCrossings(List<LineLatLng> polygon,LineLatLng gridLine){
  double closestDistance=Double.MAX_VALUE;
  double farestDistance=Double.MIN_VALUE;
  int crosses=0;
  for (  LineLatLng polyLine : polygon) {
    LatLng newlatlong=GeoTools.FindLineIntersection(polyLine,gridLine);
    if (newlatlong != null) {
      crosses++;
      if (closestDistance > GeoTools.getAproximatedDistance(gridLine.p1,newlatlong)) {
        closestPoint=new LatLng(newlatlong.latitude,newlatlong.longitude);
        closestDistance=GeoTools.getAproximatedDistance(gridLine.p1,newlatlong);
      }
      if (farestDistance < GeoTools.getAproximatedDistance(gridLine.p1,newlatlong)) {
        farestPoint=new LatLng(newlatlong.latitude,newlatlong.longitude);
        farestDistance=GeoTools.getAproximatedDistance(gridLine.p1,newlatlong);
      }
    }
  }
  return crosses;
}

Fixed version (ground truth):
private ArrayList<LatLng> findCrossings(List<LineLatLng> polygon,LineLatLng gridLine){
  ArrayList<LatLng> crossings=new ArrayList<LatLng>();
  for (  LineLatLng polyLine : polygon) {
    try {
      crossings.add(GeoTools.FindLineIntersection(polyLine,gridLine));
    }
 catch (    Exception e) {
    }
  }
  return crossings;
}
Program: 95364
Project: 95364
Buggy source:
public Trimmer(List<LineLatLng> grid,List<LineLatLng> polygon){
  for (  LineLatLng gridLine : grid) {
    int crosses=findCrossings(polygon,gridLine);
    processCrossings(crosses);
  }
}

Fixed version (ground truth):
public Trimmer(List<LineLatLng> grid,List<LineLatLng> polygon){
  for (  LineLatLng gridLine : grid) {
    ArrayList<LatLng> crosses=findCrossings(polygon,gridLine);
    processCrossings(crosses,gridLine);
  }
}
Program: 95365
Project: 95365
Buggy source:
public void sortGrid(){
  LineLatLng closestLine=new LineLatLng(firstLine);
  while (grid.size() > 0) {
    LatLng secondWp=processOneGridLine(closestLine);
    lastpnt=secondWp;
    if (grid.size() == 0)     break;
    closestLine=GeoTools.findClosestLineToPoint(lastpnt,grid);
  }
}

Fixed version (ground truth):
public void sortGrid(LatLng lastpnt){
  while (grid.size() > 0) {
    LineLatLng closestLine=GeoTools.findClosestLineToPoint(lastpnt,grid);
    LatLng secondWp=processOneGridLine(closestLine,lastpnt);
    lastpnt=secondWp;
  }
}
Program: 95366
Project: 95366
Buggy source:
public EndpointSorter(List<LineLatLng> grid,LatLng start,Double altitude){
  this.grid=grid;
  this.altitude=altitude;
  firstLine=GeoTools.findClosestLineToPoint(start,grid);
  lastpnt=firstLine.getClosestEndpointTo(start);
}

Fixed version (ground truth):
public EndpointSorter(List<LineLatLng> grid,Double altitude){
  this.grid=grid;
  this.altitude=altitude;
}
Program: 95367
Project: 95367
Buggy source:
private LatLng processOneGridLine(LineLatLng closestLine){
  LatLng firstWP=closestLine.getClosestEndpointTo(lastpnt);
  LatLng secondWp=closestLine.getFarthestEndpointTo(lastpnt);
  grid.remove(closestLine);
  addWaypointsBetween(firstWP,secondWp);
  return secondWp;
}

Fixed version (ground truth):
private LatLng processOneGridLine(LineLatLng closestLine,LatLng lastpnt){
  LatLng firstWP=closestLine.getClosestEndpointTo(lastpnt);
  LatLng secondWp=closestLine.getFarthestEndpointTo(lastpnt);
  grid.remove(closestLine);
  addWaypointsBetween(firstWP,secondWp);
  return secondWp;
}
Program: 95368
Project: 95368
Buggy source:
public List<waypoint> generate(){
  List<LatLng> polygonPoints=poly.getLatLngList();
  List<LineLatLng> circumscribedGrid=new Generator(polygonPoints,angle,lineDist).getGrid();
  List<LineLatLng> trimedGrid=new Trimmer(circumscribedGrid,polygonPoints).getTrimmedGrid();
  EndpointSorter gridSorter=new EndpointSorter(trimedGrid,lastLocation,altitude);
  gridSorter.sortGrid();
  gridPoints=gridSorter.getWaypoints();
  return gridPoints;
}

Fixed version (ground truth):
public List<waypoint> generate(){
  List<LatLng> polygonPoints=poly.getLatLngList();
  List<LineLatLng> circumscribedGrid=new Generator(polygonPoints,angle,lineDist).getGrid();
  List<LineLatLng> trimedGrid=new Trimmer(circumscribedGrid,polygonPoints).getTrimmedGrid();
  EndpointSorter gridSorter=new EndpointSorter(trimedGrid,altitude);
  gridSorter.sortGrid(lastLocation);
  gridPoints=gridSorter.getWaypoints();
  return gridPoints;
}
Program: 95369
Project: 95369
Buggy source:
public SurveyData(double defaultHatchAngle,double defaultAltitude){
  this.angle=90.0;
  this.altitude=150.0;
  this.overlap=50.0;
  this.sidelap=60.0;
}

Fixed version (ground truth):
public SurveyData(double defaultHatchAngle,double defaultAltitude){
  this.angle=defaultHatchAngle;
  this.altitude=defaultAltitude;
  this.overlap=50.0;
  this.sidelap=60.0;
}
Program: 95370
Project: 95370
Buggy source:
public void setUnit(String unit){
  this.unit=unit;
}

Fixed version (ground truth):
public void setUnit(String unit){
  if (unit != null) {
    this.unit=unit;
  }
}