new DirectedGraphLayout().visit(graph);
// Re-invert edges inverted while breaking cycles; this only seems to be required on earlier GEF versions
if (!SpringCoreUtils.isEclipseSameOrNewer(3, 6)) {
for (int i = 0; i < graph.edges.size(); i++) {
Edge e = graph.edges.getEdge(i);
if (e.isFeedback()) {
e.invert();
}
}
}
// Remove temporary root and root edges
for (int i = 0; i < rootEdges.size(); i++) {
Edge e = rootEdges.getEdge(i);
e.source.outgoing.remove(e);
e.target.incoming.remove(e);
graph.edges.remove(e);
}
graph.nodes.remove(root);
// Re-align nodes and edges' bend points topmost vertical position
int maxY = 0; // max height of graph
int maxX = 0; // max width of graph
int ranks = graph.ranks.size();
if (ranks > 1) {
int deltaY = graph.ranks.getRank(1).getNode(0).y;
Iterator nodes = graph.nodes.iterator();
while (nodes.hasNext()) {
Bean node = (Bean) nodes.next();
// Move node vertically and update max height
node.y -= deltaY;
if ((node.y + node.height) > maxY) {
maxY = node.y + node.height;
}
// Update max width
if ((node.x + node.width) > maxX) {
maxX = node.x + node.width;
}
}
Iterator edges = graph.edges.iterator();
while (edges.hasNext()) {
Edge edge = (Edge) edges.next();
if (edge.vNodes != null) {
Iterator points = edge.vNodes.iterator();
while (points.hasNext()) {
Node node = (Node) points.next();
node.y -= deltaY;