1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 """
19 Contains the GraphObject class.
20 Tests are defined :doc:`Here <unit_canvas_drawing_graphobject>`.
21 """
22
23 import operator
27 """
28 Contains metric and color information and a list of child
29 graphical objects.
30 When a Graphical object is translated to another position
31 all of its children are also translated.
32 The purpose is to be able to define a graphical object
33 position relative to it's parent.
34 """
35
36 - def __init__(self, x=0, y=0, w=0, h=0, text=''):
37 self._childs = []
38 self._rect = (x, y, w, h)
39 self._text = text
40 self._brush_color = (0, 0, 0)
41 self._pen_color = (0, 0, 0)
42
44 """
45 Translate this object to a new position and translate
46 all of it's child the same amount.
47 """
48 self._rect = tuple(map(operator.add, self._rect, (x, y, 0, 0)))
49 for child in self.childs:
50 child.translate(x, y)
51
52 @property
54 """Getter and Setter property."""
55 return self._childs
56
57 @childs.setter
59 """ """
60 self._childs = childs
61
62 @property
64 """Getter property."""
65 return self._childs[0]
66
68 """Add a new child to the list of childs."""
69 self._childs.append(child)
70
71 @property
73 """Getter property."""
74 return self._text
75
76 @property
78 """Getter property."""
79 return self.rect[:2]
80
81 @property
83 """Getter property."""
84 return self._rect
85
86 @property
88 """Getter property."""
89 return self._rect[2]
90
91 @property
93 """Getter property."""
94 return self._rect[3]
95
96 @property
98 """Getter and Setter property."""
99 return self._brush_color
100
101 @brush_color.setter
104
105 @property
107 """Getter and Setter property."""
108 return self._pen_color
109
110 @pen_color.setter
113