root/gaphor/tags/gaphor-0.12.5/gaphor/diagram/usecase.py

Revision 1443, 1.1 kB (checked in by arj..@yirdis.nl, 2 years ago)

Removed from gaphor.UML:

  • create()
  • select()
  • lselect()
  • lookup()
  • swap_element()
  • flush()

Now use an element factory directly.

Also fixes unit tests.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 """
2 Use case diagram item.
3 """
4
5 from math import pi
6 from gaphor import UML
7 from gaphor.diagram.classifier import ClassifierItem
8 from gaphor.diagram.style import ALIGN_CENTER, ALIGN_MIDDLE
9 from gaphas.util import text_align, text_extents, path_ellipse
10
11 class UseCaseItem(ClassifierItem):
12     """
13     Presentation of gaphor.UML.UseCase.
14     """
15     __uml__ = UML.UseCase
16     __style__ = {
17         'min-size':   (50, 30),
18         'name-align': (ALIGN_CENTER, ALIGN_MIDDLE),
19     }
20
21     def __init__(self, id=None):
22         super(UseCaseItem, self).__init__(id)
23         self.drawing_style = -1
24
25
26     def pre_update(self, context):
27         cr = context.cairo
28         text = self.subject.name
29         if text:
30             width, height = text_extents(cr, text)
31             self.min_width, self.min_height = width + 10, height + 20
32         super(UseCaseItem, self).pre_update(context)
33
34
35     def draw(self, context):
36         cr = context.cairo
37
38         rx = self.width / 2.
39         ry = self.height / 2.
40
41         cr.move_to(self.width, ry)
42         path_ellipse(cr, rx, ry, self.width, self.height)
43         cr.stroke()
44
45         super(UseCaseItem, self).draw(context)
46
47
48 # vim:sw=4:et
Note: See TracBrowser for help on using the browser.