use of org.eclipse.draw2d.graph.EdgeList in project whole by wholeplatform.
the class GraphLayoutStrategy method applyLayout.
public void applyLayout(DirectedGraph graph) {
NodeList nodes = graph.nodes;
for (int i = 0; i < nodes.size(); i++) {
Node node = (Node) nodes.get(i);
GraphicalEditPart part = (GraphicalEditPart) node.data;
part.getFigure().setBounds(new Rectangle(node.x, node.y, node.width, node.height));
}
EdgeList edges = graph.edges;
for (int i = 0; i < edges.size(); i++) {
Edge edge = (Edge) edges.get(i);
ConnectionEditPart connectionPart = (ConnectionEditPart) edge.data;
nodes = edge.vNodes;
PolylineConnection conn = (PolylineConnection) connectionPart.getFigure();
if (nodes != null) {
List<AbsoluteBendpoint> bends = new ArrayList<AbsoluteBendpoint>();
for (int j = 0; j < nodes.size(); j++) {
Node vn = nodes.getNode(j);
if (edge.isFeedback) {
bends.add(new AbsoluteBendpoint(vn.x, vn.y + vn.height));
bends.add(new AbsoluteBendpoint(vn.x, vn.y));
} else {
bends.add(new AbsoluteBendpoint(vn.x, vn.y));
bends.add(new AbsoluteBendpoint(vn.x, vn.y + vn.height));
}
}
conn.setRoutingConstraint(bends);
} else
conn.setRoutingConstraint(Collections.EMPTY_LIST);
}
}
use of org.eclipse.draw2d.graph.EdgeList in project jbosstools-hibernate by jbosstools.
the class ClusterEdgeCreator method recursivelyAddToCluster.
private void recursivelyAddToCluster(Node node, int depth) {
if (depth > 3)
return;
else {
depth++;
EdgeList incoming = node.incoming;
for (Iterator<?> iter = incoming.iterator(); iter.hasNext(); ) {
Edge edge = (Edge) iter.next();
Node incomingNode = edge.source;
if (!encountered.contains(incomingNode)) {
encountered.add(incomingNode);
currentCluster.set.add(incomingNode);
// System.out.println("Adding to current cluster: " + incomingNode + ", cluster: " + currentCluster);
recursivelyAddToCluster(incomingNode, depth);
} else {
// System.out.println("Already encountered: " + incomingNode);
}
}
EdgeList outgoing = node.outgoing;
for (Iterator<?> iter = outgoing.iterator(); iter.hasNext(); ) {
Edge edge = (Edge) iter.next();
Node outgoingNode = edge.target;
if (!encountered.contains(outgoingNode)) {
encountered.add(outgoingNode);
currentCluster.set.add(outgoingNode);
// System.out.println("Adding to current cluster: " + outgoingNode + ", cluster: " + currentCluster);
recursivelyAddToCluster(outgoingNode, depth);
} else {
// System.out.println("Already encountered: " + outgoingNode);
}
}
}
}
Aggregations