diff --git a/capellambse_context_diagrams/_elkjs.py b/capellambse_context_diagrams/_elkjs.py index 8888c20b..89fa2edd 100644 --- a/capellambse_context_diagrams/_elkjs.py +++ b/capellambse_context_diagrams/_elkjs.py @@ -55,8 +55,7 @@ "elk.direction": "RIGHT", "hierarchyHandling": "INCLUDE_CHILDREN", "layered.edgeLabels.sideSelection": "ALWAYS_DOWN", - "layered.nodePlacement.strategy": "BRANDES_KOEPF", - "layered.considerModelOrder.strategy": "NODES_AND_EDGES", + "layered.nodePlacement.strategy": "NETWORK_SIMPLEX", "spacing.labelNode": "0.0", } """ @@ -85,8 +84,14 @@ "widthApproximation.targetWidth": 1, # width / height "elk.contentAlignment": "V_TOP H_CENTER", } -LABEL_LAYOUT_OPTIONS = {"nodeLabels.placement": "OUTSIDE, V_BOTTOM, H_CENTER"} +LABEL_LAYOUT_OPTIONS: LayoutOptions = { + "nodeLabels.placement": "OUTSIDE, V_BOTTOM, H_CENTER" +} """Options for labels to configure ELK layouting.""" +EDGE_STRAIGHTENING_LAYOUT_OPTIONS: LayoutOptions = { + "layered.priority.straightness": "10" +} +"""Options for increasing the edge straightness priority.""" class BaseELKModel(pydantic.BaseModel): @@ -147,6 +152,8 @@ class ELKInputEdge(BaseELKModel): """Exchange data that can be fed to ELK.""" id: str + layoutOptions: LayoutOptions = pydantic.Field(default_factory=dict) + sources: cabc.MutableSequence[str] targets: cabc.MutableSequence[str] labels: cabc.MutableSequence[ELKInputLabel] = pydantic.Field( diff --git a/capellambse_context_diagrams/collectors/exchanges.py b/capellambse_context_diagrams/collectors/exchanges.py index 15870ebf..45db5d3f 100644 --- a/capellambse_context_diagrams/collectors/exchanges.py +++ b/capellambse_context_diagrams/collectors/exchanges.py @@ -4,6 +4,7 @@ from __future__ import annotations import abc +import copy import logging import operator import typing as t @@ -251,6 +252,7 @@ def make_all_owners( return root.id def add_interface(self) -> None: + """Add the ComponentExchange (interface) to the collected data.""" ex_data = generic.ExchangeData( self.obj, self.data, @@ -259,6 +261,9 @@ def add_interface(self) -> None: is_hierarchical=False, ) src, tgt = generic.exchange_data_collector(ex_data) + self.data.edges[-1].layoutOptions = copy.deepcopy( + _elkjs.EDGE_STRAIGHTENING_LAYOUT_OPTIONS + ) assert self.right is not None assert self.left is not None self.left.ports.append(makers.make_port(src.uuid))