root/gaphor/trunk/gaphor/diagram/action.py

Revision 1431, 0.9 kB (checked in by wrobe..@pld-linux.org, 1 year ago)

- fixed align code (finally)
- calculate text group sizes
- use group text sizes to calculate named item minimal size
- calculate minimal size of named elements and classifiers properly

  • NamedItem?._header_size contains size of named item header (stereotype,
    from, name)
  • ClassifierItem?.pre_update calculates only comparment total size, which
    is minimal size
  • NamedItem?.update calculates minimal size taking into account current
    minimal size

- display stereotype, when not empty

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 """
2 Action diagram item.
3 """
4
5 from math import pi
6
7 from gaphor import UML
8 from gaphor.diagram.nameditem import NamedItem
9 from gaphor.diagram.style import ALIGN_CENTER, ALIGN_MIDDLE
10
11 class ActionItem(NamedItem):
12     __uml__   = UML.Action
13     __style__ = {
14         'min-size':   (50, 30),
15         'name-align': (ALIGN_CENTER, ALIGN_MIDDLE),
16     }
17
18
19     def draw(self, context):
20         """
21         Draw action symbol.
22         """
23         super(ActionItem, self).draw(context)
24
25         c = context.cairo
26
27         d = 15
28
29         c.move_to(0, d)
30         c.arc(d, d, d, pi, 1.5 * pi)
31         c.line_to(self.width - d, 0)
32         c.arc(self.width - d, d, d, 1.5 * pi, 0)
33         c.line_to(self.width, self.height - d)
34         c.arc(self.width - d, self.height - d, d, 0, 0.5 * pi)
35         c.line_to(d, self.height)
36         c.arc(d, self.height - d, d, 0.5 * pi, pi)
37         c.close_path()
38
39         c.stroke()
40
41
42 # vim:sw=4:et
Note: See TracBrowser for help on using the browser.