Skip to content

Commit ae0768f

Browse files
author
Humberto Sanchez II
committed
<Bug>[Use Cases]: <Fix X,Y positions>
[OglActor and OglUseCase, require base class because I am vehemently DRY] [#21]
1 parent bea2622 commit ae0768f

File tree

4 files changed

+47
-24
lines changed

4 files changed

+47
-24
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name="untanglepyut",
13-
version="0.3.5",
13+
version="0.3.6",
1414
author_email='[email protected]',
1515
description='XML to Ogl Object Model',
1616
long_description=README,

untanglepyut/BaseUnTangle.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
from logging import Logger
3+
from logging import getLogger
4+
5+
from miniogl.ShapeModel import ShapeModel
6+
from ogl.OglObject import OglObject
7+
8+
from untanglepyut.Common import GraphicInformation
9+
10+
11+
class BaseUnTangle:
12+
13+
def __init__(self):
14+
self.baseLogger: Logger = getLogger(__name__)
15+
16+
def _updateModel(self, oglObject: OglObject, graphicInformation: GraphicInformation) -> ShapeModel:
17+
"""
18+
This is necessary if it is never added to a diagram
19+
and immediately serialized
20+
21+
Args:
22+
oglObject: OglObject with a model
23+
graphicInformation: The graphic class graphic information
24+
25+
Returns: The updated shape model as a way of documenting that we updated it
26+
"""
27+
model: ShapeModel = oglObject.GetModel()
28+
model.SetPosition(x=graphicInformation.x, y=graphicInformation.y)
29+
30+
return model

untanglepyut/UnTangleUseCaseDiagram.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
from logging import Logger
33
from logging import getLogger
44

5-
from ogl.OglUseCase import OglUseCase
6-
from pyutmodel.PyutUseCase import PyutUseCase
75
from untangle import Element
86

97
from pyutmodel.PyutActor import PyutActor
8+
from pyutmodel.PyutUseCase import PyutUseCase
109

1110
from ogl.OglActor import OglActor
11+
from ogl.OglUseCase import OglUseCase
1212

1313
from untanglepyut.Common import GraphicInformation
1414
from untanglepyut.Common import toGraphicInfo
@@ -17,10 +17,12 @@
1717

1818
from untanglepyut.Types import UntangledOglActors
1919
from untanglepyut.Types import UntangledOglUseCases
20+
21+
from untanglepyut.BaseUnTangle import BaseUnTangle
2022
from untanglepyut.UnTanglePyut import UnTanglePyut
2123

2224

23-
class UnTangleUseCaseDiagram:
25+
class UnTangleUseCaseDiagram(BaseUnTangle):
2426
"""
2527
<PyutDocument type="USECASE_DIAGRAM" title="Use-Cases" scrollPositionX="0" scrollPositionY="0" pixelsPerUnitX="20" pixelsPerUnitY="20">
2628
<GraphicActor width="87" height="114" x="293" y="236">
@@ -39,6 +41,8 @@ class UnTangleUseCaseDiagram:
3941
"""
4042

4143
def __init__(self):
44+
45+
super().__init__()
4246
self.logger: Logger = getLogger(__name__)
4347

4448
self._untangledOglActors: UntangledOglActors = createUntangledOglActors()
@@ -72,6 +76,8 @@ def _unTangleOglActors(self, pyutDocument: Element) -> UntangledOglActors:
7276
oglActor: OglActor = OglActor(w=graphicInfo.width, h=graphicInfo.height)
7377
oglActor.SetPosition(x=graphicInfo.x, y=graphicInfo.y)
7478

79+
self._updateModel(oglObject=oglActor, graphicInformation=graphicInfo)
80+
7581
pyutActor: PyutActor = self._untanglePyut.actorToPyutActor(graphicActor=graphicActor)
7682

7783
oglActor.pyutObject = pyutActor
@@ -90,6 +96,9 @@ def _unTangleOglUseCases(self, pyutDocument: Element) -> UntangledOglUseCases:
9096
oglUseCase: OglUseCase = OglUseCase(w=graphicInfo.width, h=graphicInfo.height)
9197

9298
oglUseCase.SetPosition(x=graphicInfo.x, y=graphicInfo.y)
99+
100+
self._updateModel(oglObject=oglUseCase, graphicInformation=graphicInfo)
101+
93102
pyutUseCase: PyutUseCase = self._untanglePyut.useCaseToPyutUseCase(graphicUseCase=graphicUseCase)
94103

95104
oglUseCase.pyutObject = pyutUseCase

untanglepyut/UnTangler.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
from untangle import parse
1212
from untangle import Element
1313

14-
from miniogl.ShapeModel import ShapeModel
1514

16-
from ogl.OglObject import OglObject
1715
from ogl.OglClass import OglClass
1816
from ogl.OglNote import OglNote
1917
from ogl.OglText import OglText
@@ -22,6 +20,8 @@
2220
from pyutmodel.PyutNote import PyutNote
2321
from pyutmodel.PyutText import PyutText
2422

23+
from untanglepyut.BaseUnTangle import BaseUnTangle
24+
2525
from untanglepyut.Common import toGraphicInfo
2626
from untanglepyut.Common import GraphicInformation
2727
from untanglepyut.Common import UntangledOglLinks
@@ -106,15 +106,15 @@ class Document:
106106
Documents = NewType('Documents', dict[DocumentTitle, Document])
107107

108108

109-
class UnTangler:
109+
class UnTangler(BaseUnTangle):
110110

111111
def __init__(self, fqFileName: str):
112112
"""
113113
114114
Args:
115115
fqFileName: Fully qualified file name
116116
"""
117-
117+
super().__init__()
118118
self.logger: Logger = getLogger(__name__)
119119

120120
self._fqFileName: str = fqFileName
@@ -309,19 +309,3 @@ def _buildDictionary(self, document: Document) -> LinkableOglObjects:
309309
linkableOglObjects[oglActor.pyutObject.id] = oglActor
310310

311311
return linkableOglObjects
312-
313-
def _updateModel(self, oglObject: OglObject, graphicInformation: GraphicInformation) -> ShapeModel:
314-
"""
315-
This is necessary if it is never added to a diagram
316-
and immediately serialized
317-
318-
Args:
319-
oglObject: OglObject with a model
320-
graphicInformation: The graphic class graphic information
321-
322-
Returns: The updated shape model as a way of documenting that we updated it
323-
"""
324-
model: ShapeModel = oglObject.GetModel()
325-
model.SetPosition(x=graphicInformation.x, y=graphicInformation.y)
326-
327-
return model

0 commit comments

Comments
 (0)