Ejemplo n.º 1
0
    def __init__(self, id=None):
        gaphas.Element.__init__(self)
        DiagramItem.__init__(self, id)

        self.min_width = self.style.min_size[0]
        self.min_height = self.style.min_size[1]
        self.auto_resize = 0
Ejemplo n.º 2
0
    def __init__(self, id=None):
        Item.__init__(self)
        DiagramItem.__init__(self, id)

        h1, h2 = Handle(), Handle()
        self._handles.append(h1)
        self._handles.append(h2)
        self._ports.append(LinePort(h1.pos, h2.pos))

        self._combined = None

        self._join_spec = self.add_text('joinSpec',
                                        pattern='{ joinSpec = %s }',
                                        style=self.STYLE_TOP,
                                        visible=self.is_join_spec_visible)

        self._name = self.add_text('name',
                                   style={
                                       'text-align': self.style.name_align,
                                       'text-padding': self.style.name_padding,
                                       'text-outside': self.style.name_outside,
                                       'text-align-str':
                                       self.style.name_align_str,
                                       'text-align-group': 'stereotype',
                                   },
                                   editable=True)

        self.watch('subject<NamedElement>.name', self.on_named_element_name)\
            .watch('subject<JoinNode>.joinSpec', self.on_join_node_join_spec)
Ejemplo n.º 3
0
    def __init__(self, id=None):
        Item.__init__(self)
        DiagramItem.__init__(self, id)
        
        h1, h2 = Handle(), Handle()
        self._handles.append(h1)
        self._handles.append(h2)
        self._ports.append(LinePort(h1.pos, h2.pos))

        self._combined = None

        self._join_spec = self.add_text('joinSpec',
            pattern='{ joinSpec = %s }',
            style=self.STYLE_TOP,
            visible=self.is_join_spec_visible)

        self._name = self.add_text('name', style={
                    'text-align': self.style.name_align,
                    'text-padding': self.style.name_padding,
                    'text-outside': self.style.name_outside,
                    'text-align-str': self.style.name_align_str,
                    'text-align-group': 'stereotype',
                }, editable=True)

        self.watch('subject<NamedElement>.name', self.on_named_element_name)\
            .watch('subject<JoinNode>.joinSpec', self.on_join_node_join_spec)
Ejemplo n.º 4
0
    def __init__(self, id=None):
        gaphas.Element.__init__(self)
        DiagramItem.__init__(self, id)

        self.min_width = self.style.min_size[0]
        self.min_height = self.style.min_size[1]
        self.auto_resize = 0
