完成世界书、骰子、apiconfig页面处理

This commit is contained in:
2026-04-30 01:35:10 +08:00
parent a3e3711b2b
commit ba9b925c32
4602 changed files with 785225 additions and 23 deletions

20
frontend/node_modules/layout-base/README.md generated vendored Normal file
View File

@@ -0,0 +1,20 @@
layout-base
================================================================================
## Description
This repository implements a basic layout model and some utilities for Cytoscape.js layout extensions.
## Usage instructions
Add `layout-base` as a dependecy to your layout extension.
`require()` in the extension to reach functionality:
* `var Integer = require(layout-base).Integer`,
* `var Layout = require(layout-base).Layout`,
* `...`
For a usage example, see [cose-base](https://github.com/iVis-at-Bilkent/cose-base) or [avsdf-base](https://github.com/iVis-at-Bilkent/avsdf-base).
![](https://github.com/iVis-at-Bilkent/layout-base/blob/master/layout-schema.png)

36
frontend/node_modules/layout-base/index.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
'use strict';
let layoutBase = function(){
return;
};
layoutBase.FDLayout = require('./src/fd/FDLayout');
layoutBase.FDLayoutConstants = require('./src/fd/FDLayoutConstants');
layoutBase.FDLayoutEdge = require('./src/fd/FDLayoutEdge');
layoutBase.FDLayoutNode = require('./src/fd/FDLayoutNode');
layoutBase.DimensionD = require('./src/util/DimensionD');
layoutBase.HashMap = require('./src/util/HashMap');
layoutBase.HashSet = require('./src/util/HashSet');
layoutBase.IGeometry = require('./src/util/IGeometry');
layoutBase.IMath = require('./src/util/IMath');
layoutBase.Integer = require('./src/util/Integer');
layoutBase.Point = require('./src/util/Point');
layoutBase.PointD = require('./src/util/PointD');
layoutBase.RandomSeed = require('./src/util/RandomSeed');
layoutBase.RectangleD = require('./src/util/RectangleD');
layoutBase.Transform = require('./src/util/Transform');
layoutBase.UniqueIDGeneretor = require('./src/util/UniqueIDGeneretor');
layoutBase.Quicksort = require('./src/util/Quicksort');
layoutBase.LinkedList = require('./src/util/LinkedList');
layoutBase.LGraphObject = require('./src/LGraphObject');
layoutBase.LGraph = require('./src/LGraph');
layoutBase.LEdge = require('./src/LEdge');
layoutBase.LGraphManager = require('./src/LGraphManager');
layoutBase.LNode = require('./src/LNode');
layoutBase.Layout = require('./src/Layout');
layoutBase.LayoutConstants = require('./src/LayoutConstants');
layoutBase.NeedlemanWunsch = require('./src/util/alignment/NeedlemanWunsch');
module.exports = layoutBase;

37
frontend/node_modules/layout-base/package.json generated vendored Normal file
View File

@@ -0,0 +1,37 @@
{
"name": "layout-base",
"version": "1.0.2",
"description": "Basic layout model and some utilities for Cytoscape.js layout extensions",
"main": "layout-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/layout-base.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/iVis-at-Bilkent/layout-base/issues"
},
"homepage": "https://github.com/iVis-at-Bilkent/layout-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",
"forever": "^0.15.3",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5"
}
}

405
frontend/node_modules/layout-base/src/LNode.js generated vendored Normal file
View File

