How to use the gaphor.diagram.shapes.Box function in gaphor

To help you get started, we’ve selected a few gaphor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gaphor / gaphor / gaphor / diagram / classes / interface.py View on Github external
def class_shape(self):
        return Box(
            Box(
                Text(
                    text=lambda: UML.model.stereotypes_str(
                        self.subject, ("interface",)
                    ),
                    style={"min-width": 0, "min-height": 0},
                ),
                EditableText(
                    text=lambda: self.subject.name or "",
                    style={"font-weight": FontWeight.BOLD},
                ),
                Text(
                    text=lambda: from_package_str(self),
                    style={"font": "sans 8", "min-width": 0, "min-height": 0},
                ),
                style={"padding": (12, 4, 12, 4)},
            ),
github gaphor / gaphor / gaphor / diagram / states / transition.py View on Github external
def __init__(self, id=None, model=None):
        super().__init__(id, model)

        self.shape_tail = Box(
            Text(
                text=lambda: stereotypes_str(self.subject),
                style={"min-width": 0, "min-height": 0},
            ),
            EditableText(text=lambda: self.subject.name or ""),
        )

        self.watch("subject[NamedElement].name")
        self.watch("subject.appliedStereotype.classifier.name")

        self.shape_middle = EditableText(
            text=lambda: self.subject
            and self.subject.guard
            and self.subject.guard.specification
            or ""
        )
github gaphor / gaphor / gaphor / diagram / interactions / interaction.py View on Github external
def __init__(self, id=None, model=None):
        super().__init__(id, model)

        self.shape = Box(
            Box(
                Text(
                    text=lambda: stereotypes_str(self.subject),
                    style={
                        "min-width": 0,
                        "min-height": 0,
                        "text-align": TextAlign.LEFT,
                    },
                ),
                EditableText(
                    text=lambda: self.subject.name or "",
                    style={"text-align": TextAlign.LEFT},
                ),
                style={"padding": (4, 4, 4, 4)},
            ),
            style={
                "min-width": 150,
github gaphor / gaphor / gaphor / diagram / actions / objectnode.py View on Github external
def __init__(self, id=None, model=None):
        super().__init__(id, model)

        self._show_ordering = False

        self.shape = IconBox(
            Box(
                Text(
                    text=lambda: stereotypes_str(self.subject),
                    style={"min-width": 0, "min-height": 0},
                ),
                EditableText(text=lambda: self.subject.name or ""),
                style={"min-width": 50, "min-height": 30, "padding": (5, 10, 5, 10)},
                draw=draw_border,
            ),
            Text(
                text=lambda: self.subject.upperBound not in (None, DEFAULT_UPPER_BOUND)
                and f"{{ upperBound = {self.subject.upperBound} }}",
                style={"min-width": 0, "min-height": 0},
            ),
            Text(
                text=lambda: self._show_ordering
                and self.subject.ordering
github gaphor / gaphor / gaphor / diagram / interactions / message.py View on Github external
def __init__(self, id=None, model=None):
        super().__init__(
            id,
            model,
            shape_middle=Box(
                Text(
                    text=lambda: stereotypes_str(self.subject),
                    style={"min-width": 0, "min-height": 0},
                ),
                EditableText(text=lambda: self.subject.name or ""),
            ),
        )

        self._is_communication = False
        self._arrow_pos = 0, 0
        self._arrow_angle = 0

        self.watch("subject[NamedElement].name")
        self.watch("subject.appliedStereotype.classifier.name")
github gaphor / gaphor / gaphor / diagram / classes / interface.py View on Github external
def ball_and_socket_shape(self, connectors=None):
        assert self.canvas
        if connectors is None:
            # distinguish between None and []
            connected_items = [
                c.item for c in self.canvas.get_connections(connected=self)
            ]
            connectors = any(
                map(lambda i: isinstance(i.subject, UML.Connector), connected_items)
            )
        return IconBox(
            Box(
                style={"min-width": self.min_width, "min-height": self.min_height},
                draw=self.draw_interface_ball_and_socket,
            ),
            Text(
                text=lambda: UML.model.stereotypes_str(self.subject),
                style={"min-width": 0, "min-height": 0},
            ),
            EditableText(
                text=lambda: self.subject.name or "",
                style={
                    "font-weight": FontWeight.NORMAL if connectors else FontWeight.BOLD
                },
github gaphor / gaphor / gaphor / diagram / profiles / extension.py View on Github external
def __init__(self, id=None, model=None):
        super().__init__(id, model)

        self.shape_middle = Box(
            Text(
                text=lambda: stereotypes_str(self.subject),
                style={"min-width": 0, "min-height": 0},
            ),
            EditableText(text=lambda: self.subject.name or ""),
        )

        self.watch("subject[NamedElement].name")
        self.watch("subject.appliedStereotype.classifier.name")
github gaphor / gaphor / gaphor / diagram / actions / flow.py View on Github external
def __init__(self, id=None, model=None):
        super().__init__(id, model)

        self.shape_tail = Box(
            Text(
                text=lambda: stereotypes_str(self.subject),
                style={"min-width": 0, "min-height": 0},
            ),
            EditableText(text=lambda: self.subject.name or ""),
        )

        self.watch("subject[NamedElement].name")
        self.watch("subject.appliedStereotype.classifier.name")

        self.shape_middle = EditableText(
            text=lambda: self.subject and self.subject.guard or ""
        )

        self.watch("subject[ControlFlow].guard")
        self.watch("subject[ObjectFlow].guard")
github gaphor / gaphor / gaphor / diagram / usecases / usecase.py View on Github external
def __init__(self, id=None, model=None):
        super().__init__(id, model)
        self.shape = Box(
            Text(
                text=lambda: stereotypes_str(self.subject),
                style={"min-width": 0, "min-height": 0},
            ),
            EditableText(
                text=lambda: self.subject.name or "",
                style={"font-weight": FontWeight.BOLD},
            ),
            style={"min-width": 50, "min-height": 30},
            draw=draw_usecase,
        )

        self.watch("subject[NamedElement].name")
        self.watch("subject.appliedStereotype.classifier.name")
github gaphor / gaphor / gaphor / diagram / classes / klass.py View on Github external
def update_shapes(self, event=None):
        def additional_stereotypes():
            if isinstance(self.subject, UML.Stereotype):
                return ["stereotype"]
            elif UML.model.is_metaclass(self.subject):
                return ["metaclass"]
            else:
                return ()

        self.shape = Box(
            Box(
                Text(
                    text=lambda: UML.model.stereotypes_str(
                        self.subject, additional_stereotypes()
                    ),
                    style={"min-width": 0, "min-height": 0},
                ),
                EditableText(
                    text=lambda: self.subject.name or "",
                    style={
                        "font-weight": FontWeight.BOLD,
                        "font-style": FontStyle.ITALIC
                        if self.subject and self.subject.isAbstract
                        else FontStyle.NORMAL,
                    },
                ),