### Serve Documentation Website with Hugo Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/contributors/buildingelk.md Start a local Hugo server instance in the 'docs/' folder to preview the documentation website. Changes are dynamically updated in the browser. ```bash hugo server ``` -------------------------------- ### ELKT Primitive Edge Example Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/tooldevelopers/graphdatastructure/elktextformat.md Illustrates the syntax for a primitive edge in ELKT, connecting source and target nodes, optionally through ports. Includes layout for start, bends, and end points. ```elkt edge source_node_id.source_port_id -> target_node_id.target_port_id { layout [ start: x, y bends: x, y | x, y | x, y end: x, y ], // any attached labels } ``` -------------------------------- ### Example Commit Message Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/contributors/developmentworkflow.md Follow this format for commit messages, including a summary, optional details, and a signed-off-by line. ```plain Core, Layered: Fix labels with layout directions #58 Using node labels inside compound nodes that are configured to use different layout directions resulted in problems with calculated insets. Signed-off-by: Christoph Daniel Schulze ``` -------------------------------- ### Basic Layout Processor Configuration Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/algorithmdevelopers/algorithmimplementation/algorithmstructure.md Configures the layout processors that should be executed before a specific phase. This example adds ROOT_PROC and FAN_PROC before phase P2_NODE_ORDERING. ```java private static final LayoutProcessorConfiguration INTERMEDIATE_PROCESSING_CONFIG = LayoutProcessorConfiguration.create() .addBefore(LayoutPhases.P2_NODE_ORDERING, IntermediateProcessorStrategy.ROOT_PROC) .addBefore(LayoutPhases.P2_NODE_ORDERING, IntermediateProcessorStrategy.FAN_PROC); @Override public LayoutProcessorConfiguration getLayoutProcessorConfiguration(ElkNode graph) { return INTERMEDIATE_PROCESSING_CONFIG; } ``` -------------------------------- ### ELKT Layout Options Example Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/tooldevelopers/graphdatastructure/elktextformat.md Demonstrates the syntax for various layout options in ELKT, including enum values, sets, and doubles. Note the specific format for padding and individual spacing. ```elkt layoutOption1: ENUM_VALUE layoutOption2: "ENUM_VALUE_1 ENUM_VALUE_2" layoutOption3: 10.0 ``` ```elkt padding: "[top=20.0,left=20.0,bottom=20.0,right=20.0]" ``` ```elkt spacing.individual: "spacing.nodeNode: 10.0 :: spacing portsSurrounding: [top=40.0,left=10.0,bottom=10.0,right=30.0]" ``` -------------------------------- ### Implement supports() Method for ILayoutSetup Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/tooldevelopers/usingeclipselayout/connectingtoelk.md Implement the supports method to determine if a setup instance can extract an ElkGraph from a given object. This method handles checks for collections of objects and specific workbench part or diagram element types. ```java public boolean supports(final Object object) { // This method may be invoked on a whole collection of elements selected // in an editor if (object instanceof Collection) { // Check if we support layout on at least one of the selected objects for (Object o : (Collection) object) { if (o instanceof SomeDiagramElementClassWeSupport) { return true; } } return false; } // If it is not a collection, it may be either a workbench part we support // or the diagram element class we already checked for above return object instanceof WorkbenchPartImplementation || object instanceof SomeDiagramClassWeSupport; } ``` -------------------------------- ### Demonstrate Default Property Value Behavior Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/tooldevelopers/graphdatastructure/layoutoptions.md This example shows how different IProperty instances with the same key but different default values can lead to different results when the property is not explicitly set. The output demonstrates that the default value is determined by the IProperty instance used in getProperty. ```java final IProperty FALSE_DEFAULT = new Property<>("an.excellent.example.property", false); final IProperty TRUE_DEFAULT = new Property<>("an.excellent.example.property", true); // Setting the property value to null effectively undefines the // property for the property holder propertyHolder.setProperty(FALSE_DEFAULT, null); System.out.println(propertyHolder.getProperty(FALSE_DEFAULT)); propertyHolder.setProperty(FALSE_DEFAULT, null); System.out.println(propertyHolder.getProperty(TRUE_DEFAULT)); ``` ```plain false true ``` -------------------------------- ### ELKT Extended Edge Example Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/tooldevelopers/graphdatastructure/elktextformat.md Shows the syntax for an extended edge in ELKT, which can connect multiple sources to multiple targets (hyperedges). It includes a layout block for edge sections. ```elkt edge source_node_id.source_port_id, another_source -> target_node_id.target_port_id, another_target { layout [ // list of edge sections ], // any attached labels } ``` -------------------------------- ### Small Example ELK Graph JSON Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/tooldevelopers/graphdatastructure/jsonformat.md A minimal example of an ELK graph structure in JSON, including layout options, nodes, and edges. ```json { "id": "root", "layoutOptions": { "elk.direction": "RIGHT" }, "children": [ { "id": "n1", "width": 10, "height": 10 }, { "id": "n2", "width": 10, "height": 10 } ], "edges": [{ "id": "e1", "sources": [ "n1" ], "targets": [ "n2" ] }] } ``` -------------------------------- ### Build Documentation Website with Hugo Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/contributors/buildingelk.md Navigate to the 'docs/' folder and run this command to build the static documentation website using Hugo. ```bash hugo ``` -------------------------------- ### ELKT Label Definition Example Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/tooldevelopers/graphdatastructure/elktextformat.md A simple example of defining a text label in ELKT. It's recommended to specify width and height as layout algorithms may not estimate text size. ```elkt label "A magnificent text" ``` -------------------------------- ### Assembling Layout Processor Configurations Conditionally Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/algorithmdevelopers/algorithmimplementation/algorithmstructure.md Demonstrates how to combine a base configuration with additional processor dependencies, which can be conditionally added based on graph features. The `addAll` method is used to merge configurations. ```java private static final LayoutProcessorConfiguration FOO_PROCESSING_ADDITIONS = LayoutProcessorConfiguration.create() .addBefore(LayoutPhases.P3_NODE_PLACEMENT, IntermediateProcessorStrategy.LEVEL_HEIGHT) .addBefore(LayoutPhases.P4_EDGE_ROUTING, IntermediateProcessorStrategy.NODE_POSITION_PROC); public LayoutProcessorConfiguration getLayoutProcessorConfiguration(ElkNode graph) { // Basic configuration LayoutProcessorConfiguration configuration = LayoutProcessorConfiguration.createFrom( INTERMEDIATE_PROCESSING_CONFIG); // Additional dependencies if (foo) { configuration.addAll(FOO_PROCESSING_ADDITIONS); } return configuration; } ``` -------------------------------- ### Add Pseudo Positions to Nodes Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/blog/posts/2023/23-01-09-constraining-the-model.md Assign pseudo positions to nodes to guide the interactive layout algorithm. This is one method for providing initial node positions. ```properties layout [position: 100, 0] ``` -------------------------------- ### Registering ILayoutMetaDataProvider Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/algorithmdevelopers/metadatalanguage.md This file must be created in the `META-INF/services` directory of your project's source folders. It should contain a single line specifying the fully qualified name of the generated `ILayoutMetaDataProvider` class. ```text org.eclipse.elk.core.data.ILayoutMetaDataProvider ``` -------------------------------- ### Implement a Layout Phase Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/algorithmdevelopers/algorithmimplementation/algorithmstructure.md Implement the `ILayoutPhase` interface for each phase of your algorithm. The `process` method contains the core logic, while `getLayoutProcessorConfiguration` allows for specifying intermediate processors. ```java public class NodeOrderer implements ILayoutPhase { @Override public LayoutProcessorConfiguration getLayoutProcessorConfiguration(ElkNode graph) { // To start with, the phase won't require any layout processors return LayoutProcessorConfiguration.create(); } public void process(ElkNode ElkNode, IElkProgressMonitor progressMonitor) { // This will be the entry point to your phase } } ``` -------------------------------- ### Edge Section JSON Structure Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/tooldevelopers/graphdatastructure/jsonformat.md Defines the properties for an edge section in JSON format, including start and end points, bend points, and connections to shapes or other sections. ```json { "startPoint": {x, y}, "endPoint": {x, y}, "bendPoints": [ ..array of {x, y} pairs.. ], "incomingShape": node and / or port identifier, "outgoingShape": node and / or port identifier, "incomingSections": [ ..array of edge section identifiers.. ], "outgoingSections": [ ..array of edge section identifiers.. ] } ``` -------------------------------- ### ELKT Node Definition Example Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/tooldevelopers/graphdatastructure/elktextformat.md Defines a node in ELKT, including its layout options and potential child elements like labels, ports, and edges. The `layout` block is optional. ```elkt node n { layout [ position: x, y size: w, h ] // list of layout options // definitions of any contained labels, ports, edges and other nodes } ``` -------------------------------- ### Layout Algorithm Entry Point Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/algorithmdevelopers/algorithmdebugging.md This is the standard method signature for layout algorithms within the Eclipse Layout Kernel, extending AbstractLayoutProvider. ```java public void layout(ElkNode layoutGraph, IElkProgressMonitor monitor) { ... } ``` -------------------------------- ### Symmetrical Space Reservation for Node Labels Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/blog/posts/2025/25-08-22-node-labels.md This example demonstrates symmetrical space reservation for node labels when they are not centered. The node reserves extra space on the opposite side of the label for symmetry. ```java node childWithLabelTopLeft { nodeLabels.placement: "INSIDE H_LEFT V_TOP" nodeSize.constraints: "NODE_LABELS" label "childWithLabelTopLeft" label "childWithLabelTopLeft2" } ``` -------------------------------- ### Check Third-Party Licenses with Maven Source: https://github.com/eclipse-elk/elk/blob/master/build/RELEASE.md Run this Maven command to check for third-party content licenses and generate a summary file. Ensure you have a local Maven repository set up. ```bash mvn org.eclipse.dash:license-tool-plugin:license-check -Dmaven.repo.local=./mvnrepo clean -Dtycho.target.eager=true -Dmaven.test.skip=true -Ddash.summary=../DEPENDENCIES ``` -------------------------------- ### ELK Edge Section Syntax Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/tooldevelopers/graphdatastructure/elktextformat.md Defines the structure for specifying an edge section in the ELK format, including start, end, bendpoints, and incoming/outgoing connections. This is an advanced usage, as layout algorithms usually generate these automatically. ```elkt section incoming_sections -> outgoing_sections [ start: x, y end: x, y bends: x, y | x, y | x, y incoming: node and / or port identifier outgoing: node and / or port identifier ] ``` -------------------------------- ### Using IElkProgressMonitor for Logging Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/algorithmdevelopers/algorithmdebugging.md Demonstrates how to use the IElkProgressMonitor to log messages, check logging status, and log graph snapshots during algorithm execution. Ensure lengthy computations are only performed if logging is enabled. ```java public void layout(ElkNode layoutGraph, IElkProgressMonitor monitor) { monitor.begin("TestAlgorithm", 2); monitor.log("Algorithm starting..."); // As with assertions, lengthy computations should only be done if logging // is in fact enabled if (monitor.isLoggingEnabled()) { // Perform some lengthy computation monitor.log("Found..."); } // You can log snapshots of the layout graph monitor.logGraph(layoutGraph, "No node placed yet"); placeNodes(layoutGraph); monitor.logGraph(layoutGraph, "All nodes placed"); progressMonitor.done(); } ``` -------------------------------- ### Configure Xtext Maven Plugin for Code Generation Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/algorithmdevelopers/metadatalanguage/automaticbuilds.md Configure the xtext-maven-plugin in your pom.xml to invoke the ELK metadata language compiler. Specify the setup class and output directory for the generated code. Replace THE_VERSION_YOU_WANT-SNAPSHOT with the actual version. ```xml org.eclipse.xtext xtext-maven-plugin 2.7.2 generate org.eclipse.elk.core.meta.MetaDataStandaloneSetup ${basedir}/src-gen/ org.eclipse.elk org.eclipse.elk.graph THE_VERSION_YOU_WANT-SNAPSHOT org.eclipse.elk org.eclipse.elk.core.meta THE_VERSION_YOU_WANT-SNAPSHOT ``` -------------------------------- ### Specify Algorithm Class with Parameter Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/algorithmdevelopers/metadatalanguage.md When defining the algorithm's main class, you can specify a parameter value to customize its behavior using the `initialize(String)` method of `AbstractLayoutProvider`. ```melk algorithm myAlgorithm(TheAbstractLayoutProviderSubclass#TheParamterValue) ``` -------------------------------- ### Get First Edge Section in ELK Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/tooldevelopers/graphdatastructure.md The `firstEdgeSection(edge, reset, removeOthers)` method returns the first edge section of a given edge. It can optionally reset layout data and remove other sections. If no sections exist, one is created. ```java ElkGraphUtil.firstEdgeSection(edge, reset, removeOthers) ``` -------------------------------- ### AbstractLayoutProvider Methods Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/tooldevelopers/usingalgorithmsdirectly.md These are the core methods of the AbstractLayoutProvider class, which serves as the entry point for layout algorithms. Ensure proper initialization and disposal. ```java void initialize(String parameter); void layout(KNode layoutGraph, IElkProgressMonitor progressMonitor); void dispose(); ``` -------------------------------- ### Build ELK Project with Maven Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/contributors/buildingelk.md Execute this Maven command to build the main ELK project. The `maven.repo.local` property is optional but helps keep builds self-contained. ```bash mvn --define elk.metadata.documentation.outputPath=/ELK_FOLDER/docs -Dmaven.repo.local=./mvnrepo clean package ``` -------------------------------- ### Implement Simple Layout Algorithm in Java Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/algorithmdevelopers/algorithmimplementation.md This snippet implements a basic layout algorithm. It retrieves properties like padding and spacing, positions nodes sequentially, and routes edges with bend points. Use this for straightforward hierarchical or layered layouts. ```java progressMonitor.begin("Simple layout", 2); // Retrieve several properties ElkPadding padding = layoutGraph.getProperty(SimpleOptions.PADDING); double edgeEdgeSpacing = layoutGraph.getProperty(SimpleOptions.SPACING_EDGE_EDGE); double edgeNodeSpacing = layoutGraph.getProperty(SimpleOptions.SPACING_EDGE_NODE); double nodeNodeSpacing = layoutGraph.getProperty(SimpleOptions.SPACING_NODE_NODE); // Get and possibly reverse the list of nodes to lay out List nodes = new ArrayList<>(layoutGraph.getChildren()); if (layoutGraph.getProperty(SimpleOptions.REVERSE_INPUT)) { Collections.reverse(nodes); } // Place the nodes double currX = padding.left; double currY = padding.top; for (ElkNode node : nodes) { // Set the node's coordinates node.setX(currX); node.setY(padding.top); // Advance the coordinates currX += node.getWidth() + nodeNodeSpacing; currY = Math.max(currY, padding.top + node.getHeight()); } if (!nodes.isEmpty()) { currX -= nodeNodeSpacing; } progressMonitor.worked(1); // Route the edges if (!layoutGraph.getContainedEdges().isEmpty()) { currY += edgeNodeSpacing; for (ElkEdge edge : layoutGraph.getContainedEdges()) { ElkNode source = ElkGraphUtil.connectableShapeToNode(edge.getSources().get(0)); ElkNode target = ElkGraphUtil.connectableShapeToNode(edge.getTargets().get(0)); ElkEdgeSection section = ElkGraphUtil.firstEdgeSection(edge, true, true); section.setStartLocation( source.getX() + source.getWidth() / 2, source.getY() + source.getHeight()); section.setEndLocation( target.getX() + target.getWidth() / 2, target.getY() + target.getHeight()); ElkGraphUtil.createBendPoint(section, section.getStartX(), currY); ElkGraphUtil.createBendPoint(section, section.getEndX(), currY); currY += edgeEdgeSpacing; } currY -= edgeEdgeSpacing; } // Set the size of the final diagram layoutGraph.setWidth(currX + padding.right); layoutGraph.setHeight(currY + padding.bottom); progressMonitor.done(); ``` -------------------------------- ### Build Metadata Compiler with Maven Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/contributors/buildingelk.md Use this Maven command to build the metadata compiler locally. The `-P elk-meta` flag activates the specific profile for the metadata compiler. ```bash mvn -P elk-meta -Dmaven.repo.local=./mvnrepo clean install ``` -------------------------------- ### Node Size With Label Placement Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/blog/posts/2025/25-08-22-node-labels.md This configuration correctly sizes the node to accommodate its labels by specifying `nodeLabels.placement`. It ensures the node's dimensions consider the label sizes. ```java node childWithLabelCenter { layout [size: 10, 10] nodeLabels.placement: "INSIDE H_CENTER V_CENTER" nodeSize.constraints: "NODE_LABELS MINIMUM_SIZE" label "childWithLabelCenter" label "childWithLabelCenter2" } ``` -------------------------------- ### Declare Supported Layout Options Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/algorithmdevelopers/metadatalanguage.md Algorithms declare supported layout options, optionally overriding default values. These declarations translate into `IProperty` constants in the algorithm's metadata provider. ```melk supports the.option.id // Standard default value ``` ```melk supports the.option.id = 42 // Overridden default value ``` -------------------------------- ### Apply Default Configurations Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/algorithmdevelopers/unittesting.md Use `@DefaultConfiguration` to apply default sizes and labels to nodes, ports, and edges in tests. Edge labels are excluded by default. ```java @RunWith(LayoutTestRunner.class) @Algorithm(MyTestClassOptions.ALGORITHM_ID) @DefaultConfiguration(nodes = true, ports = true, edges = true, edgeLabels = false) public class MyAlgorithmTest { } ``` -------------------------------- ### Alternative Method for Adding Multiple Processors Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/algorithmdevelopers/algorithmimplementation/algorithmstructure.md Provides a more concise way to add multiple processors to the same processing slot using chained 'add' calls after specifying the slot with 'before'. ```java private static final LayoutProcessorConfiguration INTERMEDIATE_PROCESSING_CONFIG = LayoutProcessorConfiguration.create() .before(LayoutPhases.P2_NODE_ORDERING) .add(IntermediateProcessorStrategy.ROOT_PROC) .add(IntermediateProcessorStrategy.FAN_PROC); ``` -------------------------------- ### Using IElkProgressMonitor for Layout Time Measurement Source: https://github.com/eclipse-elk/elk/blob/master/docs/content/documentation/algorithmdevelopers/algorithmdebugging.md Implement `IElkProgressMonitor` to track the time spent in different phases of your layout algorithm. This allows the Layout Time View to display execution details. ```java monitor.begin("My rather good layout algorithm", 2); // Phases of your algorithm should use sub-monitors executePhase1(monitor.subTask(1)); executePhase2(monitor.subTask(1)); monitor.done(); ```