@@ -0,0 +1,405 @@
var LGraphObject = require('./LGraphObject');
var Integer = require('./util/Integer');
var RectangleD = require('./util/RectangleD');
var LayoutConstants = require('./LayoutConstants');
var RandomSeed = require('./util/RandomSeed');
var PointD = require('./util/PointD');
function LNode(gm, loc, size, vNode) {
//Alternative constructor 1 : LNode(LGraphManager gm, Point loc, Dimension size, Object vNode)
if (size == null && vNode == null) {
vNode = loc;
}
LGraphObject.call(this, vNode);
//Alternative constructor 2 : LNode(Layout layout, Object vNode)
if (gm.graphManager != null)
gm = gm.graphManager;
this.estimatedSize = Integer.MIN_VALUE;
this.inclusionTreeDepth = Integer.MAX_VALUE;
this.vGraphObject = vNode;
this.edges = [];
this.graphManager = gm;
if (size != null && loc != null)
this.rect = new RectangleD(loc.x, loc.y, size.width, size.height);
else
this.rect = new RectangleD();
}
LNode.prototype = Object.create(LGraphObject.prototype);
for (var prop in LGraphObject) {
LNode[prop] = LGraphObject[prop];
}
LNode.prototype.getEdges = function ()
{
return this.edges;
};
LNode.prototype.getChild = function ()
{
return this.child;
};
LNode.prototype.getOwner = function ()
{
// if (this.owner != null) {
// if (!(this.owner == null || this.owner.getNodes().indexOf(this) > -1)) {
// throw "assert failed";
// }
// }
return this.owner;
};
LNode.prototype.getWidth = function ()
{
return this.rect.width;
};
LNode.prototype.setWidth = function (width)
{
this.rect.width = width;
};
LNode.prototype.getHeight = function ()
{
return this.rect.height;
};
LNode.prototype.setHeight = function (height)
{
this.rect.height = height;
};
LNode.prototype.getCenterX = function ()
{
return this.rect.x + this.rect.width / 2;
};
LNode.prototype.getCenterY = function ()
{
return this.rect.y + this.rect.height / 2;
};
LNode.prototype.getCenter = function ()
{
return new PointD(this.rect.x + this.rect.width / 2,
this.rect.y + this.rect.height / 2);
};
LNode.prototype.getLocation = function ()
{
return new PointD(this.rect.x, this.rect.y);
};
LNode.prototype.getRect = function ()
{
return this.rect;
};
LNode.prototype.getDiagonal = function ()
{
return Math.sqrt(this.rect.width * this.rect.width +
this.rect.height * this.rect.height);
};
/**
* This method returns half the diagonal length of this node.
*/
LNode.prototype.getHalfTheDiagonal = function () {
return Math.sqrt(this.rect.height * this.rect.height +
this.rect.width * this.rect.width) / 2;
};
LNode.prototype.setRect = function (upperLeft, dimension)
{
this.rect.x = upperLeft.x;
this.rect.y = upperLeft.y;
this.rect.width = dimension.width;
this.rect.height = dimension.height;
};
LNode.prototype.setCenter = function (cx, cy)
{
this.rect.x = cx - this.rect.width / 2;
this.rect.y = cy - this.rect.height / 2;
};
LNode.prototype.setLocation = function (x, y)
{
this.rect.x = x;
this.rect.y = y;
};
LNode.prototype.moveBy = function (dx, dy)
{
this.rect.x += dx;
this.rect.y += dy;
};
LNode.prototype.getEdgeListToNode = function (to)
{
var edgeList = [];
var edge;
var self = this;
self.edges.forEach(function(edge) {
if (edge.target == to)
{
if (edge.source != self)
throw "Incorrect edge source!";
edgeList.push(edge);
}
});
return edgeList;
};
LNode.prototype.getEdgesBetween = function (other)
{
var edgeList = [];
var edge;
var self = this;
self.edges.forEach(function(edge) {
if (!(edge.source == self || edge.target == self))
throw "Incorrect edge source and/or target";
if ((edge.target == other) || (edge.source == other))
{
edgeList.push(edge);
}
});
return edgeList;
};
LNode.prototype.getNeighborsList = function ()
{
var neighbors = new Set();
var self = this;
self.edges.forEach(function(edge) {
if (edge.source == self)
{
neighbors.add(edge.target);
}
else
{
if (edge.target != self) {
throw "Incorrect incidency!";
}
neighbors.add(edge.source);
}
});
return neighbors;
};
LNode.prototype.withChildren = function ()
{
var withNeighborsList = new Set();
var childNode;
var children;
withNeighborsList.add(this);
if (this.child != null)
{
var nodes = this.child.getNodes();
for (var i = 0; i < nodes.length; i++)
{
childNode = nodes[i];
children = childNode.withChildren();
children.forEach(function(node) {
withNeighborsList.add(node);
});
}
}
return withNeighborsList;
};
LNode.prototype.getNoOfChildren = function ()
{
var noOfChildren = 0;
var childNode;
if(this.child == null){
noOfChildren = 1;
}
else
{
var nodes = this.child.getNodes();
for (var i = 0; i < nodes.length; i++)
{
childNode = nodes[i];
noOfChildren += childNode.getNoOfChildren();
}
}
if(noOfChildren == 0){
noOfChildren = 1;
}
return noOfChildren;
};
LNode.prototype.getEstimatedSize = function () {
if (this.estimatedSize == Integer.MIN_VALUE) {
throw "assert failed";
}
return this.estimatedSize;
};
LNode.prototype.calcEstimatedSize = function () {
if (this.child == null)
{
return this.estimatedSize = (this.rect.width + this.rect.height) / 2;
}
else
{
this.estimatedSize = this.child.calcEstimatedSize();
this.rect.width = this.estimatedSize;
this.rect.height = this.estimatedSize;
return this.estimatedSize;
}
};
LNode.prototype.scatter = function () {
var randomCenterX;
var randomCenterY;
var minX = -LayoutConstants.INITIAL_WORLD_BOUNDARY;
var maxX = LayoutConstants.INITIAL_WORLD_BOUNDARY;
randomCenterX = LayoutConstants.WORLD_CENTER_X +
(RandomSeed.nextDouble() * (maxX - minX)) + minX;
var minY = -LayoutConstants.INITIAL_WORLD_BOUNDARY;
var maxY = LayoutConstants.INITIAL_WORLD_BOUNDARY;
randomCenterY = LayoutConstants.WORLD_CENTER_Y +
(RandomSeed.nextDouble() * (maxY - minY)) + minY;
this.rect.x = randomCenterX;
this.rect.y = randomCenterY
};
LNode.prototype.updateBounds = function () {
if (this.getChild() == null) {
throw "assert failed";
}
if (this.getChild().getNodes().length != 0)
{
// wrap the children nodes by re-arranging the boundaries
var childGraph = this.getChild();
childGraph.updateBounds(true);
this.rect.x = childGraph.getLeft();
this.rect.y = childGraph.getTop();
this.setWidth(childGraph.getRight() - childGraph.getLeft());
this.setHeight(childGraph.getBottom() - childGraph.getTop());
// Update compound bounds considering its label properties
if(LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS){
var width = childGraph.getRight() - childGraph.getLeft();
var height = childGraph.getBottom() - childGraph.getTop();
if(this.labelWidth > width){
this.rect.x -= (this.labelWidth - width) / 2;
this.setWidth(this.labelWidth);
}
if(this.labelHeight > height){
if(this.labelPos == "center"){
this.rect.y -= (this.labelHeight - height) / 2;
}
else if(this.labelPos == "top"){
this.rect.y -= (this.labelHeight - height);
}
this.setHeight(this.labelHeight);
}
}
}
};
LNode.prototype.getInclusionTreeDepth = function ()
{
if (this.inclusionTreeDepth == Integer.MAX_VALUE) {
throw "assert failed";
}
return this.inclusionTreeDepth;
};
LNode.prototype.transform = function (trans)
{
var left = this.rect.x;
if (left > LayoutConstants.WORLD_BOUNDARY)
{
left = LayoutConstants.WORLD_BOUNDARY;
}
else if (left < -LayoutConstants.WORLD_BOUNDARY)
{
left = -LayoutConstants.WORLD_BOUNDARY;
}
var top = this.rect.y;
if (top > LayoutConstants.WORLD_BOUNDARY)
{
top = LayoutConstants.WORLD_BOUNDARY;
}
else if (top < -LayoutConstants.WORLD_BOUNDARY)
{
top = -LayoutConstants.WORLD_BOUNDARY;
}
var leftTop = new PointD(left, top);
var vLeftTop = trans.inverseTransformPoint(leftTop);
this.setLocation(vLeftTop.x, vLeftTop.y);
};
LNode.prototype.getLeft = function ()
{
return this.rect.x;
};
LNode.prototype.getRight = function ()
{
return this.rect.x + this.rect.width;
};
LNode.prototype.getTop = function ()
{
return this.rect.y;
};
LNode.prototype.getBottom = function ()
{
return this.rect.y + this.rect.height;
};
LNode.prototype.getParent = function ()
{
if (this.owner == null)
{
return null;
}
return this.owner.getParent();
};
module.exports = LNode;

