Search in sources :

Example 1 with BasicEntityConstraint

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

the class SimpleNode method populateLayoutConstraint.

/**
 * Populate the specified layout constraint
 */
@Override
public void populateLayoutConstraint(LayoutConstraint constraint) {
    if (constraint instanceof LabelLayoutConstraint) {
        LabelLayoutConstraint labelConstraint = (LabelLayoutConstraint) constraint;
        labelConstraint.label = realObject.toString();
        labelConstraint.pointSize = 18;
    } else if (constraint instanceof BasicEntityConstraint) {
    // noop
    } else if (constraint instanceof EntityPriorityConstraint) {
        EntityPriorityConstraint priorityConstraint = (EntityPriorityConstraint) constraint;
        priorityConstraint.priority = Math.random() * 10 + 1;
    }
}
Also used : EntityPriorityConstraint(org.eclipse.zest.layouts.constraints.EntityPriorityConstraint) LabelLayoutConstraint(org.eclipse.zest.layouts.constraints.LabelLayoutConstraint) BasicEntityConstraint(org.eclipse.zest.layouts.constraints.BasicEntityConstraint)

Example 2 with BasicEntityConstraint

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

the class AbstractLayoutAlgorithm method createInternalNodes.

// public void run() {
// 
// if (started == true) {
// throw new RuntimeException("Layout has already run!");
// }
// started = true;
// //layoutStopped = false;
// isLayoutPaused = false;
// applyLayoutInternal(internalNodes, internalRelationships, internalX, internalY, internalWidth, internalHeight);
// stop();
// layoutStopped = true;
// isLayoutPaused = false;
// }
/**
 * Creates a list of InternalNode objects from the list of LayoutEntity objects the user
 * wants layed out. Sets the internal nodes' positions and sizes from the
 * external entities.
 */
private InternalNode[] createInternalNodes(LayoutEntity[] nodes) {
    InternalNode[] internalNodes = new InternalNode[nodes.length];
    BasicEntityConstraint basicEntityConstraint = new BasicEntityConstraint();
    for (int i = 0; i < nodes.length; i++) {
        basicEntityConstraint.clear();
        LayoutEntity externalNode = nodes[i];
        InternalNode internalNode = new InternalNode(externalNode);
        externalNode.populateLayoutConstraint(basicEntityConstraint);
        internalNode.setInternalLocation(externalNode.getXInLayout(), externalNode.getYInLayout());
        internalNodes[i] = internalNode;
    }
    // end of for
    return internalNodes;
}
Also used : BasicEntityConstraint(org.eclipse.zest.layouts.constraints.BasicEntityConstraint) InternalNode(org.eclipse.zest.layouts.dataStructures.InternalNode) 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)

Aggregations

BasicEntityConstraint (org.eclipse.zest.layouts.constraints.BasicEntityConstraint)2 LayoutEntity (org.eclipse.zest.layouts.LayoutEntity)1 EntityPriorityConstraint (org.eclipse.zest.layouts.constraints.EntityPriorityConstraint)1 LabelLayoutConstraint (org.eclipse.zest.layouts.constraints.LabelLayoutConstraint)1 BendPoint (org.eclipse.zest.layouts.dataStructures.BendPoint)1 DisplayIndependentPoint (org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint)1 InternalNode (org.eclipse.zest.layouts.dataStructures.InternalNode)1