Program: 57532
Project: 57532
Buggy source:
@Override public void layout(Rectangle2D area){
  if (area == null)   return;
  Set<IDVINode> dataNodes=new HashSet<IDVINode>();
  Set<IDVINode> viewNodes=new HashSet<IDVINode>();
  Collection<IDVINode> nodes=graph.getNodes();
  int summedDataNodesWidthPixels=0;
  int summedViewNodesWidthPixels=0;
  maxDataNodeHeightPixels=Integer.MIN_VALUE;
  int maxViewNodeHeightPixels=Integer.MIN_VALUE;
  for (  IDVINode node : nodes) {
    if (node instanceof ADataNode) {
      dataNodes.add(node);
      summedDataNodesWidthPixels+=node.getWidthPixels();
      if (node.getHeightPixels() > maxDataNodeHeightPixels)       maxDataNodeHeightPixels=node.getHeightPixels();
    }
 else {
      viewNodes.add(node);
      summedViewNodesWidthPixels+=node.getWidthPixels();
      if (node.getHeightPixels() > maxViewNodeHeightPixels)       maxViewNodeHeightPixels=node.getHeightPixels();
    }
  }
  sortedDataNodes.clear();
  sortedViewNodes.clear();
  sortedViewNodes.addAll(viewNodes);
  relativeNodeXCoordinates.clear();
  List<Pair<String,IDVINode>> dataNodeSortingList=new ArrayList<Pair<String,IDVINode>>();
  for (  IDVINode dataNode : dataNodes) {
    dataNodeSortingList.add(new Pair<String,IDVINode>(dataNode.getCaption().toUpperCase(),dataNode));
  }
  Collections.sort(dataNodeSortingList);
  for (  Pair<String,IDVINode> pair : dataNodeSortingList) {
    sortedDataNodes.add(pair.getSecond());
  }
  applyBaryCenterReordering();
  float dataNodeSpacingPixels=(float)(area.getWidth() - summedDataNodesWidthPixels) / (float)(dataNodes.size() - 1);
  dataNodeSpacingPixels=Math.max(dataNodeSpacingPixels,MIN_NODE_SPACING_PIXELS);
  dataNodeSpacingPixels=Math.min(dataNodeSpacingPixels,MAX_NODE_SPACING_PIXELS);
  float currentDataNodePositionX=(float)Math.max((float)(area.getMinX() + (area.getWidth() - summedDataNodesWidthPixels - (dataNodes.size() - 1) * dataNodeSpacingPixels) / 2.0f),area.getMinX());
  maxBendPointOffsetYPixels=Integer.MIN_VALUE;
  for (  Edge edge : graph.getAllEdges()) {
    if (edge.getNode1() instanceof ADataNode && edge.getNode2() instanceof ADataNode) {
      int bendPointOffsetYPixels=insideLayerEdgeRoutingStrategy.calcEdgeBendPointYOffsetPixels(edge.getNode1(),edge.getNode2());
      if (bendPointOffsetYPixels > maxBendPointOffsetYPixels) {
        maxBendPointOffsetYPixels=bendPointOffsetYPixels;
      }
    }
  }
  boolean isUpsideDown=false;
  float dataNodesBottomY=0;
  float expandDirectorFactor=1;
  if (view.isRenderedRemote()) {
    isUpsideDown=false;
    dataNodesBottomY=(float)area.getMaxY();
    expandDirectorFactor=-1;
  }
 else {
    isUpsideDown=true;
    dataNodesBottomY=(float)area.getMinY() + maxBendPointOffsetYPixels;
  }
  for (  IDVINode node : sortedDataNodes) {
    if (!node.isCustomPosition()) {
      setNodePosition(node,new Point2D.Float(currentDataNodePositionX + node.getWidthPixels() / 2.0f,dataNodesBottomY + node.getHeightPixels() / 2.0f * expandDirectorFactor));
    }
    currentDataNodePositionX+=node.getWidthPixels() + dataNodeSpacingPixels;
    node.setUpsideDown(isUpsideDown);
  }
  float viewNodeSpacingPixels=(float)(area.getWidth() - summedViewNodesWidthPixels) / (float)(viewNodes.size() - 1);
  viewNodeSpacingPixels=Math.max(viewNodeSpacingPixels,MIN_NODE_SPACING_PIXELS);
  viewNodeSpacingPixels=Math.min(viewNodeSpacingPixels,MAX_NODE_SPACING_PIXELS);
  float currentViewNodePositionX=(float)Math.max((float)(area.getMinX() + (area.getWidth() - summedViewNodesWidthPixels - (viewNodes.size() - 1) * viewNodeSpacingPixels) / 2.0f),area.getMinX());
  float viewNodesTopY=(float)area.getHeight() + (float)area.getMinY();
  for (  IDVINode node : sortedViewNodes) {
    if (!node.isCustomPosition()) {
      setNodePosition(node,new Point2D.Float(currentViewNodePositionX + node.getWidthPixels() / 2.0f,viewNodesTopY - node.getHeightPixels() / 2.0f));
    }
    currentViewNodePositionX+=node.getWidthPixels() + viewNodeSpacingPixels;
  }
  for (  IDVINode node : graph.getNodes()) {
    Point2D position=getNodePosition(node);
    float relativePosX=(float)position.getX() / (float)area.getWidth();
    relativeNodeXCoordinates.put(node,relativePosX);
  }
}