672
frontend/node_modules/layout-base/src/Layout.js generated vendored Normal file
View File

@@ -0,0 +1,672 @@
var LayoutConstants = require('./LayoutConstants');
var LGraphManager = require('./LGraphManager');
var LNode = require('./LNode');
var LEdge = require('./LEdge');
var LGraph = require('./LGraph');
var PointD = require('./util/PointD');
var Transform = require('./util/Transform');
var Emitter = require('./util/Emitter');
function Layout(isRemoteUse) {
Emitter.call( this );
//Layout Quality: 0:draft, 1:default, 2:proof
this.layoutQuality = LayoutConstants.QUALITY;
//Whether layout should create bendpoints as needed or not
this.createBendsAsNeeded =
LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED;
//Whether layout should be incremental or not
this.incremental = LayoutConstants.DEFAULT_INCREMENTAL;
//Whether we animate from before to after layout node positions
this.animationOnLayout =
LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT;
//Whether we animate the layout process or not
this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT;
//Number iterations that should be done between two successive animations
this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD;
/**
* Whether or not leaf nodes (non-compound nodes) are of uniform sizes. When
* they are, both spring and repulsion forces between two leaf nodes can be
* calculated without the expensive clipping point calculations, resulting
* in major speed-up.
*/
this.uniformLeafNodeSizes =
LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES;
/**
* This is used for creation of bendpoints by using dummy nodes and edges.
* Maps an LEdge to its dummy bendpoint path.
*/
this.edgeToDummyNodes = new Map();
this.graphManager = new LGraphManager(this);
this.isLayoutFinished = false;
this.isSubLayout = false;
this.isRemoteUse = false;
if (isRemoteUse != null) {
this.isRemoteUse = isRemoteUse;
}
}
Layout.RANDOM_SEED = 1;
Layout.prototype = Object.create( Emitter.prototype );
Layout.prototype.getGraphManager = function () {
return this.graphManager;
};
Layout.prototype.getAllNodes = function () {
return this.graphManager.getAllNodes();
};
Layout.prototype.getAllEdges = function () {
return this.graphManager.getAllEdges();
};
Layout.prototype.getAllNodesToApplyGravitation = function () {
return this.graphManager.getAllNodesToApplyGravitation();
};
Layout.prototype.newGraphManager = function () {
var gm = new LGraphManager(this);
this.graphManager = gm;
return gm;
};
Layout.prototype.newGraph = function (vGraph)
{
return new LGraph(null, this.graphManager, vGraph);
};
Layout.prototype.newNode = function (vNode)
{
return new LNode(this.graphManager, vNode);
};
Layout.prototype.newEdge = function (vEdge)
{
return new LEdge(null, null, vEdge);
};
Layout.prototype.checkLayoutSuccess = function() {
return (this.graphManager.getRoot() == null)
|| this.graphManager.getRoot().getNodes().length == 0
|| this.graphManager.includesInvalidEdge();
};
Layout.prototype.runLayout = function ()
{
this.isLayoutFinished = false;
if (this.tilingPreLayout) {
this.tilingPreLayout();
}
this.initParameters();
var isLayoutSuccessfull;
if (this.checkLayoutSuccess())
{
isLayoutSuccessfull = false;
}
else
{
isLayoutSuccessfull = this.layout();
}
if (LayoutConstants.ANIMATE === 'during') {
// If this is a 'during' layout animation. Layout is not finished yet.
// We need to perform these in index.js when layout is really finished.
return false;
}
if (isLayoutSuccessfull)
{
if (!this.isSubLayout)
{
this.doPostLayout();
}
}
if (this.tilingPostLayout) {
this.tilingPostLayout();
}
this.isLayoutFinished = true;
return isLayoutSuccessfull;
};
/**
* This method performs the operations required after layout.
*/
Layout.prototype.doPostLayout = function ()
{
//assert !isSubLayout : "Should not be called on sub-layout!";
// Propagate geometric changes to v-level objects
if(!this.incremental){
this.transform();
}
this.update();
};
/**
* This method updates the geometry of the target graph according to
* calculated layout.
*/
Layout.prototype.update2 = function () {
// update bend points
if (this.createBendsAsNeeded)
{
this.createBendpointsFromDummyNodes();
// reset all edges, since the topology has changed
this.graphManager.resetAllEdges();
}
// perform edge, node and root updates if layout is not called
// remotely
if (!this.isRemoteUse)
{
// update all edges
var edge;
var allEdges = this.graphManager.getAllEdges();
for (var i = 0; i < allEdges.length; i++)
{
edge = allEdges[i];
// this.update(edge);
}
// recursively update nodes
var node;
var nodes = this.graphManager.getRoot().getNodes();
for (var i = 0; i < nodes.length; i++)
{
node = nodes[i];
// this.update(node);
}
// update root graph
this.update(this.graphManager.getRoot());
}
};
Layout.prototype.update = function (obj) {
if (obj == null) {
this.update2();
}
else if (obj instanceof LNode) {
var node = obj;
if (node.getChild() != null)
{
// since node is compound, recursively update child nodes
var nodes = node.getChild().getNodes();
for (var i = 0; i < nodes.length; i++)
{
update(nodes[i]);
}
}
// if the l-level node is associated with a v-level graph object,
// then it is assumed that the v-level node implements the
// interface Updatable.
if (node.vGraphObject != null)
{
// cast to Updatable without any type check
var vNode = node.vGraphObject;
// call the update method of the interface
vNode.update(node);
}
}
else if (obj instanceof LEdge) {
var edge = obj;
// if the l-level edge is associated with a v-level graph object,
// then it is assumed that the v-level edge implements the
// interface Updatable.
if (edge.vGraphObject != null)
{
// cast to Updatable without any type check
var vEdge = edge.vGraphObject;
// call the update method of the interface
vEdge.update(edge);
}
}
else if (obj instanceof LGraph) {
var graph = obj;
// if the l-level graph is associated with a v-level graph object,
// then it is assumed that the v-level object implements the
// interface Updatable.
if (graph.vGraphObject != null)
{
// cast to Updatable without any type check
var vGraph = graph.vGraphObject;
// call the update method of the interface
vGraph.update(graph);
}
}
};
/**
* This method is used to set all layout parameters to default values
* determined at compile time.
*/
Layout.prototype.initParameters = function () {
if (!this.isSubLayout)
{
this.layoutQuality = LayoutConstants.QUALITY;
this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT;
this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD;
this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT;
this.incremental = LayoutConstants.DEFAULT_INCREMENTAL;
this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED;
this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES;
}
if (this.animationDuringLayout)
{
this.animationOnLayout = false;
}
};
Layout.prototype.transform = function (newLeftTop) {
if (newLeftTop == undefined) {
this.transform(new PointD(0, 0));
}
else {
// create a transformation object (from Eclipse to layout). When an
// inverse transform is applied, we get upper-left coordinate of the
// drawing or the root graph at given input coordinate (some margins
// already included in calculation of left-top).
var trans = new Transform();
var leftTop = this.graphManager.getRoot().updateLeftTop();
if (leftTop != null)
{
trans.setWorldOrgX(newLeftTop.x);
trans.setWorldOrgY(newLeftTop.y);
trans.setDeviceOrgX(leftTop.x);
trans.setDeviceOrgY(leftTop.y);
var nodes = this.getAllNodes();
var node;
for (var i = 0; i < nodes.length; i++)
{
node = nodes[i];
node.transform(trans);
}
}
}
};
Layout.prototype.positionNodesRandomly = function (graph) {
if (graph == undefined) {
//assert !this.incremental;
this.positionNodesRandomly(this.getGraphManager().getRoot());
this.getGraphManager().getRoot().updateBounds(true);
}
else {
var lNode;
var childGraph;
var nodes = graph.getNodes();
for (var i = 0; i < nodes.length; i++)
{
lNode = nodes[i];
childGraph = lNode.getChild();
if (childGraph == null)
{
lNode.scatter();
}
else if (childGraph.getNodes().length == 0)
{
lNode.scatter();
}
else
{
this.positionNodesRandomly(childGraph);
lNode.updateBounds();
}
}
}
};
/**
* This method returns a list of trees where each tree is represented as a
* list of l-nodes. The method returns a list of size 0 when:
* - The graph is not flat or
* - One of the component(s) of the graph is not a tree.
*/
Layout.prototype.getFlatForest = function ()
{
var flatForest = [];
var isForest = true;
// Quick reference for all nodes in the graph manager associated with
// this layout. The list should not be changed.
var allNodes = this.graphManager.getRoot().getNodes();
// First be sure that the graph is flat
var isFlat = true;
for (var i = 0; i < allNodes.length; i++)
{
if (allNodes[i].getChild() != null)
{
isFlat = false;
}
}
// Return empty forest if the graph is not flat.
if (!isFlat)
{
return flatForest;
}
// Run BFS for each component of the graph.
var visited = new Set();
var toBeVisited = [];
var parents = new Map();
var unProcessedNodes = [];
unProcessedNodes = unProcessedNodes.concat(allNodes);
// Each iteration of this loop finds a component of the graph and
// decides whether it is a tree or not. If it is a tree, adds it to the
// forest and continued with the next component.
while (unProcessedNodes.length > 0 && isForest)
{
toBeVisited.push(unProcessedNodes[0]);
// Start the BFS. Each iteration of this loop visits a node in a
// BFS manner.
while (toBeVisited.length > 0 && isForest)
{
//pool operation
var currentNode = toBeVisited[0];
toBeVisited.splice(0, 1);
visited.add(currentNode);
// Traverse all neighbors of this node
var neighborEdges = currentNode.getEdges();
for (var i = 0; i < neighborEdges.length; i++)
{
var currentNeighbor =
neighborEdges[i].getOtherEnd(currentNode);
// If BFS is not growing from this neighbor.
if (parents.get(currentNode) != currentNeighbor)
{
// We haven't previously visited this neighbor.
if (!visited.has(currentNeighbor))
{
toBeVisited.push(currentNeighbor);
parents.set(currentNeighbor, currentNode);
}
// Since we have previously visited this neighbor and
// this neighbor is not parent of currentNode, given
// graph contains a component that is not tree, hence
// it is not a forest.
else
{
isForest = false;
break;
}
}
}
}
// The graph contains a component that is not a tree. Empty
// previously found trees. The method will end.
if (!isForest)
{
flatForest = [];
}
// Save currently visited nodes as a tree in our forest. Reset
// visited and parents lists. Continue with the next component of
// the graph, if any.
else
{
var temp = [...visited];
flatForest.push(temp);
//flatForest = flatForest.concat(temp);
//unProcessedNodes.removeAll(visited);
for (var i = 0; i < temp.length; i++) {
var value = temp[i];
var index = unProcessedNodes.indexOf(value);
if (index > -1) {
unProcessedNodes.splice(index, 1);
}
}
visited = new Set();
parents = new Map();
}
}
return flatForest;
};
/**
* This method creates dummy nodes (an l-level node with minimal dimensions)
* for the given edge (one per bendpoint). The existing l-level structure
* is updated accordingly.
*/
Layout.prototype.createDummyNodesForBendpoints = function (edge)
{
var dummyNodes = [];
var prev = edge.source;
var graph = this.graphManager.calcLowestCommonAncestor(edge.source, edge.target);
for (var i = 0; i < edge.bendpoints.length; i++)
{
// create new dummy node
var dummyNode = this.newNode(null);
dummyNode.setRect(new Point(0, 0), new Dimension(1, 1));
graph.add(dummyNode);
// create new dummy edge between prev and dummy node
var dummyEdge = this.newEdge(null);
this.graphManager.add(dummyEdge, prev, dummyNode);
dummyNodes.add(dummyNode);
prev = dummyNode;
}
var dummyEdge = this.newEdge(null);
this.graphManager.add(dummyEdge, prev, edge.target);
this.edgeToDummyNodes.set(edge, dummyNodes);
// remove real edge from graph manager if it is inter-graph
if (edge.isInterGraph())
{
this.graphManager.remove(edge);
}
// else, remove the edge from the current graph
else
{
graph.remove(edge);
}
return dummyNodes;
};
/**
* This method creates bendpoints for edges from the dummy nodes
* at l-level.
*/
Layout.prototype.createBendpointsFromDummyNodes = function ()
{
var edges = [];
edges = edges.concat(this.graphManager.getAllEdges());
edges = [...this.edgeToDummyNodes.keys()].concat(edges);
for (var k = 0; k < edges.length; k++)
{
var lEdge = edges[k];
if (lEdge.bendpoints.length > 0)
{
var path = this.edgeToDummyNodes.get(lEdge);
for (var i = 0; i < path.length; i++)
{
var dummyNode = path[i];
var p = new PointD(dummyNode.getCenterX(),
dummyNode.getCenterY());
// update bendpoint's location according to dummy node
var ebp = lEdge.bendpoints.get(i);
ebp.x = p.x;
ebp.y = p.y;
// remove the dummy node, dummy edges incident with this
// dummy node is also removed (within the remove method)
dummyNode.getOwner().remove(dummyNode);
}
// add the real edge to graph
this.graphManager.add(lEdge, lEdge.source, lEdge.target);
}
}
};
Layout.transform = function (sliderValue, defaultValue, minDiv, maxMul) {
if (minDiv != undefined && maxMul != undefined) {
var value = defaultValue;
if (sliderValue <= 50)
{
var minValue = defaultValue / minDiv;
value -= ((defaultValue - minValue) / 50) * (50 - sliderValue);
}
else
{
var maxValue = defaultValue * maxMul;
value += ((maxValue - defaultValue) / 50) * (sliderValue - 50);
}
return value;
}
else {
var a, b;
if (sliderValue <= 50)
{
a = 9.0 * defaultValue / 500.0;
b = defaultValue / 10.0;
}
else
{
a = 9.0 * defaultValue / 50.0;
b = -8 * defaultValue;
}
return (a * sliderValue + b);
}
};
/**
* This method finds and returns the center of the given nodes, assuming
* that the given nodes form a tree in themselves.
*/
Layout.findCenterOfTree = function (nodes)
{
var list = [];
list = list.concat(nodes);
var removedNodes = [];
var remainingDegrees = new Map();
var foundCenter = false;
var centerNode = null;
if (list.length == 1 || list.length == 2)
{
foundCenter = true;
centerNode = list[0];
}
for (var i = 0; i < list.length; i++)
{
var node = list[i];
var degree = node.getNeighborsList().size;
remainingDegrees.set(node, node.getNeighborsList().size);
if (degree == 1)
{
removedNodes.push(node);
}
}
var tempList = [];
tempList = tempList.concat(removedNodes);
while (!foundCenter)
{
var tempList2 = [];
tempList2 = tempList2.concat(tempList);
tempList = [];
for (var i = 0; i < list.length; i++)
{
var node = list[i];
var index = list.indexOf(node);
if (index >= 0) {
list.splice(index, 1);
}
var neighbours = node.getNeighborsList();
neighbours.forEach(function(neighbour) {
if (removedNodes.indexOf(neighbour) < 0)
{
var otherDegree = remainingDegrees.get(neighbour);
var newDegree = otherDegree - 1;
if (newDegree == 1)
{
tempList.push(neighbour);
}
remainingDegrees.set(neighbour, newDegree);
}
});
}
removedNodes = removedNodes.concat(tempList);
if (list.length == 1 || list.length == 2)
{
foundCenter = true;
centerNode = list[0];
}
}
return centerNode;
};
/**
* During the coarsening process, this layout may be referenced by two graph managers
* this setter function grants access to change the currently being used graph manager
*/
Layout.prototype.setGraphManager = function (gm)
{
this.graphManager = gm;
};
module.exports = Layout;

