def __init__(self, id=None, model=None): super().__init__(id, model) h1, h2 = Handle(), Handle() self._handles.append(h1) self._handles.append(h2) self._ports.append(LinePort(h1.pos, h2.pos)) self._combined = None self.shape = IconBox( Box(style={"min-width": 0, "min-height": 45}, draw=self.draw_fork_node), Text( text=lambda: stereotypes_str(self.subject), style={"min-width": 0, "min-height": 0}, ), EditableText(text=lambda: self.subject and self.subject.name or ""), Text( text=lambda: isinstance(self.subject, UML.JoinNode) and self.subject.joinSpec not in (None, DEFAULT_JOIN_SPEC) and f"{{ joinSpec = {self.subject.joinSpec} }}" or "", style={"min-width": 0, "min-height": 0}, ), ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name") self.watch("subject[JoinNode].joinSpec")
def update_shapes(self, event=None): if self._folded == Folded.NONE: self.shape = 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)}, ), *(self.show_attributes and self.subject and [attributes_compartment(self.subject)] or []), *(self.show_operations and self.subject and [operations_compartment(self.subject)] or []), *(self.show_stereotypes_attrs and stereotype_compartments(self.subject) or []), style={ "min-width": 100, "min-height": 50, "vertical-align": VerticalAlign.TOP, }, draw=draw_border, ) else: self.shape = 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.BOLD}, ), )
def update_shapes(self, event=None): self.shape = Box( Box( EditableText( text=lambda: self.subject.name or "", style={"font-weight": FontWeight.BOLD}, ), Text( text=lambda: f"[{gettext('Person')}]", style={"font-size": "x-small"}, ), Text( text=lambda: self.subject.description or "", width=lambda: self.width - 8, style={"padding": (4, 0, 0, 0)}, ), style={"padding": (4, 4, 4, 4)}, ), style={ "text-align": TextAlign.LEFT if self.diagram and self.children else TextAlign.CENTER, "vertical-align": VerticalAlign.BOTTOM if self.diagram and self.children else VerticalAlign.MIDDLE, }, draw=draw_person, )
def __init__(self, diagram, id=None): super().__init__(diagram, id, width=70, height=70) self.shape = Box( Text( text=lambda: stereotypes_str( self.subject, isinstance(self.subject, UML.Profile) and ("profile",) or (), ), ), EditableText( text=lambda: self.subject and self.subject.name or "", style={"font-weight": FontWeight.BOLD}, ), Text( text=lambda: from_package_str(self), style={"font-size": "x-small"}, ), style={"padding": (24, 12, 4, 12)}, draw=draw_package, ) self.watch("subject[NamedElement].name") self.watch("subject[NamedElement].namespace.name") self.watch("subject.appliedStereotype.classifier.name")
def __init__(self, id=None, model=None): super().__init__(id, model) self._toplevel = False self._bottom = False self._subpart = False self._hdmax = 0 # maximum subpartition header height self.shape = Box( Text( text=lambda: stereotypes_str( self.subject, self.subject and self.subject.isExternal and ("external",) or (), ), ), Text(text=lambda: self.subject.name or ""), style={ "min-width": 0, "min-height": 0, "line-width": 2.4, "vertical-align": VerticalAlign.TOP, "padding": (2, 2, 2, 2), }, draw=self.draw_partition, ) self.min_width = 100 self.min_height = 300
def __init__(self, id=None, model=None): super().__init__(id, model) def role_name(): try: return self.subject.end["it.role", 0].role.name or "" except (IndexError, AttributeError) as e: return "" 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 ""), Text(text=role_name, style={ "min-width": 0, "min-height": 0 }), ) self.watch("subject<NamedElement>.name") self.watch("subject.appliedStereotype.classifier.name") self.watch("subject<Connector>.end.role.name")
def id_and_text_compartment(self): subject = self.subject if subject and (subject.externalId or subject.text): return Box( *([ Text( text=lambda: f"Id: {subject.externalId}", style={"text-align": TextAlign.LEFT}, ) ] if subject and subject.externalId else []), *([ Text( text=lambda: f"Text: {subject.text}", width=lambda: self.width - 8, style={"text-align": TextAlign.LEFT}, ) ] if subject and subject.text else []), style={ "padding": (4, 4, 4, 4), "min-height": 8 }, draw=draw_top_separator, ) else: return Box()
def __init__(self, connections, id=None, model=None): super().__init__(connections, id, model) self.shape = Box( Text(text=lambda: stereotypes_str( self.subject, isinstance(self.subject, UML.Profile) and ("profile", ) or (), ), ), EditableText( text=lambda: self.subject and self.subject.name or "", style={"font-weight": FontWeight.BOLD}, ), Text( text=lambda: from_package_str(self), style={ "font-size": 10, "min-width": 0, "min-height": 0 }, ), style={ "min-width": 50, "min-height": 70, "padding": (25, 10, 5, 10) }, draw=draw_package, ) self.watch("subject[NamedElement].name") self.watch("subject[NamedElement].namespace.name") self.watch("subject.appliedStereotype.classifier.name")
def __init__(self, diagram, id=None): super().__init__(diagram, id=id) h1, h2 = Handle(), Handle() self._handles = [h1, h2] self._ports = [LinePort(h1.pos, h2.pos)] self.watch_handle(h1) self.watch_handle(h2) self.shape = IconBox( Box(draw=self.draw_fork_node), Text( text=lambda: stereotypes_str(self.subject), ), EditableText(text=lambda: self.subject and self.subject.name or ""), Text( text=lambda: isinstance(self.subject, UML.JoinNode) and self.subject.joinSpec not in (None, DEFAULT_JOIN_SPEC) and f"{{ joinSpec = {self.subject.joinSpec} }}" or "", ), ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name") self.watch("subject[JoinNode].joinSpec") diagram.connections.add_constraint(self, constraint(vertical=(h1.pos, h2.pos))) diagram.connections.add_constraint( self, constraint(above=(h1.pos, h2.pos), delta=30) )
def __init__(self, diagram, id=None): super().__init__( diagram, id, shape=IconBox( Box( Text(text=lambda: stereotypes_str(self.subject), ), 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} }}" or "", ), Text(text=lambda: self.show_ordering and self.subject.ordering and f"{{ ordering = {self.subject.ordering} }}" or "", ), ), ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name") self.watch("subject[ObjectNode].upperBound") self.watch("subject[ObjectNode].ordering") self.watch("show_ordering")
def __init__(self, connections, id=None, model=None): super().__init__(id=id, model=model) self._matrix = Matrix() self._matrix_i2c = Matrix() self._connections = connections h1, h2 = Handle(), Handle() self._handles = [h1, h2] self._ports = [LinePort(h1.pos, h2.pos)] self._combined = None self.shape = IconBox( Box(style={"min-width": 0, "min-height": 45}, draw=self.draw_fork_node), Text( text=lambda: stereotypes_str(self.subject), ), EditableText(text=lambda: self.subject and self.subject.name or ""), Text( text=lambda: isinstance(self.subject, UML.JoinNode) and self.subject.joinSpec not in (None, DEFAULT_JOIN_SPEC) and f"{{ joinSpec = {self.subject.joinSpec} }}" or "", ), ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name") self.watch("subject[JoinNode].joinSpec") connections.add_constraint(self, constraint(vertical=(h1.pos, h2.pos))) connections.add_constraint(self, constraint(above=(h1.pos, h2.pos), delta=30))
def update_shapes(self, event=None): self.shape = Box( Box( Text(text=lambda: UML.model.stereotypes_str( self.subject, self.additional_stereotypes()), ), 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, }, ), Text( text=lambda: from_package_str(self), style={"font-size": "x-small"}, ), style={"padding": (12, 4, 12, 4)}, ), *(self.show_attributes and self.subject and [attributes_compartment(self.subject)] or []), *(self.show_operations and self.subject and [operations_compartment(self.subject)] or []), *(self.show_stereotypes and stereotype_compartments(self.subject) or []), style={ "vertical-align": VerticalAlign.TOP, }, draw=draw_border, )
def class_shape(self): return Box( Box( Text(text=lambda: UML.model.stereotypes_str( self.subject, ("interface", )), ), EditableText( text=lambda: self.subject.name or "", style={"font-weight": FontWeight.BOLD}, ), Text( text=lambda: from_package_str(self), style={ "font-size": 10, "min-width": 0, "min-height": 0 }, ), style={"padding": (12, 4, 12, 4)}, ), *(self.show_attributes and self.subject and [attributes_compartment(self.subject)] or []), *(self.show_operations and self.subject and [operations_compartment(self.subject)] or []), *(self.show_stereotypes and stereotype_compartments(self.subject) or []), style={ "min-width": 100, "min-height": 50, "vertical-align": VerticalAlign.TOP, }, draw=draw_border, )
def update_shapes(self, event=None): compartment = Box( Text( text=lambda: self.subject.entry.name and f"entry / {self.subject.entry.name}" or "", style={ "text-align": TextAlign.LEFT, "min-height": 0 }, ), Text( text=lambda: self.subject.exit.name and f"exit / {self.subject.exit.name}" or "", style={ "text-align": TextAlign.LEFT, "min-height": 0 }, ), Text( text=lambda: self.subject.doActivity.name and f"do / {self.subject.doActivity.name}" or "", style={ "text-align": TextAlign.LEFT, "min-height": 0 }, ), style={ "padding": (4, 4, 4, 4), "vertical-align": VerticalAlign.TOP }, draw=draw_top_separator, ) if not any(t.text() for t in compartment.children): compartment = Box() self.shape = Box( Box( Text( text=lambda: stereotypes_str(self.subject), style={ "min-width": 0, "min-height": 0 }, ), EditableText(text=lambda: self.subject.name or ""), style={"padding": (4, 4, 4, 4)}, ), compartment, style={ "min-width": 50, "min-height": 30, "vertical-align": VerticalAlign.TOP, }, draw=draw_state, )
def update_shapes(self): 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 ""), *(Text(text=lambda: message.name) for message in self._messages), *(Text(text=lambda: message.name) for message in self._inverted_messages), ) self.request_update()
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, }, ), Text( text=lambda: from_package_str(self), style={"font": "sans 8", "min-width": 0, "min-height": 0}, ), style={"padding": (12, 4, 12, 4)}, ), *( self.show_attributes and self.subject and [attributes_compartment(self.subject)] or [] ), *( self.show_operations and self.subject and [operations_compartment(self.subject)] or [] ), *(self.show_stereotypes and stereotype_compartments(self.subject) or []), style={ "min-width": 100, "min-height": 50, "vertical-align": VerticalAlign.TOP, }, draw=draw_border, )
def update_shapes(self, event=None): self.shape = Box( Box( Text( text=lambda: stereotypes_str(self.subject, ["block"]), style={ "min-width": 0, "min-height": 0 }, ), EditableText( text=lambda: self.subject.name or "", width=lambda: self.width - 4, style={ "font-weight": FontWeight.BOLD, "font-style": FontStyle.ITALIC if self.subject and self.subject.isAbstract else FontStyle.NORMAL, }, ), Text( text=lambda: from_package_str(self), style={ "font-size": 10, "min-width": 0, "min-height": 0 }, ), style={"padding": (12, 4, 12, 4)}, ), *(self.show_parts and self.subject and [ self.block_compartment( gettext("parts"), lambda a: a.aggregation == "composite", ) ] or []), *(self.show_references and self.subject and [ self.block_compartment( gettext("references"), lambda a: a.aggregation != "composite", ) ] or []), *(self.show_stereotypes and stereotype_compartments(self.subject) or []), style={ "min-width": 100, "min-height": 50, "vertical-align": VerticalAlign.TOP, }, draw=draw_border, )
def update_shapes(self, event=None): self.shape = Box(Box( Text( text=lambda: UML.model.stereotypes_str( self.subject, ("device", ) if isinstance(self.subject, UML.Device) else (), ), style={ "min-width": 0, "min-height": 0 }, ), EditableText( text=lambda: self.subject.name or "", style={"font-weight": FontWeight.BOLD}, ), style={"padding": (4, 4, 4, 4)}, ), *(self.show_stereotypes_attrs and stereotype_compartments(self.subject) or []), style={ "min-width": 100, "min-height": 50 }, draw=draw_node)
def __init__(self, id=None, model=None): super().__init__(id, model, style={"dash-style": (7.0, 5.0)}) self.shape_middle = Text( text=lambda: stereotypes_str(self.subject, ("import", )), ) self.watch("subject.appliedStereotype.classifier.name") self.draw_head = draw_arrow_head
def __init__(self, id=None, model=None): super().__init__(id, model) EAR = 15 OFFSET = 5 self.min_width = EAR + 2 * OFFSET self.height = 50 self.width = 100 self.body = Text( text=lambda: self.subject.body or "", width=lambda: self.width - EAR - 2 * OFFSET, style={ "text-align": TextAlign.LEFT, "vertical-align": VerticalAlign.TOP }, ) self.shape = Box( self.body, style={ "ear": EAR, "padding": (OFFSET, EAR + OFFSET, OFFSET, OFFSET) }, draw=self.draw_border, ) self.watch("subject[Comment].body")
def __init__(self, id=None, model=None): super().__init__(id, model) no_movable_handles(self) self._combined = None self.shape = IconBox( Box(style={ "min-width": 20, "min-height": 30 }, draw=draw_decision_node), # Text should be left-top Text( text=lambda: stereotypes_str(self.subject), style={ "min-width": 0, "min-height": 0 }, ), EditableText( text=lambda: self.subject and self.subject.name or ""), ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name")
def operations_compartment(subject): def lazy_format(operation): return lambda: UML.format( operation, visibility=True, type=True, multiplicity=True, default=True ) return Box( *( Text( text=lazy_format(operation), style={ "text-align": TextAlign.LEFT, "font-style": FontStyle.ITALIC if operation.isAbstract else FontStyle.NORMAL, "text-decoration": TextDecoration.UNDERLINE if operation.isStatic else TextDecoration.NONE, }, ) for operation in subject.ownedOperation ), style={"padding": (4, 4, 4, 4), "min-height": 8}, draw=draw_top_separator, )
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, "min-height": 100, "vertical-align": VerticalAlign.TOP, }, draw=draw_interaction, ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name")
def __init__(self, id=None, model=None): """ Create action item. """ 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={ "min-width": 50, "min-height": 30, "padding": (5, 10, 5, 25) }, draw=self.draw_border, ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name")
def __init__(self, id=None, model=None): super().__init__(id, model) self.is_destroyed = False self.lifetime = LifetimeItem() top = self.lifetime.top bottom = self.lifetime.bottom self._handles.append(top) self._handles.append(bottom) self._ports.append(self.lifetime.port) 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": 100, "min-height": 50}, draw=self.draw_lifeline, ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name")
def update_shapes(self, event=None): self.shape = Box( Box( Text(text=lambda: UML.model.stereotypes_str( self.subject, isinstance(self.subject, UML.Device) and ("device", ) or (), ), ), EditableText( text=lambda: self.subject.name or "", style={"font-weight": FontWeight.BOLD}, ), style={"padding": (4, 4, 4, 4)}, ), *(self.show_stereotypes and stereotype_compartments(self.subject) or []), style={ "min-width": 100, "min-height": 50, "vertical-align": VerticalAlign.TOP if self.diagram and self.children else VerticalAlign.MIDDLE, }, draw=draw_node)
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), ), EditableText( text=lambda: self.subject.name or "", style={ "font-weight": FontWeight.NORMAL if connectors else FontWeight.BOLD }, ), )
def __init__(self, id=None, model=None): super().__init__(id, model) self.shape_middle = Text( text=lambda: stereotypes_str(self.subject, ("Derivation", )), ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name")
def update_shapes(self, event=None): self.shape = Box( Box( Text(text=lambda: UML.model.stereotypes_str(self.subject), ), EditableText( text=lambda: self.subject.name or "", style={"font-weight": FontWeight.BOLD}, ), style={ "padding": (4, 34, 4, 4), "min-height": 44 }, draw=draw_component_icon, ), *(self.show_stereotypes and stereotype_compartments(self.subject) or []), style={ "min-width": 100, "min-height": 50, "vertical-align": VerticalAlign.TOP if self.canvas and self.canvas.get_children(self) else VerticalAlign.MIDDLE, }, draw=draw_border)
def update_shapes(self): self.shape = IconBox( Box(draw=draw_history_pseudostate if self.subject and self.subject. kind == "shallowHistory" else draw_initial_pseudostate), Text(text=lambda: stereotypes_str(self.subject), ), EditableText(text=lambda: self.subject.name or ""), )