From c254c8cc5ddf62adbd6e77e3fc3bf3ffe8049fa4 Mon Sep 17 00:00:00 2001 From: zahuifan Date: Sun, 4 Dec 2022 18:01:06 +0800 Subject: [PATCH] add direction suggester --- ea-scripts/Auto Layout.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ea-scripts/Auto Layout.md b/ea-scripts/Auto Layout.md index 9e86f82..268646e 100644 --- a/ea-scripts/Auto Layout.md +++ b/ea-scripts/Auto Layout.md @@ -113,11 +113,20 @@ async function doAutoLayout() { "NETWORK_SIMPLEX", ]; + const knownDirections = [ + "UNDEFINED", + "RIGHT", + "LEFT", + "DOWN", + "UP" + ]; + let nodePlacementStrategy = "BRANDES_KOEPF"; let componentComponentSpacing = "10"; let nodeNodeSpacing = "100"; let nodeNodeBetweenLayersSpacing = "100"; let discoComponentLayoutAlgorithm = "org.eclipse.elk.layered"; + let direction = "UNDEFINED"; if (selectedAlgorithm === "org.eclipse.elk.layered") { nodePlacementStrategy = await utils.suggester( @@ -125,6 +134,13 @@ async function doAutoLayout() { knownNodePlacementStrategy, "Node placement strategy" ); + + selectedDirection = await utils.suggester( + knownDirections, + knownDirections, + "Direction" + ); + direction = selectedDirection??"UNDEFINED"; } else if (selectedAlgorithm === "org.eclipse.elk.disco") { const componentLayoutAlgorithms = layoutAlgorithmsSimple.filter(al => al.id !== "org.eclipse.elk.disco"); const selectedDiscoComponentLayoutAlgorithm = await utils.suggester( @@ -173,6 +189,7 @@ async function doAutoLayout() { nodePlacementStrategy; layoutOptionsJson["org.eclipse.elk.disco.componentCompaction.componentLayoutAlgorithm"] = discoComponentLayoutAlgorithm; + layoutOptionsJson["org.eclipse.elk.direction"] = direction; const graph = { id: "root", @@ -387,4 +404,4 @@ function recalculateEndPointOfLine(line, el, elB, gapValue) { intersectA[0][1] - line.y, ]; } -} +} \ No newline at end of file