|
19 | 19 | from abc import ABC, abstractmethod |
20 | 20 | from typing import Iterable, List, Optional, Union |
21 | 21 |
|
22 | | -from ..model import Person, SoftwareSystem |
23 | 22 | from .animation import Animation, AnimationIO |
24 | 23 | from .view import View, ViewIO |
| 24 | +from ..model import Element, Person, SoftwareSystem |
25 | 25 |
|
26 | 26 |
|
27 | 27 | __all__ = ("StaticView", "StaticViewIO") |
@@ -92,3 +92,22 @@ def add_all_software_systems(self) -> None: |
92 | 92 | """Add all people in the model to this view.""" |
93 | 93 | for system in self.software_system.get_model().software_systems: |
94 | 94 | self.add(system) |
| 95 | + |
| 96 | + def add_nearest_neighbours(self, element: Element,) -> None: |
| 97 | + """Add all permitted elements from a model to this view.""" |
| 98 | + self._add_element(element, True) |
| 99 | + |
| 100 | + element_type = type(element) |
| 101 | + # TODO(ilaif): @midnighter - Should we move to @property instead |
| 102 | + # of get_X()? More pythonic. |
| 103 | + # (midnighter): Probably yes. |
| 104 | + for relationship in self.software_system.get_model().get_relationships(): |
| 105 | + if relationship.source == element and isinstance( |
| 106 | + relationship.destination, element_type |
| 107 | + ): |
| 108 | + self._add_element(relationship.destination, add_relationships=True) |
| 109 | + |
| 110 | + if relationship.destination == element and isinstance( |
| 111 | + relationship.source, element_type |
| 112 | + ): |
| 113 | + self._add_element(relationship.source, add_relationships=True) |
0 commit comments