Skip to content

Commit

Permalink
No layout after operation does not work #32
Browse files Browse the repository at this point in the history
  • Loading branch information
osamazafar980 committed Oct 11, 2023
1 parent 17a2f1b commit 4865b78
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 15 deletions.
8 changes: 4 additions & 4 deletions demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ function onLoaded() {
// FOR GENERAL USE from API FOllowing line is to be used instead of above one.
// instance.expandGraph(node.data().id, cy)

instance.expandNodes(cy.nodes(':selected'), true, runLayout = document.getElementById("cbk-run-layout3").checked, pngImage);
instance.expandNodes(cy.nodes(':selected'), true, runLayout = document.getElementById("cbk-run-layout3").checked, pngImage,setLabelPosition);

setTimeout(() => {
pngBeforeFinalGraph = cy.png({
Expand All @@ -1175,7 +1175,7 @@ function onLoaded() {
}, document.getElementById("cbk-run-layout3").checked?700:0);

}else{
instance.expandNodes(cy.nodes(':selected'), true, runLayout = document.getElementById("cbk-run-layout3").checked, pngImage);
instance.expandNodes(cy.nodes(':selected'), true, runLayout = document.getElementById("cbk-run-layout3").checked, pngImage,setLabelPosition);
cy.fit();
initializer(cy);
}
Expand All @@ -1194,7 +1194,7 @@ function onLoaded() {
scale:2,
full:true
});
instance.expandNodes(cy.nodes(':selected'), false, document.getElementById("cbk-run-layout3").checked, pngImage);
instance.expandNodes(cy.nodes(':selected'), false, document.getElementById("cbk-run-layout3").checked, pngImage, setLabelPosition);

setTimeout(() => {
pngBeforeFinalGraph = cy.png({
Expand All @@ -1210,7 +1210,7 @@ function onLoaded() {
}, document.getElementById("cbk-run-layout3").checked?700:0);

}else{
instance.expandNodes(cy.nodes(':selected'),false,document.getElementById("cbk-run-layout3").checked, pngImage);
instance.expandNodes(cy.nodes(':selected'),false,document.getElementById("cbk-run-layout3").checked, pngImage,setLabelPosition);
cy.fit();
initializer(cy);
}
Expand Down
11 changes: 9 additions & 2 deletions dist/cytoscape-complexity-management.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,12 +566,13 @@ function complexityManagement(cy) {
var isRecursive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var runLayout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var pngImage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
var setLabelPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
var nodeIDList = [];
nodes.forEach(function (node) {
if (compMgrInstance.isExpandable(node.id())) {
nodeIDList.push(node.id());
if (runLayout) {
expandGraph(node.data().id, cy, pngImage);
expandGraph(node.data().id, cy, pngImage, setLabelPosition);
}
node.removeClass("cy-expand-collapse-collapsed-node");
node.removeData("position-before-collapse");
Expand Down Expand Up @@ -769,7 +770,7 @@ function complexityManagement(cy) {
api.isExpandable = function (node) {
return compMgrInstance.isExpandable(node.id());
};
var expandGraph = function expandGraph(focusID, cy, pngImage) {
var expandGraph = function expandGraph(focusID, cy, pngImage, setLabelPosition) {
var descendants = getDescendantsInorder(instance.getCompMgrInstance('get').mainGraphManager.nodesMap.get(focusID));
cyLayout.remove(cyLayout.elements());
var fNode = cyLayout.add({
Expand Down Expand Up @@ -870,6 +871,12 @@ function complexityManagement(cy) {
cyLayout.nodes().forEach(function (node) {
node.style('label', node.id());
});
var radioButtons = document.getElementsByName('cbk-flag-display-node-label-pos');
radioButtons.forEach(function (radio) {
if (radio.checked) {
setLabelPosition(radio.value);
}
});
if (pngImage != null) {
pngImage.pngSizeProxyGraph = cyLayout.png({
scale: 2,
Expand Down
11 changes: 9 additions & 2 deletions dist/cytoscape-complexity-management.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,13 @@ function complexityManagement(cy) {
var isRecursive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var runLayout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var pngImage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
var setLabelPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
var nodeIDList = [];
nodes.forEach(function (node) {
if (compMgrInstance.isExpandable(node.id())) {
nodeIDList.push(node.id());
if (runLayout) {
expandGraph(node.data().id, cy, pngImage);
expandGraph(node.data().id, cy, pngImage, setLabelPosition);
}
node.removeClass("cy-expand-collapse-collapsed-node");
node.removeData("position-before-collapse");
Expand Down Expand Up @@ -767,7 +768,7 @@ function complexityManagement(cy) {
api.isExpandable = function (node) {
return compMgrInstance.isExpandable(node.id());
};
var expandGraph = function expandGraph(focusID, cy, pngImage) {
var expandGraph = function expandGraph(focusID, cy, pngImage, setLabelPosition) {
var descendants = getDescendantsInorder(instance.getCompMgrInstance('get').mainGraphManager.nodesMap.get(focusID));
cyLayout.remove(cyLayout.elements());
var fNode = cyLayout.add({
Expand Down Expand Up @@ -868,6 +869,12 @@ function complexityManagement(cy) {
cyLayout.nodes().forEach(function (node) {
node.style('label', node.id());
});
var radioButtons = document.getElementsByName('cbk-flag-display-node-label-pos');
radioButtons.forEach(function (radio) {
if (radio.checked) {
setLabelPosition(radio.value);
}
});
if (pngImage != null) {
pngImage.pngSizeProxyGraph = cyLayout.png({
scale: 2,
Expand Down
11 changes: 9 additions & 2 deletions dist/cytoscape-complexity-management.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -4928,12 +4928,13 @@
var isRecursive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var runLayout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var pngImage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
var setLabelPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
var nodeIDList = [];
nodes.forEach(function (node) {
if (compMgrInstance.isExpandable(node.id())) {
nodeIDList.push(node.id());
if (runLayout) {
expandGraph(node.data().id, cy, pngImage);
expandGraph(node.data().id, cy, pngImage, setLabelPosition);
}
node.removeClass("cy-expand-collapse-collapsed-node");
node.removeData("position-before-collapse");
Expand Down Expand Up @@ -5131,7 +5132,7 @@
api.isExpandable = function (node) {
return compMgrInstance.isExpandable(node.id());
};
var expandGraph = function expandGraph(focusID, cy, pngImage) {
var expandGraph = function expandGraph(focusID, cy, pngImage, setLabelPosition) {
var descendants = getDescendantsInorder(instance.getCompMgrInstance('get').mainGraphManager.nodesMap.get(focusID));
cyLayout.remove(cyLayout.elements());
var fNode = cyLayout.add({
Expand Down Expand Up @@ -5232,6 +5233,12 @@
cyLayout.nodes().forEach(function (node) {
node.style('label', node.id());
});
var radioButtons = document.getElementsByName('cbk-flag-display-node-label-pos');
radioButtons.forEach(function (radio) {
if (radio.checked) {
setLabelPosition(radio.value);
}
});
if (pngImage != null) {
pngImage.pngSizeProxyGraph = cyLayout.png({
scale: 2,
Expand Down
15 changes: 10 additions & 5 deletions src/complexity-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,15 +539,15 @@ export function complexityManagement(cy) {
actOnVisibleForMetaEdge(IDsToAdd, cy);
};

api.expandNodes = (nodes, isRecursive = false, runLayout = true, pngImage = null) => {
api.expandNodes = (nodes, isRecursive = false, runLayout = true, pngImage = null, setLabelPosition = null) => {

let nodeIDList = [];

nodes.forEach( (node) => {
if (compMgrInstance.isExpandable(node.id())) {
nodeIDList.push(node.id());
if(runLayout){
expandGraph(node.data().id, cy, pngImage)
expandGraph(node.data().id, cy, pngImage, setLabelPosition)
}
node.removeClass("cy-expand-collapse-collapsed-node");
node.removeData("position-before-collapse");
Expand All @@ -562,7 +562,7 @@ export function complexityManagement(cy) {
scale:2,
full:true
});

let returnedElements = compMgrInstance.expandNodes(nodeIDList, isRecursive);
// Add required elements to cy instance
actOnVisible([...returnedElements.nodeIDListForVisible], cy, true);
Expand Down Expand Up @@ -787,7 +787,7 @@ export function complexityManagement(cy) {
return compMgrInstance.isExpandable(node.id());
};

let expandGraph = (focusID,cy,pngImage) => {
let expandGraph = (focusID,cy,pngImage,setLabelPosition) => {

let descendants = getDescendantsInorder(instance.getCompMgrInstance('get').mainGraphManager.nodesMap.get(focusID));

Expand Down Expand Up @@ -893,7 +893,12 @@ export function complexityManagement(cy) {
var fcousNodeHeight = boundingBox.h;

cyLayout.nodes().forEach(node => {node.style('label', node.id());})

var radioButtons = document.getElementsByName('cbk-flag-display-node-label-pos');
radioButtons.forEach(function(radio) {
if(radio.checked){
setLabelPosition(radio.value);
}
});
if(pngImage!= null){
pngImage.pngSizeProxyGraph = cyLayout.png({
scale:2,
Expand Down

0 comments on commit 4865b78

Please sign in to comment.