20 """ |
20 """ |
21 def __init__(self, name): |
21 def __init__(self, name): |
22 """ |
22 """ |
23 Constructor |
23 Constructor |
24 |
24 |
25 @param name package name (string) |
25 @param name package name |
|
26 @type str |
26 """ |
27 """ |
27 self.name = name |
28 self.name = name |
28 |
29 |
29 def getName(self): |
30 def getName(self): |
30 """ |
31 """ |
31 Public method to retrieve the model name. |
32 Public method to retrieve the model name. |
32 |
33 |
33 @return model name (string) |
34 @return model name |
|
35 @rtype str |
34 """ |
36 """ |
35 return self.name |
37 return self.name |
36 |
38 |
37 |
39 |
38 class UMLItem(QGraphicsRectItem): |
40 class UMLItem(QGraphicsRectItem): |
89 |
91 |
90 def getName(self): |
92 def getName(self): |
91 """ |
93 """ |
92 Public method to retrieve the item name. |
94 Public method to retrieve the item name. |
93 |
95 |
94 @return item name (string) |
96 @return item name |
|
97 @rtype str |
95 """ |
98 """ |
96 if self.model: |
99 if self.model: |
97 return self.model.name |
100 return self.model.name |
98 else: |
101 else: |
99 return "" |
102 return "" |
100 |
103 |
101 def setSize(self, width, height): |
104 def setSize(self, width, height): |
102 """ |
105 """ |
103 Public method to set the rectangles size. |
106 Public method to set the rectangles size. |
104 |
107 |
105 @param width width of the rectangle (float) |
108 @param width width of the rectangle |
106 @param height height of the rectangle (float) |
109 @type float |
|
110 @param height height of the rectangle |
|
111 @type float |
107 """ |
112 """ |
108 rect = self.rect() |
113 rect = self.rect() |
109 rect.setSize(QSizeF(width, height)) |
114 rect.setSize(QSizeF(width, height)) |
110 self.setRect(rect) |
115 self.setRect(rect) |
111 |
116 |
112 def addAssociation(self, assoc): |
117 def addAssociation(self, assoc): |
113 """ |
118 """ |
114 Public method to add an association to this widget. |
119 Public method to add an association to this widget. |
115 |
120 |
116 @param assoc association to be added (AssociationWidget) |
121 @param assoc association to be added |
|
122 @type AssociationWidget |
117 """ |
123 """ |
118 if assoc and assoc not in self.associations: |
124 if assoc and assoc not in self.associations: |
119 self.associations.append(assoc) |
125 self.associations.append(assoc) |
120 |
126 |
121 def removeAssociation(self, assoc): |
127 def removeAssociation(self, assoc): |
122 """ |
128 """ |
123 Public method to remove an association to this widget. |
129 Public method to remove an association to this widget. |
124 |
130 |
125 @param assoc association to be removed (AssociationWidget) |
131 @param assoc association to be removed |
|
132 @type AssociationWidget |
126 """ |
133 """ |
127 if assoc and assoc in self.associations: |
134 if assoc and assoc in self.associations: |
128 self.associations.remove(assoc) |
135 self.associations.remove(assoc) |
129 |
136 |
130 def removeAssociations(self): |
137 def removeAssociations(self): |
147 |
154 |
148 def moveBy(self, dx, dy): |
155 def moveBy(self, dx, dy): |
149 """ |
156 """ |
150 Public overriden method to move the widget relative. |
157 Public overriden method to move the widget relative. |
151 |
158 |
152 @param dx relative movement in x-direction (float) |
159 @param dx relative movement in x-direction |
153 @param dy relative movement in y-direction (float) |
160 @type float |
|
161 @param dy relative movement in y-direction |
|
162 @type float |
154 """ |
163 """ |
155 super().moveBy(dx, dy) |
164 super().moveBy(dx, dy) |
156 self.adjustAssociations() |
165 self.adjustAssociations() |
157 |
166 |
158 def setPos(self, x, y): |
167 def setPos(self, x, y): |
159 """ |
168 """ |
160 Public overriden method to set the items position. |
169 Public overriden method to set the items position. |
161 |
170 |
162 @param x absolute x-position (float) |
171 @param x absolute x-position |
163 @param y absolute y-position (float) |
172 @type float |
|
173 @param y absolute y-position |
|
174 @type float |
164 """ |
175 """ |
165 super().setPos(x, y) |
176 super().setPos(x, y) |
166 self.adjustAssociations() |
177 self.adjustAssociations() |
167 |
178 |
168 def itemChange(self, change, value): |
179 def itemChange(self, change, value): |
169 """ |
180 """ |
170 Public method called when an items state changes. |
181 Public method called when an items state changes. |
171 |
182 |
172 @param change the item's change (QGraphicsItem.GraphicsItemChange) |
183 @param change the item's change |
|
184 @type QGraphicsItem.GraphicsItemChange |
173 @param value the value of the change |
185 @param value the value of the change |
174 @return adjusted values |
186 @return adjusted values |
175 """ |
187 """ |
176 if change == QGraphicsItem.GraphicsItemChange.ItemPositionChange: |
188 if change == QGraphicsItem.GraphicsItemChange.ItemPositionChange: |
177 # 1. remember to adjust associations |
189 # 1. remember to adjust associations |
189 |
201 |
190 def paint(self, painter, option, widget=None): |
202 def paint(self, painter, option, widget=None): |
191 """ |
203 """ |
192 Public method to paint the item in local coordinates. |
204 Public method to paint the item in local coordinates. |
193 |
205 |
194 @param painter reference to the painter object (QPainter) |
206 @param painter reference to the painter object |
195 @param option style options (QStyleOptionGraphicsItem) |
207 @type QPainter |
196 @param widget optional reference to the widget painted on (QWidget) |
208 @param option style options |
|
209 @type QStyleOptionGraphicsItem |
|
210 @param widget optional reference to the widget painted on |
|
211 @type QWidget |
197 """ |
212 """ |
198 pen = self.pen() |
213 pen = self.pen() |
199 if ( |
214 if ( |
200 (option.state & QStyle.StateFlag.State_Selected) == |
215 (option.state & QStyle.StateFlag.State_Selected) == |
201 QStyle.State(QStyle.StateFlag.State_Selected) |
216 QStyle.State(QStyle.StateFlag.State_Selected) |
211 |
226 |
212 def setId(self, itemId): |
227 def setId(self, itemId): |
213 """ |
228 """ |
214 Public method to assign an ID to the item. |
229 Public method to assign an ID to the item. |
215 |
230 |
216 @param itemId assigned ID (integer) |
231 @param itemId assigned ID |
|
232 @type int |
217 """ |
233 """ |
218 self.__id = itemId |
234 self.__id = itemId |
219 |
235 |
220 def getId(self): |
236 def getId(self): |
221 """ |
237 """ |
222 Public method to get the item ID. |
238 Public method to get the item ID. |
223 |
239 |
224 @return ID of the item (integer) |
240 @return ID of the item |
|
241 @rtype int |
225 """ |
242 """ |
226 return self.__id |
243 return self.__id |
227 |
244 |
228 def getItemType(self): |
245 def getItemType(self): |
229 """ |
246 """ |
230 Public method to get the item's type. |
247 Public method to get the item's type. |
231 |
248 |
232 @return item type (string) |
249 @return item type |
|
250 @rtype str |
233 """ |
251 """ |
234 return self.ItemType |
252 return self.ItemType |
235 |
253 |
236 def buildItemDataString(self): |
254 def buildItemDataString(self): |
237 """ |
255 """ |
239 |
257 |
240 This string must start with ", " and should be built like |
258 This string must start with ", " and should be built like |
241 "attribute=value" with pairs separated by ", ". value must not |
259 "attribute=value" with pairs separated by ", ". value must not |
242 contain ", " or newlines. |
260 contain ", " or newlines. |
243 |
261 |
244 @return persistence data (string) |
262 @return persistence data |
|
263 @rtype str |
245 """ |
264 """ |
246 return "" |
265 return "" |
247 |
266 |
248 def parseItemDataString(self, version, data): |
267 def parseItemDataString(self, version, data): |
249 """ |
268 """ |
250 Public method to parse the given persistence data. |
269 Public method to parse the given persistence data. |
251 |
270 |
252 @param version version of the data (string) |
271 @param version version of the data |
253 @param data persisted data to be parsed (string) |
272 @type str |
254 @return flag indicating success (boolean) |
273 @param data persisted data to be parsed |
|
274 @type str |
|
275 @return flag indicating success |
|
276 @rtype bool |
255 """ |
277 """ |
256 return True |
278 return True |