Skip to content

collectors

Functionality for collection of model data from an instance of MelodyModel and conversion of it into _elkjs.ELKInputData.

get_elkdata(diagram, params=None) 🔗

High level collector function to collect needed data for ELK.

Parameters🔗

diagram The ContextDiagram instance to get the _elkjs.ELKInputData for. params Optional render params dictionary.

Returns🔗

elkdata The data that can be fed into elkjs.

Source code in capellambse_context_diagrams/collectors/__init__.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def get_elkdata(
    diagram: context.ContextDiagram, params: dict[str, t.Any] | None = None
) -> _elkjs.ELKInputData:
    """High level collector function to collect needed data for ELK.

    Parameters
    ----------
    diagram
        The [`ContextDiagram`][capellambse_context_diagrams.context.ContextDiagram]
        instance to get the
        [`_elkjs.ELKInputData`][capellambse_context_diagrams._elkjs.ELKInputData]
        for.
    params
        Optional render params dictionary.

    Returns
    -------
    elkdata
        The data that can be fed into elkjs.
    """
    try:
        if generic.DIAGRAM_TYPE_TO_CONNECTOR_NAMES[diagram.type]:
            collector = default.collector
        else:
            collector = portless.collector
    except KeyError:
        logger.error(
            "Handling unknown diagram type %r. Default collector is used.",
            diagram.type,
        )
        collector = default.collector

    return collector(diagram, params)