Skip to content

Commit adb48b6

Browse files
committed
better edge position given direction
1 parent 12f76d1 commit adb48b6

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

graphviz2drawio/models/Rect.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ def __init__(self, x, y, width, height):
44
self.y = y
55
self.width = width
66
self.height = height
7+
self.bottom = y + height
8+
self.right = x + width
79

810
def to_dict_int(self):
911
return {

graphviz2drawio/mx/MxGraph.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,26 @@ def add_edge(self, edge):
3636
if edge.dir == DotAttr.BACK:
3737
source = self.nodes[edge.to].sid
3838
target = self.nodes[edge.fr].sid
39+
exit_x = 0.5
40+
exit_y = 0
41+
entry_x = self.edge_reposition_x[edge.sid]
42+
entry_y = 1
3943
else:
4044
target = self.nodes[edge.to].sid
4145
source = self.nodes[edge.fr].sid
46+
exit_x = 0.5
47+
exit_y = 1
48+
entry_x = self.edge_reposition_x[edge.sid]
49+
entry_y = 0
4250
edge_element = ET.SubElement(
4351
self.root,
4452
MxConst.CELL,
4553
id=edge.sid,
4654
style=Styles.EDGE.format(
47-
entry_x=self.edge_reposition_x[edge.sid],
55+
entry_x=entry_x,
56+
entry_y=entry_y,
57+
exit_x=exit_x,
58+
exit_y=exit_y,
4859
end_arrow=end_arrow,
4960
dashed=dashed,
5061
end_fill=end_fill,

graphviz2drawio/mx/Styles.py

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

44
class Styles(Enum):
55
NODE = "verticalAlign=top;align=left;overflow=fill;html=1;rounded=0;shadow=0;comic=0;labelBackgroundColor=none;strokeColor={stroke};strokeWidth=1;fillColor={fill};"
6-
EDGE = "edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;exitX=0.5;exitY=0;entryX={entry_x:.3g};entryY=1;jettySize=auto;orthogonalLoop=1;endArrow={end_arrow};dashed={dashed};endFill={end_fill};"
6+
EDGE = "edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;exitX={exit_x:.3g};exitY={exit_y:.3g};entryX={entry_x:.3g};entryY={entry_y:.3g};jettySize=auto;orthogonalLoop=1;endArrow={end_arrow};dashed={dashed};endFill={end_fill};"
77
TEXT = "margin:0px;text-align:{align};{margin};font-size:{size}px;font-family:{family};color:{color};"
88

99
def format(self, **values):

0 commit comments

Comments
 (0)