View File

@@ -0,0 +1,34 @@
var LayoutConstants = require('../LayoutConstants');
function FDLayoutConstants() {
}
//FDLayoutConstants inherits static props in LayoutConstants
for (var prop in LayoutConstants) {
FDLayoutConstants[prop] = LayoutConstants[prop];
}
FDLayoutConstants.MAX_ITERATIONS = 2500;
FDLayoutConstants.DEFAULT_EDGE_LENGTH = 50;
FDLayoutConstants.DEFAULT_SPRING_STRENGTH = 0.45;
FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = 4500.0;
FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = 0.4;
FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = 1.0;
FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = 3.8;
FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = 1.5;
FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION = true;
FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION = true;
FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = 0.3;
FDLayoutConstants.COOLING_ADAPTATION_FACTOR = 0.33;
FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT = 1000;
FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT = 5000;
FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL = 100.0;
FDLayoutConstants.MAX_NODE_DISPLACEMENT = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL * 3;
FDLayoutConstants.MIN_REPULSION_DIST = FDLayoutConstants.DEFAULT_EDGE_LENGTH / 10.0;
FDLayoutConstants.CONVERGENCE_CHECK_PERIOD = 100;
FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = 0.1;
FDLayoutConstants.MIN_EDGE_LENGTH = 1;
FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD = 10;
module.exports = FDLayoutConstants;

