Program: 17758
Project: 17758
Buggy source:
/** 
 * Run the selection logic
 */
public void selectionLogic(Point rcbp,Point sloc,Rectangle rect,boolean onePt,boolean showShadows,Set<String> nodes,Set<FabricLink> links,Set<Integer> cols,boolean shiftPressed){
  if ((nodeNameLocations_ == null) || (drainNameLocations_ == null)) {
    return;
  }
  MinMax colRange=null;
  MinMax nodeRange=null;
  if (shiftPressed) {
    colRange=new MinMax();
    colRange.init();
    nodeRange=new MinMax();
    nodeRange.init();
    Iterator<Integer> cit=cols.iterator();
    while (cit.hasNext()) {
      Integer col=cit.next();
      colRange.update(col.intValue());
    }
    Iterator<String> nit=nodes.iterator();
    while (nit.hasNext()) {
      String node=nit.next();
      int row=bfn_.getNodeDefinition(node).nodeRow;
      nodeRange.update(row);
    }
  }
  int startRow=(rcbp == null) ? rect.y : rcbp.y;
  int endRow=(rcbp == null) ? rect.y + rect.height : rcbp.y;
  int startCol=(rcbp == null) ? rect.x : rcbp.x;
  int endCol=(rcbp == null) ? rect.x + rect.width : rcbp.x;
  boolean nodeAdd=false;
  boolean linkAdd=false;
  String gotDrain=null;
  if (onePt) {
    Point2D worldPt=viewToWorld(sloc);
    Iterator<String> dnlit=drainNameLocations_.keySet().iterator();
    while (dnlit.hasNext()) {
      String target=dnlit.next();
      List<Rectangle2D> nameLoc=drainNameLocations_.get(target);
      if (nameLoc.contains(worldPt)) {
        gotDrain=target;
        break;
      }
    }
  }
  boolean gotLink=false;
  for (int row=startRow; row <= endRow; row++) {
    for (int col=startCol; col <= endCol; col++) {
      Integer rowObj=Integer.valueOf(row);
      Integer colObj=Integer.valueOf(col);
      String target=bfn_.getNodeForRow(rowObj);
      if ((target != null) && (gotDrain == null)) {
        boolean gotIt=false;
        if (onePt) {
          BioFabricNetwork.NodeInfo tni=bfn_.getNodeDefinition(target);
          MinMax range=tni.getColRange(showShadows);
          if ((col >= range.min) && (col <= range.max)) {
            if (nodes.contains(target)) {
              nodes.remove(target);
            }
 else {
              if (nodeRange != null) {
                nodeRange.update(row);
              }
              nodes.add(target);
              nodeAdd=true;
            }
            gotIt=true;
          }
        }
        if (!gotIt) {
          Point2D worldPt=rowColToWorld(new Point(col,row));
          Rectangle2D nameLoc=nodeNameLocations_.get(target);
          if (nameLoc.contains(worldPt)) {
            if (nodes.contains(target)) {
              nodes.remove(target);
            }
 else {
              if (nodeRange != null) {
                nodeRange.update(row);
              }
              nodes.add(target);
              nodeAdd=true;
            }
          }
        }
      }
      BioFabricNetwork.LinkInfo linf=bfn_.getLinkDefinition(colObj,showShadows);
      if (linf != null) {
        if ((rowObj.intValue() == linf.getStartRow()) || (rowObj.intValue() == linf.getEndRow())) {
          boolean removeIt=false;
          if (cols.contains(colObj)) {
            cols.remove(colObj);
            removeIt=true;
          }
 else {
            if (colRange != null) {
              colRange.update(col);
            }
            cols.add(colObj);
          }
          String src=bfn_.getSourceForColumn(colObj,showShadows);
          String trg=bfn_.getTargetForColumn(colObj,showShadows);
          if (removeIt) {
            links.remove(linf.getLink());
          }
 else {
            links.add(linf.getLink().clone());
            nodes.add(src);
            nodes.add(trg);
          }
          gotLink=true;
        }
      }
    }
  }
  if (!gotLink && (gotDrain != null)) {
    if (nodes.contains(gotDrain)) {
      nodes.remove(gotDrain);
    }
 else {
      if (nodeRange != null) {
        int row=bfn_.getNodeDefinition(gotDrain).nodeRow;
        nodeRange.update(row);
      }
      nodes.add(gotDrain);
      nodeAdd=true;
    }
  }
  if (shiftPressed) {
    if (linkAdd && (colRange.min != Integer.MAX_VALUE)) {
      for (int i=colRange.min; i < colRange.max; i++) {
        Integer colObj=Integer.valueOf(i);
        cols.add(colObj);
        String src=bfn_.getSourceForColumn(colObj,showShadows);
        String trg=bfn_.getTargetForColumn(colObj,showShadows);
        BioFabricNetwork.LinkInfo linf=bfn_.getLinkDefinition(colObj,showShadows);
        links.add(linf.getLink().clone());
        nodes.add(src);
        nodes.add(trg);
      }
    }
    if (nodeAdd && (nodeRange.min != Integer.MAX_VALUE)) {
      for (int i=nodeRange.min; i < nodeRange.max; i++) {
        Integer rowObj=Integer.valueOf(i);
        String target=bfn_.getNodeForRow(rowObj);
        nodes.add(target);
      }
    }
  }
  return;
}