Ejemplo n.º 5
0
    def __init__(self, id=None, model=None):
        Item.__init__(self)
        DiagramItem.__init__(self, 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._join_spec = self.add_text(
            "joinSpec",
            pattern="{ joinSpec = %s }",
            style=self.STYLE_TOP,
            visible=self.is_join_spec_visible,
        )

        self._name = self.add_text(
            "name",
            style={
                "text-align": self.style.name_align,
                "text-padding": self.style.name_padding,
                "text-outside": self.style.name_outside,
                "text-align-str": self.style.name_align_str,
                "text-align-group": "stereotype",
            },
            editable=True,
        )

        self.watch("subject<NamedElement>.name",
                   self.on_named_element_name).watch(
                       "subject<JoinNode>.joinSpec",
                       self.on_join_node_join_spec)
Ejemplo n.º 6
0
    def __init__(self, id=None):
        Item.__init__(self)
        DiagramItem.__init__(self, id)

        h1, h2 = Handle(), Handle()
        self._handles.append(h1)
        self._handles.append(h2)
        self._ports.append(LinePort(h1.pos, h2.pos))

        self._combined = None

        self._join_spec = self.add_text(
            "joinSpec.value", pattern="{ joinSpec = %s }", style=self.STYLE_TOP, visible=self.is_join_spec_visible
        )

        self._name = self.add_text(
            "name",
            style={
                "text-align": self.style.name_align,
                "text-padding": self.style.name_padding,
                "text-outside": self.style.name_outside,
                "text-align-str": self.style.name_align_str,
                "text-align-group": "stereotype",
            },
            editable=True,
        )

        self.watch("subject<NamedElement>.name", self.on_named_element_name).watch(
            "subject<JoinNode>.joinSpec<LiteralSpecification>.value", self.on_join_node_join_spec
        )
Ejemplo n.º 7
0
    def draw(self, context):
        """
        Draw vertical line - symbol of fork and join nodes. Join
        specification is also drawn above the item.
        """
        Item.draw(self, context)
        DiagramItem.draw(self, context)

        cr = context.cairo

        cr.set_line_width(6)
        h1, h2 = self._handles
        cr.move_to(h1.pos.x, h1.pos.y)
        cr.line_to(h2.pos.x, h2.pos.y)

        cr.stroke()
Ejemplo n.º 8
0
    def draw(self, context):
        """
        Draw vertical line - symbol of fork and join nodes. Join
        specification is also drawn above the item.
        """
        Item.draw(self, context)
        DiagramItem.draw(self, context)

        cr = context.cairo

        cr.set_line_width(6)
        h1, h2 = self._handles
        cr.move_to(h1.pos.x, h1.pos.y)
        cr.line_to(h2.pos.x, h2.pos.y)

        cr.stroke()
Ejemplo n.º 9
0
    def save(self, save_func):
        DiagramItem.save(self, save_func)
        save_func("matrix", tuple(self.matrix))
        for prop in ("orthogonal", "horizontal"):
            save_func(prop, getattr(self, prop))
        points = []
        for h in self.handles():
            points.append(tuple(map(float, h.pos)))
        save_func("points", points)

        canvas = self.canvas
        c = canvas.get_connection(self.head)
        if c:
            save_func("head-connection", c.connected, reference=True)
        c = canvas.get_connection(self.tail)
        if c:
            save_func("tail-connection", c.connected, reference=True)
Ejemplo n.º 10
0
    def save(self, save_func):
        DiagramItem.save(self, save_func)
        save_func("matrix", tuple(self.matrix))
        for prop in ("orthogonal", "horizontal"):
            save_func(prop, getattr(self, prop))
        points = []
        for h in self.handles():
            points.append(tuple(map(float, h.pos)))
        save_func("points", points)

        canvas = self.canvas
        c = canvas.get_connection(self.head)
        if c:
            save_func("head-connection", c.connected, reference=True)
        c = canvas.get_connection(self.tail)
        if c:
            save_func("tail-connection", c.connected, reference=True)
Ejemplo n.º 11
0
    def postload(self):
        if hasattr(self, "_load_orthogonal"):
            # Ensure there are enough handles
            if self._load_orthogonal and len(self._handles) < 3:
                p0 = self._handles[-1].pos
                self._handles.insert(1, self._create_handle(p0))
            self.orthogonal = self._load_orthogonal
            del self._load_orthogonal

        # First update matrix and solve constraints (NE and SW handle are
        # lazy and are resolved by the constraint solver rather than set
        # directly.
        self.canvas.update_matrix(self)
        self.canvas.solver.solve()

        if hasattr(self, "_load_head_connection"):
            self._postload_connect(self.head, self._load_head_connection)
            del self._load_head_connection

        if hasattr(self, "_load_tail_connection"):
            self._postload_connect(self.tail, self._load_tail_connection)
            del self._load_tail_connection

        DiagramItem.postload(self)
Ejemplo n.º 12
0
    def load(self, name, value):
        if name == "matrix":
            self.matrix = eval(value)
        elif name == "points":
            points = eval(value)
            for x in range(len(points) - 2):
                h = self._create_handle((0, 0))
                self._handles.insert(1, h)
            for i, p in enumerate(points):
                self.handles()[i].pos = p

            # Update connection ports of the line. Only handles are saved
            # in Gaphor file therefore ports need to be recreated after
            # handles information is loaded.
            self._update_ports()

        elif name == "orthogonal":
            self._load_orthogonal = eval(value)
        elif name in ("head_connection", "head-connection"):
            self._load_head_connection = value
        elif name in ("tail_connection", "tail-connection"):
            self._load_tail_connection = value
        else:
            DiagramItem.load(self, name, value)
Ejemplo n.º 13
0
    def load(self, name, value):
        if name == "matrix":
            self.matrix = eval(value)
        elif name == "points":
            points = eval(value)
            for x in range(len(points) - 2):
                h = self._create_handle((0, 0))
                self._handles.insert(1, h)
            for i, p in enumerate(points):
                self.handles()[i].pos = p

            # Update connection ports of the line. Only handles are saved
            # in Gaphor file therefore ports need to be recreated after
            # handles information is loaded.
            self._update_ports()

        elif name == "orthogonal":
            self._load_orthogonal = eval(value)
        elif name in ("head_connection", "head-connection"):
            self._load_head_connection = value
        elif name in ("tail_connection", "tail-connection"):
            self._load_tail_connection = value
        else:
            DiagramItem.load(self, name, value)
Ejemplo n.º 14
0
    def postload(self):
        if hasattr(self, "_load_orthogonal"):
            # Ensure there are enough handles
            if self._load_orthogonal and len(self._handles) < 3:
                p0 = self._handles[-1].pos
                self._handles.insert(1, self._create_handle(p0))
            self.orthogonal = self._load_orthogonal
            del self._load_orthogonal

        # First update matrix and solve constraints (NE and SW handle are
        # lazy and are resolved by the constraint solver rather than set
        # directly.
        self.canvas.update_matrix(self)
        self.canvas.solver.solve()

        if hasattr(self, "_load_head_connection"):
            self._postload_connect(self.head, self._load_head_connection)
            del self._load_head_connection

        if hasattr(self, "_load_tail_connection"):
            self._postload_connect(self.tail, self._load_tail_connection)
            del self._load_tail_connection

        DiagramItem.postload(self)
Ejemplo n.º 15
0
 def pre_update(self, context):
     # super(ElementItem, self).pre_update(context)
     self.update_stereotype()
     DiagramItem.pre_update(self, context)
     gaphas.Element.pre_update(self, context)
Ejemplo n.º 16
0
 def draw(self, context):
     self.fill_background(context)
     self.highlight(context)
     gaphas.Element.draw(self, context)
     DiagramItem.draw(self, context)
Ejemplo n.º 17
0
 def point(self, pos):
     d1 = gaphas.Element.point(self, pos)
     d2 = DiagramItem.point(self, pos)
     return min(d1, d2)
Ejemplo n.º 18
0
 def load(self, name, value):
     if name == 'matrix':
         self.matrix = eval(value)
     else:
         DiagramItem.load(self, name, value)
Ejemplo n.º 19
0
 def save(self, save_func):
     save_func("matrix", tuple(self.matrix))
     save_func("height", float(self._handles[1].pos.y))
     if self._combined:
         save_func("combined", self._combined, reference=True)
     DiagramItem.save(self, save_func)
Ejemplo n.º 20
0
 def save(self, save_func):
     save_func('matrix', tuple(self.matrix))
     save_func('height', float(self._handles[1].pos.y))
     if self._combined:
         save_func('combined', self._combined, reference=True)
     DiagramItem.save(self, save_func)
Ejemplo n.º 21
0
 def draw(self, context):
     self.fill_background(context)
     self.highlight(context)
     gaphas.Element.draw(self, context)
     DiagramItem.draw(self, context)
Ejemplo n.º 22
0
 def pre_update(self, context):
     self.update_stereotype()
     Item.pre_update(self, context)
     DiagramItem.pre_update(self, context)
Ejemplo n.º 23
0
 def draw(self, context):
     gaphas.Line.draw(self, context)
     DiagramItem.draw(self, context)
Ejemplo n.º 24
0
 def post_update(self, context):
     gaphas.Line.post_update(self, context)
     DiagramItem.post_update(self, context)
Ejemplo n.º 25
0
    def pre_update(self, context):
        # first, update stereotype to know its text
        self.update_stereotype()

        gaphas.Line.pre_update(self, context)
        DiagramItem.pre_update(self, context)
Ejemplo n.º 26
0
 def __init__(self, id=None):
     gaphas.Line.__init__(self)
     DiagramItem.__init__(self, id)
     self.fuzziness = 2
Ejemplo n.º 27
0
 def post_update(self, context):
     Item.post_update(self, context)
     DiagramItem.post_update(self, context)
Ejemplo n.º 28
0
 def pre_update(self, context):
     self.update_stereotype()
     Item.pre_update(self, context)
     DiagramItem.pre_update(self, context)
Ejemplo n.º 29
0
 def save(self, save_func):
     save_func("matrix", tuple(self.matrix))
     for prop in ("width", "height"):
         self.save_property(save_func, prop)
     DiagramItem.save(self, save_func)
Ejemplo n.º 30
0
 def post_update(self, context):
     gaphas.Element.post_update(self, context)
     DiagramItem.post_update(self, context)
Ejemplo n.º 31
0
 def save(self, save_func):
     save_func('matrix', tuple(self.matrix))
     save_func('height', float(self._handles[1].pos.y))
     if self._combined:
         save_func('combined', self._combined, reference=True)
     DiagramItem.save(self, save_func)
Ejemplo n.º 32
0
 def save(self, save_func):
     save_func("matrix", tuple(self.matrix))
     save_func("height", float(self._handles[1].pos.y))
     if self._combined:
         save_func("combined", self._combined, reference=True)
     DiagramItem.save(self, save_func)
Ejemplo n.º 33
0
 def post_update(self, context):
     Item.post_update(self, context)
     DiagramItem.post_update(self, context)
Ejemplo n.º 34
0
 def __init__(self, id=None):
     gaphas.Line.__init__(self)
     DiagramItem.__init__(self, id)
     self.fuzziness = 2
Ejemplo n.º 35
0
 def save(self, save_func):
     DiagramItem.save(self, save_func)
Ejemplo n.º 36
0
    def pre_update(self, context):
        # first, update stereotype to know its text
        self.update_stereotype()

        gaphas.Line.pre_update(self, context)
        DiagramItem.pre_update(self, context)
Ejemplo n.º 37
0
 def save(self, save_func):
     save_func('matrix', tuple(self.matrix))
     for prop in ('width', 'height'):
         self.save_property(save_func, prop)
     DiagramItem.save(self, save_func)
Ejemplo n.º 38
0
 def post_update(self, context):
     gaphas.Line.post_update(self, context)
     DiagramItem.post_update(self, context)
Ejemplo n.º 39
0
 def pre_update(self, context):
     # super(ElementItem, self).pre_update(context)
     self.update_stereotype()
     DiagramItem.pre_update(self, context)
     gaphas.Element.pre_update(self, context)
Ejemplo n.º 40
0
 def draw(self, context):
     gaphas.Line.draw(self, context)
     DiagramItem.draw(self, context)
Ejemplo n.º 41
0
 def post_update(self, context):
     gaphas.Element.post_update(self, context)
     DiagramItem.post_update(self, context)
Ejemplo n.º 42
0
 def point(self, pos):
     d1 = gaphas.Line.point(self, pos)
     d2 = DiagramItem.point(self, pos)
     return min(d1, d2)
Ejemplo n.º 43
0
 def save(self, save_func):
     DiagramItem.save(self, save_func)
Ejemplo n.º 44
0
 def load(self, name, value):
     if name == "matrix":
         self.matrix = eval(value)
     else:
         DiagramItem.load(self, name, value)