73
frontend/node_modules/layout-base/src/util/Point.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
/*
*This class is the javascript implementation of the Point.java class in jdk
*/
function Point(x, y, p) {
this.x = null;
this.y = null;
if (x == null && y == null && p == null) {
this.x = 0;
this.y = 0;
}
else if (typeof x == 'number' && typeof y == 'number' && p == null) {
this.x = x;
this.y = y;
}
else if (x.constructor.name == 'Point' && y == null && p == null) {
p = x;
this.x = p.x;
this.y = p.y;
}
}
Point.prototype.getX = function () {
return this.x;
}
Point.prototype.getY = function () {
return this.y;
}
Point.prototype.getLocation = function () {
return new Point(this.x, this.y);
}
Point.prototype.setLocation = function (x, y, p) {
if (x.constructor.name == 'Point' && y == null && p == null) {
p = x;
this.setLocation(p.x, p.y);
}
else if (typeof x == 'number' && typeof y == 'number' && p == null) {
//if both parameters are integer just move (x,y) location
if (parseInt(x) == x && parseInt(y) == y) {
this.move(x, y);
}
else {
this.x = Math.floor(x + 0.5);
this.y = Math.floor(y + 0.5);
}
}
}
Point.prototype.move = function (x, y) {
this.x = x;
this.y = y;
}
Point.prototype.translate = function (dx, dy) {
this.x += dx;
this.y += dy;
}
Point.prototype.equals = function (obj) {
if (obj.constructor.name == "Point") {
var pt = obj;
return (this.x == pt.x) && (this.y == pt.y);
}
return this == obj;
}
Point.prototype.toString = function () {
return new Point().constructor.name + "[x=" + this.x + ",y=" + this.y + "]";
}
module.exports = Point;

