14 import Utilities |
14 import Utilities |
15 import Utilities.ModuleParser |
15 import Utilities.ModuleParser |
16 import Preferences |
16 import Preferences |
17 |
17 |
18 from .UMLDiagramBuilder import UMLDiagramBuilder |
18 from .UMLDiagramBuilder import UMLDiagramBuilder |
19 from .ClassItem import ClassItem, ClassModel |
|
20 from .AssociationItem import AssociationItem, Generalisation |
|
21 from . import GraphicsUtilities |
|
22 |
19 |
23 |
20 |
24 class UMLClassDiagramBuilder(UMLDiagramBuilder): |
21 class UMLClassDiagramBuilder(UMLDiagramBuilder): |
25 """ |
22 """ |
26 Class implementing a builder for UML like class diagrams. |
23 Class implementing a builder for UML like class diagrams. |
150 """ |
147 """ |
151 Private method to arrange the shapes on the canvas. |
148 Private method to arrange the shapes on the canvas. |
152 |
149 |
153 The algorithm is borrowed from Boa Constructor. |
150 The algorithm is borrowed from Boa Constructor. |
154 """ |
151 """ |
|
152 from . import GraphicsUtilities |
155 generations = GraphicsUtilities.sort(nodes, routes) |
153 generations = GraphicsUtilities.sort(nodes, routes) |
156 |
154 |
157 # calculate width and height of all elements |
155 # calculate width and height of all elements |
158 sizes = [] |
156 sizes = [] |
159 for generation in generations: |
157 for generation in generations: |
224 @param _class class to be shown (ModuleParser.Class) |
222 @param _class class to be shown (ModuleParser.Class) |
225 @param x x-coordinate (float) |
223 @param x x-coordinate (float) |
226 @param y y-coordinate (float) |
224 @param y y-coordinate (float) |
227 @param isRbModule flag indicating a Ruby module (boolean) |
225 @param isRbModule flag indicating a Ruby module (boolean) |
228 """ |
226 """ |
|
227 from .ClassItem import ClassItem, ClassModel |
229 meths = sorted(_class.methods.keys()) |
228 meths = sorted(_class.methods.keys()) |
230 attrs = sorted(_class.attributes.keys()) |
229 attrs = sorted(_class.attributes.keys()) |
231 name = _class.name |
230 name = _class.name |
232 if isRbModule: |
231 if isRbModule: |
233 name = "{0} (Module)".format(name) |
232 name = "{0} (Module)".format(name) |
247 |
246 |
248 @param _class class to be shown (string) |
247 @param _class class to be shown (string) |
249 @param x x-coordinate (float) |
248 @param x x-coordinate (float) |
250 @param y y-coordinate (float) |
249 @param y y-coordinate (float) |
251 """ |
250 """ |
|
251 from .ClassItem import ClassItem, ClassModel |
252 cl = ClassModel(_class) |
252 cl = ClassModel(_class) |
253 cw = ClassItem(cl, True, x, y, noAttrs=self.noAttrs, scene=self.scene) |
253 cw = ClassItem(cl, True, x, y, noAttrs=self.noAttrs, scene=self.scene) |
254 cw.setId(self.umlView.getItemId()) |
254 cw.setId(self.umlView.getItemId()) |
255 self.allClasses[_class] = cw |
255 self.allClasses[_class] = cw |
256 if _class not in self.allModules[self.file]: |
256 if _class not in self.allModules[self.file]: |
260 """ |
260 """ |
261 Private method to generate the associations between the class shapes. |
261 Private method to generate the associations between the class shapes. |
262 |
262 |
263 @param routes list of relationsships |
263 @param routes list of relationsships |
264 """ |
264 """ |
|
265 from .AssociationItem import AssociationItem, Generalisation |
265 for route in routes: |
266 for route in routes: |
266 if len(route) > 1: |
267 if len(route) > 1: |
267 assoc = AssociationItem( |
268 assoc = AssociationItem( |
268 self.__getCurrentShape(route[1]), |
269 self.__getCurrentShape(route[1]), |
269 self.__getCurrentShape(route[0]), |
270 self.__getCurrentShape(route[0]), |