use of org.eclipse.elk.core.LayoutConfigurator in project elk by eclipse.
the class LayoutConfigurationManager method createConfigurator.
/**
* Create a layout configurator and initialize it with the option values from the given layout
* configuration store provider.
*/
public <T> LayoutConfigurator createConfigurator(final LayoutMapping layoutMapping) {
LayoutConfigurator result = new LayoutConfigurator();
if (configProvider != null) {
configureElement(layoutMapping.getLayoutGraph(), layoutMapping, result);
Iterator<ElkGraphElement> allElements = Iterators.filter(layoutMapping.getLayoutGraph().eAllContents(), ElkGraphElement.class);
while (allElements.hasNext()) {
ElkGraphElement element = allElements.next();
configureElement(element, layoutMapping, result);
}
}
return result;
}
use of org.eclipse.elk.core.LayoutConfigurator in project elk by eclipse.
the class BasicConsiderModelOrderTest method preferEdgesConfigurator.
@ConfiguratorProvider
public LayoutConfigurator preferEdgesConfigurator() {
LayoutConfigurator config = new LayoutConfigurator();
config.configure(ElkNode.class).setProperty(LayeredOptions.CROSSING_MINIMIZATION_STRATEGY, CrossingMinimizationStrategy.LAYER_SWEEP);
config.configure(ElkNode.class).setProperty(LayeredOptions.CONSIDER_MODEL_ORDER_STRATEGY, OrderingStrategy.PREFER_EDGES);
return config;
}
use of org.eclipse.elk.core.LayoutConfigurator in project elk by eclipse.
the class InvertedPortProcessorTest method configurator.
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Configuration
@ConfiguratorProvider
public LayoutConfigurator configurator() {
LayoutConfigurator config = new LayoutConfigurator();
config.configure(ElkNode.class).setProperty(LayeredOptions.EDGE_ROUTING, EdgeRouting.ORTHOGONAL);
return config;
}
use of org.eclipse.elk.core.LayoutConfigurator in project elk by eclipse.
the class DiagramLayoutEngine method layout.
/**
* Perform layout on the given layout graph mapping. If zero or one layout configurator is
* passed, the layout engine is executed exactly once. If multiple layout configurators are
* passed, the layout engine is executed accordingly often, but the resulting layout is applied
* only once. This is useful for composition of multiple algorithms that process only parts of
* the graph. Layout listeners are notified before and after the layout has been computed.
*
* @param mapping
* a mapping for the layout graph
* @param progressMonitor
* a progress monitor to which progress of the layout algorithm is reported
* @param params
* layout parameters
* @return a status indicating success or failure
*/
public IStatus layout(final LayoutMapping mapping, final IElkProgressMonitor progressMonitor, final Parameters params) {
mapping.setProperty(MAPPING_CONNECTOR, connector);
handleAncestors(mapping, params);
LinkedList<IGraphElementVisitor> visitors = new LinkedList<IGraphElementVisitor>();
visitors.add(algorithmResolver);
// Set up graph validators
if (params.getGlobalSettings().getProperty(CoreOptions.VALIDATE_OPTIONS)) {
visitors.add(layoutOptionValidatorProvider.get());
}
if (params.getGlobalSettings().getProperty(CoreOptions.VALIDATE_GRAPH)) {
visitors.add(graphValidatorProvider.get());
}
// Notify listeners of the to-be-executed layout
LayoutConnectorsService.getInstance().fireLayoutAboutToStart(mapping, progressMonitor);
IStatus status = null;
if (params.configurators.isEmpty()) {
// Perform layout without any extra configuration
IGraphElementVisitor[] visitorsArray = visitors.toArray(new IGraphElementVisitor[visitors.size()]);
status = layout(mapping, progressMonitor, visitorsArray);
} else if (params.configurators.size() == 1) {
// Perform layout once with an extra configuration
visitors.addFirst(params.configurators.get(0));
IGraphElementVisitor[] visitorsArray = visitors.toArray(new IGraphElementVisitor[visitors.size()]);
status = layout(mapping, progressMonitor, visitorsArray);
} else {
// Perform layout multiple times with different configurations
progressMonitor.begin("Diagram layout engine", params.configurators.size());
ListIterator<IGraphElementVisitor> configIter = params.configurators.listIterator();
while (configIter.hasNext()) {
visitors.addFirst(configIter.next());
IGraphElementVisitor[] visitorsArray = visitors.toArray(new IGraphElementVisitor[visitors.size()]);
status = layout(mapping, progressMonitor, visitorsArray);
if (!status.isOK()) {
break;
}
visitors.removeFirst();
// If an additional layout configurator is attached to the graph, consider it in the future
LayoutConfigurator addConfig = mapping.getLayoutGraph().getProperty(LayoutConfigurator.ADD_LAYOUT_CONFIG);
if (addConfig != null) {
ListIterator<IGraphElementVisitor> configIter2 = params.configurators.listIterator(configIter.nextIndex());
while (configIter2.hasNext()) {
IGraphElementVisitor c = configIter2.next();
if (c instanceof LayoutConfigurator) {
((LayoutConfigurator) c).overrideWith(addConfig);
}
}
}
}
progressMonitor.done();
// Log the final result to be displayed in our debug views
progressMonitor.logGraph(mapping.getLayoutGraph(), "Result");
}
mapping.setProperty(MAPPING_STATUS, status);
// Notify listeners of the executed layout
LayoutConnectorsService.getInstance().fireLayoutDone(mapping, progressMonitor);
return status;
}
use of org.eclipse.elk.core.LayoutConfigurator in project elk by eclipse.
the class BasicCycleBreakerTest method modelOrderPreferEdgesConfigurator.
@ConfiguratorProvider
public LayoutConfigurator modelOrderPreferEdgesConfigurator() {
LayoutConfigurator config = configuratorFor(CycleBreakingStrategy.MODEL_ORDER);
config.configure(ElkNode.class).setProperty(LayeredOptions.CONSIDER_MODEL_ORDER_STRATEGY, OrderingStrategy.PREFER_EDGES);
return config;
}
Aggregations