eric6/Graphics/UMLClassDiagramBuilder.py

changeset 7254
f00d825fbdb3
parent 7229
53054eb5b15a
child 7360
9190402e4505
equal deleted inserted replaced
7253:50dbe65a1334 7254:f00d825fbdb3
70 70
71 self.allClasses = {} 71 self.allClasses = {}
72 self.allModules = {} 72 self.allModules = {}
73 73
74 try: 74 try:
75 extensions = Preferences.getPython("PythonExtensions") + \ 75 extensions = (
76 Preferences.getPython("Python3Extensions") + ['.rb'] 76 Preferences.getPython("PythonExtensions") +
77 Preferences.getPython("Python3Extensions") +
78 ['.rb']
79 )
77 module = Utilities.ModuleParser.readModule( 80 module = Utilities.ModuleParser.readModule(
78 self.file, extensions=extensions, caching=False) 81 self.file, extensions=extensions, caching=False)
79 except ImportError: 82 except ImportError:
80 ct = QGraphicsTextItem(None) 83 ct = QGraphicsTextItem(None)
81 ct.setHtml( 84 ct.setHtml(
203 self.umlView.setSceneSize(swidth, sheight) 206 self.umlView.setSceneSize(swidth, sheight)
204 207
205 # distribute each generation across the width and the 208 # distribute each generation across the width and the
206 # generations across height 209 # generations across height
207 y = 10.0 210 y = 10.0
208 for currentWidth, currentHeight, generation in \ 211 for currentWidth, currentHeight, generation in (
209 zip_longest(widths, heights, generations): 212 zip_longest(widths, heights, generations)
213 ):
210 x = 10.0 214 x = 10.0
211 # whiteSpace is the space between any two elements 215 # whiteSpace is the space between any two elements
212 whiteSpace = (width - currentWidth - 20) / \ 216 whiteSpace = (
217 (width - currentWidth - 20) /
213 (len(generation) - 1.0 or 2.0) 218 (len(generation) - 1.0 or 2.0)
219 )
214 for className in generation: 220 for className in generation:
215 cw = self.__getCurrentShape(className) 221 cw = self.__getCurrentShape(className)
216 cw.setPos(x, y) 222 cw.setPos(x, y)
217 rect = cw.sceneBoundingRect() 223 rect = cw.sceneBoundingRect()
218 x = x + rect.width() + whiteSpace 224 x = x + rect.width() + whiteSpace
291 @param version version of the data (string) 297 @param version version of the data (string)
292 @param data persisted data to be parsed (string) 298 @param data persisted data to be parsed (string)
293 @return flag indicating success (boolean) 299 @return flag indicating success (boolean)
294 """ 300 """
295 parts = data.split(", ") 301 parts = data.split(", ")
296 if len(parts) != 2 or \ 302 if (
297 not parts[0].startswith("file=") or \ 303 len(parts) != 2 or
298 not parts[1].startswith("no_attributes="): 304 not parts[0].startswith("file=") or
305 not parts[1].startswith("no_attributes=")
306 ):
299 return False 307 return False
300 308
301 self.file = parts[0].split("=", 1)[1].strip() 309 self.file = parts[0].split("=", 1)[1].strip()
302 self.noAttrs = Utilities.toBool(parts[1].split("=", 1)[1].strip()) 310 self.noAttrs = Utilities.toBool(parts[1].split("=", 1)[1].strip())
303 311

eric ide

mercurial