First commit.

Signed-off-by: Chen Xiao <abigwc@gmail.com>
This commit is contained in:
Chen Xiao
2026-05-08 14:43:16 +08:00
commit 0b64e2de94
10989 changed files with 2253791 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
var FDLayoutConstants = require('layout-base').FDLayoutConstants;
function CoSEConstants() {
}
//CoSEConstants inherits static props in FDLayoutConstants
for (var prop in FDLayoutConstants) {
CoSEConstants[prop] = FDLayoutConstants[prop];
}
CoSEConstants.DEFAULT_USE_MULTI_LEVEL_SCALING = false;
CoSEConstants.DEFAULT_RADIAL_SEPARATION = FDLayoutConstants.DEFAULT_EDGE_LENGTH;
CoSEConstants.DEFAULT_COMPONENT_SEPERATION = 60;
CoSEConstants.TILE = true;
CoSEConstants.TILING_PADDING_VERTICAL = 10;
CoSEConstants.TILING_PADDING_HORIZONTAL = 10;
CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = false; // make this true when cose is used incrementally as a part of other non-incremental layout
module.exports = CoSEConstants;
+12
View File
@@ -0,0 +1,12 @@
var FDLayoutEdge = require('layout-base').FDLayoutEdge;
function CoSEEdge(source, target, vEdge) {
FDLayoutEdge.call(this, source, target, vEdge);
}
CoSEEdge.prototype = Object.create(FDLayoutEdge.prototype);
for (var prop in FDLayoutEdge) {
CoSEEdge[prop] = FDLayoutEdge[prop];
}
module.exports = CoSEEdge
+12
View File
@@ -0,0 +1,12 @@
var LGraph = require('layout-base').LGraph;
function CoSEGraph(parent, graphMgr, vGraph) {
LGraph.call(this, parent, graphMgr, vGraph);
}
CoSEGraph.prototype = Object.create(LGraph.prototype);
for (var prop in LGraph) {
CoSEGraph[prop] = LGraph[prop];
}
module.exports = CoSEGraph;
+12
View File
@@ -0,0 +1,12 @@
var LGraphManager = require('layout-base').LGraphManager;
function CoSEGraphManager(layout) {
LGraphManager.call(this, layout);
}
CoSEGraphManager.prototype = Object.create(LGraphManager.prototype);
for (var prop in LGraphManager) {
CoSEGraphManager[prop] = LGraphManager[prop];
}
module.exports = CoSEGraphManager;
+1243
View File
File diff suppressed because it is too large Load Diff
+120
View File
@@ -0,0 +1,120 @@
var FDLayoutNode = require('layout-base').FDLayoutNode;
var IMath = require('layout-base').IMath;
function CoSENode(gm, loc, size, vNode) {
FDLayoutNode.call(this, gm, loc, size, vNode);
}
CoSENode.prototype = Object.create(FDLayoutNode.prototype);
for (var prop in FDLayoutNode) {
CoSENode[prop] = FDLayoutNode[prop];
}
CoSENode.prototype.move = function ()
{
var layout = this.graphManager.getLayout();
this.displacementX = layout.coolingFactor *
(this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.noOfChildren;
this.displacementY = layout.coolingFactor *
(this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.noOfChildren;
if (Math.abs(this.displacementX) > layout.coolingFactor * layout.maxNodeDisplacement)
{
this.displacementX = layout.coolingFactor * layout.maxNodeDisplacement *
IMath.sign(this.displacementX);
}
if (Math.abs(this.displacementY) > layout.coolingFactor * layout.maxNodeDisplacement)
{
this.displacementY = layout.coolingFactor * layout.maxNodeDisplacement *
IMath.sign(this.displacementY);
}
// a simple node, just move it
if (this.child == null)
{
this.moveBy(this.displacementX, this.displacementY);
}
// an empty compound node, again just move it
else if (this.child.getNodes().length == 0)
{
this.moveBy(this.displacementX, this.displacementY);
}
// non-empty compound node, propogate movement to children as well
else
{
this.propogateDisplacementToChildren(this.displacementX,
this.displacementY);
}
layout.totalDisplacement +=
Math.abs(this.displacementX) + Math.abs(this.displacementY);
this.springForceX = 0;
this.springForceY = 0;
this.repulsionForceX = 0;
this.repulsionForceY = 0;
this.gravitationForceX = 0;
this.gravitationForceY = 0;
this.displacementX = 0;
this.displacementY = 0;
};
CoSENode.prototype.propogateDisplacementToChildren = function (dX, dY)
{
var nodes = this.getChild().getNodes();
var node;
for (var i = 0; i < nodes.length; i++)
{
node = nodes[i];
if (node.getChild() == null)
{
node.moveBy(dX, dY);
node.displacementX += dX;
node.displacementY += dY;
}
else
{
node.propogateDisplacementToChildren(dX, dY);
}
}
};
CoSENode.prototype.setPred1 = function (pred1)
{
this.pred1 = pred1;
};
CoSENode.prototype.getPred1 = function ()
{
return pred1;
};
CoSENode.prototype.getPred2 = function ()
{
return pred2;
};
CoSENode.prototype.setNext = function (next)
{
this.next = next;
};
CoSENode.prototype.getNext = function ()
{
return next;
};
CoSENode.prototype.setProcessed = function (processed)
{
this.processed = processed;
};
CoSENode.prototype.isProcessed = function ()
{
return processed;
};
module.exports = CoSENode;