Fixed version (ground truth):
/** 
 * Run the selection logic
 */
public void selectionLogic(Point rcbp,Point sloc,Rectangle rect,boolean onePt,boolean showShadows,Set<String> nodes,Set<FabricLink> links,Set<Integer> cols,boolean shiftPressed){
  if ((nodeNameLocations_ == null) || (drainNameLocations_ == null)) {
    return;
  }
  MinMax colRange=null;
  MinMax nodeRange=null;
  if (shiftPressed) {
    colRange=new MinMax();
    colRange.init();
    nodeRange=new MinMax();
    nodeRange.init();
    Iterator<Integer> cit=cols.iterator();
    while (cit.hasNext()) {
      Integer col=cit.next();
      colRange.update(col.intValue());
    }
    Iterator<String> nit=nodes.iterator();
    while (nit.hasNext()) {
      String node=nit.next();
      int row=bfn_.getNodeDefinition(node).nodeRow;
      nodeRange.update(row);
    }
  }
  int startRow=(rcbp == null) ? rect.y : rcbp.y;
  int endRow=(rcbp == null) ? rect.y + rect.height : rcbp.y;
  int startCol=(rcbp == null) ? rect.x : rcbp.x;
  int endCol=(rcbp == null) ? rect.x + rect.width : rcbp.x;
  boolean nodeAdd=false;
  boolean linkAdd=false;
  String gotDrain=null;
  if (onePt) {
    Point2D worldPt=viewToWorld(sloc);
    Iterator<String> dnlit=drainNameLocations_.keySet().iterator();
    while (dnlit.hasNext()) {
      String target=dnlit.next();
      List<Rectangle2D> nameLocs=drainNameLocations_.get(target);
      for (      Rectangle2D zone : nameLocs) {
        if (zone.contains(worldPt)) {
          gotDrain=target;
          break;
        }
      }
    }
  }
  boolean gotLink=false;
  for (int row=startRow; row <= endRow; row++) {
    for (int col=startCol; col <= endCol; col++) {
      Integer rowObj=Integer.valueOf(row);
      Integer colObj=Integer.valueOf(col);
      String target=bfn_.getNodeForRow(rowObj);
      if ((target != null) && (gotDrain == null)) {
        boolean gotIt=false;
        if (onePt) {
          BioFabricNetwork.NodeInfo tni=bfn_.getNodeDefinition(target);
          MinMax range=tni.getColRange(showShadows);
          if ((col >= range.min) && (col <= range.max)) {
            if (nodes.contains(target)) {
              nodes.remove(target);
            }
 else {
              if (nodeRange != null) {
                nodeRange.update(row);
              }
              nodes.add(target);
              nodeAdd=true;
            }
            gotIt=true;
          }
        }
        if (!gotIt) {
          Point2D worldPt=rowColToWorld(new Point(col,row));
          Rectangle2D nameLoc=nodeNameLocations_.get(target);
          if (nameLoc.contains(worldPt)) {
            if (nodes.contains(target)) {
              nodes.remove(target);
            }
 else {
              if (nodeRange != null) {
                nodeRange.update(row);
              }
              nodes.add(target);
              nodeAdd=true;
            }
          }
        }
      }
      BioFabricNetwork.LinkInfo linf=bfn_.getLinkDefinition(colObj,showShadows);
      if (linf != null) {
        if ((rowObj.intValue() == linf.getStartRow()) || (rowObj.intValue() == linf.getEndRow())) {
          boolean removeIt=false;
          if (cols.contains(colObj)) {
            cols.remove(colObj);
            removeIt=true;
          }
 else {
            if (colRange != null) {
              colRange.update(col);
            }
            cols.add(colObj);
          }
          String src=bfn_.getSourceForColumn(colObj,showShadows);
          String trg=bfn_.getTargetForColumn(colObj,showShadows);
          if (removeIt) {
            links.remove(linf.getLink());
          }
 else {
            links.add(linf.getLink().clone());
            nodes.add(src);
            nodes.add(trg);
          }
          gotLink=true;
        }
      }
    }
  }
  if (!gotLink && (gotDrain != null)) {
    if (nodes.contains(gotDrain)) {
      nodes.remove(gotDrain);
    }
 else {
      if (nodeRange != null) {
        int row=bfn_.getNodeDefinition(gotDrain).nodeRow;
        nodeRange.update(row);
      }
      nodes.add(gotDrain);
      nodeAdd=true;
    }
  }
  if (shiftPressed) {
    if (linkAdd && (colRange.min != Integer.MAX_VALUE)) {
      for (int i=colRange.min; i < colRange.max; i++) {
        Integer colObj=Integer.valueOf(i);
        cols.add(colObj);
        String src=bfn_.getSourceForColumn(colObj,showShadows);
        String trg=bfn_.getTargetForColumn(colObj,showShadows);
        BioFabricNetwork.LinkInfo linf=bfn_.getLinkDefinition(colObj,showShadows);
        links.add(linf.getLink().clone());
        nodes.add(src);
        nodes.add(trg);
      }
    }
    if (nodeAdd && (nodeRange.min != Integer.MAX_VALUE)) {
      for (int i=nodeRange.min; i < nodeRange.max; i++) {
        Integer rowObj=Integer.valueOf(i);
        String target=bfn_.getNodeForRow(rowObj);
        nodes.add(target);
      }
    }
  }
  return;
}