5. WHAT IS LAYOUT?
• Graph layout consists of
• Node positioning
• Edge routing with crossing minimization
• Label placement
• Involves aesthetics, suggestion, and domain knowledge
• Auto-layout: Almost all algorithmic steps are NP-hard
6. ECLIPSE LAYOUT KERNEL
• Originates in the KIELER project (Uni Kiel)
• High-quality layout algorithms
• Numerous options for fine-tuning
• Flexible infrastructure for integration
• Open-source at Eclipse
• Current release 0.3.0
23. HOW TO INVOKE A LAYOUT
THE APPLICATION SIDE
• The low-level way:
‣ Build an ElkGraph yourself and pass it to a layout algorithm
‣ Copy the resulting coordinates to your diagram
layoutAlgorithm.layout(graph, progressMonitor);
24. HOW TO INVOKE A LAYOUT
THE APPLICATION SIDE
DiagramLayoutEngine.invokeLayout(
// The editor or view that contains the diagram
workbenchPart,
// An optional selection inside the diagram
diagramPart,
// Parameters of the layout invocation,
// including algorithm options
parameters
);
• The high-level way:
25. HOW TO CONNECT YOUR DIAGRAM
THE APPLICATION SIDE
public interface IDiagramLayoutConnector {
/**
* Build a graph from the given diagram.
*/
LayoutMapping buildLayoutGraph(
IWorkbenchPart workbenchPart,
Object diagramPart);
/**
* Apply the computed layout back to the diagram.
*/
void applyLayout(
LayoutMapping mapping,
IPropertyHolder settings);
}
26. HOW TO CONNECT YOUR DIAGRAM
THE APPLICATION SIDE
• Create a Google Guice Module that binds your layout connector
• For Sirius, inherit from the GmfDiagramLayoutConnector
• Create a Setup class that creates an Injector from your module
• Register the Setup class with the extension point
org.eclipse.elk.core.service.layoutConnectors