Program: 57738
Project: 57738
Buggy source:
/** 
 * Sets the list of nodes that are used as the basis for rendering the mapped data. Triggers a complete re-build of the layout. Creates the layout used for the rendering.
 * @param linearizedNodes setter, see  {@link #linearizedNodes}
 */
public void setLinearizedNodes(List<ALinearizableNode> linearizedNodes){
  float[] color;
  relationShipRenderers=new ArrayList<RelationshipRenderer>(linearizedNodes.size());
  Row baseRow=new Row("String_Node_Str");
  layoutManger.setBaseElementLayout(baseRow);
  Column dataSetColumn=new Column("String_Node_Str");
  dataSetColumn.setBottomUp(false);
  baseRow.append(dataSetColumn);
  Column captionColumn=new Column("String_Node_Str");
  captionColumn.setBottomUp(false);
  captionColumn.setPixelSizeX(100);
  baseRow.append(captionColumn);
  this.linearizedNodes=linearizedNodes;
  int nodeCount=0;
  float previousNodePosition=viewFrustum.getHeight() + yOffset;
  int previousNrDavids=0;
  ArrayList<ArrayList<Row>> rowListForDataContainers=new ArrayList<ArrayList<Row>>((int)(usedDataContainers.size() * 1.6));
  for (  DataContainer dataContainer : usedDataContainers) {
    rowListForDataContainers.add(new ArrayList<Row>(linearizedNodes.size() * 2));
  }
  ArrayList<Integer> davidIDs=new ArrayList<Integer>(linearizedNodes.size() * 2);
  ElementLayout xSpacing=new ElementLayout();
  xSpacing.setPixelSizeX(5);
  ArrayList<ALinearizableNode> resolvedNodes=new ArrayList<ALinearizableNode>();
  for (  ALinearizableNode node : linearizedNodes) {
    if (node instanceof ComplexNode) {
      List<ALinearizableNode> embeddedNodes=((ComplexNode)node).getNodes();
      resolvedNodes.addAll(embeddedNodes);
    }
 else     resolvedNodes.add(node);
  }
  for (  ALinearizableNode node : resolvedNodes) {
    if (node.getNumAssociatedRows() == 0)     continue;
    List<Integer> subDavidIDs=node.getDavidIDs();
    int currentNrDavids=subDavidIDs.size();
    davidIDs.addAll(subDavidIDs);
    float currentNodePositionY=node.getPosition().y();
    float deviation;
    if (node.getParentNode() != null) {
      currentNodePositionY=node.getParentNode().getPosition().y();
      currentNrDavids=node.getParentNode().getNumAssociatedRows();
    }
    float previousLowerHeight=previousNodePosition - rowHeight * ((float)previousNrDavids) / 2;
    float currentUpperHeight=(currentNodePositionY + rowHeight * ((float)currentNrDavids) / 2);
    deviation=previousLowerHeight - currentUpperHeight;
    if (previousNodePosition > 0 && deviation > 0) {
      Row spacing=new Row();
      spacing.setAbsoluteSizeY(deviation);
      dataSetColumn.append(spacing);
      captionColumn.append(spacing);
    }
    previousNodePosition=currentNodePositionY;
    previousNrDavids=currentNrDavids;
    if (nodeCount % 2 == 0)     color=EVEN_BACKGROUND_COLOR;
 else     color=ODD_BACKGROUND_COLOR;
    RelationshipRenderer relationShipRenderer=new RelationshipRenderer(color);
    relationShipRenderers.add(relationShipRenderer);
    float x=node.getPosition().x() + parentView.getPixelGLConverter().getGLWidthForPixelWidth(node.getWidthPixels()) / 2;
    float height=parentView.getPixelGLConverter().getGLHeightForPixelHeight(node.getHeightPixels());
    relationShipRenderer.topLeft[0]=x - xOffset;
    relationShipRenderer.topLeft[1]=node.getPosition().y() + height / 2 - yOffset;
    relationShipRenderer.bottomLeft[0]=x - xOffset;
    relationShipRenderer.bottomLeft[1]=node.getPosition().y() - height / 2 - yOffset;
    nodeCount++;
    int idCount=0;
    for (    Integer davidID : subDavidIDs) {
      Row row=new Row();
      RowBackgroundRenderer rowBackgroundRenderer=new RowBackgroundRenderer(color);
      row.addBackgroundRenderer(rowBackgroundRenderer);
      row.setAbsoluteSizeY(rowHeight);
      dataSetColumn.append(row);
      for (int dataContainerCount=0; dataContainerCount < usedDataContainers.size(); dataContainerCount++) {
        Row dataContainerRow=new Row("String_Node_Str" + dataContainerCount + "String_Node_Str"+ idCount);
        row.append(dataContainerRow);
        rowListForDataContainers.get(dataContainerCount).add(dataContainerRow);
        if (dataContainerCount != usedDataContainers.size() - 1) {
          row.append(xSpacing);
        }
      }
      ElementLayout rowCaption=new ElementLayout();
      rowCaption.setAbsoluteSizeY(rowHeight);
      RowCaptionRenderer captionRenderer=new RowCaptionRenderer(davidID,parentView,this,color);
      rowCaption.setRenderer(captionRenderer);
      captionColumn.append(rowCaption);
      if (idCount == 0)       relationShipRenderer.topRightLayout=row;
      if (idCount == subDavidIDs.size() - 1)       relationShipRenderer.bottomRightLayout=row;
      idCount++;
    }
  }
  ElementLayout ySpacing=new ElementLayout();
  ySpacing.setPixelSizeY(5);
  dataSetColumn.append(ySpacing);
  Row captionRow=new Row("String_Node_Str");
  captionRow.setPixelSizeY(40);
  dataSetColumn.append(captionRow);
  for (int dataContainerCount=0; dataContainerCount < usedDataContainers.size(); dataContainerCount++) {
    ElementLayout captionLayout=new ElementLayout("String_Node_Str");
    captionRow.append(captionLayout);
    if (dataContainerCount != usedDataContainers.size() - 1) {
      captionRow.append(xSpacing);
    }
    prepareData(usedDataContainers.get(dataContainerCount),rowListForDataContainers.get(dataContainerCount),captionLayout,davidIDs);
  }
}

