@SuppressWarnings("unchecked") protected void setDummyEdges() { int nodeCount = nodeList.size(); // if node count is only one then we don't have to worry about whether // the nodes are connected if (nodeCount > 1) { NodeList candidateList = new NodeList(); for (Iterator<Node> iter = nodeList.iterator(); iter.hasNext(); ) { Node sourceNode = iter.next(); // we will need to set up a dummy relationship for any node not // in one already if (sourceNode.outgoing.size() == 0 && sourceNode.incoming.size() == 0) { candidateList.add(sourceNode); sourceNode.setRowConstraint(2); } else { sourceNode.setRowConstraint(1); } } if (candidateList.size() > 1) { int index = 0; while (index < candidateList.size() - 1) { Node sourceNode = candidateList.getNode(index++); Node targetNode = candidateList.getNode(index); newDummyEdge(targetNode, sourceNode); } } } }
private static EntityNode getNode(NodeList list, Table model) { for (int i = 0; i < list.size(); i++) { EntityNode node = (EntityNode) list.get(i); if (node.model == model) { return node; } } return null; }