use of org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm in project archi by archimatetool.
the class GraphContainer method applyLayout.
@Override
public void applyLayout() {
if ((this.getNodes().size() == 0)) {
return;
}
int layoutStyle = 0;
if (checkStyle(ZestStyles.NODES_NO_LAYOUT_RESIZE)) {
layoutStyle = LayoutStyles.NO_LAYOUT_NODE_RESIZING;
}
if (layoutAlgorithm == null) {
layoutAlgorithm = new TreeLayoutAlgorithm(layoutStyle);
}
layoutAlgorithm.setStyle(layoutAlgorithm.getStyle() | layoutStyle);
// calculate the size for the layout algorithm
// Dimension d = this.scalledLayer.getSize();
Dimension d = new Dimension();
d.width = (int) scaledWidth;
d.height = (int) scaledHeight;
d.width = d.width - 10;
d.height = d.height - 10;
if (d.isEmpty()) {
return;
}
LayoutRelationship[] connectionsToLayout = getGraph().getConnectionsToLayout(getNodes());
LayoutEntity[] nodesToLayout = getGraph().getNodesToLayout(getNodes());
try {
Animation.markBegin();
layoutAlgorithm.applyLayout(nodesToLayout, connectionsToLayout, 25, 25, d.width - 50, d.height - 50, false, false);
Animation.run(ANIMATION_TIME);
getFigure().getUpdateManager().performUpdate();
} catch (InvalidLayoutConfiguration e) {
e.printStackTrace();
}
}
Aggregations