root/gaphor/trunk/gaphor/diagram/actor.py

Revision 1467, 1.6 kB (checked in by wrobe..@pld-linux.org, 1 year 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 Actor item classes.
3 """
4
5 from math import pi
6
7 from gaphor import UML
8 from gaphor.diagram.style import ALIGN_CENTER, ALIGN_BOTTOM
9 from gaphor.diagram.classifier import ClassifierItem
10
11 class ActorItem(ClassifierItem):
12     """
13     Actor item is a classifier in icon mode.
14
15     Maybe it should be possible to switch to comparment mode in the future.
16     """
17
18     __uml__ = UML.Actor
19
20     HEAD = 11
21     ARM  = 19
22     NECK = 10
23     BODY = 20
24     __style__ = {
25         'min-size': (ARM * 2, HEAD + NECK + BODY + ARM),
26         'name-align': (ALIGN_CENTER, ALIGN_BOTTOM),
27         'name-padding': (5, 0, 5, 0),
28         'name-outside': True,
29     }
30
31     def __init__(self, id = None):
32         ClassifierItem.__init__(self, id)
33
34         self.drawing_style = self.DRAW_ICON
35
36
37     def draw_icon(self, context):
38         """
39         Draw actor's icon creature.
40         """
41         super(ActorItem, self).draw(context)
42
43         cr = context.cairo
44
45         head, neck, arm, body = self.HEAD, self.NECK, self.ARM, self.BODY
46
47         fx = self.width / (arm * 2);
48         fy = self.height / (head + neck + body + arm)
49
50         x = arm * fx
51         y = (head / 2) * fy
52         cy = head * fy
53
54         cr.move_to(x + head * fy / 2.0, y)
55         cr.arc(x, y, head * fy / 2.0, 0, 2 * pi)
56
57         cr.move_to(x, y + cy / 2)
58         cr.line_to(arm * fx, (head + neck + body) * fy)
59
60         cr.move_to(0, (head + neck) * fy)
61         cr.line_to(arm * 2 * fx, (head + neck) * fy)
62
63         cr.move_to(0, (head + neck + body + arm) * fy)
64         cr.line_to(arm * fx, (head + neck + body) * fy)
65         cr.line_to(arm * 2 * fx, (head + neck + body + arm) * fy)
66         cr.stroke()
67
68
69 # vim:sw=4:et
Note: See TracBrowser for help on using the browser.