root/gaphor/tags/gaphor-0.12.0/gaphor/diagram/artifact.py

Revision 1467, 1.5 kB (checked in by wrobe..@pld-linux.org, 2 years ago)

- fixes in actor and artifact classes to reuse classifier class properly
- interface folding fixes
- classifier module code cleanup

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 """
2 Artifact item.
3 """
4
5 from gaphor import UML
6 from gaphor.diagram.classifier import ClassifierItem
7
8 class ArtifactItem(ClassifierItem):
9
10     __uml__  = UML.Artifact
11     __icon__ = True
12
13     __style__ = {
14             'name-padding': (10, 25, 10, 10),
15     }
16
17     ICON_HEIGHT = 20
18
19     def __init__(self, id=None):
20         ClassifierItem.__init__(self, id)
21         self.height = 50
22         self.width = 120
23         # Set drawing style to compartment w/ small icon
24         self.drawing_style = self.DRAW_COMPARTMENT_ICON
25         self._line = []
26        
27     def update_compartment_icon(self, context):
28         super(ArtifactItem, self).update_compartment_icon(context)
29         w = self.ICON_WIDTH
30         h = self.ICON_HEIGHT
31         ix, iy = self.get_icon_pos()
32         ear = 5
33         self._line = (
34                 (ix + w - ear, iy + ear),
35                 (ix + w, iy + ear),
36                 (ix + w - ear, iy),
37                 (ix, iy),
38                 (ix, iy + h),
39                 (ix + w, iy + h),
40                 (ix + w, iy + ear))
41
42
43     def draw_compartment_icon(self, context):
44         cr = context.cairo
45         cr.save()
46
47         # draw icon
48         w = self.ICON_WIDTH
49         h = self.ICON_HEIGHT
50         ix, iy = self.get_icon_pos()
51         ear = 5
52         cr.set_line_width(1.0)
53         cr.move_to(ix + w - ear, iy)
54         for x, y in self._line:
55             cr.line_to(x, y)
56         cr.stroke()
57
58         cr.restore()
59         self.draw_compartment(context)
60
61 # vim:sw=4:et
Note: See TracBrowser for help on using the browser.