// Difference from DGLA; use the unmodified Draw2D DirectedGraph since
// the extended one from the superclass does not handle the horizontal
// use case properly.
DirectedGraph graph = new DirectedGraph();
for (InternalNode internalNode : entitiesToLayout) {
Node node = new Node(internalNode);
// Difference from DGLA; get the height/width from the InternalNode
// and apply it to the Draw2D Node. Take orientation into account.
int height = new Double(internalNode.getHeightInLayout()).intValue();
int width = new Double(internalNode.getWidthInLayout()).intValue();
if ((layout_styles & SWT.HORIZONTAL) == SWT.HORIZONTAL) {
node.setSize(new Dimension(height, width));
}
else {
node.setSize(new Dimension(width, height));
}
// End difference from DGLA
mapping.put(internalNode, node);
graph.nodes.add(node);
}
for (InternalRelationship relationship : relationshipsToConsider) {
Node source = (Node) mapping.get(relationship.getSource());
Node dest = (Node) mapping.get(relationship.getDestination());
if (source != null && dest != null) {
Edge edge = new Edge(relationship, source, dest);
graph.edges.add(edge);
}
}
DirectedGraphLayout directedGraphLayout = new DirectedGraphLayout();
directedGraphLayout.visit(graph);
for (Iterator iterator = graph.nodes.iterator(); iterator.hasNext();) {
Node node = (Node) iterator.next();
InternalNode internalNode = (InternalNode) node.data;
// For horizontal layout transpose the x and y coordinates
if ((layout_styles & SWT.HORIZONTAL) == SWT.HORIZONTAL) {
internalNode.setInternalLocation(node.y, node.x);
}