Program: 58436
Project: 58436
Buggy source:
/** 
 * <p> This method chooses which groups (and therefore heat maps) are to be rendered at the passive side. It does so based on a virtualArray containing all elements to be rendered. </p> <p> This is called in the passive heat map. </p> <p> It also re-sorts the passive group's virtual arrays to minimize crossings and sets elements that are in a passive group but not in the supplied virtual array to   {@link GLHeatMap#SELECTION_HIDDEN} so that they can behidden on demand.
 */
public void choosePassiveHeatMaps(HashMap<Integer,Integer> relationMap,ArrayList<ContentVirtualArray> foreignContentVAs){
  ContentGroupList groupList=contentVA.getGroupList();
  groupList.updateGroupInfo();
  selectedGroups.clear();
  for (  ContentVirtualArray foreignVa : foreignContentVAs) {
    for (    Integer contentID : foreignVa) {
      int vaIndex=contentVA.indexOf(contentID);
      Group selectedGroup=groupList.getGroupOfVAIndex(vaIndex);
      GroupInfo currentInfo;
      if (!selectedGroups.containsKey(selectedGroup)) {
        currentInfo=new GroupInfo();
        selectedGroups.put(selectedGroup,currentInfo);
      }
 else {
        currentInfo=selectedGroups.get(selectedGroup);
      }
      GLHeatMap heatMap=hashHeatMaps.get(selectedGroup.getGroupIndex());
      ContentVirtualArray heatMapVA=heatMap.getContentVA();
      int index=heatMapVA.indexOf(contentID);
      if (index >= 0)       heatMapVA.move(index,currentInfo.getContainedNrGenes());
 else       System.out.println("String_Node_Str");
      currentInfo.increaseContainedNumberOfGenesByOne();
    }
  }
  for (int groupIndex=groupList.size() - 1; groupIndex >= 0; groupIndex--) {
    Group group=groupList.get(groupIndex);
    if (selectedGroups.containsKey(group)) {
      GLHeatMap heatMap=hashHeatMaps.get(group.getGroupIndex());
      int nrGenes=selectedGroups.get(group).getContainedNrGenes();
      ContentVirtualArray contentVA=heatMap.getContentVA();
      for (      ContentVirtualArray foreignVA : foreignContentVAs) {
        Integer foreignContentLastOrdererIndex=0;
        for (int contentIndex=0; contentIndex < nrGenes; contentIndex++) {
          Integer contentID=contentVA.get(contentIndex);
          int foreignIndex=foreignVA.indexOf(contentID);
          if (foreignIndex != -1) {
            foreignVA.move(foreignIndex,foreignContentLastOrdererIndex++);
          }
        }
      }
      for (int foreignVAIndex=foreignContentVAs.size() - 1; foreignVAIndex >= 0; foreignVAIndex--) {
        int lastMovedIndex=0;
        ContentVirtualArray foreignVA=foreignContentVAs.get(foreignVAIndex);
        for (        int foreignID : foreignVA) {
          int contentIndex=contentVA.indexOf(foreignID);
          if (contentIndex != -1) {
            contentVA.move(contentIndex,lastMovedIndex++);
            if (contentIndex != lastMovedIndex - 1)             System.out.println("String_Node_Str");
          }
        }
      }
      SelectionDelta contentSelectionDelta=new SelectionDelta(EIDType.EXPRESSION_INDEX);
      for (int contentIndex=nrGenes; contentIndex < contentVA.size(); contentIndex++) {
        SelectionDeltaItem item=new SelectionDeltaItem();
        item.setPrimaryID(contentVA.get(contentIndex));
        item.setSelectionType(GLHeatMap.SELECTION_HIDDEN);
        contentSelectionDelta.add(item);
      }
      SelectionUpdateEvent event=new SelectionUpdateEvent();
      event.setSender(this);
      event.setSelectionDelta(contentSelectionDelta);
      eventPublisher.triggerEvent(event);
    }
  }
  for (  Group group : selectedGroups.keySet()) {
    GLHeatMap heatMap=hashHeatMaps.get(group.getGroupIndex());
    heatMap.recalculateLayout();
  }
}

