Skip to content

Commit

Permalink
Saving Test Images #30
Browse files Browse the repository at this point in the history
  • Loading branch information
Osama committed Aug 1, 2023
1 parent d4009b4 commit af763b4
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 61 deletions.
32 changes: 20 additions & 12 deletions demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,14 +532,20 @@ function onLoaded() {

cy.nodes().forEach(node => {
if(node.id()!= topLevelFocusParent.id() && node.parent().length == 0){

var newboundingBox = {w: node.width(),h:node.height(), ...node.position()};
if(node.isChildless()){
node.select();

}else{
selectChildren(node);
}
var newboundingBox = cy.collection(cy.$(":selected")).boundingBox();
newboundingBox = {...newboundingBox,w: node.width(),h:node.height()};
var width = newboundingBox.w;
var height = newboundingBox.h;

componentNodes.push({id: node.id(),data:cy.$(":selected"),pos:{
x: newboundingBox.x,
y: newboundingBox.y}});
x: (newboundingBox.x2 + newboundingBox.x1)/2,
y: (newboundingBox.y1 + newboundingBox.y2)/2}});
var newNode = cyLayout.add({
group: 'nodes',
data: {
Expand All @@ -550,16 +556,17 @@ function onLoaded() {


newNode.position({
x: newboundingBox.x,
y: newboundingBox.y
x: (newboundingBox.x2 + newboundingBox.x1)/2,
y: (newboundingBox.y1 + newboundingBox.y2)/2
});

newNode.style({
'width': Math.max(width,height), // Set the new width of the node
'height': Math.max(width,height), // Set the new height of the node
'label' : document.getElementById("cbk-flag-display-node-labels").checked ? newNode.data().id : ''
});


cy.nodes().unselect();
compoundsCounter++;
}
})
Expand Down Expand Up @@ -610,21 +617,22 @@ function onLoaded() {
cyLayout.add(children)
children.forEach(child => {
child.select()
var newboundingBox = {w: child.width(),h:child.height(), ...child.position()};
var newboundingBox = cy.collection(cy.$(":selected")).boundingBox();
newboundingBox = {...newboundingBox,w: child.width(),h:child.height()};
var width = newboundingBox.w;
var height = newboundingBox.h;

if(child.id() != focusID){
if(child.isChildless()){
componentNodes.push({id: child.id(), data:cy.$(":selected"),pos:{
x: child.position().x,
y: child.position().y}});
x: (newboundingBox.x2 + newboundingBox.x1)/2,
y: (newboundingBox.y1 + newboundingBox.y2)/2}});


newNode = cyLayout.getElementById(child.id())
newNode.position({
x: child.position().x,
y: child.position().y
x: (newboundingBox.x2 + newboundingBox.x1)/2,
y: (newboundingBox.y1 + newboundingBox.y2)/2
});

newNode.style({
Expand Down
32 changes: 20 additions & 12 deletions dist/cytoscape-complexity-management.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1173,18 +1173,24 @@ function expandGraph(focusID, cy) {
var componentNodes = [];
cy.nodes().forEach(function (node) {
if (node.id() != topLevelFocusParent.id() && node.parent().length == 0) {
var newboundingBox = _objectSpread2({
if (node.isChildless()) {
node.select();
} else {
selectChildren(node);
}
var newboundingBox = cy.collection(cy.$(":selected")).boundingBox();
newboundingBox = _objectSpread2(_objectSpread2({}, newboundingBox), {}, {
w: node.width(),
h: node.height()
}, node.position());
});
var width = newboundingBox.w;
var height = newboundingBox.h;
componentNodes.push({
id: node.id(),
data: cy.$(":selected"),
pos: {
x: newboundingBox.x,
y: newboundingBox.y
x: (newboundingBox.x2 + newboundingBox.x1) / 2,
y: (newboundingBox.y1 + newboundingBox.y2) / 2
}
});
var newNode = cyLayout.add({
Expand All @@ -1195,8 +1201,8 @@ function expandGraph(focusID, cy) {
}
});
newNode.position({
x: newboundingBox.x,
y: newboundingBox.y
x: (newboundingBox.x2 + newboundingBox.x1) / 2,
y: (newboundingBox.y1 + newboundingBox.y2) / 2
});
newNode.style({
'width': Math.max(width, height),
Expand All @@ -1205,6 +1211,7 @@ function expandGraph(focusID, cy) {
// Set the new height of the node
'label': document.getElementById("cbk-flag-display-node-labels").checked ? newNode.data().id : ''
});
cy.nodes().unselect();
}
});
if (cy.getElementById(focusID).parent().length == 0) {
Expand Down Expand Up @@ -1249,10 +1256,11 @@ function expandGraph(focusID, cy) {
cyLayout.add(children);
children.forEach(function (child) {
child.select();
var newboundingBox = _objectSpread2({
var newboundingBox = cy.collection(cy.$(":selected")).boundingBox();
newboundingBox = _objectSpread2(_objectSpread2({}, newboundingBox), {}, {
w: child.width(),
h: child.height()
}, child.position());
});
var width = newboundingBox.w;
var height = newboundingBox.h;
if (child.id() != focusID) {
Expand All @@ -1261,14 +1269,14 @@ function expandGraph(focusID, cy) {
id: child.id(),
data: cy.$(":selected"),
pos: {
x: child.position().x,
y: child.position().y
x: (newboundingBox.x2 + newboundingBox.x1) / 2,
y: (newboundingBox.y1 + newboundingBox.y2) / 2
}
});
newNode = cyLayout.getElementById(child.id());
newNode.position({
x: child.position().x,
y: child.position().y
x: (newboundingBox.x2 + newboundingBox.x1) / 2,
y: (newboundingBox.y1 + newboundingBox.y2) / 2
});
newNode.style({
'width': Math.max(width, height) + 'px',
Expand Down
32 changes: 20 additions & 12 deletions dist/cytoscape-complexity-management.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1171,18 +1171,24 @@ function expandGraph(focusID, cy) {
var componentNodes = [];
cy.nodes().forEach(function (node) {
if (node.id() != topLevelFocusParent.id() && node.parent().length == 0) {
var newboundingBox = _objectSpread2({
if (node.isChildless()) {
node.select();
} else {
selectChildren(node);
}
var newboundingBox = cy.collection(cy.$(":selected")).boundingBox();
newboundingBox = _objectSpread2(_objectSpread2({}, newboundingBox), {}, {
w: node.width(),
h: node.height()
}, node.position());
});
var width = newboundingBox.w;
var height = newboundingBox.h;
componentNodes.push({
id: node.id(),
data: cy.$(":selected"),
pos: {
x: newboundingBox.x,
y: newboundingBox.y
x: (newboundingBox.x2 + newboundingBox.x1) / 2,
y: (newboundingBox.y1 + newboundingBox.y2) / 2
}
});
var newNode = cyLayout.add({
Expand All @@ -1193,8 +1199,8 @@ function expandGraph(focusID, cy) {
}
});
newNode.position({
x: newboundingBox.x,
y: newboundingBox.y
x: (newboundingBox.x2 + newboundingBox.x1) / 2,
y: (newboundingBox.y1 + newboundingBox.y2) / 2
});
newNode.style({
'width': Math.max(width, height),
Expand All @@ -1203,6 +1209,7 @@ function expandGraph(focusID, cy) {
// Set the new height of the node
'label': document.getElementById("cbk-flag-display-node-labels").checked ? newNode.data().id : ''
});
cy.nodes().unselect();
}
});
if (cy.getElementById(focusID).parent().length == 0) {
Expand Down Expand Up @@ -1247,10 +1254,11 @@ function expandGraph(focusID, cy) {
cyLayout.add(children);
children.forEach(function (child) {
child.select();
var newboundingBox = _objectSpread2({
var newboundingBox = cy.collection(cy.$(":selected")).boundingBox();
newboundingBox = _objectSpread2(_objectSpread2({}, newboundingBox), {}, {
w: child.width(),
h: child.height()
}, child.position());
});
var width = newboundingBox.w;
var height = newboundingBox.h;
if (child.id() != focusID) {
Expand All @@ -1259,14 +1267,14 @@ function expandGraph(focusID, cy) {
id: child.id(),
data: cy.$(":selected"),
pos: {
x: child.position().x,
y: child.position().y
x: (newboundingBox.x2 + newboundingBox.x1) / 2,
y: (newboundingBox.y1 + newboundingBox.y2) / 2
}
});
newNode = cyLayout.getElementById(child.id());
newNode.position({
x: child.position().x,
y: child.position().y
x: (newboundingBox.x2 + newboundingBox.x1) / 2,
y: (newboundingBox.y1 + newboundingBox.y2) / 2
});
newNode.style({
'width': Math.max(width, height) + 'px',
Expand Down
32 changes: 20 additions & 12 deletions dist/cytoscape-complexity-management.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -5535,18 +5535,24 @@
var componentNodes = [];
cy.nodes().forEach(function (node) {
if (node.id() != topLevelFocusParent.id() && node.parent().length == 0) {
var newboundingBox = _objectSpread2({
if (node.isChildless()) {
node.select();
} else {
selectChildren(node);
}
var newboundingBox = cy.collection(cy.$(":selected")).boundingBox();
newboundingBox = _objectSpread2(_objectSpread2({}, newboundingBox), {}, {
w: node.width(),
h: node.height()
}, node.position());
});
var width = newboundingBox.w;
var height = newboundingBox.h;
componentNodes.push({
id: node.id(),
data: cy.$(":selected"),
pos: {
x: newboundingBox.x,
y: newboundingBox.y
x: (newboundingBox.x2 + newboundingBox.x1) / 2,
y: (newboundingBox.y1 + newboundingBox.y2) / 2
}
});
var newNode = cyLayout.add({
Expand All @@ -5557,8 +5563,8 @@
}
});
newNode.position({
x: newboundingBox.x,
y: newboundingBox.y
x: (newboundingBox.x2 + newboundingBox.x1) / 2,
y: (newboundingBox.y1 + newboundingBox.y2) / 2
});
newNode.style({
'width': Math.max(width, height),
Expand All @@ -5567,6 +5573,7 @@
// Set the new height of the node
'label': document.getElementById("cbk-flag-display-node-labels").checked ? newNode.data().id : ''
});
cy.nodes().unselect();
}
});
if (cy.getElementById(focusID).parent().length == 0) {
Expand Down Expand Up @@ -5611,10 +5618,11 @@
cyLayout.add(children);
children.forEach(function (child) {
child.select();
var newboundingBox = _objectSpread2({
var newboundingBox = cy.collection(cy.$(":selected")).boundingBox();
newboundingBox = _objectSpread2(_objectSpread2({}, newboundingBox), {}, {
w: child.width(),
h: child.height()
}, child.position());
});
var width = newboundingBox.w;
var height = newboundingBox.h;
if (child.id() != focusID) {
Expand All @@ -5623,14 +5631,14 @@
id: child.id(),
data: cy.$(":selected"),
pos: {
x: child.position().x,
y: child.position().y
x: (newboundingBox.x2 + newboundingBox.x1) / 2,
y: (newboundingBox.y1 + newboundingBox.y2) / 2
}
});
newNode = cyLayout.getElementById(child.id());
newNode.position({
x: child.position().x,
y: child.position().y
x: (newboundingBox.x2 + newboundingBox.x1) / 2,
y: (newboundingBox.y1 + newboundingBox.y2) / 2
});
newNode.style({
'width': Math.max(width, height) + 'px',
Expand Down
33 changes: 20 additions & 13 deletions src/cue-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,20 @@ function expandGraph(focusID,cy){

cy.nodes().forEach(node => {
if(node.id()!= topLevelFocusParent.id() && node.parent().length == 0){

var newboundingBox = {w: node.width(),h:node.height(), ...node.position()};
if(node.isChildless()){
node.select();

}else{
selectChildren(node);
}
var newboundingBox = cy.collection(cy.$(":selected")).boundingBox();
newboundingBox = {...newboundingBox,w: node.width(),h:node.height()};
var width = newboundingBox.w;
var height = newboundingBox.h;

componentNodes.push({id: node.id(),data:cy.$(":selected"),pos:{
x: newboundingBox.x,
y: newboundingBox.y}});
x: (newboundingBox.x2 + newboundingBox.x1)/2,
y: (newboundingBox.y1 + newboundingBox.y2)/2}});
var newNode = cyLayout.add({
group: 'nodes',
data: {
Expand All @@ -197,16 +203,17 @@ function expandGraph(focusID,cy){


newNode.position({
x: newboundingBox.x,
y: newboundingBox.y
x: (newboundingBox.x2 + newboundingBox.x1)/2,
y: (newboundingBox.y1 + newboundingBox.y2)/2
});

newNode.style({
'width': Math.max(width,height), // Set the new width of the node
'height': Math.max(width,height), // Set the new height of the node
'label' : document.getElementById("cbk-flag-display-node-labels").checked ? newNode.data().id : ''
});


cy.nodes().unselect();
compoundsCounter++;
}
})
Expand Down Expand Up @@ -257,21 +264,22 @@ function expandGraph(focusID,cy){
cyLayout.add(children)
children.forEach(child => {
child.select()
var newboundingBox = {w: child.width(),h:child.height(), ...child.position()};
var newboundingBox = cy.collection(cy.$(":selected")).boundingBox();
newboundingBox = {...newboundingBox,w: child.width(),h:child.height()};
var width = newboundingBox.w;
var height = newboundingBox.h;

if(child.id() != focusID){
if(child.isChildless()){
componentNodes.push({id: child.id(), data:cy.$(":selected"),pos:{
x: child.position().x,
y: child.position().y}});
x: (newboundingBox.x2 + newboundingBox.x1)/2,
y: (newboundingBox.y1 + newboundingBox.y2)/2}});


newNode = cyLayout.getElementById(child.id())
newNode.position({
x: child.position().x,
y: child.position().y
x: (newboundingBox.x2 + newboundingBox.x1)/2,
y: (newboundingBox.y1 + newboundingBox.y2)/2
});

newNode.style({
Expand Down Expand Up @@ -338,7 +346,6 @@ function expandGraph(focusID,cy){
});
}


function translateNode(a,a1) {
// Step 1: Find the displacement vector d between a and a1
return { x: a1.x - a.x, y: a1.y - a.y };
Expand Down

0 comments on commit af763b4

Please sign in to comment.