Skip to content

styling

Functions for style overrides of diagram elements.

BLUE_ACTOR_FNCS module-attribute 🔗

BLUE_ACTOR_FNCS: dict[str, Styler] = {'node': parent_is_actor_fills_blue}

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

CSSStyles module-attribute 🔗

CSSStyles = Union[StyleOverrides, None]

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 ModelElement with a gradient.

See also

parent_is_actor_fills_blue

SYSTEM_CAP_STYLING module-attribute 🔗

SYSTEM_CAP_STYLING: dict[str, Styler] = {'node': style_center_symbol}

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

Styler module-attribute 🔗

Styler = Callable[[ModelElement, 'serializers.DiagramSerializer'], Union[StyleOverrides, None]]

Function that produces CSSStyles for given obj.

parent_is_actor_fills_blue 🔗

parent_is_actor_fills_blue(obj: m.ModelElement, serializer: serializers.DiagramSerializer) -> CSSStyles

Return CSSStyles for given obj rendering it blue.

Source code in capellambse_context_diagrams/styling.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def parent_is_actor_fills_blue(
    obj: m.ModelElement, 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 🔗

style_center_symbol(obj: m.ModelElement, serializer: serializers.DiagramSerializer) -> CSSStyles

Return CSSStyles for given obj.

Source code in capellambse_context_diagrams/styling.py
53
54
55
56
57
58
59
60
61
62
63
def style_center_symbol(
    obj: m.ModelElement, 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",
    }