use of org.eclipse.draw2d.AbsoluteBendpoint 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);
}
}
Aggregations