Program: 56768
Project: 56768
Buggy source:
private void createLayout(LayoutManager layoutManager,boolean isHighlightLayout){
  Row baseRow=new Row("String_Node_Str");
  layoutManager.setBaseElementLayout(baseRow);
  if ((contextualTablePerspectives == null || contextualTablePerspectives.isEmpty()) && (geneTablePerspectives == null || geneTablePerspectives.isEmpty()))   return;
  ElementLayout xSpacing=new ElementLayout();
  xSpacing.setPixelSizeX(SPACING_PIXEL_WIDTH);
  float[] color;
  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(CAPTION_COLUMN_PIXEL_WIDTH);
  Row buttonRow=new Row("String_Node_Str");
  buttonRow.setPixelSizeY(50);
  buttonRow.append(createButton(EPickingType.FIT_TO_VIEW_WIDTH_BUTTON.name(),0,"String_Node_Str"));
  buttonRow.append(xSpacing);
  buttonRow.append(createButton(EPickingType.CENTER_LINE_ALIGNMENT_BUTTON.name(),0,"String_Node_Str"));
  captionColumn.append(buttonRow);
  baseRow.append(captionColumn);
  int nodeCount=0;
  float previousNodePosition=viewFrustum.getHeight() + yOffset - parentView.getPixelGLConverter().getGLHeightForPixelHeight(50);
  int previousNrDavids=0;
  ArrayList<ArrayList<ElementLayout>> rowListForContextTablePerspectives=new ArrayList<ArrayList<ElementLayout>>();
  List<Integer> contextRowIDs=new ArrayList<>();
  if (contextualTablePerspectives != null && !contextualTablePerspectives.isEmpty()) {
    int bottomYSpacing=10;
    for (int count=0; count < contextualTablePerspectives.get(0).size(); count++) {
      rowListForContextTablePerspectives.add(new ArrayList<ElementLayout>());
    }
    int numContextRows=0;
    for (    List<TablePerspective> resolvedContextPerspectives : contextualTablePerspectives) {
      TablePerspective contextTPerspective=resolvedContextPerspectives.get(0);
      IDType contextRowIDType=contextTPerspective.getDataDomain().getOppositeIDType(sampleIDType);
      VirtualArray va=contextTPerspective.getPerspective(contextRowIDType).getVirtualArray();
      for (      Integer rowID : va) {
        contextRowIDs.add(rowID);
        if (numContextRows % 2 == 0)         color=EVEN_BACKGROUND_COLOR;
 else         color=ODD_BACKGROUND_COLOR;
        Row row=new Row("String_Node_Str" + numContextRows);
        row.setAbsoluteSizeY(rowHeight);
        dataSetColumn.append(row);
        for (int tablePerspectiveCount=0; tablePerspectiveCount < contextualTablePerspectives.get(0).size(); tablePerspectiveCount++) {
          ElementLayout tablePerspectiveLayout=new ElementLayout("String_Node_Str" + tablePerspectiveCount + "String_Node_Str"+ numContextRows);
          if (!isHighlightLayout) {
            tablePerspectiveLayout.addBackgroundRenderer(new RowBackgroundRenderer(color));
          }
          row.append(tablePerspectiveLayout);
          rowListForContextTablePerspectives.get(tablePerspectiveCount).add(tablePerspectiveLayout);
          if (tablePerspectiveCount != contextualTablePerspectives.size() - 1) {
            row.append(xSpacing);
          }
        }
        ElementLayout rowCaption=new ElementLayout("String_Node_Str");
        rowCaption.setAbsoluteSizeY(rowHeight);
        if (isHighlightLayout) {
          if (va.size() == 1) {
            rowCaption.setRenderer(new RowCaptionRenderer(contextRowIDType,rowID,parentView,this,color,contextTPerspective.getPerspective(contextRowIDType).getLabel()));
          }
 else {
            rowCaption.setRenderer(new RowCaptionRenderer(contextRowIDType,rowID,parentView,this,color));
          }
        }
        captionColumn.append(rowCaption);
        numContextRows++;
      }
    }
    PathSizeConfiguration newConfig=new PathSizeConfiguration.Builder(parentView.getPathRenderer().getSizeConfig()).pathStartSpacing(parentView.getPixelGLConverter().getPixelHeightForGLHeight(rowHeight) * numContextRows + defaultSpacing + bottomYSpacing).build();
    parentView.getPathRenderer().setSizeConfig(newConfig);
    previousNodePosition=0;
    ElementLayout spacing=new ElementLayout();
    spacing.setPixelSizeY(bottomYSpacing);
    dataSetColumn.append(spacing);
    captionColumn.append(spacing);
  }
  ArrayList<ArrayList<ElementLayout>> rowListForTablePerspectives=new ArrayList<ArrayList<ElementLayout>>(geneTablePerspectives.size());
  for (int count=0; count < geneTablePerspectives.size(); count++) {
    rowListForTablePerspectives.add(new ArrayList<ElementLayout>(linearizedNodes.size() * 2));
  }
  IDType davidIDType=IDType.getIDType("String_Node_Str");
  ArrayList<Integer> davidIDs=new ArrayList<Integer>(linearizedNodes.size() * 2);
  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.getMappedDavidIDs().size() == 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().getMappedDavidIDs().size();
    }
    float previousLowerHeight=previousNodePosition - rowHeight * (previousNrDavids) / 2;
    float currentUpperHeight=(currentNodePositionY + rowHeight * (currentNrDavids) / 2);
    deviation=previousLowerHeight - currentUpperHeight;
    if (previousNodePosition > 0 && deviation > 0) {
      ElementLayout spacing=new ElementLayout("String_Node_Str");
      spacing.setFrameColor(0,0,1,0.8f);
      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=null;
    if (!isHighlightLayout) {
      relationShipRenderer=new RelationshipRenderer(color,parentView);
      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("String_Node_Str" + davidID);
      row.setAbsoluteSizeY(rowHeight);
      dataSetColumn.append(row);
      for (int tablePerspectiveCount=0; tablePerspectiveCount < geneTablePerspectives.size(); tablePerspectiveCount++) {
        ElementLayout tablePerspectiveLayout=new ElementLayout("String_Node_Str" + tablePerspectiveCount + "String_Node_Str"+ idCount);
        if (!isHighlightLayout) {
          tablePerspectiveLayout.addBackgroundRenderer(new RowBackgroundRenderer(color));
        }
        row.append(tablePerspectiveLayout);
        rowListForTablePerspectives.get(tablePerspectiveCount).add(tablePerspectiveLayout);
        if (tablePerspectiveCount != geneTablePerspectives.size() - 1) {
          row.append(xSpacing);
        }
      }
      ElementLayout rowCaption=new ElementLayout();
      rowCaption.setAbsoluteSizeY(rowHeight);
      if (isHighlightLayout) {
        RowCaptionRenderer captionRenderer=new RowCaptionRenderer(davidIDType,davidID,parentView,this,color);
        rowCaption.setRenderer(captionRenderer);
      }
      captionColumn.append(rowCaption);
      if (!isHighlightLayout) {
        if (relationShipRenderer == null) {
          throw new IllegalStateException("String_Node_Str");
        }
 else {
          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 topCaptionRow=new Row("String_Node_Str");
  topCaptionRow.setPixelSizeY(50);
  dataSetColumn.add(0,topCaptionRow);
  Row bottomCaptionRow=new Row("String_Node_Str");
  bottomCaptionRow.setPixelSizeY(50);
  dataSetColumn.append(bottomCaptionRow);
  for (int tablePerspectiveCount=0; tablePerspectiveCount < geneTablePerspectives.size(); tablePerspectiveCount++) {
    if (contextualTablePerspectives != null && contextualTablePerspectives.size() > 0) {
      for (      List<TablePerspective> resolvedContextTablePerspectives : contextualTablePerspectives) {
        TablePerspective contextTablePerspective=resolvedContextTablePerspectives.get(tablePerspectiveCount);
        prepareData(contextTablePerspective,rowListForContextTablePerspectives.get(tablePerspectiveCount),null,null,contextTablePerspective.getDataDomain().getOppositeIDType(sampleIDType),contextRowIDs,isHighlightLayout,geneTablePerspectives.get(tablePerspectiveCount));
      }
    }
    ColumnCaptionLayout topCaptionLayout=new ColumnCaptionLayout(parentView,this);
    topCaptionRow.append(topCaptionLayout);
    ColumnCaptionLayout bottomCaptionLayout=new ColumnCaptionLayout(parentView,this);
    bottomCaptionRow.append(bottomCaptionLayout);
    if (tablePerspectiveCount != geneTablePerspectives.size() - 1) {
      bottomCaptionRow.append(xSpacing);
      topCaptionRow.append(xSpacing);
    }
    prepareData(geneTablePerspectives.get(tablePerspectiveCount),rowListForTablePerspectives.get(tablePerspectiveCount),topCaptionLayout,bottomCaptionLayout,davidIDType,davidIDs,isHighlightLayout,null);
  }
  calcMinWidthPixels();
  PixelGLConverter pixelGLConverter=parentView.getPixelGLConverter();
  float minWidth=pixelGLConverter.getGLWidthForPixelWidth(minWidthPixels);
  if (!parentView.isFitWidthToScreen() && viewFrustum.getWidth() < minWidth) {
    viewFrustum.setRight(minWidth);
  }
}

Fixed version (ground truth):
private void createLayout(LayoutManager layoutManager,boolean isHighlightLayout){
  Row baseRow=new Row("String_Node_Str");
  layoutManager.setBaseElementLayout(baseRow);
  if ((contextualTablePerspectives == null || contextualTablePerspectives.isEmpty()) && (geneTablePerspectives == null || geneTablePerspectives.isEmpty()))   return;
  ElementLayout xSpacing=new ElementLayout();
  xSpacing.setPixelSizeX(SPACING_PIXEL_WIDTH);
  float[] color;
  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(CAPTION_COLUMN_PIXEL_WIDTH);
  Row buttonRow=new Row("String_Node_Str");
  buttonRow.setPixelSizeY(50);
  buttonRow.append(createButton(EPickingType.FIT_TO_VIEW_WIDTH_BUTTON.name(),0,"String_Node_Str"));
  buttonRow.append(xSpacing);
  buttonRow.append(createButton(EPickingType.CENTER_LINE_ALIGNMENT_BUTTON.name(),0,"String_Node_Str"));
  captionColumn.append(buttonRow);
  baseRow.append(captionColumn);
  int nodeCount=0;
  float previousNodePosition=viewFrustum.getHeight() + yOffset - parentView.getPixelGLConverter().getGLHeightForPixelHeight(50);
  int previousNrDavids=0;
  Map<TablePerspective,List<ElementLayout>> rowsForContextTablePerspectives=new HashMap<>();
  Map<TablePerspective,List<Integer>> contextRowIDs=new HashMap<>();
  if (contextualTablePerspectives != null && !contextualTablePerspectives.isEmpty()) {
    int bottomYSpacing=10;
    int numContextRows=0;
    for (int tpRowIndex=0; tpRowIndex < contextualTablePerspectives.size(); tpRowIndex++) {
      List<TablePerspective> resolvedContextPerspectives=contextualTablePerspectives.get(tpRowIndex);
      TablePerspective contextTPerspective=resolvedContextPerspectives.get(0);
      IDType contextRowIDType=contextTPerspective.getDataDomain().getOppositeIDType(sampleIDType);
      VirtualArray va=contextTPerspective.getPerspective(contextRowIDType).getVirtualArray();
      List<Integer> ids=new ArrayList<>();
      for (      TablePerspective tp : resolvedContextPerspectives) {
        contextRowIDs.put(tp,ids);
      }
      for (      Integer rowID : va) {
        ids.add(rowID);
        if (numContextRows % 2 == 0)         color=EVEN_BACKGROUND_COLOR;
 else         color=ODD_BACKGROUND_COLOR;
        Row row=new Row("String_Node_Str" + numContextRows);
        row.setAbsoluteSizeY(rowHeight);
        dataSetColumn.append(row);
        for (int tablePerspectiveCount=0; tablePerspectiveCount < contextualTablePerspectives.get(0).size(); tablePerspectiveCount++) {
          ElementLayout tablePerspectiveLayout=new ElementLayout("String_Node_Str" + tablePerspectiveCount + "String_Node_Str"+ numContextRows);
          if (!isHighlightLayout) {
            tablePerspectiveLayout.addBackgroundRenderer(new RowBackgroundRenderer(color));
          }
          row.append(tablePerspectiveLayout);
          TablePerspective tp=contextualTablePerspectives.get(tpRowIndex).get(tablePerspectiveCount);
          List<ElementLayout> layouts=rowsForContextTablePerspectives.get(tp);
          if (layouts == null) {
            layouts=new ArrayList<>();
            rowsForContextTablePerspectives.put(tp,layouts);
          }
          layouts.add(tablePerspectiveLayout);
          if (tablePerspectiveCount != contextualTablePerspectives.size() - 1) {
            row.append(xSpacing);
          }
        }
        ElementLayout rowCaption=new ElementLayout("String_Node_Str");
        rowCaption.setAbsoluteSizeY(rowHeight);
        if (isHighlightLayout) {
          if (va.size() == 1) {
            rowCaption.setRenderer(new RowCaptionRenderer(contextRowIDType,rowID,parentView,this,color,contextTPerspective.getPerspective(contextRowIDType).getLabel()));
          }
 else {
            rowCaption.setRenderer(new RowCaptionRenderer(contextRowIDType,rowID,parentView,this,color));
          }
        }
        captionColumn.append(rowCaption);
        numContextRows++;
      }
    }
    PathSizeConfiguration newConfig=new PathSizeConfiguration.Builder(parentView.getPathRenderer().getSizeConfig()).pathStartSpacing(parentView.getPixelGLConverter().getPixelHeightForGLHeight(rowHeight) * numContextRows + defaultSpacing + bottomYSpacing).build();
    parentView.getPathRenderer().setSizeConfig(newConfig);
    previousNodePosition=0;
    ElementLayout spacing=new ElementLayout();
    spacing.setPixelSizeY(bottomYSpacing);
    dataSetColumn.append(spacing);
    captionColumn.append(spacing);
  }
  ArrayList<ArrayList<ElementLayout>> rowListForTablePerspectives=new ArrayList<ArrayList<ElementLayout>>(geneTablePerspectives.size());
  for (int count=0; count < geneTablePerspectives.size(); count++) {
    rowListForTablePerspectives.add(new ArrayList<ElementLayout>(linearizedNodes.size() * 2));
  }
  IDType davidIDType=IDType.getIDType("String_Node_Str");
  ArrayList<Integer> davidIDs=new ArrayList<Integer>(linearizedNodes.size() * 2);
  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.getMappedDavidIDs().size() == 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().getMappedDavidIDs().size();
    }
    float previousLowerHeight=previousNodePosition - rowHeight * (previousNrDavids) / 2;
    float currentUpperHeight=(currentNodePositionY + rowHeight * (currentNrDavids) / 2);
    deviation=previousLowerHeight - currentUpperHeight;
    if (previousNodePosition > 0 && deviation > 0) {
      ElementLayout spacing=new ElementLayout("String_Node_Str");
      spacing.setFrameColor(0,0,1,0.8f);
      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=null;
    if (!isHighlightLayout) {
      relationShipRenderer=new RelationshipRenderer(color,parentView);
      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("String_Node_Str" + davidID);
      row.setAbsoluteSizeY(rowHeight);
      dataSetColumn.append(row);
      for (int tablePerspectiveCount=0; tablePerspectiveCount < geneTablePerspectives.size(); tablePerspectiveCount++) {
        ElementLayout tablePerspectiveLayout=new ElementLayout("String_Node_Str" + tablePerspectiveCount + "String_Node_Str"+ idCount);
        if (!isHighlightLayout) {
          tablePerspectiveLayout.addBackgroundRenderer(new RowBackgroundRenderer(color));
        }
        row.append(tablePerspectiveLayout);
        rowListForTablePerspectives.get(tablePerspectiveCount).add(tablePerspectiveLayout);
        if (tablePerspectiveCount != geneTablePerspectives.size() - 1) {
          row.append(xSpacing);
        }
      }
      ElementLayout rowCaption=new ElementLayout();
      rowCaption.setAbsoluteSizeY(rowHeight);
      if (isHighlightLayout) {
        RowCaptionRenderer captionRenderer=new RowCaptionRenderer(davidIDType,davidID,parentView,this,color);
        rowCaption.setRenderer(captionRenderer);
      }
      captionColumn.append(rowCaption);
      if (!isHighlightLayout) {
        if (relationShipRenderer == null) {
          throw new IllegalStateException("String_Node_Str");
        }
 else {
          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 topCaptionRow=new Row("String_Node_Str");
  topCaptionRow.setPixelSizeY(50);
  dataSetColumn.add(0,topCaptionRow);
  Row bottomCaptionRow=new Row("String_Node_Str");
  bottomCaptionRow.setPixelSizeY(50);
  dataSetColumn.append(bottomCaptionRow);
  for (int tablePerspectiveCount=0; tablePerspectiveCount < geneTablePerspectives.size(); tablePerspectiveCount++) {
    if (contextualTablePerspectives != null && contextualTablePerspectives.size() > 0) {
      for (      List<TablePerspective> resolvedContextTablePerspectives : contextualTablePerspectives) {
        TablePerspective contextTablePerspective=resolvedContextTablePerspectives.get(tablePerspectiveCount);
        prepareData(contextTablePerspective,rowsForContextTablePerspectives.get(contextTablePerspective),null,null,contextTablePerspective.getDataDomain().getOppositeIDType(sampleIDType),contextRowIDs.get(contextTablePerspective),isHighlightLayout,geneTablePerspectives.get(tablePerspectiveCount));
      }
    }
    ColumnCaptionLayout topCaptionLayout=new ColumnCaptionLayout(parentView,this);
    topCaptionRow.append(topCaptionLayout);
    ColumnCaptionLayout bottomCaptionLayout=new ColumnCaptionLayout(parentView,this);
    bottomCaptionRow.append(bottomCaptionLayout);
    if (tablePerspectiveCount != geneTablePerspectives.size() - 1) {
      bottomCaptionRow.append(xSpacing);
      topCaptionRow.append(xSpacing);
    }
    prepareData(geneTablePerspectives.get(tablePerspectiveCount),rowListForTablePerspectives.get(tablePerspectiveCount),topCaptionLayout,bottomCaptionLayout,davidIDType,davidIDs,isHighlightLayout,null);
  }
  calcMinWidthPixels();
  PixelGLConverter pixelGLConverter=parentView.getPixelGLConverter();
  float minWidth=pixelGLConverter.getGLWidthForPixelWidth(minWidthPixels);
  if (!parentView.isFitWidthToScreen() && viewFrustum.getWidth() < minWidth) {
    viewFrustum.setRight(minWidth);
  }
}