1
0
Fork 0

GraphViewer: Prepared the adapter to support NodeReducer as a worker

This commit is contained in:
Michael Hackstein 2013-07-04 12:37:31 +02:00
parent 630712c017
commit bf01f6b8a0
1 changed files with 15 additions and 15 deletions

View File

@ -289,6 +289,17 @@ function AbstractAdapter(nodes, edges) {
nodes.push(commNode); nodes.push(commNode);
}, },
requestCollapse = function (focus) {
var com = reducer.getCommunity(limit, focus);
collapseCommunity(com);
},
checkNodeLimit = function (focus) {
if (limit < nodes.length) {
requestCollapse(focus);
}
},
expandCommunity = function (commNode) { expandCommunity = function (commNode) {
var commId = commNode._id, var commId = commNode._id,
nodesToAdd = cachedCommunities[commId].nodes, nodesToAdd = cachedCommunities[commId].nodes,
@ -296,8 +307,7 @@ function AbstractAdapter(nodes, edges) {
com; com;
removeNode(commNode); removeNode(commNode);
if (limit < nodes.length + nodesToAdd.length) { if (limit < nodes.length + nodesToAdd.length) {
com = reducer.getCommunity(limit); requestCollapse();
collapseCommunity(com);
} }
_.each(nodesToAdd, function(n) { _.each(nodesToAdd, function(n) {
delete joinedInCommunities[n._id]; delete joinedInCommunities[n._id];
@ -336,21 +346,11 @@ function AbstractAdapter(nodes, edges) {
} }
}, },
checkNodeLimit = function (focus) {
if (limit < nodes.length) {
var com = reducer.getCommunity(limit, focus);
collapseCommunity(com);
}
},
setNodeLimit = function (pLimit, callback) { setNodeLimit = function (pLimit, callback) {
limit = pLimit; limit = pLimit;
if (limit < nodes.length) { checkNodeLimit();
var com = reducer.getCommunity(limit); if (callback !== undefined) {
collapseCommunity(com); callback();
if (callback !== undefined) {
callback();
}
} }
}, },