157
frontend/node_modules/layout-base/src/util/Transform.js generated vendored Normal file
View File

@@ -0,0 +1,157 @@
var PointD = require('./PointD');
function Transform(x, y) {
this.lworldOrgX = 0.0;
this.lworldOrgY = 0.0;
this.ldeviceOrgX = 0.0;
this.ldeviceOrgY = 0.0;
this.lworldExtX = 1.0;
this.lworldExtY = 1.0;
this.ldeviceExtX = 1.0;
this.ldeviceExtY = 1.0;
}
Transform.prototype.getWorldOrgX = function ()
{
return this.lworldOrgX;
}
Transform.prototype.setWorldOrgX = function (wox)
{
this.lworldOrgX = wox;
}
Transform.prototype.getWorldOrgY = function ()
{
return this.lworldOrgY;
}
Transform.prototype.setWorldOrgY = function (woy)
{
this.lworldOrgY = woy;
}
Transform.prototype.getWorldExtX = function ()
{
return this.lworldExtX;
}
Transform.prototype.setWorldExtX = function (wex)
{
this.lworldExtX = wex;
}
Transform.prototype.getWorldExtY = function ()
{
return this.lworldExtY;
}
Transform.prototype.setWorldExtY = function (wey)
{
this.lworldExtY = wey;
}
/* Device related */
Transform.prototype.getDeviceOrgX = function ()
{
return this.ldeviceOrgX;
}
Transform.prototype.setDeviceOrgX = function (dox)
{
this.ldeviceOrgX = dox;
}
Transform.prototype.getDeviceOrgY = function ()
{
return this.ldeviceOrgY;
}
Transform.prototype.setDeviceOrgY = function (doy)
{
this.ldeviceOrgY = doy;
}
Transform.prototype.getDeviceExtX = function ()
{
return this.ldeviceExtX;
}
Transform.prototype.setDeviceExtX = function (dex)
{
this.ldeviceExtX = dex;
}
Transform.prototype.getDeviceExtY = function ()
{
return this.ldeviceExtY;
}
Transform.prototype.setDeviceExtY = function (dey)
{
this.ldeviceExtY = dey;
}
Transform.prototype.transformX = function (x)
{
var xDevice = 0.0;
var worldExtX = this.lworldExtX;
if (worldExtX != 0.0)
{
xDevice = this.ldeviceOrgX +
((x - this.lworldOrgX) * this.ldeviceExtX / worldExtX);
}
return xDevice;
}
Transform.prototype.transformY = function (y)
{
var yDevice = 0.0;
var worldExtY = this.lworldExtY;
if (worldExtY != 0.0)
{
yDevice = this.ldeviceOrgY +
((y - this.lworldOrgY) * this.ldeviceExtY / worldExtY);
}
return yDevice;
}
Transform.prototype.inverseTransformX = function (x)
{
var xWorld = 0.0;
var deviceExtX = this.ldeviceExtX;
if (deviceExtX != 0.0)
{
xWorld = this.lworldOrgX +
((x - this.ldeviceOrgX) * this.lworldExtX / deviceExtX);
}
return xWorld;
}
Transform.prototype.inverseTransformY = function (y)
{
var yWorld = 0.0;
var deviceExtY = this.ldeviceExtY;
if (deviceExtY != 0.0)
{
yWorld = this.lworldOrgY +
((y - this.ldeviceOrgY) * this.lworldExtY / deviceExtY);
}
return yWorld;
}
Transform.prototype.inverseTransformPoint = function (inPoint)
{
var outPoint =
new PointD(this.inverseTransformX(inPoint.x),
this.inverseTransformY(inPoint.y));
return outPoint;
}
module.exports = Transform;

View File

@@ -0,0 +1,29 @@
function UniqueIDGeneretor() {
}
UniqueIDGeneretor.lastID = 0;
UniqueIDGeneretor.createID = function (obj) {
if (UniqueIDGeneretor.isPrimitive(obj)) {
return obj;
}
if (obj.uniqueID != null) {
return obj.uniqueID;
}
obj.uniqueID = UniqueIDGeneretor.getString();
UniqueIDGeneretor.lastID++;
return obj.uniqueID;
}
UniqueIDGeneretor.getString = function (id) {
if (id == null)
id = UniqueIDGeneretor.lastID;
return "Object#" + id + "";
}
UniqueIDGeneretor.isPrimitive = function (arg) {
var type = typeof arg;
return arg == null || (type != "object" && type != "function");
}
module.exports = UniqueIDGeneretor;