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();
}
}
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();
}
}
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;
}
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();
}
}
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;
}
Aggregations