root/gaphor/trunk/gaphor/diagram/classes/implementation.py

Revision 2255, 1.1 kB (checked in by arj..@yirdis.nl, 9 months ago)

moved classes items to seperate package. More unit tests for interface item.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 """
2 Implementation of interface.
3 """
4
5 from gaphor import UML
6 from gaphor.diagram.diagramline import DiagramLine
7
8 class ImplementationItem(DiagramLine):
9
10     __uml__          = UML.Implementation
11
12     def __init__(self, id = None):
13         DiagramLine.__init__(self, id)
14         self._solid = False
15
16     def post_update(self, context):
17         # change look into solid line when connected to folded interface
18         from interface import InterfaceItem
19         conn_to = self.head.connected_to
20         if isinstance(conn_to, InterfaceItem) \
21            and conn_to.is_folded():
22             self._solid = True
23         else:
24             self._solid = False
25         DiagramLine.post_update(self, context)
26
27     def draw_head(self, context):
28         cr = context.cairo
29         cr.move_to(0, 0)
30         if not self._solid:
31             cr.set_dash((), 0)
32             cr.line_to(15, -10)
33             cr.line_to(15, 10)
34             cr.close_path()
35             cr.stroke()
36             cr.move_to(15, 0)
37
38     def draw(self, context):
39         if not self._solid:
40             context.cairo.set_dash((7.0, 5.0), 0)
41         super(ImplementationItem, self).draw(context)
42
43
44 # vim:sw=4
Note: See TracBrowser for help on using the browser.