Search in sources :

Example 6 with TreeLayoutAlgorithm

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();
    }
}
Also used : TreeLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm) Dimension(org.eclipse.draw2d.geometry.Dimension) LayoutEntity(org.eclipse.zest.layouts.LayoutEntity) Point(org.eclipse.draw2d.geometry.Point) LayoutRelationship(org.eclipse.zest.layouts.LayoutRelationship) InvalidLayoutConfiguration(org.eclipse.zest.layouts.InvalidLayoutConfiguration)

Aggregations

TreeLayoutAlgorithm (org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm)6 Dimension (org.eclipse.draw2d.geometry.Dimension)3 Point (org.eclipse.draw2d.geometry.Point)2 InvalidLayoutConfiguration (org.eclipse.zest.layouts.InvalidLayoutConfiguration)2 LayoutAlgorithm (org.eclipse.zest.layouts.LayoutAlgorithm)2 LayoutEntity (org.eclipse.zest.layouts.LayoutEntity)2 LayoutRelationship (org.eclipse.zest.layouts.LayoutRelationship)2 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)1 GraphMLReader (com.tinkerpop.blueprints.util.io.graphml.GraphMLReader)1 ReverseCellGraphContentProvider (eu.esdihumboldt.hale.ui.common.graph.content.ReverseCellGraphContentProvider)1 GraphLabelProvider (eu.esdihumboldt.hale.ui.common.graph.labels.GraphLabelProvider)1 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1