Search in sources :

Example 6 with LayoutRelationship

use of org.eclipse.zest.layouts.LayoutRelationship in project archi by archimatetool.

the class AbstractLayoutAlgorithm method clearBendPoints.

/**
 * Clear out all old bend points before doing a layout
 */
private void clearBendPoints(LayoutRelationship[] relationships) {
    for (int i = 0; i < relationships.length; i++) {
        LayoutRelationship rel = relationships[i];
        rel.clearBendPoints();
    }
}
Also used : BasicEntityConstraint(org.eclipse.zest.layouts.constraints.BasicEntityConstraint) BendPoint(org.eclipse.zest.layouts.dataStructures.BendPoint) DisplayIndependentPoint(org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint) LayoutRelationship(org.eclipse.zest.layouts.LayoutRelationship)

Example 7 with LayoutRelationship

use of org.eclipse.zest.layouts.LayoutRelationship in project archi by archimatetool.

the class Graph method applyLayoutInternal.

private void applyLayoutInternal() {
    hasPendingLayoutRequest = false;
    if ((this.getNodes().size() == 0)) {
        return;
    }
    int layoutStyle = 0;
    if ((nodeStyle & ZestStyles.NODES_NO_LAYOUT_RESIZE) > 0) {
        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.getViewport().getSize();
    d.width = d.width - 10;
    d.height = d.height - 10;
    if (this.preferredSize.width >= 0) {
        d.width = preferredSize.width;
    }
    if (this.preferredSize.height >= 0) {
        d.height = preferredSize.height;
    }
    if (d.isEmpty()) {
        return;
    }
    LayoutRelationship[] connectionsToLayout = getConnectionsToLayout(nodes);
    LayoutEntity[] nodesToLayout = getNodesToLayout(getNodes());
    try {
        if ((nodeStyle & ZestStyles.NODES_NO_LAYOUT_ANIMATION) == 0 && animationEnabled) {
            Animation.markBegin();
        }
        layoutAlgorithm.applyLayout(nodesToLayout, connectionsToLayout, 0, 0, d.width, d.height, false, false);
        if ((nodeStyle & ZestStyles.NODES_NO_LAYOUT_ANIMATION) == 0 && animationEnabled) {
            Animation.run(animationTime);
        }
        getLightweightSystem().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) LayoutConstraint(org.eclipse.zest.layouts.constraints.LayoutConstraint) LayoutRelationship(org.eclipse.zest.layouts.LayoutRelationship) InvalidLayoutConfiguration(org.eclipse.zest.layouts.InvalidLayoutConfiguration)

Example 8 with LayoutRelationship

use of org.eclipse.zest.layouts.LayoutRelationship in project archi by archimatetool.

the class Graph method getConnectionsToLayout.

LayoutRelationship[] getConnectionsToLayout(List nodesToLayout) {
    // @tag zest.bug.156528-Filters.follows : make sure not to layout
    // filtered connections, if the style says so.
    LayoutRelationship[] entities;
    if (ZestStyles.checkStyle(style, ZestStyles.IGNORE_INVISIBLE_LAYOUT)) {
        LinkedList connectionList = new LinkedList();
        for (Iterator i = this.getConnections().iterator(); i.hasNext(); ) {
            GraphConnection next = (GraphConnection) i.next();
            if (next.isVisible() && nodesToLayout.contains(next.getSource()) && nodesToLayout.contains(next.getDestination())) {
                connectionList.add(next.getLayoutRelationship());
            }
        }
        entities = (LayoutRelationship[]) connectionList.toArray(new LayoutRelationship[] {});
    } else {
        LinkedList nodeList = new LinkedList();
        for (Iterator i = this.getConnections().iterator(); i.hasNext(); ) {
            GraphConnection next = (GraphConnection) i.next();
            if (nodesToLayout.contains(next.getSource()) && nodesToLayout.contains(next.getDestination())) {
                nodeList.add(next.getLayoutRelationship());
            }
        }
        entities = (LayoutRelationship[]) nodeList.toArray(new LayoutRelationship[] {});
    }
    return entities;
}
Also used : Iterator(java.util.Iterator) LinkedList(java.util.LinkedList) LayoutRelationship(org.eclipse.zest.layouts.LayoutRelationship)

Example 9 with LayoutRelationship

use of org.eclipse.zest.layouts.LayoutRelationship 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)

Example 10 with LayoutRelationship

use of org.eclipse.zest.layouts.LayoutRelationship in project archi by archimatetool.

the class AbstractLayoutAlgorithm method verifyInput.

/**
 * Verifies the endpoints of the relationships are entities in the entitiesToLayout list.
 * Allows other classes in this package to use this method to verify the input
 */
public static boolean verifyInput(LayoutEntity[] entitiesToLayout, LayoutRelationship[] relationshipsToConsider) {
    boolean stillValid = true;
    for (int i = 0; i < relationshipsToConsider.length; i++) {
        LayoutRelationship relationship = relationshipsToConsider[i];
        LayoutEntity source = relationship.getSourceInLayout();
        LayoutEntity destination = relationship.getDestinationInLayout();
        boolean containsSrc = false;
        boolean containsDest = false;
        int j = 0;
        while (j < entitiesToLayout.length && !(containsSrc && containsDest)) {
            if (entitiesToLayout[j].equals(source)) {
                containsSrc = true;
            }
            if (entitiesToLayout[j].equals(destination)) {
                containsDest = true;
            }
            j++;
        }
        stillValid = containsSrc && containsDest;
    }
    return stillValid;
}
Also used : LayoutEntity(org.eclipse.zest.layouts.LayoutEntity) BasicEntityConstraint(org.eclipse.zest.layouts.constraints.BasicEntityConstraint) BendPoint(org.eclipse.zest.layouts.dataStructures.BendPoint) DisplayIndependentPoint(org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint) LayoutRelationship(org.eclipse.zest.layouts.LayoutRelationship)

Aggregations

LayoutRelationship (org.eclipse.zest.layouts.LayoutRelationship)11 LayoutEntity (org.eclipse.zest.layouts.LayoutEntity)6 InvalidLayoutConfiguration (org.eclipse.zest.layouts.InvalidLayoutConfiguration)4 BasicEntityConstraint (org.eclipse.zest.layouts.constraints.BasicEntityConstraint)4 BendPoint (org.eclipse.zest.layouts.dataStructures.BendPoint)4 DisplayIndependentPoint (org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint)4 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)2 List (java.util.List)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 Point (org.eclipse.draw2d.geometry.Point)2 LayoutBendPoint (org.eclipse.zest.layouts.LayoutBendPoint)2 TreeLayoutAlgorithm (org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm)2 InternalRelationship (org.eclipse.zest.layouts.dataStructures.InternalRelationship)2 ProgressEvent (org.eclipse.zest.layouts.progress.ProgressEvent)2 ProgressListener (org.eclipse.zest.layouts.progress.ProgressListener)2 Cursor (java.awt.Cursor)1 Point (java.awt.Point)1 Hashtable (java.util.Hashtable)1 LinkedList (java.util.LinkedList)1