def __init__(self, id=None, model=None): super().__init__(id, model) self.shape = IconBox( Box( style={ "min-width": ARM * 2, "min-height": HEAD + NECK + BODY + ARM }, draw=draw_actor, ), 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}, ), ) self.watch("subject<NamedElement>.name") self.watch("subject.appliedStereotype.classifier.name")
def update_shapes(self, event=None): self.shape = Box( Box( Text(text=lambda: stereotypes_str(self.subject, ["requirement"]), ), 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": "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 []), self.id_and_text_compartment(), style={ "vertical-align": VerticalAlign.TOP, }, draw=draw_border, )
def __init__(self, diagram, id=None): super().__init__(diagram, id) self._connections = diagram.connections self.is_destroyed = False self.lifetime = LifetimeItem() top = self.lifetime.top bottom = self.lifetime.bottom self._handles.append(top) self._handles.append(bottom) self.watch_handle(top) self.watch_handle(bottom) self._ports.append(self.lifetime.port) self.shape = Box( Text(text=lambda: stereotypes_str(self.subject), ), EditableText( text=lambda: self.subject.name or "", style={"font-weight": FontWeight.BOLD}, ), draw=self.draw_lifeline, ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name") self.setup_constraints()
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) self.shape_middle = Text( text=lambda: stereotypes_str(self.subject, ("Derivation", )), ) 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, 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, 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 __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 __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): 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 ""), )
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, 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, 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 test_just_additional_stereotypes(self): """Test additional stereotypes conversion without applied stereotypes """ cls = self.factory.create(uml2.Class) result = modelfactory.stereotypes_str(cls, ('test',)) self.assertEquals(fmt % 'test', result)
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, 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 __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 __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) self.shape_middle = Text( text=lambda: stereotypes_str(self.subject, ("Subquantityof", )), ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name") self.draw_tail = draw_tail_composite
def __init__(self, id=None, model=None): super().__init__(id, model, style={"dash-style": (7.0, 5.0)}) self.shape_middle = Box( Text(text=lambda: stereotypes_str(self.subject), ), EditableText(text=lambda: self.subject.name or ""), ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name")
def update_shapes(self): self.shape = IconBox( Box(style={"background-color": (1, 1, 1, 1)}, draw=draw_border), Text(text=lambda: stereotypes_str(self.subject, ("proxy", ))), EditableText( text=lambda: self.subject and self.subject.name or ""), style=text_position(self.connected_side()), ) self.request_update()
def __init__(self, diagram, id=None): super().__init__(diagram, id, style={"dash-style": (7.0, 5.0)}) self.shape_middle = Box( Text(text=lambda: stereotypes_str(self.subject, ("extend", ))), EditableText(text=lambda: self.subject.name or ""), ) self.watch("subject.appliedStereotype.classifier.name").watch( "subject[NamedElement].name") self.draw_head = draw_arrow_head
def __init__(self, diagram, id=None): super().__init__(diagram, id) self.shape_middle = Box( Text(text=lambda: stereotypes_str(self.subject), ), EditableText(text=lambda: self.subject.name or ""), ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name")
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}, ) ) self.watch("subject.appliedStereotype.classifier.name")
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 __init__(self, diagram, id=None): super().__init__(diagram, id) # AssociationEnds are really inseparable from the AssociationItem. # We give them the same id as the association item. self._head_end = AssociationEnd(owner=self, end="head") self._tail_end = AssociationEnd(owner=self, end="tail") # Direction depends on the ends that hold the ownedEnd attributes. self._dir_angle = 0 self._dir_pos = 0, 0 self.shape_middle = Box( Text( text=lambda: stereotypes_str(self.subject), ), EditableText(text=lambda: self.subject.name or ""), ) # For the association ends: base = "subject[Association].memberEnd[Property]" self.watch("subject[NamedElement].name").watch( "subject.appliedStereotype.classifier.name" ).watch(f"{base}.name", self.on_association_end_value).watch( f"{base}.aggregation", self.on_association_end_value ).watch( f"{base}.appliedStereotype.slot.definingFeature.name", self.on_association_end_value, ).watch( f"{base}.appliedStereotype.slot.value", self.on_association_end_value ).watch( f"{base}.classifier", self.on_association_end_value ).watch( f"{base}.visibility", self.on_association_end_value ).watch( f"{base}.lowerValue", self.on_association_end_value ).watch( f"{base}.upperValue", self.on_association_end_value ).watch( f"{base}.owningAssociation", self.on_association_end_value ).watch( f"{base}.type[Class].ownedAttribute", self.on_association_end_value ).watch( f"{base}.type[Interface].ownedAttribute", self.on_association_end_value ).watch( f"{base}.appliedStereotype.classifier", self.on_association_end_value ).watch( "subject[Association].memberEnd" ).watch( "subject[Association].ownedEnd" ).watch( "subject[Association].navigableOwnedEnd" ).watch( "show_direction" )
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 __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, (self.relation_type, )), style={ "min-width": 0, "min-height": 0 }, ) self.draw_head = draw_arrow_head self.watch("subject.appliedStereotype.classifier.name")
def __init__(self, diagram, id=None): super().__init__(diagram, id, width=50, height=30) self.shape = Box( Text(text=lambda: stereotypes_str(self.subject), ), EditableText(text=lambda: self.subject.name or ""), style={"padding": (4, 12, 4, 24)}, draw=self.draw_border, ) self.watch("subject[NamedElement].name") self.watch("subject.appliedStereotype.classifier.name")