Search in sources :

Example 6 with MapPropertyHolder

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

the class LayoutConfigurator method overrideWith.

/**
 * Copy all options from the given configurator to this one, possibly overriding the own options. The
 * {@link IOptionFilter}s of this configurator are cleared and filled with the filters of {@code other}.
 *
 * @return {@code this}
 */
public LayoutConfigurator overrideWith(final LayoutConfigurator other) {
    for (Map.Entry<ElkGraphElement, MapPropertyHolder> entry : other.elementOptionMap.entrySet()) {
        MapPropertyHolder thisHolder = this.elementOptionMap.get(entry.getKey());
        if (thisHolder == null) {
            thisHolder = new MapPropertyHolder();
            this.elementOptionMap.put(entry.getKey(), thisHolder);
        }
        thisHolder.copyProperties(entry.getValue());
    }
    for (Map.Entry<Class<? extends ElkGraphElement>, MapPropertyHolder> entry : other.classOptionMap.entrySet()) {
        MapPropertyHolder thisHolder = this.classOptionMap.get(entry.getKey());
        if (thisHolder == null) {
            thisHolder = new MapPropertyHolder();
            this.classOptionMap.put(entry.getKey(), thisHolder);
        }
        thisHolder.copyProperties(entry.getValue());
    }
    this.clearLayout = other.clearLayout;
    this.optionFilters.clear();
    this.optionFilters.addAll(other.optionFilters);
    return this;
}
Also used : MapPropertyHolder(org.eclipse.elk.graph.properties.MapPropertyHolder) Map(java.util.Map) ElkGraphElement(org.eclipse.elk.graph.ElkGraphElement)

Example 7 with MapPropertyHolder

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

the class LayoutConfigurator method visit.

/**
 * Apply this layout configurator to the given graph element.
 */
@Override
public void visit(final ElkGraphElement element) {
    if (clearLayout) {
        element.getProperties().clear();
    }
    MapPropertyHolder combined = findClassOptions(element);
    // implicitly overwrite options specified for a class with options specified for the specific element
    combined.copyProperties(getProperties(element));
    applyProperties(element, combined);
}
Also used : MapPropertyHolder(org.eclipse.elk.graph.properties.MapPropertyHolder)

Example 8 with MapPropertyHolder

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

the class LayoutConfigurator method configure.

/**
 * Add and return a property holder for the given element. If such a property holder is
 * already present, the previous instance is returned.
 */
public IPropertyHolder configure(final ElkGraphElement element) {
    MapPropertyHolder result = elementOptionMap.get(element);
    if (result == null) {
        result = new MapPropertyHolder();
        elementOptionMap.put(element, result);
    }
    return result;
}
Also used : MapPropertyHolder(org.eclipse.elk.graph.properties.MapPropertyHolder)

Aggregations

MapPropertyHolder (org.eclipse.elk.graph.properties.MapPropertyHolder)8 Map (java.util.Map)2 ElkNode (org.eclipse.elk.graph.ElkNode)2 HashMap (java.util.HashMap)1 Attribute (org.eclipse.elk.alg.graphviz.dot.dot.Attribute)1 AttributeStatement (org.eclipse.elk.alg.graphviz.dot.dot.AttributeStatement)1 EdgeStatement (org.eclipse.elk.alg.graphviz.dot.dot.EdgeStatement)1 Graph (org.eclipse.elk.alg.graphviz.dot.dot.Graph)1 NodeStatement (org.eclipse.elk.alg.graphviz.dot.dot.NodeStatement)1 Statement (org.eclipse.elk.alg.graphviz.dot.dot.Statement)1 Subgraph (org.eclipse.elk.alg.graphviz.dot.dot.Subgraph)1 DotSwitch (org.eclipse.elk.alg.graphviz.dot.dot.util.DotSwitch)1 ElkPadding (org.eclipse.elk.core.math.ElkPadding)1 KVector (org.eclipse.elk.core.math.KVector)1 Pair (org.eclipse.elk.core.util.Pair)1 ElkGraphElement (org.eclipse.elk.graph.ElkGraphElement)1 ElkPort (org.eclipse.elk.graph.ElkPort)1 IPropertyHolder (org.eclipse.elk.graph.properties.IPropertyHolder)1