Skip to content

styling

Functions for style overrides of diagram elements.

BLUE_ACTOR_FNCS: dict[str, Styler] = {'node': parent_is_actor_fills_blue} module-attribute 🔗

CSSStyle for coloring Actor Functions (Functions of Components with the attribute is_actor set to True) with a blue gradient like in Capella.

CSSStyles = t.Union[diagram.StyleOverrides, None] module-attribute 🔗

A dictionary with CSS styles. The keys are the attribute names and the values can be of the types str, aird.RGB and even t.Sequence[aird.RGB] for coloring a common.GenericElement with a gradient.

See also🔗

parent_is_actor_fills_blue

SYSTEM_CAP_STYLING: dict[str, Styler] = {'node': style_center_symbol} module-attribute 🔗

CSSStyle for custom styling of SystemAnalysis diagrams. The center box is drawn with a white background and a grey dashed line.

Styler = t.Callable[[common.GenericElement, 'serializers.DiagramSerializer'], t.Union[diagram.StyleOverrides, None]] module-attribute 🔗

Function that produces CSSStyles for given obj.

parent_is_actor_fills_blue(obj, serializer) 🔗

Return CSSStyles for given obj rendering it blue.

Source code in capellambse_context_diagrams/styling.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def parent_is_actor_fills_blue(
    obj: common.GenericElement, serializer: serializers.DiagramSerializer
) -> CSSStyles:
    """Return ``CSSStyles`` for given ``obj`` rendering it blue."""
    del serializer
    try:
        if obj.owner.is_actor:
            return {
                "fill": [
                    capstyle.COLORS["_CAP_Actor_Blue_min"],
                    capstyle.COLORS["_CAP_Actor_Blue"],
                ],
                "stroke": capstyle.COLORS["_CAP_Actor_Border_Blue"],
            }
    except AttributeError:
        pass

    return None

style_center_symbol(obj, serializer) 🔗

Return CSSStyles for given obj.

Source code in capellambse_context_diagrams/styling.py
54
55
56
57
58
59
60
61
62
63
64
def style_center_symbol(
    obj: common.GenericElement, serializer: serializers.DiagramSerializer
) -> CSSStyles:
    """Return ``CSSStyles`` for given ``obj``."""
    if obj != serializer._diagram.target:  # type: ignore[has-type]
        return None
    return {
        "fill": capstyle.COLORS["white"],
        "stroke": capstyle.COLORS["gray"],
        "stroke-dasharray": 3,
    }