Program: 57715
Project: 57715
Buggy source:
public void handlePathwayElementSelection(SelectionType selectionType,int externalID){
  setDisplayListDirty();
  if (geneSelectionManager.checkStatus(selectionType,externalID)) {
    return;
  }
  PathwayVertexRep previouslySelectedVertexRep=null;
  if (geneSelectionManager.getElements(SelectionType.SELECTION).size() == 1) {
    previouslySelectedVertexRep=(PathwayVertexRep)pathwayItemManager.getPathwayVertexRep((Integer)geneSelectionManager.getElements(SelectionType.SELECTION).toArray()[0]);
  }
  geneSelectionManager.clearSelection(selectionType);
  if (metaboliteSelectionManager.getNumberOfElements(selectionType) > 0) {
    metaboliteSelectionManager.clearSelection(selectionType);
    metaboliteSelectionManager.triggerSelectionUpdateEvent();
  }
  PathwayVertexRep vertexRep=(PathwayVertexRep)pathwayItemManager.getPathwayVertexRep(externalID);
  if (vertexRep.getType() == EPathwayVertexType.compound) {
    metaboliteSelectionManager.addToType(selectionType,vertexRep.getName().hashCode());
    metaboliteSelectionManager.triggerSelectionUpdateEvent();
  }
  if (previouslySelectedVertexRep != null && selectionType == SelectionType.SELECTION) {
    if (!isControlKeyDown) {
      KShortestPaths<PathwayVertexRep,DefaultEdge> pathAlgo=new KShortestPaths<PathwayVertexRep,DefaultEdge>(pathway,previouslySelectedVertexRep,MAX_PATHS);
      if (vertexRep != previouslySelectedVertexRep)       allPaths=pathAlgo.getPaths(vertexRep);
      if (allPaths != null && allPaths.size() > 0) {
        selectedPath=allPaths.get(selectedPathID);
        allPaths.clear();
        selectedPathID=0;
        allPaths.add(selectedPath);
        triggerPathUpdate();
        isBubbleTextureDirty=true;
      }
    }
 else     if (selectedPath != null) {
      KShortestPaths<PathwayVertexRep,DefaultEdge> pathAlgo=new KShortestPaths<PathwayVertexRep,DefaultEdge>(pathway,selectedPath.getStartVertex(),MAX_PATHS);
      allPaths=pathAlgo.getPaths(vertexRep);
      if (allPaths != null && allPaths.size() > 0) {
        selectedPath=allPaths.get(selectedPathID);
        allPaths.clear();
        selectedPathID=0;
        allPaths.add(selectedPath);
        triggerPathUpdate();
        isBubbleTextureDirty=true;
      }
    }
  }
 else   if (previouslySelectedVertexRep != null && selectionType == SelectionType.MOUSE_OVER) {
    KShortestPaths<PathwayVertexRep,DefaultEdge> pathAlgo=new KShortestPaths<PathwayVertexRep,DefaultEdge>(pathway,previouslySelectedVertexRep,MAX_PATHS);
    if (vertexRep != previouslySelectedVertexRep) {
      List<GraphPath<PathwayVertexRep,DefaultEdge>> mouseOverPaths=pathAlgo.getPaths(vertexRep);
      if (mouseOverPaths != null && mouseOverPaths.size() > 0) {
        allPaths=mouseOverPaths;
        selectedPath=allPaths.get(selectedPathID);
        if (selectedPath != null && isControlKeyDown)         allPaths.add(selectedPath);
        isBubbleTextureDirty=true;
      }
    }
  }
  geneSelectionManager.addToType(selectionType,vertexRep.getID());
  int iConnectionID=generalManager.getIDCreator().createID(ManagedObjectType.CONNECTION);
  geneSelectionManager.addConnectionID(iConnectionID,vertexRep.getID());
  connectedElementRepresentationManager.clear(geneSelectionManager.getIDType(),selectionType);
  createConnectionLines(selectionType,iConnectionID);
  SelectionDelta selectionDelta=createExternalSelectionDelta(geneSelectionManager.getDelta());
  SelectionUpdateEvent event=new SelectionUpdateEvent();
  event.setSender(this);
  event.setDataDomainID(dataDomain.getDataDomainID());
  event.setSelectionDelta((SelectionDelta)selectionDelta);
  eventPublisher.triggerEvent(event);
}