Fixed version (ground truth):
/** 
 * <p> This method chooses which groups (and therefore heat maps) are to be rendered at the passive side. It does so based on a virtualArray containing all elements to be rendered. </p> <p> This is called in the passive heat map. </p> <p> It also re-sorts the passive group's virtual arrays to minimize crossings and sets elements that are in a passive group but not in the supplied virtual array to   {@link GLHeatMap#SELECTION_HIDDEN} so that they can behidden on demand.
 */
public void choosePassiveHeatMaps(HashMap<Integer,Integer> relationMap,ArrayList<ContentVirtualArray> foreignContentVAs){
  ContentGroupList groupList=contentVA.getGroupList();
  groupList.updateGroupInfo();
  selectedGroups.clear();
  for (  ContentVirtualArray foreignVa : foreignContentVAs) {
    for (    Integer contentID : foreignVa) {
      int vaIndex=contentVA.indexOf(contentID);
      Group selectedGroup=groupList.getGroupOfVAIndex(vaIndex);
      GroupInfo currentInfo;
      if (!selectedGroups.containsKey(selectedGroup)) {
        currentInfo=new GroupInfo();
        selectedGroups.put(selectedGroup,currentInfo);
      }
 else {
        currentInfo=selectedGroups.get(selectedGroup);
      }
      GLHeatMap heatMap=hashHeatMaps.get(selectedGroup.getGroupIndex());
      ContentVirtualArray heatMapVA=heatMap.getContentVA();
      int index=heatMapVA.indexOf(contentID);
      if (index >= 0)       heatMapVA.move(index,currentInfo.getContainedNrGenes());
 else       System.out.println("String_Node_Str");
      currentInfo.increaseContainedNumberOfGenesByOne();
    }
  }
  for (int groupIndex=groupList.size() - 1; groupIndex >= 0; groupIndex--) {
    Group group=groupList.get(groupIndex);
    if (selectedGroups.containsKey(group)) {
      GLHeatMap heatMap=hashHeatMaps.get(group.getGroupIndex());
      int nrGenes=selectedGroups.get(group).getContainedNrGenes();
      ContentVirtualArray contentVA=heatMap.getContentVA();
      for (      ContentVirtualArray foreignVA : foreignContentVAs) {
        Integer foreignContentLastOrdererIndex=0;
        for (int contentIndex=0; contentIndex < nrGenes; contentIndex++) {
          Integer contentID=contentVA.get(contentIndex);
          int foreignIndex=foreignVA.indexOf(contentID);
          if (foreignIndex != -1) {
            foreignVA.move(foreignIndex,foreignContentLastOrdererIndex++);
          }
        }
      }
      for (int foreignVAIndex=foreignContentVAs.size() - 1; foreignVAIndex >= 0; foreignVAIndex--) {
        int lastMovedIndex=0;
        ContentVirtualArray foreignVA=foreignContentVAs.get(foreignVAIndex);
        for (        int foreignID : foreignVA) {
          int contentIndex=contentVA.indexOf(foreignID);
          if (contentIndex != -1) {
            contentVA.move(contentIndex,lastMovedIndex++);
          }
        }
      }
      SelectionDelta contentSelectionDelta=new SelectionDelta(EIDType.EXPRESSION_INDEX);
      for (int contentIndex=nrGenes; contentIndex < contentVA.size(); contentIndex++) {
        SelectionDeltaItem item=new SelectionDeltaItem();
        item.setPrimaryID(contentVA.get(contentIndex));
        item.setSelectionType(GLHeatMap.SELECTION_HIDDEN);
        contentSelectionDelta.add(item);
      }
      SelectionUpdateEvent event=new SelectionUpdateEvent();
      event.setSender(this);
      event.setSelectionDelta(contentSelectionDelta);
      eventPublisher.triggerEvent(event);
    }
  }
  for (  Group group : selectedGroups.keySet()) {
    GLHeatMap heatMap=hashHeatMaps.get(group.getGroupIndex());
    heatMap.recalculateLayout();
  }
}