Fixed version (ground truth):
@Override public void layout(Rectangle2D area){
  if (area == null)   return;
  Set<IDVINode> dataNodes=new HashSet<IDVINode>();
  Set<IDVINode> viewNodes=new HashSet<IDVINode>();
  Collection<IDVINode> nodes=graph.getNodes();
  int summedDataNodesWidthPixels=0;
  int summedViewNodesWidthPixels=0;
  maxDataNodeHeightPixels=Integer.MIN_VALUE;
  int maxViewNodeHeightPixels=Integer.MIN_VALUE;
  for (  IDVINode node : nodes) {
    if (node instanceof ADataNode) {
      dataNodes.add(node);
      summedDataNodesWidthPixels+=node.getWidthPixels();
      if (node.getHeightPixels() > maxDataNodeHeightPixels)       maxDataNodeHeightPixels=node.getHeightPixels();
    }
 else {
      viewNodes.add(node);
      summedViewNodesWidthPixels+=node.getWidthPixels();
      if (node.getHeightPixels() > maxViewNodeHeightPixels)       maxViewNodeHeightPixels=node.getHeightPixels();
    }
  }
  sortedDataNodes.clear();
  sortedViewNodes.clear();
  sortedViewNodes.addAll(viewNodes);
  relativeNodeXCoordinates.clear();
  List<Pair<String,IDVINode>> dataNodeSortingList=new ArrayList<Pair<String,IDVINode>>();
  for (  IDVINode dataNode : dataNodes) {
    dataNodeSortingList.add(new Pair<String,IDVINode>(dataNode.getCaption().toUpperCase(),dataNode));
  }
  Collections.sort(dataNodeSortingList);
  for (  Pair<String,IDVINode> pair : dataNodeSortingList) {
    sortedDataNodes.add(pair.getSecond());
  }
  applyBaryCenterReordering();
  float dataNodeSpacingPixels;
  if (dataNodes.size() == 1) {
    dataNodeSpacingPixels=0;
  }
 else {
    dataNodeSpacingPixels=(float)(area.getWidth() - summedDataNodesWidthPixels) / (float)(dataNodes.size() - 1);
  }
  dataNodeSpacingPixels=Math.max(dataNodeSpacingPixels,MIN_NODE_SPACING_PIXELS);
  dataNodeSpacingPixels=Math.min(dataNodeSpacingPixels,MAX_NODE_SPACING_PIXELS);
  float currentDataNodePositionX=(float)Math.max((float)(area.getMinX() + (area.getWidth() - summedDataNodesWidthPixels - (dataNodes.size() - 1) * dataNodeSpacingPixels) / 2.0f),area.getMinX());
  maxBendPointOffsetYPixels=0;
  for (  Edge edge : graph.getAllEdges()) {
    if (edge.getNode1() instanceof ADataNode && edge.getNode2() instanceof ADataNode) {
      int bendPointOffsetYPixels=insideLayerEdgeRoutingStrategy.calcEdgeBendPointYOffsetPixels(edge.getNode1(),edge.getNode2());
      if (bendPointOffsetYPixels > maxBendPointOffsetYPixels) {
        maxBendPointOffsetYPixels=bendPointOffsetYPixels;
      }
    }
  }
  boolean isUpsideDown=false;
  float dataNodesBottomY=0;
  float expandDirectorFactor=1;
  if (view.isRenderedRemote()) {
    isUpsideDown=false;
    dataNodesBottomY=(float)area.getMaxY();
    expandDirectorFactor=-1;
  }
 else {
    isUpsideDown=true;
    dataNodesBottomY=(float)area.getMinY() + maxBendPointOffsetYPixels;
  }
  for (  IDVINode node : sortedDataNodes) {
    if (!node.isCustomPosition()) {
      setNodePosition(node,new Point2D.Float(currentDataNodePositionX + node.getWidthPixels() / 2.0f,dataNodesBottomY + node.getHeightPixels() / 2.0f * expandDirectorFactor));
    }
    currentDataNodePositionX+=node.getWidthPixels() + dataNodeSpacingPixels;
    node.setUpsideDown(isUpsideDown);
  }
  float viewNodeSpacingPixels=(float)(area.getWidth() - summedViewNodesWidthPixels) / (float)(viewNodes.size() - 1);
  viewNodeSpacingPixels=Math.max(viewNodeSpacingPixels,MIN_NODE_SPACING_PIXELS);
  viewNodeSpacingPixels=Math.min(viewNodeSpacingPixels,MAX_NODE_SPACING_PIXELS);
  float currentViewNodePositionX=(float)Math.max((float)(area.getMinX() + (area.getWidth() - summedViewNodesWidthPixels - (viewNodes.size() - 1) * viewNodeSpacingPixels) / 2.0f),area.getMinX());
  float viewNodesTopY=(float)area.getHeight() + (float)area.getMinY();
  for (  IDVINode node : sortedViewNodes) {
    if (!node.isCustomPosition()) {
      setNodePosition(node,new Point2D.Float(currentViewNodePositionX + node.getWidthPixels() / 2.0f,viewNodesTopY - node.getHeightPixels() / 2.0f));
    }
    currentViewNodePositionX+=node.getWidthPixels() + viewNodeSpacingPixels;
  }
  for (  IDVINode node : graph.getNodes()) {
    Point2D position=getNodePosition(node);
    float relativePosX=(float)position.getX() / (float)area.getWidth();
    relativeNodeXCoordinates.put(node,relativePosX);
  }
}