Search in sources :

Example 1 with IPropertyHolder

use of org.eclipse.elk.graph.properties.IPropertyHolder in project elk by eclipse.

the class DiagramLayoutEngine method handleAncestors.

/**
 * Handle the ancestors of the parent element if {@link CoreOptions#LAYOUT_ANCESTORS} is set.
 * For every ancestor node of the parent element (i.e. {@link LayoutMapping#getParentElement()}),
 * all containing elements that are not ancestors are excluded from layout.
 *
 * @param mapping
 *            a mapping for the layout graph
 * @param params
 *            layout parameters
 */
protected void handleAncestors(final LayoutMapping mapping, final Parameters params) {
    boolean layoutAncestors = params.getGlobalSettings().getProperty(CoreOptions.LAYOUT_ANCESTORS);
    if (layoutAncestors) {
        // Mark all parallel areas for exclusion from layout
        ElkGraphElement graphElem = mapping.getGraphMap().inverse().get(mapping.getParentElement());
        if (graphElem instanceof ElkNode && ((ElkNode) graphElem).getParent() != null) {
            if (params.configurators.isEmpty()) {
                params.configurators.add(new LayoutConfigurator());
            }
            ElkNode node = (ElkNode) graphElem;
            do {
                ElkNode parent = node.getParent();
                for (ElkNode child : parent.getChildren()) {
                    if (child != node) {
                        for (IGraphElementVisitor c : params.configurators) {
                            if (c instanceof LayoutConfigurator) {
                                IPropertyHolder childConfig = ((LayoutConfigurator) c).configure(child);
                                // Do not layout the content of the child node
                                childConfig.setProperty(CoreOptions.NO_LAYOUT, true);
                                // Do not change the size of the child node
                                childConfig.setProperty(CoreOptions.NODE_SIZE_CONSTRAINTS, SizeConstraint.fixed());
                                // Do not move the ports of the child node
                                childConfig.setProperty(CoreOptions.PORT_CONSTRAINTS, PortConstraints.FIXED_POS);
                            }
                        }
                    }
                }
                node = parent;
            } while (node.getParent() != null);
        }
    }
}
Also used : ElkNode(org.eclipse.elk.graph.ElkNode) ElkGraphElement(org.eclipse.elk.graph.ElkGraphElement) IPropertyHolder(org.eclipse.elk.graph.properties.IPropertyHolder) LayoutConfigurator(org.eclipse.elk.core.LayoutConfigurator) IGraphElementVisitor(org.eclipse.elk.core.util.IGraphElementVisitor)

Example 2 with IPropertyHolder

use of org.eclipse.elk.graph.properties.IPropertyHolder in project elk by eclipse.

the class CompoundGraphPreprocessor method createExternalPortProperties.

/**
 * Create suitable port properties for dummy external ports.
 *
 * @param graph
 *            the graph for which the dummy external port is created
 * @return properties to apply to the dummy port
 */
private static IPropertyHolder createExternalPortProperties(final LGraph graph) {
    IPropertyHolder propertyHolder = new MapPropertyHolder();
    // FIXME No idea why ...
    double offset = graph.getProperty(LayeredOptions.SPACING_EDGE_EDGE) / 2;
    propertyHolder.setProperty(LayeredOptions.PORT_BORDER_OFFSET, offset);
    return propertyHolder;
}
Also used : MapPropertyHolder(org.eclipse.elk.graph.properties.MapPropertyHolder) IPropertyHolder(org.eclipse.elk.graph.properties.IPropertyHolder)

Example 3 with IPropertyHolder

use of org.eclipse.elk.graph.properties.IPropertyHolder in project sirius-components by eclipse-sirius.

the class SiriusWebLayoutConfigurator method visit.

@Override
public void visit(final ElkGraphElement element) {
    super.visit(element);
    IPropertyHolder typeProperties = this.getPropertiesByType(element.getProperty(ELKDiagramConverter.PROPERTY_TYPE));
    this.applyProperties(element, typeProperties);
    IPropertyHolder idProperties = this.getPropertiesById(element.getIdentifier());
    this.applyProperties(element, idProperties);
}
Also used : IPropertyHolder(org.eclipse.elk.graph.properties.IPropertyHolder)

Aggregations

IPropertyHolder (org.eclipse.elk.graph.properties.IPropertyHolder)3 LayoutConfigurator (org.eclipse.elk.core.LayoutConfigurator)1 IGraphElementVisitor (org.eclipse.elk.core.util.IGraphElementVisitor)1 ElkGraphElement (org.eclipse.elk.graph.ElkGraphElement)1 ElkNode (org.eclipse.elk.graph.ElkNode)1 MapPropertyHolder (org.eclipse.elk.graph.properties.MapPropertyHolder)1