Fixed class movement in draw process
This commit is contained in:
parent
e5b3e80378
commit
2790dbfbab
@ -43,6 +43,12 @@ class UMLClass:
|
||||
def dimension(self, value: int):
|
||||
self._dimension = value
|
||||
|
||||
def __str__(self):
|
||||
return f'{self._cls}: {self._position} {self._dimension}'
|
||||
|
||||
def __repr__(self):
|
||||
return f'{self._cls}: {self._position} {self._dimension}'
|
||||
|
||||
def implementation_as_xml(self, base_class: 'UMLClass') -> str:
|
||||
base_point = Position(
|
||||
base_class.position.x + int(base_class.dimension.width / 2),
|
||||
|
@ -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
|
||||
|
@ -17,11 +17,11 @@ class UmletCreatorService(UmletCreatorABC):
|
||||
UmletCreatorABC.__init__(self)
|
||||
|
||||
self._settings: UMLCreatorSettings = config.get_configuration(UMLCreatorSettings)
|
||||
self._moved_classes: list[UMLClass] = []
|
||||
self._padding = 30
|
||||
|
||||
def _sort_by_implementation(self, uml_classes: List[UMLClass], implementations: List[ClassImplementation]):
|
||||
base_sub_map: dict[UMLClass, list[UMLClass]] = {}
|
||||
moved_classes: list[UMLClass] = []
|
||||
for implementation in implementations:
|
||||
sub_class: UMLClass = uml_classes.where(lambda u: u.cls == implementation.subclass).first()
|
||||
base_class: UMLClass = uml_classes.where(lambda u: u.cls == implementation.base).first()
|
||||
@ -29,6 +29,8 @@ class UmletCreatorService(UmletCreatorABC):
|
||||
if base_class not in base_sub_map:
|
||||
base_sub_map[base_class] = []
|
||||
|
||||
if sub_class in base_sub_map[base_class]:
|
||||
continue
|
||||
base_sub_map[base_class].append(sub_class)
|
||||
|
||||
last_base = Position(self._padding, self._padding)
|
||||
@ -50,10 +52,11 @@ class UmletCreatorService(UmletCreatorABC):
|
||||
sub_class.position.y = last_sub.y + self._padding * 2
|
||||
|
||||
last_sub.x = sub_class.position.x + sub_class.dimension.width + self._padding
|
||||
moved_classes.append(sub_class)
|
||||
if sub_class.position.y + sub_class.dimension.height > highest_y:
|
||||
highest_y = sub_class.position.y + sub_class.dimension.height
|
||||
|
||||
self._moved_classes.append(sub_class)
|
||||
|
||||
last_base.x = last_sub.x
|
||||
if last_base.x <= self._settings.max_pixel_x:
|
||||
last_base.x += self._padding * 2
|
||||
@ -61,10 +64,10 @@ class UmletCreatorService(UmletCreatorABC):
|
||||
last_base.x = self._padding
|
||||
last_base.y = highest_y + self._padding * 2
|
||||
|
||||
moved_classes.append(base)
|
||||
self._moved_classes.append(base)
|
||||
|
||||
for cls in uml_classes:
|
||||
if cls in moved_classes:
|
||||
if cls in self._moved_classes:
|
||||
continue
|
||||
|
||||
if cls.position.y <= last_base.y:
|
||||
|
Loading…
Reference in New Issue
Block a user