Fixed version (ground truth):
public void handlePathwayElementSelection(SelectionType selectionType,int externalID){
  setDisplayListDirty();
  if (geneSelectionManager.checkStatus(selectionType,externalID)) {
    return;
  }
  PathwayVertexRep previouslySelectedVertexRep=null;
  if (geneSelectionManager.getElements(SelectionType.SELECTION).size() == 1) {
    previouslySelectedVertexRep=(PathwayVertexRep)pathwayItemManager.getPathwayVertexRep((Integer)geneSelectionManager.getElements(SelectionType.SELECTION).toArray()[0]);
  }
  geneSelectionManager.clearSelection(selectionType);
  if (metaboliteSelectionManager.getNumberOfElements(selectionType) > 0) {
    metaboliteSelectionManager.clearSelection(selectionType);
    metaboliteSelectionManager.triggerSelectionUpdateEvent();
  }
  PathwayVertexRep vertexRep=(PathwayVertexRep)pathwayItemManager.getPathwayVertexRep(externalID);
  if (vertexRep.getType() == EPathwayVertexType.compound) {
    metaboliteSelectionManager.addToType(selectionType,vertexRep.getName().hashCode());
    metaboliteSelectionManager.triggerSelectionUpdateEvent();
  }
  if (previouslySelectedVertexRep != null && selectionType == SelectionType.SELECTION) {
    if (!isControlKeyDown) {
      KShortestPaths<PathwayVertexRep,DefaultEdge> pathAlgo=new KShortestPaths<PathwayVertexRep,DefaultEdge>(pathway,previouslySelectedVertexRep,MAX_PATHS);
      if (vertexRep != previouslySelectedVertexRep)       allPaths=pathAlgo.getPaths(vertexRep);
      if (allPaths != null && allPaths.size() > 0) {
        if (allPaths.size() <= selectedPathID)         selectedPathID=0;
        selectedPath=allPaths.get(selectedPathID);
        allPaths.clear();
        selectedPathID=0;
        allPaths.add(selectedPath);
        triggerPathUpdate();
        isBubbleTextureDirty=true;
      }
    }
 else     if (selectedPath != null) {
      KShortestPaths<PathwayVertexRep,DefaultEdge> pathAlgo=new KShortestPaths<PathwayVertexRep,DefaultEdge>(pathway,selectedPath.getStartVertex(),MAX_PATHS);
      allPaths=pathAlgo.getPaths(vertexRep);
      if (allPaths != null && allPaths.size() > 0) {
        if (allPaths.size() <= selectedPathID)         selectedPathID=0;
        selectedPath=allPaths.get(selectedPathID);
        allPaths.clear();
        selectedPathID=0;
        allPaths.add(selectedPath);
        triggerPathUpdate();
        isBubbleTextureDirty=true;
      }
    }
  }
 else   if (previouslySelectedVertexRep != null && selectionType == SelectionType.MOUSE_OVER) {
    KShortestPaths<PathwayVertexRep,DefaultEdge> pathAlgo=new KShortestPaths<PathwayVertexRep,DefaultEdge>(pathway,previouslySelectedVertexRep,MAX_PATHS);
    if (vertexRep != previouslySelectedVertexRep) {
      List<GraphPath<PathwayVertexRep,DefaultEdge>> mouseOverPaths=pathAlgo.getPaths(vertexRep);
      if (mouseOverPaths != null && mouseOverPaths.size() > 0) {
        allPaths=mouseOverPaths;
        if (allPaths.size() <= selectedPathID)         selectedPathID=0;
        selectedPath=allPaths.get(selectedPathID);
        if (selectedPath != null && isControlKeyDown)         allPaths.add(selectedPath);
        isBubbleTextureDirty=true;
      }
    }
  }
  geneSelectionManager.addToType(selectionType,vertexRep.getID());
  int iConnectionID=generalManager.getIDCreator().createID(ManagedObjectType.CONNECTION);
  geneSelectionManager.addConnectionID(iConnectionID,vertexRep.getID());
  connectedElementRepresentationManager.clear(geneSelectionManager.getIDType(),selectionType);
  createConnectionLines(selectionType,iConnectionID);
  SelectionDelta selectionDelta=createExternalSelectionDelta(geneSelectionManager.getDelta());
  SelectionUpdateEvent event=new SelectionUpdateEvent();
  event.setSender(this);
  event.setDataDomainID(dataDomain.getDataDomainID());
  event.setSelectionDelta((SelectionDelta)selectionDelta);
  eventPublisher.triggerEvent(event);
}