Fixed version (ground truth):
/** 
 * Sets the list of nodes that are used as the basis for rendering the mapped data. Triggers a complete re-build of the layout. Creates the layout used for the rendering.
 * @param linearizedNodes setter, see  {@link #linearizedNodes}
 */
public void setLinearizedNodes(List<ALinearizableNode> linearizedNodes){
  float[] color;
  relationShipRenderers=new ArrayList<RelationshipRenderer>(linearizedNodes.size());
  Row baseRow=new Row("String_Node_Str");
  layoutManger.setBaseElementLayout(baseRow);
  Column dataSetColumn=new Column("String_Node_Str");
  dataSetColumn.setBottomUp(false);
  baseRow.append(dataSetColumn);
  Column captionColumn=new Column("String_Node_Str");
  captionColumn.setBottomUp(false);
  captionColumn.setPixelSizeX(100);
  baseRow.append(captionColumn);
  this.linearizedNodes=linearizedNodes;
  int nodeCount=0;
  float previousNodePosition=viewFrustum.getHeight() + yOffset;
  int previousNrDavids=0;
  ArrayList<ArrayList<Row>> rowListForDataContainers=new ArrayList<ArrayList<Row>>((int)(usedDataContainers.size() * 1.6));
  for (  DataContainer dataContainer : usedDataContainers) {
    rowListForDataContainers.add(new ArrayList<Row>(linearizedNodes.size() * 2));
  }
  ArrayList<Integer> davidIDs=new ArrayList<Integer>(linearizedNodes.size() * 2);
  ElementLayout xSpacing=new ElementLayout();
  xSpacing.setPixelSizeX(5);
  ArrayList<ALinearizableNode> resolvedNodes=new ArrayList<ALinearizableNode>();
  for (  ALinearizableNode node : linearizedNodes) {
    if (node instanceof ComplexNode) {
      List<ALinearizableNode> embeddedNodes=((ComplexNode)node).getNodes();
      resolvedNodes.addAll(embeddedNodes);
    }
 else     resolvedNodes.add(node);
  }
  for (  ALinearizableNode node : resolvedNodes) {
    if (node.getNumAssociatedRows() == 0)     continue;
    List<Integer> subDavidIDs=node.getMappedDavidIDs();
    int currentNrDavids=subDavidIDs.size();
    davidIDs.addAll(subDavidIDs);
    float currentNodePositionY=node.getPosition().y();
    float deviation;
    if (node.getParentNode() != null) {
      currentNodePositionY=node.getParentNode().getPosition().y();
      currentNrDavids=node.getParentNode().getNumAssociatedRows();
    }
    float previousLowerHeight=previousNodePosition - rowHeight * ((float)previousNrDavids) / 2;
    float currentUpperHeight=(currentNodePositionY + rowHeight * ((float)currentNrDavids) / 2);
    deviation=previousLowerHeight - currentUpperHeight;
    if (previousNodePosition > 0 && deviation > 0) {
      Row spacing=new Row();
      spacing.setAbsoluteSizeY(deviation);
      dataSetColumn.append(spacing);
      captionColumn.append(spacing);
    }
    previousNodePosition=currentNodePositionY;
    previousNrDavids=currentNrDavids;
    if (nodeCount % 2 == 0)     color=EVEN_BACKGROUND_COLOR;
 else     color=ODD_BACKGROUND_COLOR;
    RelationshipRenderer relationShipRenderer=new RelationshipRenderer(color);
    relationShipRenderers.add(relationShipRenderer);
    float x=node.getPosition().x() + parentView.getPixelGLConverter().getGLWidthForPixelWidth(node.getWidthPixels()) / 2;
    float height=parentView.getPixelGLConverter().getGLHeightForPixelHeight(node.getHeightPixels());
    relationShipRenderer.topLeft[0]=x - xOffset;
    relationShipRenderer.topLeft[1]=node.getPosition().y() + height / 2 - yOffset;
    relationShipRenderer.bottomLeft[0]=x - xOffset;
    relationShipRenderer.bottomLeft[1]=node.getPosition().y() - height / 2 - yOffset;
    nodeCount++;
    int idCount=0;
    for (    Integer davidID : subDavidIDs) {
      Row row=new Row();
      RowBackgroundRenderer rowBackgroundRenderer=new RowBackgroundRenderer(color);
      row.addBackgroundRenderer(rowBackgroundRenderer);
      row.setAbsoluteSizeY(rowHeight);
      dataSetColumn.append(row);
      for (int dataContainerCount=0; dataContainerCount < usedDataContainers.size(); dataContainerCount++) {
        Row dataContainerRow=new Row("String_Node_Str" + dataContainerCount + "String_Node_Str"+ idCount);
        row.append(dataContainerRow);
        rowListForDataContainers.get(dataContainerCount).add(dataContainerRow);
        if (dataContainerCount != usedDataContainers.size() - 1) {
          row.append(xSpacing);
        }
      }
      ElementLayout rowCaption=new ElementLayout();
      rowCaption.setAbsoluteSizeY(rowHeight);
      RowCaptionRenderer captionRenderer=new RowCaptionRenderer(davidID,parentView,this,color);
      rowCaption.setRenderer(captionRenderer);
      captionColumn.append(rowCaption);
      if (idCount == 0)       relationShipRenderer.topRightLayout=row;
      if (idCount == subDavidIDs.size() - 1)       relationShipRenderer.bottomRightLayout=row;
      idCount++;
    }
  }
  ElementLayout ySpacing=new ElementLayout();
  ySpacing.setPixelSizeY(5);
  dataSetColumn.append(ySpacing);
  Row captionRow=new Row("String_Node_Str");
  captionRow.setPixelSizeY(40);
  dataSetColumn.append(captionRow);
  for (int dataContainerCount=0; dataContainerCount < usedDataContainers.size(); dataContainerCount++) {
    ElementLayout captionLayout=new ElementLayout("String_Node_Str");
    captionRow.append(captionLayout);
    if (dataContainerCount != usedDataContainers.size() - 1) {
      captionRow.append(xSpacing);
    }
    prepareData(usedDataContainers.get(dataContainerCount),rowListForDataContainers.get(dataContainerCount),captionLayout,davidIDs);
  }
}