From 5e56f0f455a882d9df3c3147ab79b6725e0b9f1b Mon Sep 17 00:00:00 2001 From: Jef Jaeken Date: Fri, 1 Jun 2018 09:16:55 +0200 Subject: [PATCH 1/2] Add separate cluster padding top/bottom --- .idea/codeStyles/codeStyleConfig.xml | 5 +++++ .idea/dagre.iml | 12 ++++++++++++ .idea/inspectionProfiles/Project_Default.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ lib/layout.js | 4 ++-- lib/position/bk.js | 11 +++++++---- 7 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/dagre.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 00000000..a55e7a17 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/dagre.iml b/.idea/dagre.iml new file mode 100644 index 00000000..24643cc3 --- /dev/null +++ b/.idea/dagre.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..5b5702d4 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..abc70213 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lib/layout.js b/lib/layout.js index c56c3bbb..e614b33a 100644 --- a/lib/layout.js +++ b/lib/layout.js @@ -94,8 +94,8 @@ function updateInputGraph(inputGraph, layoutGraph) { inputGraph.graph().height = layoutGraph.graph().height; } -var graphNumAttrs = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"], - graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" }, +var graphNumAttrs = ["nodesep", "edgesep", "ranksep", "marginx", "marginy", "clusterpaddingtop", "clusterpaddingbottom"], + graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb", clusterpaddingtop: 20, clusterpaddingbottom: 20 }, graphAttrs = ["acyclicer", "ranker", "rankdir", "align"], nodeNumAttrs = ["width", "height"], nodeDefaults = { width: 0, height: 0 }, diff --git a/lib/position/bk.js b/lib/position/bk.js index d3ebcebe..c1e616ff 100644 --- a/lib/position/bk.js +++ b/lib/position/bk.js @@ -265,7 +265,7 @@ function horizontalCompaction(g, layering, root, align, reverseSep) { function buildBlockGraph(g, layering, root, reverseSep) { var blockGraph = new Graph(), graphLabel = g.graph(), - sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep); + sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep, graphLabel.clusterpaddingtop, graphLabel.clusterpaddingbottom); _.forEach(layering, function(layer) { var u; @@ -376,7 +376,7 @@ function positionX(g) { return balance(xss, g.graph().align); } -function sep(nodeSep, edgeSep, reverseSep) { +function sep(nodeSep, edgeSep, reverseSep, clusterpaddingtop, clusterpaddingbottom) { return function(g, v, w) { var vLabel = g.node(v), wLabel = g.node(w), @@ -395,8 +395,11 @@ function sep(nodeSep, edgeSep, reverseSep) { } delta = 0; - sum += (vLabel.dummy ? edgeSep : nodeSep) / 2; - sum += (wLabel.dummy ? edgeSep : nodeSep) / 2; + const vPadding = vLabel.borderType === "borderRight" ? clusterpaddingbottom : clusterpaddingtop; + const wPadding = wLabel.borderType === "borderRight" ? clusterpaddingbottom : clusterpaddingtop; + + sum += (vLabel.dummy ? vLabel.dummy === 'border' ? vPadding : edgeSep : nodeSep) / 2; + sum += (wLabel.dummy ? wLabel.dummy === 'border' ? wPadding : edgeSep : nodeSep) / 2; sum += wLabel.width / 2; if (_.has(wLabel, "labelpos")) { From 85d1ce7aad4dd0cf821b47c7f76d54263b146793 Mon Sep 17 00:00:00 2001 From: Jef Jaeken Date: Mon, 4 Jun 2018 10:57:14 +0200 Subject: [PATCH 2/2] Change to vars and double quote string --- lib/position/bk.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/position/bk.js b/lib/position/bk.js index c1e616ff..e3c8a872 100644 --- a/lib/position/bk.js +++ b/lib/position/bk.js @@ -395,11 +395,11 @@ function sep(nodeSep, edgeSep, reverseSep, clusterpaddingtop, clusterpaddingbott } delta = 0; - const vPadding = vLabel.borderType === "borderRight" ? clusterpaddingbottom : clusterpaddingtop; - const wPadding = wLabel.borderType === "borderRight" ? clusterpaddingbottom : clusterpaddingtop; + var vPadding = vLabel.borderType === "borderRight" ? clusterpaddingbottom : clusterpaddingtop; + var wPadding = wLabel.borderType === "borderRight" ? clusterpaddingbottom : clusterpaddingtop; - sum += (vLabel.dummy ? vLabel.dummy === 'border' ? vPadding : edgeSep : nodeSep) / 2; - sum += (wLabel.dummy ? wLabel.dummy === 'border' ? wPadding : edgeSep : nodeSep) / 2; + sum += (vLabel.dummy ? vLabel.dummy === "border" ? vPadding : edgeSep : nodeSep) / 2; + sum += (wLabel.dummy ? wLabel.dummy === "border" ? wPadding : edgeSep : nodeSep) / 2; sum += wLabel.width / 2; if (_.has(wLabel, "labelpos")) {