use of org.eclipse.draw2d.graph.DirectedGraph in project jbosstools-hibernate by jbosstools.
the class DirectedGraphLayoutVisitor method layoutDiagram.
/**
* Public method for reading graph nodes
*/
public void layoutDiagram(ConfigurationEditPart diagram) {
partToNodesMap = new HashMap<AbstractGraphicalEditPart, Object>();
addedAssociations = new HashSet<AssociationEditPart>();
graph = new DirectedGraph();
addNodes(diagram);
if (graph.nodes.size() > 0) {
addEdges(diagram);
new NodeJoiningDirectedGraphLayout().visit(graph);
applyResults(diagram);
}
}
use of org.eclipse.draw2d.graph.DirectedGraph in project archi by archimatetool.
the class DirectedGraphLayoutAlgorithm method applyLayoutInternal.
@Override
protected void applyLayoutInternal(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider, double boundsX, double boundsY, double boundsWidth, double boundsHeight) {
HashMap mapping = new HashMap(entitiesToLayout.length);
DirectedGraph graph = new DirectedGraph();
for (int i = 0; i < entitiesToLayout.length; i++) {
InternalNode internalNode = entitiesToLayout[i];
Node node = new Node(internalNode);
node.setSize(new Dimension(10, 10));
mapping.put(internalNode, node);
graph.nodes.add(node);
}
for (int i = 0; i < relationshipsToConsider.length; i++) {
InternalRelationship relationship = relationshipsToConsider[i];
Node source = (Node) mapping.get(relationship.getSource());
Node dest = (Node) mapping.get(relationship.getDestination());
Edge edge = new Edge(relationship, source, dest);
graph.edges.add(edge);
}
DirectedGraphLayout directedGraphLayout = new ExtendedDirectedGraphLayout();
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);
} else {
internalNode.setInternalLocation(node.x, node.y);
}
}
updateLayoutLocations(entitiesToLayout);
}
Aggregations