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
+3
View File
@@ -0,0 +1,3 @@
{
"presets": ["env"]
}
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 - present, iVis@Bilkent.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+26
View File
@@ -0,0 +1,26 @@
cose-base
================================================================================
## Description
This is a core module for compound spring embedder based layout styles such as CoSE-Bilkent, fCoSE, and CiSE.
## Dependencies
* layout-base ^1.0.0
## Usage instructions
Add `cose-base` as a dependecy to your layout extension.
`require()` in the extension to reach functionality:
* `var CoSEConstants = require('cose-base').CoSEConstants`,
* `var CoSELayout = require('cose-base').CoSELayout`,
* `...`
To reach functionality of `layout-base`:
* `var Integer = require('cose-base').layoutBase.Integer`,
* `var Layout = require('cose-base').layoutBase.Layout`,
* `...`
+23
View File
@@ -0,0 +1,23 @@
{
"name": "cose-base",
"description": "Core module for compound spring embedder based layout styles",
"main": "cose-base.js",
"dependencies": {
"layout-base": "^1.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/iVis-at-Bilkent/cose-base.git"
},
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"keywords": [
"layout"
],
"license": "MIT"
}
+1447
View File
File diff suppressed because it is too large Load Diff
+15
View File
@@ -0,0 +1,15 @@
'use strict';
let coseBase = {};
coseBase.layoutBase = require('layout-base');
coseBase.CoSEConstants = require('./src/CoSEConstants');
coseBase.CoSEEdge = require('./src/CoSEEdge');
coseBase.CoSEGraph = require('./src/CoSEGraph');
coseBase.CoSEGraphManager = require('./src/CoSEGraphManager');
coseBase.CoSELayout = require('./src/CoSELayout');
coseBase.CoSENode = require('./src/CoSENode');
module.exports = coseBase;
+39
View File
@@ -0,0 +1,39 @@
{
"name": "cose-base",
"version": "1.0.3",
"description": "Core module for compound spring embedder based layout styles",
"main": "cose-base.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "cross-env NODE_ENV=production webpack"
},
"repository": {
"type": "git",
"url": "git+https://github.com/iVis-at-Bilkent/cose-base.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/iVis-at-Bilkent/cose-base/issues"
},
"homepage": "https://github.com/iVis-at-Bilkent/cose-base#readme",
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-env": "^1.5.1",
"camelcase": "^4.1.0",
"cpy-cli": "^1.0.1",
"cross-env": "^5.1.6",
"eslint": "^3.19.0",
"gh-pages": "^1.1.0",
"npm-run-all": "^4.1.2",
"rimraf": "^2.6.2",
"update": "^0.7.4",
"updater-license": "^1.0.0",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5"
},
"dependencies": {
"layout-base": "^1.0.0"
}
}
+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;
+43
View File
@@ -0,0 +1,43 @@
const path = require('path');
const pkg = require('./package.json');
const camelcase = require('camelcase');
const process = require('process');
const webpack = require('webpack');
const env = process.env;
const NODE_ENV = env.NODE_ENV;
const MIN = env.MIN;
const PROD = NODE_ENV === 'production';
let config = {
devtool: PROD ? false : 'inline-source-map',
entry: './index.js',
output: {
path: path.join( __dirname ),
filename: 'cose-base.js',
library: camelcase( pkg.name ),
libraryTarget: 'umd'
},
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' }
]
},
externals: PROD ? {
'layout-base': {
commonjs2: 'layout-base',
commonjs: 'layout-base',
amd: 'layout-base',
root: 'layoutBase'
}
} : {},
plugins: MIN ? [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console: false,
}
})
] : []
};
module.exports = config;