Improved sort criteria
This commit is contained in:
parent
405dded626
commit
83f666353f
@ -6,6 +6,7 @@ class ClassImplementation:
|
||||
def __init__(self, base: PythonClass, subclass: PythonClass):
|
||||
self._base = base
|
||||
self._subclass = subclass
|
||||
self.is_first = True
|
||||
|
||||
@property
|
||||
def base(self) -> PythonClass:
|
||||
@ -16,7 +17,7 @@ class ClassImplementation:
|
||||
return self._subclass
|
||||
|
||||
def __str__(self):
|
||||
return f'<{self._subclass.name} -> {self._base.name}>'
|
||||
return f'<{type(self).__name__} {self.is_first} {self._subclass.name} -> {self._base.name}>'
|
||||
|
||||
def __repr__(self):
|
||||
return f'<{self._subclass.name} -> {self._base.name}>'
|
||||
return f'<{type(self).__name__} {self.is_first} {self._subclass.name} -> {self._base.name}>'
|
||||
|
@ -50,6 +50,7 @@ class ImplementationScannerService(ImplementationScannerABC):
|
||||
|
||||
implementation = self._get_implementation(name, sub, classes)
|
||||
if implementation is not None:
|
||||
implementation.is_first = False
|
||||
implementations.append(implementation)
|
||||
return implementations
|
||||
return None
|
||||
|
@ -34,7 +34,8 @@ class UmletCreatorService(UmletCreatorABC):
|
||||
base_sub_map[base_class].append(sub_class)
|
||||
|
||||
last_base = Position(self._padding, self._padding)
|
||||
highest_y = 0
|
||||
highest_y = self._padding
|
||||
|
||||
for base in base_sub_map:
|
||||
subclasses = base_sub_map[base]
|
||||
|
||||
@ -43,8 +44,9 @@ class UmletCreatorService(UmletCreatorABC):
|
||||
|
||||
last_sub = Position(base.position.x, base.position.y + base.dimension.height)
|
||||
for sub_class in subclasses:
|
||||
sub_class.position.x = base.position.x
|
||||
sub_class.position.y = base.position.y
|
||||
if sub_class not in self._moved_classes:
|
||||
sub_class.position.x = base.position.x
|
||||
sub_class.position.y = base.position.y
|
||||
|
||||
if sub_class.position.x <= last_sub.x:
|
||||
sub_class.position.x = last_sub.x
|
||||
@ -70,16 +72,15 @@ class UmletCreatorService(UmletCreatorABC):
|
||||
if cls in self._moved_classes:
|
||||
continue
|
||||
|
||||
if cls.position.y <= last_base.y:
|
||||
cls.position.y = last_base.y
|
||||
|
||||
new_x = last_base.x + self._padding
|
||||
new_x = last_base.x
|
||||
if new_x <= self._settings.max_pixel_x:
|
||||
cls.position.x = new_x
|
||||
last_base.x = cls.position.x + cls.dimension.width
|
||||
last_base.x = new_x + cls.dimension.width + self._padding
|
||||
cls.position.y = last_base.y
|
||||
else:
|
||||
last_base.x = self._padding
|
||||
last_base.y = highest_y + self._padding * 2
|
||||
cls.position.x = self._padding
|
||||
cls.position.y = highest_y + self._padding * 2
|
||||
last_base = cls.position
|
||||
|
||||
if cls.position.y + cls.dimension.height > highest_y:
|
||||
highest_y = cls.position.y + cls.dimension.height
|
||||
|
Loading…
Reference in New Issue
Block a user