@webskill/sdk 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abnfDiagram-O67JEVCF-DtYFjfqO.js +109 -0
- package/dist/agent.d.ts +3 -3
- package/dist/agent.js +1174 -169
- package/dist/{approval-DwN2o2QG.js → approval-7CuZS3Z4.js} +104 -18
- package/dist/arc-8U_6NQWm.js +130 -0
- package/dist/architecture-7GRP2DOG-RTw1wpAq.js +4 -0
- package/dist/architectureDiagram-NJMV4G6O-XmmXrJAK.js +7473 -0
- package/dist/array-DQfpQNY8.js +8 -0
- package/dist/blockDiagram-BEXU5L5S-D4yjnCD1.js +2582 -0
- package/dist/browser.d.ts +455 -49
- package/dist/browser.js +2134 -138
- package/dist/c4Diagram-YGBWAQC7-BLmA_JSd.js +3668 -0
- package/dist/channel-CZxxLrG7.js +9 -0
- package/dist/chunk-2Q5K7J3B-Ck03gkFR.js +21 -0
- package/dist/chunk-3FUC2YCW-tr6jmbQf.js +530 -0
- package/dist/chunk-5DYCD2WN-Bt97YGTd.js +58 -0
- package/dist/chunk-5VM5RSS4-BBxa48HL.js +21 -0
- package/dist/chunk-6AEJRKK7-JXK89I-O.js +14 -0
- package/dist/chunk-742MDFTN-CPmgCGwC.js +466 -0
- package/dist/chunk-7INBJB4K-C9jq9o66.js +6552 -0
- package/dist/chunk-7M6MHVWA-BrKCWcR1.js +4894 -0
- package/dist/chunk-7PRAP22T-BHED6GVs.js +95 -0
- package/dist/chunk-DUW6YSOI-DoZj78PO.js +19 -0
- package/dist/chunk-FOHPRMQF-Dkbp819z.js +27189 -0
- package/dist/chunk-GNY47TPC-Bpvq1T49.js +87 -0
- package/dist/chunk-GTNCS2PH-CLmh4I2c.js +686 -0
- package/dist/chunk-GWA4HPMP-B6vN3fkL.js +95 -0
- package/dist/chunk-J5ZVWO5B-Bi_Pcobw.js +26 -0
- package/dist/chunk-JWPE2WC7-D1rC79GS.js +12 -0
- package/dist/chunk-LNGE3PJU-D5OIoe3Z.js +2582 -0
- package/dist/chunk-MBY4JIJT-C34L7a4f.js +2276 -0
- package/dist/chunk-NETBCI7D-Cg84k8N8.js +321 -0
- package/dist/chunk-O7XYJQB3-B6K0KOSL.js +8846 -0
- package/dist/chunk-UA2S7LBM-DxHM29_K.js +612 -0
- package/dist/chunk-WEXAMYUT-Ba6jFWhB.js +33 -0
- package/dist/chunk-XXDRQBXY-DPbSy4kg.js +12 -0
- package/dist/chunk-Y2CYZVJY-U3QOMqrW.js +15 -0
- package/dist/chunk-Z7XXMR3K-oLg1h8F3.js +1038 -0
- package/dist/chunk-ZIGJFQKS-DqEFBuHR.js +2215 -0
- package/dist/classDiagram-v2-NBCMYWYE-BqnOWIUt.js +3845 -0
- package/dist/cose-bilkent-JH36ORCC-C0dTAHVK.js +4270 -0
- package/dist/cynefin-OW5HDTMX-B2QvgEQj.js +4 -0
- package/dist/cynefinDiagram-VND7K2PF-yAWc6Z3W.js +479 -0
- package/dist/cytoscape.esm-C64mRh9B.js +28325 -0
- package/dist/dagre-6A5THRUB-D0w2W27v.js +4816 -0
- package/dist/defaultLocale-B_EoOkSF.js +249 -0
- package/dist/diagram-22UHCM2B-DvgzhUzP.js +6115 -0
- package/dist/diagram-3UASUU5V-DWgUB-ef.js +795 -0
- package/dist/diagram-ATOU4E4O-P1olqwIs.js +553 -0
- package/dist/diagram-CDSNMT55-BUlZuLUe.js +402 -0
- package/dist/diagram-MLGK6HIB-6w5qmkGt.js +186 -0
- package/dist/diagram-MPIPVDR6-DEFiSo8o.js +289 -0
- package/dist/dist-UajCDt3n.js +92 -0
- package/dist/ebnfDiagram-ZINNZB2B-CI8liCfR.js +123 -0
- package/dist/elk-276RUBZZ-3SvW6OAK.js +90034 -0
- package/dist/erDiagram-OPXOYQCR-CPTbKhwP.js +2301 -0
- package/dist/eventmodeling-NTZA5JFV-BlyuqGp0.js +4 -0
- package/dist/flowDiagram-KWPJA3E3-CcUJ6HbV.js +18 -0
- package/dist/ganttDiagram-FUAMR5RP-31UjY0KK.js +3939 -0
- package/dist/{toolSource-C9oNuKmr.js → geometry-CRhuySKV.js} +169 -12
- package/dist/gitGraph-4MIJSDKK-ChdVlrk7.js +4 -0
- package/dist/gitGraphDiagram-X574FWY7-DKuxJymB.js +1153 -0
- package/dist/governance.d.ts +22 -4
- package/dist/governance.js +100 -10
- package/dist/graphlib-tk9gQYuN.js +4194 -0
- package/dist/{index-DHopiH_m.d.ts → index-7No55dRb.d.ts} +161 -11
- package/dist/{index-B8Tgmpwh.d.ts → index-ShvCB5I9.d.ts} +2 -2
- package/dist/{index-CYLt5u4L.d.ts → index-V76_OFj2.d.ts} +789 -21
- package/dist/index.d.ts +4 -4
- package/dist/index.js +11 -9
- package/dist/info-A6RAGUB7-CxRAt9S9.js +4 -0
- package/dist/infoDiagram-VRGFBTTK-pRspGfjZ.js +25 -0
- package/dist/init-CMOIWdg-.js +16 -0
- package/dist/ishikawaDiagram-OU5B5YK6-DKerAPAg.js +975 -0
- package/dist/journeyDiagram-ZHPQQLJL-C4MK-YO5.js +1227 -0
- package/dist/kanban-definition-PNTS6WVX-BqsZpMXx.js +1244 -0
- package/dist/katex-BcRRvyh_.js +26465 -0
- package/dist/{kind-DaKqLX2F.js → kind-Dc8x0HWz.js} +54 -7
- package/dist/line-LgV8iVMV.js +48 -0
- package/dist/linear-BWKR0Tqd.js +393 -0
- package/dist/linkedDocument-CZZOl9cO.js +456 -0
- package/dist/mcp.d.ts +2 -2
- package/dist/{memoryArtifactStore-D6dLeY55.js → memoryArtifactStore-Bs7glPqm.js} +14 -0
- package/dist/mermaid-parser.core-pYR5siSx.js +754 -0
- package/dist/mermaid.core-DMtwGCHy.js +1756 -0
- package/dist/mindmap-definition-NLK3R4M7-CXbD-myG.js +1312 -0
- package/dist/node.d.ts +3 -3
- package/dist/node.js +12 -5
- package/dist/{openUiLibrary-b0i7F_oZ.js → openUiLibrary-B7j3rLrm.js} +1 -1
- package/dist/{openUiSpecLang-CLXJEeRU.js → openUiSpecLang-BSYYnjay.js} +1 -1
- package/dist/ordinal-CxA6GHQS.js +84 -0
- package/dist/packet-AYTQ26CC-BOm08cxl.js +4 -0
- package/dist/path-C27Z2Bjv.js +106 -0
- package/dist/{pathSecurity-B1owvJAF.js → pathSecurity-CirkQwWP.js} +12 -1
- package/dist/pegDiagram-GJSIUBJH-BLGJOewQ.js +115 -0
- package/dist/pie-WAS4IAKB-Dvg7glpk.js +4 -0
- package/dist/pieDiagram-5QR66LMP-laoaV_PB.js +298 -0
- package/dist/quadrantDiagram-O4NWA36T-Db_wFBkT.js +2236 -0
- package/dist/radar-RG4KPBEZ-BZDaTu06.js +4 -0
- package/dist/railroad-74A4TZTK-C-UhjkOy.js +4 -0
- package/dist/railroad-abnf-HS5TGJTU-dUKVA4OS.js +4 -0
- package/dist/railroad-ebnf-LZEXJU2U-DzQumk18.js +4 -0
- package/dist/railroad-peg-WCYAUIDC-B3vvTWed.js +4 -0
- package/dist/railroadDiagram-XR7U4H2S-BY0sTM4X.js +89 -0
- package/dist/requirementDiagram-PLB6GJNP-3rkQfEhs.js +2474 -0
- package/dist/rough.cjs-AmDd_NQk.js +1395 -0
- package/dist/sankeyDiagram-IPEJSGJF-CGAJhyG2.js +3578 -0
- package/dist/sequenceDiagram-PO4LG4MO-9FJjFX06.js +5522 -0
- package/dist/sizeCapture-INFHLROL-D8PWxdOn.js +56 -0
- package/dist/{skill-CAJMsLod.js → skill-WSUDp6A1.js} +1 -1
- package/dist/{skillVersionStore-B24Jjjry-BkOk9wI_.d.ts → skillVersionStore-S4_HJ_Fl-Cvy9LqVu.d.ts} +35 -4
- package/dist/src-NkhI3UMl.js +2653 -0
- package/dist/stateDiagram-v2-GCMORJYK-B0O3wc1-.js +2715 -0
- package/dist/swimlanes-2SLR337P-D4EOnrpu.js +6637 -0
- package/dist/swimlanesDiagram-TC7HE7FX-BUx29EJ9.js +30 -0
- package/dist/testing.d.ts +2 -1
- package/dist/testing.js +1 -1
- package/dist/timeline-definition-EJHVYXUP-CrgiiB4C.js +1513 -0
- package/dist/treeView-Q6P3EWNA-C1by-Gzc.js +4 -0
- package/dist/treemap-WGGIJYW6-mC2NZ6ad.js +4 -0
- package/dist/{types-BvTV_05--BW8zDuEk.d.ts → types-CpDRZ0rA-BiZBXGm4.d.ts} +66 -8
- package/dist/ui-react.d.ts +3 -3
- package/dist/ui-react.js +3746 -96
- package/dist/ui-vue.d.ts +1 -1
- package/dist/ui.d.ts +3 -3
- package/dist/ui.js +2 -2
- package/dist/usecaseDiagram-POWQR4AR-BUt_TQOY.js +14397 -0
- package/dist/vennDiagram-UO4OBE2U-CwXr0wjA.js +2808 -0
- package/dist/wardley-WFR3VGLG-CVSYjq_S.js +4 -0
- package/dist/wardleyDiagram-VNRHLVJA-Cpfd47dQ.js +874 -0
- package/dist/{webSkillApi-Cib6G-94.js → webSkillApi-D5VMUnrv.js} +2 -2
- package/dist/{webskillLitCatalog-W06npwej.js → webskillLitCatalog-D5BCiMCU.js} +1 -1
- package/dist/xychartDiagram-PMCCYNJV-e1TeVoc6.js +2704 -0
- package/package.json +1 -1
- package/dist/linkedDocument-C0gj1sMq.js +0 -245
|
@@ -0,0 +1,4270 @@
|
|
|
1
|
+
import { o as __toESM, t as __commonJSMin } from "./rolldown-runtime-BHkdefai.js";
|
|
2
|
+
import { n as __name } from "./chunk-Y2CYZVJY-U3QOMqrW.js";
|
|
3
|
+
import { m as log, p as select_default } from "./src-NkhI3UMl.js";
|
|
4
|
+
import { t as cytoscape$1 } from "./cytoscape.esm-C64mRh9B.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js
|
|
7
|
+
var require_layout_base = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
8
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
9
|
+
if (typeof exports === "object" && typeof module === "object") module.exports = factory();
|
|
10
|
+
else if (typeof define === "function" && define.amd) define([], factory);
|
|
11
|
+
else if (typeof exports === "object") exports["layoutBase"] = factory();
|
|
12
|
+
else root["layoutBase"] = factory();
|
|
13
|
+
})(exports, function() {
|
|
14
|
+
return (function(modules) {
|
|
15
|
+
var installedModules = {};
|
|
16
|
+
function __webpack_require__(moduleId) {
|
|
17
|
+
if (installedModules[moduleId]) return installedModules[moduleId].exports;
|
|
18
|
+
var module$15 = installedModules[moduleId] = {
|
|
19
|
+
i: moduleId,
|
|
20
|
+
l: false,
|
|
21
|
+
exports: {}
|
|
22
|
+
};
|
|
23
|
+
modules[moduleId].call(module$15.exports, module$15, module$15.exports, __webpack_require__);
|
|
24
|
+
module$15.l = true;
|
|
25
|
+
return module$15.exports;
|
|
26
|
+
}
|
|
27
|
+
__webpack_require__.m = modules;
|
|
28
|
+
__webpack_require__.c = installedModules;
|
|
29
|
+
__webpack_require__.i = function(value) {
|
|
30
|
+
return value;
|
|
31
|
+
};
|
|
32
|
+
__webpack_require__.d = function(exports$13, name, getter) {
|
|
33
|
+
if (!__webpack_require__.o(exports$13, name)) Object.defineProperty(exports$13, name, {
|
|
34
|
+
configurable: false,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: getter
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
__webpack_require__.n = function(module$16) {
|
|
40
|
+
var getter = module$16 && module$16.__esModule ? function getDefault() {
|
|
41
|
+
return module$16["default"];
|
|
42
|
+
} : function getModuleExports() {
|
|
43
|
+
return module$16;
|
|
44
|
+
};
|
|
45
|
+
__webpack_require__.d(getter, "a", getter);
|
|
46
|
+
return getter;
|
|
47
|
+
};
|
|
48
|
+
__webpack_require__.o = function(object, property) {
|
|
49
|
+
return Object.prototype.hasOwnProperty.call(object, property);
|
|
50
|
+
};
|
|
51
|
+
__webpack_require__.p = "";
|
|
52
|
+
return __webpack_require__(__webpack_require__.s = 26);
|
|
53
|
+
})([
|
|
54
|
+
(function(module$17, exports$14, __webpack_require__) {
|
|
55
|
+
"use strict";
|
|
56
|
+
function LayoutConstants() {}
|
|
57
|
+
/**
|
|
58
|
+
* Layout Quality: 0:draft, 1:default, 2:proof
|
|
59
|
+
*/
|
|
60
|
+
LayoutConstants.QUALITY = 1;
|
|
61
|
+
/**
|
|
62
|
+
* Default parameters
|
|
63
|
+
*/
|
|
64
|
+
LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED = false;
|
|
65
|
+
LayoutConstants.DEFAULT_INCREMENTAL = false;
|
|
66
|
+
LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT = true;
|
|
67
|
+
LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT = false;
|
|
68
|
+
LayoutConstants.DEFAULT_ANIMATION_PERIOD = 50;
|
|
69
|
+
LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = false;
|
|
70
|
+
LayoutConstants.DEFAULT_GRAPH_MARGIN = 15;
|
|
71
|
+
LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = false;
|
|
72
|
+
LayoutConstants.SIMPLE_NODE_SIZE = 40;
|
|
73
|
+
LayoutConstants.SIMPLE_NODE_HALF_SIZE = LayoutConstants.SIMPLE_NODE_SIZE / 2;
|
|
74
|
+
LayoutConstants.EMPTY_COMPOUND_NODE_SIZE = 40;
|
|
75
|
+
LayoutConstants.MIN_EDGE_LENGTH = 1;
|
|
76
|
+
LayoutConstants.WORLD_BOUNDARY = 1e6;
|
|
77
|
+
LayoutConstants.INITIAL_WORLD_BOUNDARY = LayoutConstants.WORLD_BOUNDARY / 1e3;
|
|
78
|
+
LayoutConstants.WORLD_CENTER_X = 1200;
|
|
79
|
+
LayoutConstants.WORLD_CENTER_Y = 900;
|
|
80
|
+
module$17.exports = LayoutConstants;
|
|
81
|
+
}),
|
|
82
|
+
(function(module$18, exports$15, __webpack_require__) {
|
|
83
|
+
"use strict";
|
|
84
|
+
var LGraphObject = __webpack_require__(2);
|
|
85
|
+
var IGeometry = __webpack_require__(8);
|
|
86
|
+
var IMath = __webpack_require__(9);
|
|
87
|
+
function LEdge(source, target, vEdge) {
|
|
88
|
+
LGraphObject.call(this, vEdge);
|
|
89
|
+
this.isOverlapingSourceAndTarget = false;
|
|
90
|
+
this.vGraphObject = vEdge;
|
|
91
|
+
this.bendpoints = [];
|
|
92
|
+
this.source = source;
|
|
93
|
+
this.target = target;
|
|
94
|
+
}
|
|
95
|
+
LEdge.prototype = Object.create(LGraphObject.prototype);
|
|
96
|
+
for (var prop in LGraphObject) LEdge[prop] = LGraphObject[prop];
|
|
97
|
+
LEdge.prototype.getSource = function() {
|
|
98
|
+
return this.source;
|
|
99
|
+
};
|
|
100
|
+
LEdge.prototype.getTarget = function() {
|
|
101
|
+
return this.target;
|
|
102
|
+
};
|
|
103
|
+
LEdge.prototype.isInterGraph = function() {
|
|
104
|
+
return this.isInterGraph;
|
|
105
|
+
};
|
|
106
|
+
LEdge.prototype.getLength = function() {
|
|
107
|
+
return this.length;
|
|
108
|
+
};
|
|
109
|
+
LEdge.prototype.isOverlapingSourceAndTarget = function() {
|
|
110
|
+
return this.isOverlapingSourceAndTarget;
|
|
111
|
+
};
|
|
112
|
+
LEdge.prototype.getBendpoints = function() {
|
|
113
|
+
return this.bendpoints;
|
|
114
|
+
};
|
|
115
|
+
LEdge.prototype.getLca = function() {
|
|
116
|
+
return this.lca;
|
|
117
|
+
};
|
|
118
|
+
LEdge.prototype.getSourceInLca = function() {
|
|
119
|
+
return this.sourceInLca;
|
|
120
|
+
};
|
|
121
|
+
LEdge.prototype.getTargetInLca = function() {
|
|
122
|
+
return this.targetInLca;
|
|
123
|
+
};
|
|
124
|
+
LEdge.prototype.getOtherEnd = function(node) {
|
|
125
|
+
if (this.source === node) return this.target;
|
|
126
|
+
else if (this.target === node) return this.source;
|
|
127
|
+
else throw "Node is not incident with this edge";
|
|
128
|
+
};
|
|
129
|
+
LEdge.prototype.getOtherEndInGraph = function(node, graph) {
|
|
130
|
+
var otherEnd = this.getOtherEnd(node);
|
|
131
|
+
var root = graph.getGraphManager().getRoot();
|
|
132
|
+
while (true) {
|
|
133
|
+
if (otherEnd.getOwner() == graph) return otherEnd;
|
|
134
|
+
if (otherEnd.getOwner() == root) break;
|
|
135
|
+
otherEnd = otherEnd.getOwner().getParent();
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
};
|
|
139
|
+
LEdge.prototype.updateLength = function() {
|
|
140
|
+
var clipPointCoordinates = new Array(4);
|
|
141
|
+
this.isOverlapingSourceAndTarget = IGeometry.getIntersection(this.target.getRect(), this.source.getRect(), clipPointCoordinates);
|
|
142
|
+
if (!this.isOverlapingSourceAndTarget) {
|
|
143
|
+
this.lengthX = clipPointCoordinates[0] - clipPointCoordinates[2];
|
|
144
|
+
this.lengthY = clipPointCoordinates[1] - clipPointCoordinates[3];
|
|
145
|
+
if (Math.abs(this.lengthX) < 1) this.lengthX = IMath.sign(this.lengthX);
|
|
146
|
+
if (Math.abs(this.lengthY) < 1) this.lengthY = IMath.sign(this.lengthY);
|
|
147
|
+
this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
LEdge.prototype.updateLengthSimple = function() {
|
|
151
|
+
this.lengthX = this.target.getCenterX() - this.source.getCenterX();
|
|
152
|
+
this.lengthY = this.target.getCenterY() - this.source.getCenterY();
|
|
153
|
+
if (Math.abs(this.lengthX) < 1) this.lengthX = IMath.sign(this.lengthX);
|
|
154
|
+
if (Math.abs(this.lengthY) < 1) this.lengthY = IMath.sign(this.lengthY);
|
|
155
|
+
this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY);
|
|
156
|
+
};
|
|
157
|
+
module$18.exports = LEdge;
|
|
158
|
+
}),
|
|
159
|
+
(function(module$19, exports$16, __webpack_require__) {
|
|
160
|
+
"use strict";
|
|
161
|
+
function LGraphObject(vGraphObject) {
|
|
162
|
+
this.vGraphObject = vGraphObject;
|
|
163
|
+
}
|
|
164
|
+
module$19.exports = LGraphObject;
|
|
165
|
+
}),
|
|
166
|
+
(function(module$20, exports$17, __webpack_require__) {
|
|
167
|
+
"use strict";
|
|
168
|
+
var LGraphObject = __webpack_require__(2);
|
|
169
|
+
var Integer = __webpack_require__(10);
|
|
170
|
+
var RectangleD = __webpack_require__(13);
|
|
171
|
+
var LayoutConstants = __webpack_require__(0);
|
|
172
|
+
var RandomSeed = __webpack_require__(16);
|
|
173
|
+
var PointD = __webpack_require__(4);
|
|
174
|
+
function LNode(gm, loc, size, vNode) {
|
|
175
|
+
if (size == null && vNode == null) vNode = loc;
|
|
176
|
+
LGraphObject.call(this, vNode);
|
|
177
|
+
if (gm.graphManager != null) gm = gm.graphManager;
|
|
178
|
+
this.estimatedSize = Integer.MIN_VALUE;
|
|
179
|
+
this.inclusionTreeDepth = Integer.MAX_VALUE;
|
|
180
|
+
this.vGraphObject = vNode;
|
|
181
|
+
this.edges = [];
|
|
182
|
+
this.graphManager = gm;
|
|
183
|
+
if (size != null && loc != null) this.rect = new RectangleD(loc.x, loc.y, size.width, size.height);
|
|
184
|
+
else this.rect = new RectangleD();
|
|
185
|
+
}
|
|
186
|
+
LNode.prototype = Object.create(LGraphObject.prototype);
|
|
187
|
+
for (var prop in LGraphObject) LNode[prop] = LGraphObject[prop];
|
|
188
|
+
LNode.prototype.getEdges = function() {
|
|
189
|
+
return this.edges;
|
|
190
|
+
};
|
|
191
|
+
LNode.prototype.getChild = function() {
|
|
192
|
+
return this.child;
|
|
193
|
+
};
|
|
194
|
+
LNode.prototype.getOwner = function() {
|
|
195
|
+
return this.owner;
|
|
196
|
+
};
|
|
197
|
+
LNode.prototype.getWidth = function() {
|
|
198
|
+
return this.rect.width;
|
|
199
|
+
};
|
|
200
|
+
LNode.prototype.setWidth = function(width) {
|
|
201
|
+
this.rect.width = width;
|
|
202
|
+
};
|
|
203
|
+
LNode.prototype.getHeight = function() {
|
|
204
|
+
return this.rect.height;
|
|
205
|
+
};
|
|
206
|
+
LNode.prototype.setHeight = function(height) {
|
|
207
|
+
this.rect.height = height;
|
|
208
|
+
};
|
|
209
|
+
LNode.prototype.getCenterX = function() {
|
|
210
|
+
return this.rect.x + this.rect.width / 2;
|
|
211
|
+
};
|
|
212
|
+
LNode.prototype.getCenterY = function() {
|
|
213
|
+
return this.rect.y + this.rect.height / 2;
|
|
214
|
+
};
|
|
215
|
+
LNode.prototype.getCenter = function() {
|
|
216
|
+
return new PointD(this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2);
|
|
217
|
+
};
|
|
218
|
+
LNode.prototype.getLocation = function() {
|
|
219
|
+
return new PointD(this.rect.x, this.rect.y);
|
|
220
|
+
};
|
|
221
|
+
LNode.prototype.getRect = function() {
|
|
222
|
+
return this.rect;
|
|
223
|
+
};
|
|
224
|
+
LNode.prototype.getDiagonal = function() {
|
|
225
|
+
return Math.sqrt(this.rect.width * this.rect.width + this.rect.height * this.rect.height);
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* This method returns half the diagonal length of this node.
|
|
229
|
+
*/
|
|
230
|
+
LNode.prototype.getHalfTheDiagonal = function() {
|
|
231
|
+
return Math.sqrt(this.rect.height * this.rect.height + this.rect.width * this.rect.width) / 2;
|
|
232
|
+
};
|
|
233
|
+
LNode.prototype.setRect = function(upperLeft, dimension) {
|
|
234
|
+
this.rect.x = upperLeft.x;
|
|
235
|
+
this.rect.y = upperLeft.y;
|
|
236
|
+
this.rect.width = dimension.width;
|
|
237
|
+
this.rect.height = dimension.height;
|
|
238
|
+
};
|
|
239
|
+
LNode.prototype.setCenter = function(cx, cy) {
|
|
240
|
+
this.rect.x = cx - this.rect.width / 2;
|
|
241
|
+
this.rect.y = cy - this.rect.height / 2;
|
|
242
|
+
};
|
|
243
|
+
LNode.prototype.setLocation = function(x, y) {
|
|
244
|
+
this.rect.x = x;
|
|
245
|
+
this.rect.y = y;
|
|
246
|
+
};
|
|
247
|
+
LNode.prototype.moveBy = function(dx, dy) {
|
|
248
|
+
this.rect.x += dx;
|
|
249
|
+
this.rect.y += dy;
|
|
250
|
+
};
|
|
251
|
+
LNode.prototype.getEdgeListToNode = function(to) {
|
|
252
|
+
var edgeList = [];
|
|
253
|
+
var self = this;
|
|
254
|
+
self.edges.forEach(function(edge) {
|
|
255
|
+
if (edge.target == to) {
|
|
256
|
+
if (edge.source != self) throw "Incorrect edge source!";
|
|
257
|
+
edgeList.push(edge);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
return edgeList;
|
|
261
|
+
};
|
|
262
|
+
LNode.prototype.getEdgesBetween = function(other) {
|
|
263
|
+
var edgeList = [];
|
|
264
|
+
var self = this;
|
|
265
|
+
self.edges.forEach(function(edge) {
|
|
266
|
+
if (!(edge.source == self || edge.target == self)) throw "Incorrect edge source and/or target";
|
|
267
|
+
if (edge.target == other || edge.source == other) edgeList.push(edge);
|
|
268
|
+
});
|
|
269
|
+
return edgeList;
|
|
270
|
+
};
|
|
271
|
+
LNode.prototype.getNeighborsList = function() {
|
|
272
|
+
var neighbors = /* @__PURE__ */ new Set();
|
|
273
|
+
var self = this;
|
|
274
|
+
self.edges.forEach(function(edge) {
|
|
275
|
+
if (edge.source == self) neighbors.add(edge.target);
|
|
276
|
+
else {
|
|
277
|
+
if (edge.target != self) throw "Incorrect incidency!";
|
|
278
|
+
neighbors.add(edge.source);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
return neighbors;
|
|
282
|
+
};
|
|
283
|
+
LNode.prototype.withChildren = function() {
|
|
284
|
+
var withNeighborsList = /* @__PURE__ */ new Set();
|
|
285
|
+
var childNode;
|
|
286
|
+
var children;
|
|
287
|
+
withNeighborsList.add(this);
|
|
288
|
+
if (this.child != null) {
|
|
289
|
+
var nodes = this.child.getNodes();
|
|
290
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
291
|
+
childNode = nodes[i];
|
|
292
|
+
children = childNode.withChildren();
|
|
293
|
+
children.forEach(function(node) {
|
|
294
|
+
withNeighborsList.add(node);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return withNeighborsList;
|
|
299
|
+
};
|
|
300
|
+
LNode.prototype.getNoOfChildren = function() {
|
|
301
|
+
var noOfChildren = 0;
|
|
302
|
+
var childNode;
|
|
303
|
+
if (this.child == null) noOfChildren = 1;
|
|
304
|
+
else {
|
|
305
|
+
var nodes = this.child.getNodes();
|
|
306
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
307
|
+
childNode = nodes[i];
|
|
308
|
+
noOfChildren += childNode.getNoOfChildren();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (noOfChildren == 0) noOfChildren = 1;
|
|
312
|
+
return noOfChildren;
|
|
313
|
+
};
|
|
314
|
+
LNode.prototype.getEstimatedSize = function() {
|
|
315
|
+
if (this.estimatedSize == Integer.MIN_VALUE) throw "assert failed";
|
|
316
|
+
return this.estimatedSize;
|
|
317
|
+
};
|
|
318
|
+
LNode.prototype.calcEstimatedSize = function() {
|
|
319
|
+
if (this.child == null) return this.estimatedSize = (this.rect.width + this.rect.height) / 2;
|
|
320
|
+
else {
|
|
321
|
+
this.estimatedSize = this.child.calcEstimatedSize();
|
|
322
|
+
this.rect.width = this.estimatedSize;
|
|
323
|
+
this.rect.height = this.estimatedSize;
|
|
324
|
+
return this.estimatedSize;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
LNode.prototype.scatter = function() {
|
|
328
|
+
var randomCenterX;
|
|
329
|
+
var randomCenterY;
|
|
330
|
+
var minX = -LayoutConstants.INITIAL_WORLD_BOUNDARY;
|
|
331
|
+
var maxX = LayoutConstants.INITIAL_WORLD_BOUNDARY;
|
|
332
|
+
randomCenterX = LayoutConstants.WORLD_CENTER_X + RandomSeed.nextDouble() * (maxX - minX) + minX;
|
|
333
|
+
var minY = -LayoutConstants.INITIAL_WORLD_BOUNDARY;
|
|
334
|
+
var maxY = LayoutConstants.INITIAL_WORLD_BOUNDARY;
|
|
335
|
+
randomCenterY = LayoutConstants.WORLD_CENTER_Y + RandomSeed.nextDouble() * (maxY - minY) + minY;
|
|
336
|
+
this.rect.x = randomCenterX;
|
|
337
|
+
this.rect.y = randomCenterY;
|
|
338
|
+
};
|
|
339
|
+
LNode.prototype.updateBounds = function() {
|
|
340
|
+
if (this.getChild() == null) throw "assert failed";
|
|
341
|
+
if (this.getChild().getNodes().length != 0) {
|
|
342
|
+
var childGraph = this.getChild();
|
|
343
|
+
childGraph.updateBounds(true);
|
|
344
|
+
this.rect.x = childGraph.getLeft();
|
|
345
|
+
this.rect.y = childGraph.getTop();
|
|
346
|
+
this.setWidth(childGraph.getRight() - childGraph.getLeft());
|
|
347
|
+
this.setHeight(childGraph.getBottom() - childGraph.getTop());
|
|
348
|
+
if (LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS) {
|
|
349
|
+
var width = childGraph.getRight() - childGraph.getLeft();
|
|
350
|
+
var height = childGraph.getBottom() - childGraph.getTop();
|
|
351
|
+
if (this.labelWidth > width) {
|
|
352
|
+
this.rect.x -= (this.labelWidth - width) / 2;
|
|
353
|
+
this.setWidth(this.labelWidth);
|
|
354
|
+
}
|
|
355
|
+
if (this.labelHeight > height) {
|
|
356
|
+
if (this.labelPos == "center") this.rect.y -= (this.labelHeight - height) / 2;
|
|
357
|
+
else if (this.labelPos == "top") this.rect.y -= this.labelHeight - height;
|
|
358
|
+
this.setHeight(this.labelHeight);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
LNode.prototype.getInclusionTreeDepth = function() {
|
|
364
|
+
if (this.inclusionTreeDepth == Integer.MAX_VALUE) throw "assert failed";
|
|
365
|
+
return this.inclusionTreeDepth;
|
|
366
|
+
};
|
|
367
|
+
LNode.prototype.transform = function(trans) {
|
|
368
|
+
var left = this.rect.x;
|
|
369
|
+
if (left > LayoutConstants.WORLD_BOUNDARY) left = LayoutConstants.WORLD_BOUNDARY;
|
|
370
|
+
else if (left < -LayoutConstants.WORLD_BOUNDARY) left = -LayoutConstants.WORLD_BOUNDARY;
|
|
371
|
+
var top = this.rect.y;
|
|
372
|
+
if (top > LayoutConstants.WORLD_BOUNDARY) top = LayoutConstants.WORLD_BOUNDARY;
|
|
373
|
+
else if (top < -LayoutConstants.WORLD_BOUNDARY) top = -LayoutConstants.WORLD_BOUNDARY;
|
|
374
|
+
var leftTop = new PointD(left, top);
|
|
375
|
+
var vLeftTop = trans.inverseTransformPoint(leftTop);
|
|
376
|
+
this.setLocation(vLeftTop.x, vLeftTop.y);
|
|
377
|
+
};
|
|
378
|
+
LNode.prototype.getLeft = function() {
|
|
379
|
+
return this.rect.x;
|
|
380
|
+
};
|
|
381
|
+
LNode.prototype.getRight = function() {
|
|
382
|
+
return this.rect.x + this.rect.width;
|
|
383
|
+
};
|
|
384
|
+
LNode.prototype.getTop = function() {
|
|
385
|
+
return this.rect.y;
|
|
386
|
+
};
|
|
387
|
+
LNode.prototype.getBottom = function() {
|
|
388
|
+
return this.rect.y + this.rect.height;
|
|
389
|
+
};
|
|
390
|
+
LNode.prototype.getParent = function() {
|
|
391
|
+
if (this.owner == null) return null;
|
|
392
|
+
return this.owner.getParent();
|
|
393
|
+
};
|
|
394
|
+
module$20.exports = LNode;
|
|
395
|
+
}),
|
|
396
|
+
(function(module$21, exports$18, __webpack_require__) {
|
|
397
|
+
"use strict";
|
|
398
|
+
function PointD(x, y) {
|
|
399
|
+
if (x == null && y == null) {
|
|
400
|
+
this.x = 0;
|
|
401
|
+
this.y = 0;
|
|
402
|
+
} else {
|
|
403
|
+
this.x = x;
|
|
404
|
+
this.y = y;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
PointD.prototype.getX = function() {
|
|
408
|
+
return this.x;
|
|
409
|
+
};
|
|
410
|
+
PointD.prototype.getY = function() {
|
|
411
|
+
return this.y;
|
|
412
|
+
};
|
|
413
|
+
PointD.prototype.setX = function(x) {
|
|
414
|
+
this.x = x;
|
|
415
|
+
};
|
|
416
|
+
PointD.prototype.setY = function(y) {
|
|
417
|
+
this.y = y;
|
|
418
|
+
};
|
|
419
|
+
PointD.prototype.getDifference = function(pt) {
|
|
420
|
+
return new DimensionD(this.x - pt.x, this.y - pt.y);
|
|
421
|
+
};
|
|
422
|
+
PointD.prototype.getCopy = function() {
|
|
423
|
+
return new PointD(this.x, this.y);
|
|
424
|
+
};
|
|
425
|
+
PointD.prototype.translate = function(dim) {
|
|
426
|
+
this.x += dim.width;
|
|
427
|
+
this.y += dim.height;
|
|
428
|
+
return this;
|
|
429
|
+
};
|
|
430
|
+
module$21.exports = PointD;
|
|
431
|
+
}),
|
|
432
|
+
(function(module$22, exports$19, __webpack_require__) {
|
|
433
|
+
"use strict";
|
|
434
|
+
var LGraphObject = __webpack_require__(2);
|
|
435
|
+
var Integer = __webpack_require__(10);
|
|
436
|
+
var LayoutConstants = __webpack_require__(0);
|
|
437
|
+
var LGraphManager = __webpack_require__(6);
|
|
438
|
+
var LNode = __webpack_require__(3);
|
|
439
|
+
var LEdge = __webpack_require__(1);
|
|
440
|
+
var RectangleD = __webpack_require__(13);
|
|
441
|
+
var Point = __webpack_require__(12);
|
|
442
|
+
var LinkedList = __webpack_require__(11);
|
|
443
|
+
function LGraph(parent, obj2, vGraph) {
|
|
444
|
+
LGraphObject.call(this, vGraph);
|
|
445
|
+
this.estimatedSize = Integer.MIN_VALUE;
|
|
446
|
+
this.margin = LayoutConstants.DEFAULT_GRAPH_MARGIN;
|
|
447
|
+
this.edges = [];
|
|
448
|
+
this.nodes = [];
|
|
449
|
+
this.isConnected = false;
|
|
450
|
+
this.parent = parent;
|
|
451
|
+
if (obj2 != null && obj2 instanceof LGraphManager) this.graphManager = obj2;
|
|
452
|
+
else if (obj2 != null && obj2 instanceof Layout) this.graphManager = obj2.graphManager;
|
|
453
|
+
}
|
|
454
|
+
LGraph.prototype = Object.create(LGraphObject.prototype);
|
|
455
|
+
for (var prop in LGraphObject) LGraph[prop] = LGraphObject[prop];
|
|
456
|
+
LGraph.prototype.getNodes = function() {
|
|
457
|
+
return this.nodes;
|
|
458
|
+
};
|
|
459
|
+
LGraph.prototype.getEdges = function() {
|
|
460
|
+
return this.edges;
|
|
461
|
+
};
|
|
462
|
+
LGraph.prototype.getGraphManager = function() {
|
|
463
|
+
return this.graphManager;
|
|
464
|
+
};
|
|
465
|
+
LGraph.prototype.getParent = function() {
|
|
466
|
+
return this.parent;
|
|
467
|
+
};
|
|
468
|
+
LGraph.prototype.getLeft = function() {
|
|
469
|
+
return this.left;
|
|
470
|
+
};
|
|
471
|
+
LGraph.prototype.getRight = function() {
|
|
472
|
+
return this.right;
|
|
473
|
+
};
|
|
474
|
+
LGraph.prototype.getTop = function() {
|
|
475
|
+
return this.top;
|
|
476
|
+
};
|
|
477
|
+
LGraph.prototype.getBottom = function() {
|
|
478
|
+
return this.bottom;
|
|
479
|
+
};
|
|
480
|
+
LGraph.prototype.isConnected = function() {
|
|
481
|
+
return this.isConnected;
|
|
482
|
+
};
|
|
483
|
+
LGraph.prototype.add = function(obj1, sourceNode, targetNode) {
|
|
484
|
+
if (sourceNode == null && targetNode == null) {
|
|
485
|
+
var newNode = obj1;
|
|
486
|
+
if (this.graphManager == null) throw "Graph has no graph mgr!";
|
|
487
|
+
if (this.getNodes().indexOf(newNode) > -1) throw "Node already in graph!";
|
|
488
|
+
newNode.owner = this;
|
|
489
|
+
this.getNodes().push(newNode);
|
|
490
|
+
return newNode;
|
|
491
|
+
} else {
|
|
492
|
+
var newEdge = obj1;
|
|
493
|
+
if (!(this.getNodes().indexOf(sourceNode) > -1 && this.getNodes().indexOf(targetNode) > -1)) throw "Source or target not in graph!";
|
|
494
|
+
if (!(sourceNode.owner == targetNode.owner && sourceNode.owner == this)) throw "Both owners must be this graph!";
|
|
495
|
+
if (sourceNode.owner != targetNode.owner) return null;
|
|
496
|
+
newEdge.source = sourceNode;
|
|
497
|
+
newEdge.target = targetNode;
|
|
498
|
+
newEdge.isInterGraph = false;
|
|
499
|
+
this.getEdges().push(newEdge);
|
|
500
|
+
sourceNode.edges.push(newEdge);
|
|
501
|
+
if (targetNode != sourceNode) targetNode.edges.push(newEdge);
|
|
502
|
+
return newEdge;
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
LGraph.prototype.remove = function(obj) {
|
|
506
|
+
var node = obj;
|
|
507
|
+
if (obj instanceof LNode) {
|
|
508
|
+
if (node == null) throw "Node is null!";
|
|
509
|
+
if (!(node.owner != null && node.owner == this)) throw "Owner graph is invalid!";
|
|
510
|
+
if (this.graphManager == null) throw "Owner graph manager is invalid!";
|
|
511
|
+
var edgesToBeRemoved = node.edges.slice();
|
|
512
|
+
var edge;
|
|
513
|
+
var s = edgesToBeRemoved.length;
|
|
514
|
+
for (var i = 0; i < s; i++) {
|
|
515
|
+
edge = edgesToBeRemoved[i];
|
|
516
|
+
if (edge.isInterGraph) this.graphManager.remove(edge);
|
|
517
|
+
else edge.source.owner.remove(edge);
|
|
518
|
+
}
|
|
519
|
+
var index = this.nodes.indexOf(node);
|
|
520
|
+
if (index == -1) throw "Node not in owner node list!";
|
|
521
|
+
this.nodes.splice(index, 1);
|
|
522
|
+
} else if (obj instanceof LEdge) {
|
|
523
|
+
var edge = obj;
|
|
524
|
+
if (edge == null) throw "Edge is null!";
|
|
525
|
+
if (!(edge.source != null && edge.target != null)) throw "Source and/or target is null!";
|
|
526
|
+
if (!(edge.source.owner != null && edge.target.owner != null && edge.source.owner == this && edge.target.owner == this)) throw "Source and/or target owner is invalid!";
|
|
527
|
+
var sourceIndex = edge.source.edges.indexOf(edge);
|
|
528
|
+
var targetIndex = edge.target.edges.indexOf(edge);
|
|
529
|
+
if (!(sourceIndex > -1 && targetIndex > -1)) throw "Source and/or target doesn't know this edge!";
|
|
530
|
+
edge.source.edges.splice(sourceIndex, 1);
|
|
531
|
+
if (edge.target != edge.source) edge.target.edges.splice(targetIndex, 1);
|
|
532
|
+
var index = edge.source.owner.getEdges().indexOf(edge);
|
|
533
|
+
if (index == -1) throw "Not in owner's edge list!";
|
|
534
|
+
edge.source.owner.getEdges().splice(index, 1);
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
LGraph.prototype.updateLeftTop = function() {
|
|
538
|
+
var top = Integer.MAX_VALUE;
|
|
539
|
+
var left = Integer.MAX_VALUE;
|
|
540
|
+
var nodeTop;
|
|
541
|
+
var nodeLeft;
|
|
542
|
+
var margin;
|
|
543
|
+
var nodes = this.getNodes();
|
|
544
|
+
var s = nodes.length;
|
|
545
|
+
for (var i = 0; i < s; i++) {
|
|
546
|
+
var lNode = nodes[i];
|
|
547
|
+
nodeTop = lNode.getTop();
|
|
548
|
+
nodeLeft = lNode.getLeft();
|
|
549
|
+
if (top > nodeTop) top = nodeTop;
|
|
550
|
+
if (left > nodeLeft) left = nodeLeft;
|
|
551
|
+
}
|
|
552
|
+
if (top == Integer.MAX_VALUE) return null;
|
|
553
|
+
if (nodes[0].getParent().paddingLeft != void 0) margin = nodes[0].getParent().paddingLeft;
|
|
554
|
+
else margin = this.margin;
|
|
555
|
+
this.left = left - margin;
|
|
556
|
+
this.top = top - margin;
|
|
557
|
+
return new Point(this.left, this.top);
|
|
558
|
+
};
|
|
559
|
+
LGraph.prototype.updateBounds = function(recursive) {
|
|
560
|
+
var left = Integer.MAX_VALUE;
|
|
561
|
+
var right = -Integer.MAX_VALUE;
|
|
562
|
+
var top = Integer.MAX_VALUE;
|
|
563
|
+
var bottom = -Integer.MAX_VALUE;
|
|
564
|
+
var nodeLeft;
|
|
565
|
+
var nodeRight;
|
|
566
|
+
var nodeTop;
|
|
567
|
+
var nodeBottom;
|
|
568
|
+
var margin;
|
|
569
|
+
var nodes = this.nodes;
|
|
570
|
+
var s = nodes.length;
|
|
571
|
+
for (var i = 0; i < s; i++) {
|
|
572
|
+
var lNode = nodes[i];
|
|
573
|
+
if (recursive && lNode.child != null) lNode.updateBounds();
|
|
574
|
+
nodeLeft = lNode.getLeft();
|
|
575
|
+
nodeRight = lNode.getRight();
|
|
576
|
+
nodeTop = lNode.getTop();
|
|
577
|
+
nodeBottom = lNode.getBottom();
|
|
578
|
+
if (left > nodeLeft) left = nodeLeft;
|
|
579
|
+
if (right < nodeRight) right = nodeRight;
|
|
580
|
+
if (top > nodeTop) top = nodeTop;
|
|
581
|
+
if (bottom < nodeBottom) bottom = nodeBottom;
|
|
582
|
+
}
|
|
583
|
+
var boundingRect = new RectangleD(left, top, right - left, bottom - top);
|
|
584
|
+
if (left == Integer.MAX_VALUE) {
|
|
585
|
+
this.left = this.parent.getLeft();
|
|
586
|
+
this.right = this.parent.getRight();
|
|
587
|
+
this.top = this.parent.getTop();
|
|
588
|
+
this.bottom = this.parent.getBottom();
|
|
589
|
+
}
|
|
590
|
+
if (nodes[0].getParent().paddingLeft != void 0) margin = nodes[0].getParent().paddingLeft;
|
|
591
|
+
else margin = this.margin;
|
|
592
|
+
this.left = boundingRect.x - margin;
|
|
593
|
+
this.right = boundingRect.x + boundingRect.width + margin;
|
|
594
|
+
this.top = boundingRect.y - margin;
|
|
595
|
+
this.bottom = boundingRect.y + boundingRect.height + margin;
|
|
596
|
+
};
|
|
597
|
+
LGraph.calculateBounds = function(nodes) {
|
|
598
|
+
var left = Integer.MAX_VALUE;
|
|
599
|
+
var right = -Integer.MAX_VALUE;
|
|
600
|
+
var top = Integer.MAX_VALUE;
|
|
601
|
+
var bottom = -Integer.MAX_VALUE;
|
|
602
|
+
var nodeLeft;
|
|
603
|
+
var nodeRight;
|
|
604
|
+
var nodeTop;
|
|
605
|
+
var nodeBottom;
|
|
606
|
+
var s = nodes.length;
|
|
607
|
+
for (var i = 0; i < s; i++) {
|
|
608
|
+
var lNode = nodes[i];
|
|
609
|
+
nodeLeft = lNode.getLeft();
|
|
610
|
+
nodeRight = lNode.getRight();
|
|
611
|
+
nodeTop = lNode.getTop();
|
|
612
|
+
nodeBottom = lNode.getBottom();
|
|
613
|
+
if (left > nodeLeft) left = nodeLeft;
|
|
614
|
+
if (right < nodeRight) right = nodeRight;
|
|
615
|
+
if (top > nodeTop) top = nodeTop;
|
|
616
|
+
if (bottom < nodeBottom) bottom = nodeBottom;
|
|
617
|
+
}
|
|
618
|
+
return new RectangleD(left, top, right - left, bottom - top);
|
|
619
|
+
};
|
|
620
|
+
LGraph.prototype.getInclusionTreeDepth = function() {
|
|
621
|
+
if (this == this.graphManager.getRoot()) return 1;
|
|
622
|
+
else return this.parent.getInclusionTreeDepth();
|
|
623
|
+
};
|
|
624
|
+
LGraph.prototype.getEstimatedSize = function() {
|
|
625
|
+
if (this.estimatedSize == Integer.MIN_VALUE) throw "assert failed";
|
|
626
|
+
return this.estimatedSize;
|
|
627
|
+
};
|
|
628
|
+
LGraph.prototype.calcEstimatedSize = function() {
|
|
629
|
+
var size = 0;
|
|
630
|
+
var nodes = this.nodes;
|
|
631
|
+
var s = nodes.length;
|
|
632
|
+
for (var i = 0; i < s; i++) {
|
|
633
|
+
var lNode = nodes[i];
|
|
634
|
+
size += lNode.calcEstimatedSize();
|
|
635
|
+
}
|
|
636
|
+
if (size == 0) this.estimatedSize = LayoutConstants.EMPTY_COMPOUND_NODE_SIZE;
|
|
637
|
+
else this.estimatedSize = size / Math.sqrt(this.nodes.length);
|
|
638
|
+
return this.estimatedSize;
|
|
639
|
+
};
|
|
640
|
+
LGraph.prototype.updateConnected = function() {
|
|
641
|
+
var self = this;
|
|
642
|
+
if (this.nodes.length == 0) {
|
|
643
|
+
this.isConnected = true;
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
var queue = new LinkedList();
|
|
647
|
+
var visited = /* @__PURE__ */ new Set();
|
|
648
|
+
var currentNode = this.nodes[0];
|
|
649
|
+
var neighborEdges;
|
|
650
|
+
var currentNeighbor;
|
|
651
|
+
currentNode.withChildren().forEach(function(node) {
|
|
652
|
+
queue.push(node);
|
|
653
|
+
visited.add(node);
|
|
654
|
+
});
|
|
655
|
+
while (queue.length !== 0) {
|
|
656
|
+
currentNode = queue.shift();
|
|
657
|
+
neighborEdges = currentNode.getEdges();
|
|
658
|
+
var size = neighborEdges.length;
|
|
659
|
+
for (var i = 0; i < size; i++) {
|
|
660
|
+
currentNeighbor = neighborEdges[i].getOtherEndInGraph(currentNode, this);
|
|
661
|
+
if (currentNeighbor != null && !visited.has(currentNeighbor)) currentNeighbor.withChildren().forEach(function(node) {
|
|
662
|
+
queue.push(node);
|
|
663
|
+
visited.add(node);
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
this.isConnected = false;
|
|
668
|
+
if (visited.size >= this.nodes.length) {
|
|
669
|
+
var noOfVisitedInThisGraph = 0;
|
|
670
|
+
visited.forEach(function(visitedNode) {
|
|
671
|
+
if (visitedNode.owner == self) noOfVisitedInThisGraph++;
|
|
672
|
+
});
|
|
673
|
+
if (noOfVisitedInThisGraph == this.nodes.length) this.isConnected = true;
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
module$22.exports = LGraph;
|
|
677
|
+
}),
|
|
678
|
+
(function(module$23, exports$20, __webpack_require__) {
|
|
679
|
+
"use strict";
|
|
680
|
+
var LGraph;
|
|
681
|
+
var LEdge = __webpack_require__(1);
|
|
682
|
+
function LGraphManager(layout) {
|
|
683
|
+
LGraph = __webpack_require__(5);
|
|
684
|
+
this.layout = layout;
|
|
685
|
+
this.graphs = [];
|
|
686
|
+
this.edges = [];
|
|
687
|
+
}
|
|
688
|
+
LGraphManager.prototype.addRoot = function() {
|
|
689
|
+
var ngraph = this.layout.newGraph();
|
|
690
|
+
var nnode = this.layout.newNode(null);
|
|
691
|
+
var root = this.add(ngraph, nnode);
|
|
692
|
+
this.setRootGraph(root);
|
|
693
|
+
return this.rootGraph;
|
|
694
|
+
};
|
|
695
|
+
LGraphManager.prototype.add = function(newGraph, parentNode, newEdge, sourceNode, targetNode) {
|
|
696
|
+
if (newEdge == null && sourceNode == null && targetNode == null) {
|
|
697
|
+
if (newGraph == null) throw "Graph is null!";
|
|
698
|
+
if (parentNode == null) throw "Parent node is null!";
|
|
699
|
+
if (this.graphs.indexOf(newGraph) > -1) throw "Graph already in this graph mgr!";
|
|
700
|
+
this.graphs.push(newGraph);
|
|
701
|
+
if (newGraph.parent != null) throw "Already has a parent!";
|
|
702
|
+
if (parentNode.child != null) throw "Already has a child!";
|
|
703
|
+
newGraph.parent = parentNode;
|
|
704
|
+
parentNode.child = newGraph;
|
|
705
|
+
return newGraph;
|
|
706
|
+
} else {
|
|
707
|
+
targetNode = newEdge;
|
|
708
|
+
sourceNode = parentNode;
|
|
709
|
+
newEdge = newGraph;
|
|
710
|
+
var sourceGraph = sourceNode.getOwner();
|
|
711
|
+
var targetGraph = targetNode.getOwner();
|
|
712
|
+
if (!(sourceGraph != null && sourceGraph.getGraphManager() == this)) throw "Source not in this graph mgr!";
|
|
713
|
+
if (!(targetGraph != null && targetGraph.getGraphManager() == this)) throw "Target not in this graph mgr!";
|
|
714
|
+
if (sourceGraph == targetGraph) {
|
|
715
|
+
newEdge.isInterGraph = false;
|
|
716
|
+
return sourceGraph.add(newEdge, sourceNode, targetNode);
|
|
717
|
+
} else {
|
|
718
|
+
newEdge.isInterGraph = true;
|
|
719
|
+
newEdge.source = sourceNode;
|
|
720
|
+
newEdge.target = targetNode;
|
|
721
|
+
if (this.edges.indexOf(newEdge) > -1) throw "Edge already in inter-graph edge list!";
|
|
722
|
+
this.edges.push(newEdge);
|
|
723
|
+
if (!(newEdge.source != null && newEdge.target != null)) throw "Edge source and/or target is null!";
|
|
724
|
+
if (!(newEdge.source.edges.indexOf(newEdge) == -1 && newEdge.target.edges.indexOf(newEdge) == -1)) throw "Edge already in source and/or target incidency list!";
|
|
725
|
+
newEdge.source.edges.push(newEdge);
|
|
726
|
+
newEdge.target.edges.push(newEdge);
|
|
727
|
+
return newEdge;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
LGraphManager.prototype.remove = function(lObj) {
|
|
732
|
+
if (lObj instanceof LGraph) {
|
|
733
|
+
var graph = lObj;
|
|
734
|
+
if (graph.getGraphManager() != this) throw "Graph not in this graph mgr";
|
|
735
|
+
if (!(graph == this.rootGraph || graph.parent != null && graph.parent.graphManager == this)) throw "Invalid parent node!";
|
|
736
|
+
var edgesToBeRemoved = [];
|
|
737
|
+
edgesToBeRemoved = edgesToBeRemoved.concat(graph.getEdges());
|
|
738
|
+
var edge;
|
|
739
|
+
var s = edgesToBeRemoved.length;
|
|
740
|
+
for (var i = 0; i < s; i++) {
|
|
741
|
+
edge = edgesToBeRemoved[i];
|
|
742
|
+
graph.remove(edge);
|
|
743
|
+
}
|
|
744
|
+
var nodesToBeRemoved = [];
|
|
745
|
+
nodesToBeRemoved = nodesToBeRemoved.concat(graph.getNodes());
|
|
746
|
+
var node;
|
|
747
|
+
s = nodesToBeRemoved.length;
|
|
748
|
+
for (var i = 0; i < s; i++) {
|
|
749
|
+
node = nodesToBeRemoved[i];
|
|
750
|
+
graph.remove(node);
|
|
751
|
+
}
|
|
752
|
+
if (graph == this.rootGraph) this.setRootGraph(null);
|
|
753
|
+
var index = this.graphs.indexOf(graph);
|
|
754
|
+
this.graphs.splice(index, 1);
|
|
755
|
+
graph.parent = null;
|
|
756
|
+
} else if (lObj instanceof LEdge) {
|
|
757
|
+
edge = lObj;
|
|
758
|
+
if (edge == null) throw "Edge is null!";
|
|
759
|
+
if (!edge.isInterGraph) throw "Not an inter-graph edge!";
|
|
760
|
+
if (!(edge.source != null && edge.target != null)) throw "Source and/or target is null!";
|
|
761
|
+
if (!(edge.source.edges.indexOf(edge) != -1 && edge.target.edges.indexOf(edge) != -1)) throw "Source and/or target doesn't know this edge!";
|
|
762
|
+
var index = edge.source.edges.indexOf(edge);
|
|
763
|
+
edge.source.edges.splice(index, 1);
|
|
764
|
+
index = edge.target.edges.indexOf(edge);
|
|
765
|
+
edge.target.edges.splice(index, 1);
|
|
766
|
+
if (!(edge.source.owner != null && edge.source.owner.getGraphManager() != null)) throw "Edge owner graph or owner graph manager is null!";
|
|
767
|
+
if (edge.source.owner.getGraphManager().edges.indexOf(edge) == -1) throw "Not in owner graph manager's edge list!";
|
|
768
|
+
var index = edge.source.owner.getGraphManager().edges.indexOf(edge);
|
|
769
|
+
edge.source.owner.getGraphManager().edges.splice(index, 1);
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
LGraphManager.prototype.updateBounds = function() {
|
|
773
|
+
this.rootGraph.updateBounds(true);
|
|
774
|
+
};
|
|
775
|
+
LGraphManager.prototype.getGraphs = function() {
|
|
776
|
+
return this.graphs;
|
|
777
|
+
};
|
|
778
|
+
LGraphManager.prototype.getAllNodes = function() {
|
|
779
|
+
if (this.allNodes == null) {
|
|
780
|
+
var nodeList = [];
|
|
781
|
+
var graphs = this.getGraphs();
|
|
782
|
+
var s = graphs.length;
|
|
783
|
+
for (var i = 0; i < s; i++) nodeList = nodeList.concat(graphs[i].getNodes());
|
|
784
|
+
this.allNodes = nodeList;
|
|
785
|
+
}
|
|
786
|
+
return this.allNodes;
|
|
787
|
+
};
|
|
788
|
+
LGraphManager.prototype.resetAllNodes = function() {
|
|
789
|
+
this.allNodes = null;
|
|
790
|
+
};
|
|
791
|
+
LGraphManager.prototype.resetAllEdges = function() {
|
|
792
|
+
this.allEdges = null;
|
|
793
|
+
};
|
|
794
|
+
LGraphManager.prototype.resetAllNodesToApplyGravitation = function() {
|
|
795
|
+
this.allNodesToApplyGravitation = null;
|
|
796
|
+
};
|
|
797
|
+
LGraphManager.prototype.getAllEdges = function() {
|
|
798
|
+
if (this.allEdges == null) {
|
|
799
|
+
var edgeList = [];
|
|
800
|
+
var graphs = this.getGraphs();
|
|
801
|
+
graphs.length;
|
|
802
|
+
for (var i = 0; i < graphs.length; i++) edgeList = edgeList.concat(graphs[i].getEdges());
|
|
803
|
+
edgeList = edgeList.concat(this.edges);
|
|
804
|
+
this.allEdges = edgeList;
|
|
805
|
+
}
|
|
806
|
+
return this.allEdges;
|
|
807
|
+
};
|
|
808
|
+
LGraphManager.prototype.getAllNodesToApplyGravitation = function() {
|
|
809
|
+
return this.allNodesToApplyGravitation;
|
|
810
|
+
};
|
|
811
|
+
LGraphManager.prototype.setAllNodesToApplyGravitation = function(nodeList) {
|
|
812
|
+
if (this.allNodesToApplyGravitation != null) throw "assert failed";
|
|
813
|
+
this.allNodesToApplyGravitation = nodeList;
|
|
814
|
+
};
|
|
815
|
+
LGraphManager.prototype.getRoot = function() {
|
|
816
|
+
return this.rootGraph;
|
|
817
|
+
};
|
|
818
|
+
LGraphManager.prototype.setRootGraph = function(graph) {
|
|
819
|
+
if (graph.getGraphManager() != this) throw "Root not in this graph mgr!";
|
|
820
|
+
this.rootGraph = graph;
|
|
821
|
+
if (graph.parent == null) graph.parent = this.layout.newNode("Root node");
|
|
822
|
+
};
|
|
823
|
+
LGraphManager.prototype.getLayout = function() {
|
|
824
|
+
return this.layout;
|
|
825
|
+
};
|
|
826
|
+
LGraphManager.prototype.isOneAncestorOfOther = function(firstNode, secondNode) {
|
|
827
|
+
if (!(firstNode != null && secondNode != null)) throw "assert failed";
|
|
828
|
+
if (firstNode == secondNode) return true;
|
|
829
|
+
var ownerGraph = firstNode.getOwner();
|
|
830
|
+
var parentNode;
|
|
831
|
+
do {
|
|
832
|
+
parentNode = ownerGraph.getParent();
|
|
833
|
+
if (parentNode == null) break;
|
|
834
|
+
if (parentNode == secondNode) return true;
|
|
835
|
+
ownerGraph = parentNode.getOwner();
|
|
836
|
+
if (ownerGraph == null) break;
|
|
837
|
+
} while (true);
|
|
838
|
+
ownerGraph = secondNode.getOwner();
|
|
839
|
+
do {
|
|
840
|
+
parentNode = ownerGraph.getParent();
|
|
841
|
+
if (parentNode == null) break;
|
|
842
|
+
if (parentNode == firstNode) return true;
|
|
843
|
+
ownerGraph = parentNode.getOwner();
|
|
844
|
+
if (ownerGraph == null) break;
|
|
845
|
+
} while (true);
|
|
846
|
+
return false;
|
|
847
|
+
};
|
|
848
|
+
LGraphManager.prototype.calcLowestCommonAncestors = function() {
|
|
849
|
+
var edge;
|
|
850
|
+
var sourceNode;
|
|
851
|
+
var targetNode;
|
|
852
|
+
var sourceAncestorGraph;
|
|
853
|
+
var targetAncestorGraph;
|
|
854
|
+
var edges = this.getAllEdges();
|
|
855
|
+
var s = edges.length;
|
|
856
|
+
for (var i = 0; i < s; i++) {
|
|
857
|
+
edge = edges[i];
|
|
858
|
+
sourceNode = edge.source;
|
|
859
|
+
targetNode = edge.target;
|
|
860
|
+
edge.lca = null;
|
|
861
|
+
edge.sourceInLca = sourceNode;
|
|
862
|
+
edge.targetInLca = targetNode;
|
|
863
|
+
if (sourceNode == targetNode) {
|
|
864
|
+
edge.lca = sourceNode.getOwner();
|
|
865
|
+
continue;
|
|
866
|
+
}
|
|
867
|
+
sourceAncestorGraph = sourceNode.getOwner();
|
|
868
|
+
while (edge.lca == null) {
|
|
869
|
+
edge.targetInLca = targetNode;
|
|
870
|
+
targetAncestorGraph = targetNode.getOwner();
|
|
871
|
+
while (edge.lca == null) {
|
|
872
|
+
if (targetAncestorGraph == sourceAncestorGraph) {
|
|
873
|
+
edge.lca = targetAncestorGraph;
|
|
874
|
+
break;
|
|
875
|
+
}
|
|
876
|
+
if (targetAncestorGraph == this.rootGraph) break;
|
|
877
|
+
if (edge.lca != null) throw "assert failed";
|
|
878
|
+
edge.targetInLca = targetAncestorGraph.getParent();
|
|
879
|
+
targetAncestorGraph = edge.targetInLca.getOwner();
|
|
880
|
+
}
|
|
881
|
+
if (sourceAncestorGraph == this.rootGraph) break;
|
|
882
|
+
if (edge.lca == null) {
|
|
883
|
+
edge.sourceInLca = sourceAncestorGraph.getParent();
|
|
884
|
+
sourceAncestorGraph = edge.sourceInLca.getOwner();
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
if (edge.lca == null) throw "assert failed";
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
LGraphManager.prototype.calcLowestCommonAncestor = function(firstNode, secondNode) {
|
|
891
|
+
if (firstNode == secondNode) return firstNode.getOwner();
|
|
892
|
+
var firstOwnerGraph = firstNode.getOwner();
|
|
893
|
+
do {
|
|
894
|
+
if (firstOwnerGraph == null) break;
|
|
895
|
+
var secondOwnerGraph = secondNode.getOwner();
|
|
896
|
+
do {
|
|
897
|
+
if (secondOwnerGraph == null) break;
|
|
898
|
+
if (secondOwnerGraph == firstOwnerGraph) return secondOwnerGraph;
|
|
899
|
+
secondOwnerGraph = secondOwnerGraph.getParent().getOwner();
|
|
900
|
+
} while (true);
|
|
901
|
+
firstOwnerGraph = firstOwnerGraph.getParent().getOwner();
|
|
902
|
+
} while (true);
|
|
903
|
+
return firstOwnerGraph;
|
|
904
|
+
};
|
|
905
|
+
LGraphManager.prototype.calcInclusionTreeDepths = function(graph, depth) {
|
|
906
|
+
if (graph == null && depth == null) {
|
|
907
|
+
graph = this.rootGraph;
|
|
908
|
+
depth = 1;
|
|
909
|
+
}
|
|
910
|
+
var node;
|
|
911
|
+
var nodes = graph.getNodes();
|
|
912
|
+
var s = nodes.length;
|
|
913
|
+
for (var i = 0; i < s; i++) {
|
|
914
|
+
node = nodes[i];
|
|
915
|
+
node.inclusionTreeDepth = depth;
|
|
916
|
+
if (node.child != null) this.calcInclusionTreeDepths(node.child, depth + 1);
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
LGraphManager.prototype.includesInvalidEdge = function() {
|
|
920
|
+
var edge;
|
|
921
|
+
var s = this.edges.length;
|
|
922
|
+
for (var i = 0; i < s; i++) {
|
|
923
|
+
edge = this.edges[i];
|
|
924
|
+
if (this.isOneAncestorOfOther(edge.source, edge.target)) return true;
|
|
925
|
+
}
|
|
926
|
+
return false;
|
|
927
|
+
};
|
|
928
|
+
module$23.exports = LGraphManager;
|
|
929
|
+
}),
|
|
930
|
+
(function(module$24, exports$21, __webpack_require__) {
|
|
931
|
+
"use strict";
|
|
932
|
+
var LayoutConstants = __webpack_require__(0);
|
|
933
|
+
function FDLayoutConstants() {}
|
|
934
|
+
for (var prop in LayoutConstants) FDLayoutConstants[prop] = LayoutConstants[prop];
|
|
935
|
+
FDLayoutConstants.MAX_ITERATIONS = 2500;
|
|
936
|
+
FDLayoutConstants.DEFAULT_EDGE_LENGTH = 50;
|
|
937
|
+
FDLayoutConstants.DEFAULT_SPRING_STRENGTH = .45;
|
|
938
|
+
FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = 4500;
|
|
939
|
+
FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = .4;
|
|
940
|
+
FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = 1;
|
|
941
|
+
FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = 3.8;
|
|
942
|
+
FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = 1.5;
|
|
943
|
+
FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION = true;
|
|
944
|
+
FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION = true;
|
|
945
|
+
FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = .3;
|
|
946
|
+
FDLayoutConstants.COOLING_ADAPTATION_FACTOR = .33;
|
|
947
|
+
FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT = 1e3;
|
|
948
|
+
FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT = 5e3;
|
|
949
|
+
FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL = 100;
|
|
950
|
+
FDLayoutConstants.MAX_NODE_DISPLACEMENT = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL * 3;
|
|
951
|
+
FDLayoutConstants.MIN_REPULSION_DIST = FDLayoutConstants.DEFAULT_EDGE_LENGTH / 10;
|
|
952
|
+
FDLayoutConstants.CONVERGENCE_CHECK_PERIOD = 100;
|
|
953
|
+
FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = .1;
|
|
954
|
+
FDLayoutConstants.MIN_EDGE_LENGTH = 1;
|
|
955
|
+
FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD = 10;
|
|
956
|
+
module$24.exports = FDLayoutConstants;
|
|
957
|
+
}),
|
|
958
|
+
(function(module$25, exports$22, __webpack_require__) {
|
|
959
|
+
"use strict";
|
|
960
|
+
/**
|
|
961
|
+
* This class maintains a list of static geometry related utility methods.
|
|
962
|
+
*
|
|
963
|
+
*
|
|
964
|
+
* Copyright: i-Vis Research Group, Bilkent University, 2007 - present
|
|
965
|
+
*/
|
|
966
|
+
var Point = __webpack_require__(12);
|
|
967
|
+
function IGeometry() {}
|
|
968
|
+
/**
|
|
969
|
+
* This method calculates *half* the amount in x and y directions of the two
|
|
970
|
+
* input rectangles needed to separate them keeping their respective
|
|
971
|
+
* positioning, and returns the result in the input array. An input
|
|
972
|
+
* separation buffer added to the amount in both directions. We assume that
|
|
973
|
+
* the two rectangles do intersect.
|
|
974
|
+
*/
|
|
975
|
+
IGeometry.calcSeparationAmount = function(rectA, rectB, overlapAmount, separationBuffer) {
|
|
976
|
+
if (!rectA.intersects(rectB)) throw "assert failed";
|
|
977
|
+
var directions = new Array(2);
|
|
978
|
+
this.decideDirectionsForOverlappingNodes(rectA, rectB, directions);
|
|
979
|
+
overlapAmount[0] = Math.min(rectA.getRight(), rectB.getRight()) - Math.max(rectA.x, rectB.x);
|
|
980
|
+
overlapAmount[1] = Math.min(rectA.getBottom(), rectB.getBottom()) - Math.max(rectA.y, rectB.y);
|
|
981
|
+
if (rectA.getX() <= rectB.getX() && rectA.getRight() >= rectB.getRight()) overlapAmount[0] += Math.min(rectB.getX() - rectA.getX(), rectA.getRight() - rectB.getRight());
|
|
982
|
+
else if (rectB.getX() <= rectA.getX() && rectB.getRight() >= rectA.getRight()) overlapAmount[0] += Math.min(rectA.getX() - rectB.getX(), rectB.getRight() - rectA.getRight());
|
|
983
|
+
if (rectA.getY() <= rectB.getY() && rectA.getBottom() >= rectB.getBottom()) overlapAmount[1] += Math.min(rectB.getY() - rectA.getY(), rectA.getBottom() - rectB.getBottom());
|
|
984
|
+
else if (rectB.getY() <= rectA.getY() && rectB.getBottom() >= rectA.getBottom()) overlapAmount[1] += Math.min(rectA.getY() - rectB.getY(), rectB.getBottom() - rectA.getBottom());
|
|
985
|
+
var slope = Math.abs((rectB.getCenterY() - rectA.getCenterY()) / (rectB.getCenterX() - rectA.getCenterX()));
|
|
986
|
+
if (rectB.getCenterY() === rectA.getCenterY() && rectB.getCenterX() === rectA.getCenterX()) slope = 1;
|
|
987
|
+
var moveByY = slope * overlapAmount[0];
|
|
988
|
+
var moveByX = overlapAmount[1] / slope;
|
|
989
|
+
if (overlapAmount[0] < moveByX) moveByX = overlapAmount[0];
|
|
990
|
+
else moveByY = overlapAmount[1];
|
|
991
|
+
overlapAmount[0] = -1 * directions[0] * (moveByX / 2 + separationBuffer);
|
|
992
|
+
overlapAmount[1] = -1 * directions[1] * (moveByY / 2 + separationBuffer);
|
|
993
|
+
};
|
|
994
|
+
/**
|
|
995
|
+
* This method decides the separation direction of overlapping nodes
|
|
996
|
+
*
|
|
997
|
+
* if directions[0] = -1, then rectA goes left
|
|
998
|
+
* if directions[0] = 1, then rectA goes right
|
|
999
|
+
* if directions[1] = -1, then rectA goes up
|
|
1000
|
+
* if directions[1] = 1, then rectA goes down
|
|
1001
|
+
*/
|
|
1002
|
+
IGeometry.decideDirectionsForOverlappingNodes = function(rectA, rectB, directions) {
|
|
1003
|
+
if (rectA.getCenterX() < rectB.getCenterX()) directions[0] = -1;
|
|
1004
|
+
else directions[0] = 1;
|
|
1005
|
+
if (rectA.getCenterY() < rectB.getCenterY()) directions[1] = -1;
|
|
1006
|
+
else directions[1] = 1;
|
|
1007
|
+
};
|
|
1008
|
+
/**
|
|
1009
|
+
* This method calculates the intersection (clipping) points of the two
|
|
1010
|
+
* input rectangles with line segment defined by the centers of these two
|
|
1011
|
+
* rectangles. The clipping points are saved in the input double array and
|
|
1012
|
+
* whether or not the two rectangles overlap is returned.
|
|
1013
|
+
*/
|
|
1014
|
+
IGeometry.getIntersection2 = function(rectA, rectB, result) {
|
|
1015
|
+
var p1x = rectA.getCenterX();
|
|
1016
|
+
var p1y = rectA.getCenterY();
|
|
1017
|
+
var p2x = rectB.getCenterX();
|
|
1018
|
+
var p2y = rectB.getCenterY();
|
|
1019
|
+
if (rectA.intersects(rectB)) {
|
|
1020
|
+
result[0] = p1x;
|
|
1021
|
+
result[1] = p1y;
|
|
1022
|
+
result[2] = p2x;
|
|
1023
|
+
result[3] = p2y;
|
|
1024
|
+
return true;
|
|
1025
|
+
}
|
|
1026
|
+
var topLeftAx = rectA.getX();
|
|
1027
|
+
var topLeftAy = rectA.getY();
|
|
1028
|
+
var topRightAx = rectA.getRight();
|
|
1029
|
+
var bottomLeftAx = rectA.getX();
|
|
1030
|
+
var bottomLeftAy = rectA.getBottom();
|
|
1031
|
+
var bottomRightAx = rectA.getRight();
|
|
1032
|
+
var halfWidthA = rectA.getWidthHalf();
|
|
1033
|
+
var halfHeightA = rectA.getHeightHalf();
|
|
1034
|
+
var topLeftBx = rectB.getX();
|
|
1035
|
+
var topLeftBy = rectB.getY();
|
|
1036
|
+
var topRightBx = rectB.getRight();
|
|
1037
|
+
var bottomLeftBx = rectB.getX();
|
|
1038
|
+
var bottomLeftBy = rectB.getBottom();
|
|
1039
|
+
var bottomRightBx = rectB.getRight();
|
|
1040
|
+
var halfWidthB = rectB.getWidthHalf();
|
|
1041
|
+
var halfHeightB = rectB.getHeightHalf();
|
|
1042
|
+
var clipPointAFound = false;
|
|
1043
|
+
var clipPointBFound = false;
|
|
1044
|
+
if (p1x === p2x) {
|
|
1045
|
+
if (p1y > p2y) {
|
|
1046
|
+
result[0] = p1x;
|
|
1047
|
+
result[1] = topLeftAy;
|
|
1048
|
+
result[2] = p2x;
|
|
1049
|
+
result[3] = bottomLeftBy;
|
|
1050
|
+
return false;
|
|
1051
|
+
} else if (p1y < p2y) {
|
|
1052
|
+
result[0] = p1x;
|
|
1053
|
+
result[1] = bottomLeftAy;
|
|
1054
|
+
result[2] = p2x;
|
|
1055
|
+
result[3] = topLeftBy;
|
|
1056
|
+
return false;
|
|
1057
|
+
}
|
|
1058
|
+
} else if (p1y === p2y) {
|
|
1059
|
+
if (p1x > p2x) {
|
|
1060
|
+
result[0] = topLeftAx;
|
|
1061
|
+
result[1] = p1y;
|
|
1062
|
+
result[2] = topRightBx;
|
|
1063
|
+
result[3] = p2y;
|
|
1064
|
+
return false;
|
|
1065
|
+
} else if (p1x < p2x) {
|
|
1066
|
+
result[0] = topRightAx;
|
|
1067
|
+
result[1] = p1y;
|
|
1068
|
+
result[2] = topLeftBx;
|
|
1069
|
+
result[3] = p2y;
|
|
1070
|
+
return false;
|
|
1071
|
+
}
|
|
1072
|
+
} else {
|
|
1073
|
+
var slopeA = rectA.height / rectA.width;
|
|
1074
|
+
var slopeB = rectB.height / rectB.width;
|
|
1075
|
+
var slopePrime = (p2y - p1y) / (p2x - p1x);
|
|
1076
|
+
var cardinalDirectionA = void 0;
|
|
1077
|
+
var cardinalDirectionB = void 0;
|
|
1078
|
+
var tempPointAx = void 0;
|
|
1079
|
+
var tempPointAy = void 0;
|
|
1080
|
+
var tempPointBx = void 0;
|
|
1081
|
+
var tempPointBy = void 0;
|
|
1082
|
+
if (-slopeA === slopePrime) if (p1x > p2x) {
|
|
1083
|
+
result[0] = bottomLeftAx;
|
|
1084
|
+
result[1] = bottomLeftAy;
|
|
1085
|
+
clipPointAFound = true;
|
|
1086
|
+
} else {
|
|
1087
|
+
result[0] = topRightAx;
|
|
1088
|
+
result[1] = topLeftAy;
|
|
1089
|
+
clipPointAFound = true;
|
|
1090
|
+
}
|
|
1091
|
+
else if (slopeA === slopePrime) if (p1x > p2x) {
|
|
1092
|
+
result[0] = topLeftAx;
|
|
1093
|
+
result[1] = topLeftAy;
|
|
1094
|
+
clipPointAFound = true;
|
|
1095
|
+
} else {
|
|
1096
|
+
result[0] = bottomRightAx;
|
|
1097
|
+
result[1] = bottomLeftAy;
|
|
1098
|
+
clipPointAFound = true;
|
|
1099
|
+
}
|
|
1100
|
+
if (-slopeB === slopePrime) if (p2x > p1x) {
|
|
1101
|
+
result[2] = bottomLeftBx;
|
|
1102
|
+
result[3] = bottomLeftBy;
|
|
1103
|
+
clipPointBFound = true;
|
|
1104
|
+
} else {
|
|
1105
|
+
result[2] = topRightBx;
|
|
1106
|
+
result[3] = topLeftBy;
|
|
1107
|
+
clipPointBFound = true;
|
|
1108
|
+
}
|
|
1109
|
+
else if (slopeB === slopePrime) if (p2x > p1x) {
|
|
1110
|
+
result[2] = topLeftBx;
|
|
1111
|
+
result[3] = topLeftBy;
|
|
1112
|
+
clipPointBFound = true;
|
|
1113
|
+
} else {
|
|
1114
|
+
result[2] = bottomRightBx;
|
|
1115
|
+
result[3] = bottomLeftBy;
|
|
1116
|
+
clipPointBFound = true;
|
|
1117
|
+
}
|
|
1118
|
+
if (clipPointAFound && clipPointBFound) return false;
|
|
1119
|
+
if (p1x > p2x) if (p1y > p2y) {
|
|
1120
|
+
cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 4);
|
|
1121
|
+
cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 2);
|
|
1122
|
+
} else {
|
|
1123
|
+
cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 3);
|
|
1124
|
+
cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 1);
|
|
1125
|
+
}
|
|
1126
|
+
else if (p1y > p2y) {
|
|
1127
|
+
cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 1);
|
|
1128
|
+
cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 3);
|
|
1129
|
+
} else {
|
|
1130
|
+
cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 2);
|
|
1131
|
+
cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 4);
|
|
1132
|
+
}
|
|
1133
|
+
if (!clipPointAFound) switch (cardinalDirectionA) {
|
|
1134
|
+
case 1:
|
|
1135
|
+
tempPointAy = topLeftAy;
|
|
1136
|
+
tempPointAx = p1x + -halfHeightA / slopePrime;
|
|
1137
|
+
result[0] = tempPointAx;
|
|
1138
|
+
result[1] = tempPointAy;
|
|
1139
|
+
break;
|
|
1140
|
+
case 2:
|
|
1141
|
+
tempPointAx = bottomRightAx;
|
|
1142
|
+
tempPointAy = p1y + halfWidthA * slopePrime;
|
|
1143
|
+
result[0] = tempPointAx;
|
|
1144
|
+
result[1] = tempPointAy;
|
|
1145
|
+
break;
|
|
1146
|
+
case 3:
|
|
1147
|
+
tempPointAy = bottomLeftAy;
|
|
1148
|
+
tempPointAx = p1x + halfHeightA / slopePrime;
|
|
1149
|
+
result[0] = tempPointAx;
|
|
1150
|
+
result[1] = tempPointAy;
|
|
1151
|
+
break;
|
|
1152
|
+
case 4:
|
|
1153
|
+
tempPointAx = bottomLeftAx;
|
|
1154
|
+
tempPointAy = p1y + -halfWidthA * slopePrime;
|
|
1155
|
+
result[0] = tempPointAx;
|
|
1156
|
+
result[1] = tempPointAy;
|
|
1157
|
+
break;
|
|
1158
|
+
}
|
|
1159
|
+
if (!clipPointBFound) switch (cardinalDirectionB) {
|
|
1160
|
+
case 1:
|
|
1161
|
+
tempPointBy = topLeftBy;
|
|
1162
|
+
tempPointBx = p2x + -halfHeightB / slopePrime;
|
|
1163
|
+
result[2] = tempPointBx;
|
|
1164
|
+
result[3] = tempPointBy;
|
|
1165
|
+
break;
|
|
1166
|
+
case 2:
|
|
1167
|
+
tempPointBx = bottomRightBx;
|
|
1168
|
+
tempPointBy = p2y + halfWidthB * slopePrime;
|
|
1169
|
+
result[2] = tempPointBx;
|
|
1170
|
+
result[3] = tempPointBy;
|
|
1171
|
+
break;
|
|
1172
|
+
case 3:
|
|
1173
|
+
tempPointBy = bottomLeftBy;
|
|
1174
|
+
tempPointBx = p2x + halfHeightB / slopePrime;
|
|
1175
|
+
result[2] = tempPointBx;
|
|
1176
|
+
result[3] = tempPointBy;
|
|
1177
|
+
break;
|
|
1178
|
+
case 4:
|
|
1179
|
+
tempPointBx = bottomLeftBx;
|
|
1180
|
+
tempPointBy = p2y + -halfWidthB * slopePrime;
|
|
1181
|
+
result[2] = tempPointBx;
|
|
1182
|
+
result[3] = tempPointBy;
|
|
1183
|
+
break;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
return false;
|
|
1187
|
+
};
|
|
1188
|
+
/**
|
|
1189
|
+
* This method returns in which cardinal direction does input point stays
|
|
1190
|
+
* 1: North
|
|
1191
|
+
* 2: East
|
|
1192
|
+
* 3: South
|
|
1193
|
+
* 4: West
|
|
1194
|
+
*/
|
|
1195
|
+
IGeometry.getCardinalDirection = function(slope, slopePrime, line) {
|
|
1196
|
+
if (slope > slopePrime) return line;
|
|
1197
|
+
else return 1 + line % 4;
|
|
1198
|
+
};
|
|
1199
|
+
/**
|
|
1200
|
+
* This method calculates the intersection of the two lines defined by
|
|
1201
|
+
* point pairs (s1,s2) and (f1,f2).
|
|
1202
|
+
*/
|
|
1203
|
+
IGeometry.getIntersection = function(s1, s2, f1, f2) {
|
|
1204
|
+
if (f2 == null) return this.getIntersection2(s1, s2, f1);
|
|
1205
|
+
var x1 = s1.x;
|
|
1206
|
+
var y1 = s1.y;
|
|
1207
|
+
var x2 = s2.x;
|
|
1208
|
+
var y2 = s2.y;
|
|
1209
|
+
var x3 = f1.x;
|
|
1210
|
+
var y3 = f1.y;
|
|
1211
|
+
var x4 = f2.x;
|
|
1212
|
+
var y4 = f2.y;
|
|
1213
|
+
var x = void 0, y = void 0;
|
|
1214
|
+
var a1 = void 0, a2 = void 0, b1 = void 0, b2 = void 0, c1 = void 0, c2 = void 0;
|
|
1215
|
+
var denom = void 0;
|
|
1216
|
+
a1 = y2 - y1;
|
|
1217
|
+
b1 = x1 - x2;
|
|
1218
|
+
c1 = x2 * y1 - x1 * y2;
|
|
1219
|
+
a2 = y4 - y3;
|
|
1220
|
+
b2 = x3 - x4;
|
|
1221
|
+
c2 = x4 * y3 - x3 * y4;
|
|
1222
|
+
denom = a1 * b2 - a2 * b1;
|
|
1223
|
+
if (denom === 0) return null;
|
|
1224
|
+
x = (b1 * c2 - b2 * c1) / denom;
|
|
1225
|
+
y = (a2 * c1 - a1 * c2) / denom;
|
|
1226
|
+
return new Point(x, y);
|
|
1227
|
+
};
|
|
1228
|
+
/**
|
|
1229
|
+
* This method finds and returns the angle of the vector from the + x-axis
|
|
1230
|
+
* in clockwise direction (compatible w/ Java coordinate system!).
|
|
1231
|
+
*/
|
|
1232
|
+
IGeometry.angleOfVector = function(Cx, Cy, Nx, Ny) {
|
|
1233
|
+
var C_angle = void 0;
|
|
1234
|
+
if (Cx !== Nx) {
|
|
1235
|
+
C_angle = Math.atan((Ny - Cy) / (Nx - Cx));
|
|
1236
|
+
if (Nx < Cx) C_angle += Math.PI;
|
|
1237
|
+
else if (Ny < Cy) C_angle += this.TWO_PI;
|
|
1238
|
+
} else if (Ny < Cy) C_angle = this.ONE_AND_HALF_PI;
|
|
1239
|
+
else C_angle = this.HALF_PI;
|
|
1240
|
+
return C_angle;
|
|
1241
|
+
};
|
|
1242
|
+
/**
|
|
1243
|
+
* This method checks whether the given two line segments (one with point
|
|
1244
|
+
* p1 and p2, the other with point p3 and p4) intersect at a point other
|
|
1245
|
+
* than these points.
|
|
1246
|
+
*/
|
|
1247
|
+
IGeometry.doIntersect = function(p1, p2, p3, p4) {
|
|
1248
|
+
var a = p1.x;
|
|
1249
|
+
var b = p1.y;
|
|
1250
|
+
var c = p2.x;
|
|
1251
|
+
var d = p2.y;
|
|
1252
|
+
var p = p3.x;
|
|
1253
|
+
var q = p3.y;
|
|
1254
|
+
var r = p4.x;
|
|
1255
|
+
var s = p4.y;
|
|
1256
|
+
var det = (c - a) * (s - q) - (r - p) * (d - b);
|
|
1257
|
+
if (det === 0) return false;
|
|
1258
|
+
else {
|
|
1259
|
+
var lambda = ((s - q) * (r - a) + (p - r) * (s - b)) / det;
|
|
1260
|
+
var gamma = ((b - d) * (r - a) + (c - a) * (s - b)) / det;
|
|
1261
|
+
return 0 < lambda && lambda < 1 && 0 < gamma && gamma < 1;
|
|
1262
|
+
}
|
|
1263
|
+
};
|
|
1264
|
+
/**
|
|
1265
|
+
* Some useful pre-calculated constants
|
|
1266
|
+
*/
|
|
1267
|
+
IGeometry.HALF_PI = .5 * Math.PI;
|
|
1268
|
+
IGeometry.ONE_AND_HALF_PI = 1.5 * Math.PI;
|
|
1269
|
+
IGeometry.TWO_PI = 2 * Math.PI;
|
|
1270
|
+
IGeometry.THREE_PI = 3 * Math.PI;
|
|
1271
|
+
module$25.exports = IGeometry;
|
|
1272
|
+
}),
|
|
1273
|
+
(function(module$26, exports$23, __webpack_require__) {
|
|
1274
|
+
"use strict";
|
|
1275
|
+
function IMath() {}
|
|
1276
|
+
/**
|
|
1277
|
+
* This method returns the sign of the input value.
|
|
1278
|
+
*/
|
|
1279
|
+
IMath.sign = function(value) {
|
|
1280
|
+
if (value > 0) return 1;
|
|
1281
|
+
else if (value < 0) return -1;
|
|
1282
|
+
else return 0;
|
|
1283
|
+
};
|
|
1284
|
+
IMath.floor = function(value) {
|
|
1285
|
+
return value < 0 ? Math.ceil(value) : Math.floor(value);
|
|
1286
|
+
};
|
|
1287
|
+
IMath.ceil = function(value) {
|
|
1288
|
+
return value < 0 ? Math.floor(value) : Math.ceil(value);
|
|
1289
|
+
};
|
|
1290
|
+
module$26.exports = IMath;
|
|
1291
|
+
}),
|
|
1292
|
+
(function(module$27, exports$24, __webpack_require__) {
|
|
1293
|
+
"use strict";
|
|
1294
|
+
function Integer() {}
|
|
1295
|
+
Integer.MAX_VALUE = 2147483647;
|
|
1296
|
+
Integer.MIN_VALUE = -2147483648;
|
|
1297
|
+
module$27.exports = Integer;
|
|
1298
|
+
}),
|
|
1299
|
+
(function(module$28, exports$25, __webpack_require__) {
|
|
1300
|
+
"use strict";
|
|
1301
|
+
var _createClass = function() {
|
|
1302
|
+
function defineProperties(target, props) {
|
|
1303
|
+
for (var i = 0; i < props.length; i++) {
|
|
1304
|
+
var descriptor = props[i];
|
|
1305
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
1306
|
+
descriptor.configurable = true;
|
|
1307
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
1308
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
return function(Constructor, protoProps, staticProps) {
|
|
1312
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
1313
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
1314
|
+
return Constructor;
|
|
1315
|
+
};
|
|
1316
|
+
}();
|
|
1317
|
+
function _classCallCheck(instance, Constructor) {
|
|
1318
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
1319
|
+
}
|
|
1320
|
+
var nodeFrom = function nodeFrom(value) {
|
|
1321
|
+
return {
|
|
1322
|
+
value,
|
|
1323
|
+
next: null,
|
|
1324
|
+
prev: null
|
|
1325
|
+
};
|
|
1326
|
+
};
|
|
1327
|
+
var add = function add(prev, node, next, list) {
|
|
1328
|
+
if (prev !== null) prev.next = node;
|
|
1329
|
+
else list.head = node;
|
|
1330
|
+
if (next !== null) next.prev = node;
|
|
1331
|
+
else list.tail = node;
|
|
1332
|
+
node.prev = prev;
|
|
1333
|
+
node.next = next;
|
|
1334
|
+
list.length++;
|
|
1335
|
+
return node;
|
|
1336
|
+
};
|
|
1337
|
+
var _remove = function _remove(node, list) {
|
|
1338
|
+
var prev = node.prev, next = node.next;
|
|
1339
|
+
if (prev !== null) prev.next = next;
|
|
1340
|
+
else list.head = next;
|
|
1341
|
+
if (next !== null) next.prev = prev;
|
|
1342
|
+
else list.tail = prev;
|
|
1343
|
+
node.prev = node.next = null;
|
|
1344
|
+
list.length--;
|
|
1345
|
+
return node;
|
|
1346
|
+
};
|
|
1347
|
+
module$28.exports = function() {
|
|
1348
|
+
function LinkedList(vals) {
|
|
1349
|
+
var _this = this;
|
|
1350
|
+
_classCallCheck(this, LinkedList);
|
|
1351
|
+
this.length = 0;
|
|
1352
|
+
this.head = null;
|
|
1353
|
+
this.tail = null;
|
|
1354
|
+
if (vals != null) vals.forEach(function(v) {
|
|
1355
|
+
return _this.push(v);
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
_createClass(LinkedList, [
|
|
1359
|
+
{
|
|
1360
|
+
key: "size",
|
|
1361
|
+
value: function size() {
|
|
1362
|
+
return this.length;
|
|
1363
|
+
}
|
|
1364
|
+
},
|
|
1365
|
+
{
|
|
1366
|
+
key: "insertBefore",
|
|
1367
|
+
value: function insertBefore(val, otherNode) {
|
|
1368
|
+
return add(otherNode.prev, nodeFrom(val), otherNode, this);
|
|
1369
|
+
}
|
|
1370
|
+
},
|
|
1371
|
+
{
|
|
1372
|
+
key: "insertAfter",
|
|
1373
|
+
value: function insertAfter(val, otherNode) {
|
|
1374
|
+
return add(otherNode, nodeFrom(val), otherNode.next, this);
|
|
1375
|
+
}
|
|
1376
|
+
},
|
|
1377
|
+
{
|
|
1378
|
+
key: "insertNodeBefore",
|
|
1379
|
+
value: function insertNodeBefore(newNode, otherNode) {
|
|
1380
|
+
return add(otherNode.prev, newNode, otherNode, this);
|
|
1381
|
+
}
|
|
1382
|
+
},
|
|
1383
|
+
{
|
|
1384
|
+
key: "insertNodeAfter",
|
|
1385
|
+
value: function insertNodeAfter(newNode, otherNode) {
|
|
1386
|
+
return add(otherNode, newNode, otherNode.next, this);
|
|
1387
|
+
}
|
|
1388
|
+
},
|
|
1389
|
+
{
|
|
1390
|
+
key: "push",
|
|
1391
|
+
value: function push(val) {
|
|
1392
|
+
return add(this.tail, nodeFrom(val), null, this);
|
|
1393
|
+
}
|
|
1394
|
+
},
|
|
1395
|
+
{
|
|
1396
|
+
key: "unshift",
|
|
1397
|
+
value: function unshift(val) {
|
|
1398
|
+
return add(null, nodeFrom(val), this.head, this);
|
|
1399
|
+
}
|
|
1400
|
+
},
|
|
1401
|
+
{
|
|
1402
|
+
key: "remove",
|
|
1403
|
+
value: function remove(node) {
|
|
1404
|
+
return _remove(node, this);
|
|
1405
|
+
}
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
key: "pop",
|
|
1409
|
+
value: function pop() {
|
|
1410
|
+
return _remove(this.tail, this).value;
|
|
1411
|
+
}
|
|
1412
|
+
},
|
|
1413
|
+
{
|
|
1414
|
+
key: "popNode",
|
|
1415
|
+
value: function popNode() {
|
|
1416
|
+
return _remove(this.tail, this);
|
|
1417
|
+
}
|
|
1418
|
+
},
|
|
1419
|
+
{
|
|
1420
|
+
key: "shift",
|
|
1421
|
+
value: function shift() {
|
|
1422
|
+
return _remove(this.head, this).value;
|
|
1423
|
+
}
|
|
1424
|
+
},
|
|
1425
|
+
{
|
|
1426
|
+
key: "shiftNode",
|
|
1427
|
+
value: function shiftNode() {
|
|
1428
|
+
return _remove(this.head, this);
|
|
1429
|
+
}
|
|
1430
|
+
},
|
|
1431
|
+
{
|
|
1432
|
+
key: "get_object_at",
|
|
1433
|
+
value: function get_object_at(index) {
|
|
1434
|
+
if (index <= this.length()) {
|
|
1435
|
+
var i = 1;
|
|
1436
|
+
var current = this.head;
|
|
1437
|
+
while (i < index) {
|
|
1438
|
+
current = current.next;
|
|
1439
|
+
i++;
|
|
1440
|
+
}
|
|
1441
|
+
return current.value;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
key: "set_object_at",
|
|
1447
|
+
value: function set_object_at(index, value) {
|
|
1448
|
+
if (index <= this.length()) {
|
|
1449
|
+
var i = 1;
|
|
1450
|
+
var current = this.head;
|
|
1451
|
+
while (i < index) {
|
|
1452
|
+
current = current.next;
|
|
1453
|
+
i++;
|
|
1454
|
+
}
|
|
1455
|
+
current.value = value;
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
]);
|
|
1460
|
+
return LinkedList;
|
|
1461
|
+
}();
|
|
1462
|
+
}),
|
|
1463
|
+
(function(module$29, exports$26, __webpack_require__) {
|
|
1464
|
+
"use strict";
|
|
1465
|
+
function Point(x, y, p) {
|
|
1466
|
+
this.x = null;
|
|
1467
|
+
this.y = null;
|
|
1468
|
+
if (x == null && y == null && p == null) {
|
|
1469
|
+
this.x = 0;
|
|
1470
|
+
this.y = 0;
|
|
1471
|
+
} else if (typeof x == "number" && typeof y == "number" && p == null) {
|
|
1472
|
+
this.x = x;
|
|
1473
|
+
this.y = y;
|
|
1474
|
+
} else if (x.constructor.name == "Point" && y == null && p == null) {
|
|
1475
|
+
p = x;
|
|
1476
|
+
this.x = p.x;
|
|
1477
|
+
this.y = p.y;
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
Point.prototype.getX = function() {
|
|
1481
|
+
return this.x;
|
|
1482
|
+
};
|
|
1483
|
+
Point.prototype.getY = function() {
|
|
1484
|
+
return this.y;
|
|
1485
|
+
};
|
|
1486
|
+
Point.prototype.getLocation = function() {
|
|
1487
|
+
return new Point(this.x, this.y);
|
|
1488
|
+
};
|
|
1489
|
+
Point.prototype.setLocation = function(x, y, p) {
|
|
1490
|
+
if (x.constructor.name == "Point" && y == null && p == null) {
|
|
1491
|
+
p = x;
|
|
1492
|
+
this.setLocation(p.x, p.y);
|
|
1493
|
+
} else if (typeof x == "number" && typeof y == "number" && p == null) if (parseInt(x) == x && parseInt(y) == y) this.move(x, y);
|
|
1494
|
+
else {
|
|
1495
|
+
this.x = Math.floor(x + .5);
|
|
1496
|
+
this.y = Math.floor(y + .5);
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1499
|
+
Point.prototype.move = function(x, y) {
|
|
1500
|
+
this.x = x;
|
|
1501
|
+
this.y = y;
|
|
1502
|
+
};
|
|
1503
|
+
Point.prototype.translate = function(dx, dy) {
|
|
1504
|
+
this.x += dx;
|
|
1505
|
+
this.y += dy;
|
|
1506
|
+
};
|
|
1507
|
+
Point.prototype.equals = function(obj) {
|
|
1508
|
+
if (obj.constructor.name == "Point") {
|
|
1509
|
+
var pt = obj;
|
|
1510
|
+
return this.x == pt.x && this.y == pt.y;
|
|
1511
|
+
}
|
|
1512
|
+
return this == obj;
|
|
1513
|
+
};
|
|
1514
|
+
Point.prototype.toString = function() {
|
|
1515
|
+
return new Point().constructor.name + "[x=" + this.x + ",y=" + this.y + "]";
|
|
1516
|
+
};
|
|
1517
|
+
module$29.exports = Point;
|
|
1518
|
+
}),
|
|
1519
|
+
(function(module$30, exports$27, __webpack_require__) {
|
|
1520
|
+
"use strict";
|
|
1521
|
+
function RectangleD(x, y, width, height) {
|
|
1522
|
+
this.x = 0;
|
|
1523
|
+
this.y = 0;
|
|
1524
|
+
this.width = 0;
|
|
1525
|
+
this.height = 0;
|
|
1526
|
+
if (x != null && y != null && width != null && height != null) {
|
|
1527
|
+
this.x = x;
|
|
1528
|
+
this.y = y;
|
|
1529
|
+
this.width = width;
|
|
1530
|
+
this.height = height;
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
RectangleD.prototype.getX = function() {
|
|
1534
|
+
return this.x;
|
|
1535
|
+
};
|
|
1536
|
+
RectangleD.prototype.setX = function(x) {
|
|
1537
|
+
this.x = x;
|
|
1538
|
+
};
|
|
1539
|
+
RectangleD.prototype.getY = function() {
|
|
1540
|
+
return this.y;
|
|
1541
|
+
};
|
|
1542
|
+
RectangleD.prototype.setY = function(y) {
|
|
1543
|
+
this.y = y;
|
|
1544
|
+
};
|
|
1545
|
+
RectangleD.prototype.getWidth = function() {
|
|
1546
|
+
return this.width;
|
|
1547
|
+
};
|
|
1548
|
+
RectangleD.prototype.setWidth = function(width) {
|
|
1549
|
+
this.width = width;
|
|
1550
|
+
};
|
|
1551
|
+
RectangleD.prototype.getHeight = function() {
|
|
1552
|
+
return this.height;
|
|
1553
|
+
};
|
|
1554
|
+
RectangleD.prototype.setHeight = function(height) {
|
|
1555
|
+
this.height = height;
|
|
1556
|
+
};
|
|
1557
|
+
RectangleD.prototype.getRight = function() {
|
|
1558
|
+
return this.x + this.width;
|
|
1559
|
+
};
|
|
1560
|
+
RectangleD.prototype.getBottom = function() {
|
|
1561
|
+
return this.y + this.height;
|
|
1562
|
+
};
|
|
1563
|
+
RectangleD.prototype.intersects = function(a) {
|
|
1564
|
+
if (this.getRight() < a.x) return false;
|
|
1565
|
+
if (this.getBottom() < a.y) return false;
|
|
1566
|
+
if (a.getRight() < this.x) return false;
|
|
1567
|
+
if (a.getBottom() < this.y) return false;
|
|
1568
|
+
return true;
|
|
1569
|
+
};
|
|
1570
|
+
RectangleD.prototype.getCenterX = function() {
|
|
1571
|
+
return this.x + this.width / 2;
|
|
1572
|
+
};
|
|
1573
|
+
RectangleD.prototype.getMinX = function() {
|
|
1574
|
+
return this.getX();
|
|
1575
|
+
};
|
|
1576
|
+
RectangleD.prototype.getMaxX = function() {
|
|
1577
|
+
return this.getX() + this.width;
|
|
1578
|
+
};
|
|
1579
|
+
RectangleD.prototype.getCenterY = function() {
|
|
1580
|
+
return this.y + this.height / 2;
|
|
1581
|
+
};
|
|
1582
|
+
RectangleD.prototype.getMinY = function() {
|
|
1583
|
+
return this.getY();
|
|
1584
|
+
};
|
|
1585
|
+
RectangleD.prototype.getMaxY = function() {
|
|
1586
|
+
return this.getY() + this.height;
|
|
1587
|
+
};
|
|
1588
|
+
RectangleD.prototype.getWidthHalf = function() {
|
|
1589
|
+
return this.width / 2;
|
|
1590
|
+
};
|
|
1591
|
+
RectangleD.prototype.getHeightHalf = function() {
|
|
1592
|
+
return this.height / 2;
|
|
1593
|
+
};
|
|
1594
|
+
module$30.exports = RectangleD;
|
|
1595
|
+
}),
|
|
1596
|
+
(function(module$31, exports$28, __webpack_require__) {
|
|
1597
|
+
"use strict";
|
|
1598
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
|
|
1599
|
+
return typeof obj;
|
|
1600
|
+
} : function(obj) {
|
|
1601
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
1602
|
+
};
|
|
1603
|
+
function UniqueIDGeneretor() {}
|
|
1604
|
+
UniqueIDGeneretor.lastID = 0;
|
|
1605
|
+
UniqueIDGeneretor.createID = function(obj) {
|
|
1606
|
+
if (UniqueIDGeneretor.isPrimitive(obj)) return obj;
|
|
1607
|
+
if (obj.uniqueID != null) return obj.uniqueID;
|
|
1608
|
+
obj.uniqueID = UniqueIDGeneretor.getString();
|
|
1609
|
+
UniqueIDGeneretor.lastID++;
|
|
1610
|
+
return obj.uniqueID;
|
|
1611
|
+
};
|
|
1612
|
+
UniqueIDGeneretor.getString = function(id) {
|
|
1613
|
+
if (id == null) id = UniqueIDGeneretor.lastID;
|
|
1614
|
+
return "Object#" + id;
|
|
1615
|
+
};
|
|
1616
|
+
UniqueIDGeneretor.isPrimitive = function(arg) {
|
|
1617
|
+
var type = typeof arg === "undefined" ? "undefined" : _typeof(arg);
|
|
1618
|
+
return arg == null || type != "object" && type != "function";
|
|
1619
|
+
};
|
|
1620
|
+
module$31.exports = UniqueIDGeneretor;
|
|
1621
|
+
}),
|
|
1622
|
+
(function(module$32, exports$29, __webpack_require__) {
|
|
1623
|
+
"use strict";
|
|
1624
|
+
function _toConsumableArray(arr) {
|
|
1625
|
+
if (Array.isArray(arr)) {
|
|
1626
|
+
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
|
1627
|
+
return arr2;
|
|
1628
|
+
} else return Array.from(arr);
|
|
1629
|
+
}
|
|
1630
|
+
var LayoutConstants = __webpack_require__(0);
|
|
1631
|
+
var LGraphManager = __webpack_require__(6);
|
|
1632
|
+
var LNode = __webpack_require__(3);
|
|
1633
|
+
var LEdge = __webpack_require__(1);
|
|
1634
|
+
var LGraph = __webpack_require__(5);
|
|
1635
|
+
var PointD = __webpack_require__(4);
|
|
1636
|
+
var Transform = __webpack_require__(17);
|
|
1637
|
+
var Emitter = __webpack_require__(27);
|
|
1638
|
+
function Layout(isRemoteUse) {
|
|
1639
|
+
Emitter.call(this);
|
|
1640
|
+
this.layoutQuality = LayoutConstants.QUALITY;
|
|
1641
|
+
this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED;
|
|
1642
|
+
this.incremental = LayoutConstants.DEFAULT_INCREMENTAL;
|
|
1643
|
+
this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT;
|
|
1644
|
+
this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT;
|
|
1645
|
+
this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD;
|
|
1646
|
+
/**
|
|
1647
|
+
* Whether or not leaf nodes (non-compound nodes) are of uniform sizes. When
|
|
1648
|
+
* they are, both spring and repulsion forces between two leaf nodes can be
|
|
1649
|
+
* calculated without the expensive clipping point calculations, resulting
|
|
1650
|
+
* in major speed-up.
|
|
1651
|
+
*/
|
|
1652
|
+
this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES;
|
|
1653
|
+
/**
|
|
1654
|
+
* This is used for creation of bendpoints by using dummy nodes and edges.
|
|
1655
|
+
* Maps an LEdge to its dummy bendpoint path.
|
|
1656
|
+
*/
|
|
1657
|
+
this.edgeToDummyNodes = /* @__PURE__ */ new Map();
|
|
1658
|
+
this.graphManager = new LGraphManager(this);
|
|
1659
|
+
this.isLayoutFinished = false;
|
|
1660
|
+
this.isSubLayout = false;
|
|
1661
|
+
this.isRemoteUse = false;
|
|
1662
|
+
if (isRemoteUse != null) this.isRemoteUse = isRemoteUse;
|
|
1663
|
+
}
|
|
1664
|
+
Layout.RANDOM_SEED = 1;
|
|
1665
|
+
Layout.prototype = Object.create(Emitter.prototype);
|
|
1666
|
+
Layout.prototype.getGraphManager = function() {
|
|
1667
|
+
return this.graphManager;
|
|
1668
|
+
};
|
|
1669
|
+
Layout.prototype.getAllNodes = function() {
|
|
1670
|
+
return this.graphManager.getAllNodes();
|
|
1671
|
+
};
|
|
1672
|
+
Layout.prototype.getAllEdges = function() {
|
|
1673
|
+
return this.graphManager.getAllEdges();
|
|
1674
|
+
};
|
|
1675
|
+
Layout.prototype.getAllNodesToApplyGravitation = function() {
|
|
1676
|
+
return this.graphManager.getAllNodesToApplyGravitation();
|
|
1677
|
+
};
|
|
1678
|
+
Layout.prototype.newGraphManager = function() {
|
|
1679
|
+
var gm = new LGraphManager(this);
|
|
1680
|
+
this.graphManager = gm;
|
|
1681
|
+
return gm;
|
|
1682
|
+
};
|
|
1683
|
+
Layout.prototype.newGraph = function(vGraph) {
|
|
1684
|
+
return new LGraph(null, this.graphManager, vGraph);
|
|
1685
|
+
};
|
|
1686
|
+
Layout.prototype.newNode = function(vNode) {
|
|
1687
|
+
return new LNode(this.graphManager, vNode);
|
|
1688
|
+
};
|
|
1689
|
+
Layout.prototype.newEdge = function(vEdge) {
|
|
1690
|
+
return new LEdge(null, null, vEdge);
|
|
1691
|
+
};
|
|
1692
|
+
Layout.prototype.checkLayoutSuccess = function() {
|
|
1693
|
+
return this.graphManager.getRoot() == null || this.graphManager.getRoot().getNodes().length == 0 || this.graphManager.includesInvalidEdge();
|
|
1694
|
+
};
|
|
1695
|
+
Layout.prototype.runLayout = function() {
|
|
1696
|
+
this.isLayoutFinished = false;
|
|
1697
|
+
if (this.tilingPreLayout) this.tilingPreLayout();
|
|
1698
|
+
this.initParameters();
|
|
1699
|
+
var isLayoutSuccessfull;
|
|
1700
|
+
if (this.checkLayoutSuccess()) isLayoutSuccessfull = false;
|
|
1701
|
+
else isLayoutSuccessfull = this.layout();
|
|
1702
|
+
if (LayoutConstants.ANIMATE === "during") return false;
|
|
1703
|
+
if (isLayoutSuccessfull) {
|
|
1704
|
+
if (!this.isSubLayout) this.doPostLayout();
|
|
1705
|
+
}
|
|
1706
|
+
if (this.tilingPostLayout) this.tilingPostLayout();
|
|
1707
|
+
this.isLayoutFinished = true;
|
|
1708
|
+
return isLayoutSuccessfull;
|
|
1709
|
+
};
|
|
1710
|
+
/**
|
|
1711
|
+
* This method performs the operations required after layout.
|
|
1712
|
+
*/
|
|
1713
|
+
Layout.prototype.doPostLayout = function() {
|
|
1714
|
+
if (!this.incremental) this.transform();
|
|
1715
|
+
this.update();
|
|
1716
|
+
};
|
|
1717
|
+
/**
|
|
1718
|
+
* This method updates the geometry of the target graph according to
|
|
1719
|
+
* calculated layout.
|
|
1720
|
+
*/
|
|
1721
|
+
Layout.prototype.update2 = function() {
|
|
1722
|
+
if (this.createBendsAsNeeded) {
|
|
1723
|
+
this.createBendpointsFromDummyNodes();
|
|
1724
|
+
this.graphManager.resetAllEdges();
|
|
1725
|
+
}
|
|
1726
|
+
if (!this.isRemoteUse) {
|
|
1727
|
+
var allEdges = this.graphManager.getAllEdges();
|
|
1728
|
+
for (var i = 0; i < allEdges.length; i++) allEdges[i];
|
|
1729
|
+
var nodes = this.graphManager.getRoot().getNodes();
|
|
1730
|
+
for (var i = 0; i < nodes.length; i++) nodes[i];
|
|
1731
|
+
this.update(this.graphManager.getRoot());
|
|
1732
|
+
}
|
|
1733
|
+
};
|
|
1734
|
+
Layout.prototype.update = function(obj) {
|
|
1735
|
+
if (obj == null) this.update2();
|
|
1736
|
+
else if (obj instanceof LNode) {
|
|
1737
|
+
var node = obj;
|
|
1738
|
+
if (node.getChild() != null) {
|
|
1739
|
+
var nodes = node.getChild().getNodes();
|
|
1740
|
+
for (var i = 0; i < nodes.length; i++) update(nodes[i]);
|
|
1741
|
+
}
|
|
1742
|
+
if (node.vGraphObject != null) node.vGraphObject.update(node);
|
|
1743
|
+
} else if (obj instanceof LEdge) {
|
|
1744
|
+
var edge = obj;
|
|
1745
|
+
if (edge.vGraphObject != null) edge.vGraphObject.update(edge);
|
|
1746
|
+
} else if (obj instanceof LGraph) {
|
|
1747
|
+
var graph = obj;
|
|
1748
|
+
if (graph.vGraphObject != null) graph.vGraphObject.update(graph);
|
|
1749
|
+
}
|
|
1750
|
+
};
|
|
1751
|
+
/**
|
|
1752
|
+
* This method is used to set all layout parameters to default values
|
|
1753
|
+
* determined at compile time.
|
|
1754
|
+
*/
|
|
1755
|
+
Layout.prototype.initParameters = function() {
|
|
1756
|
+
if (!this.isSubLayout) {
|
|
1757
|
+
this.layoutQuality = LayoutConstants.QUALITY;
|
|
1758
|
+
this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT;
|
|
1759
|
+
this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD;
|
|
1760
|
+
this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT;
|
|
1761
|
+
this.incremental = LayoutConstants.DEFAULT_INCREMENTAL;
|
|
1762
|
+
this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED;
|
|
1763
|
+
this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES;
|
|
1764
|
+
}
|
|
1765
|
+
if (this.animationDuringLayout) this.animationOnLayout = false;
|
|
1766
|
+
};
|
|
1767
|
+
Layout.prototype.transform = function(newLeftTop) {
|
|
1768
|
+
if (newLeftTop == void 0) this.transform(new PointD(0, 0));
|
|
1769
|
+
else {
|
|
1770
|
+
var trans = new Transform();
|
|
1771
|
+
var leftTop = this.graphManager.getRoot().updateLeftTop();
|
|
1772
|
+
if (leftTop != null) {
|
|
1773
|
+
trans.setWorldOrgX(newLeftTop.x);
|
|
1774
|
+
trans.setWorldOrgY(newLeftTop.y);
|
|
1775
|
+
trans.setDeviceOrgX(leftTop.x);
|
|
1776
|
+
trans.setDeviceOrgY(leftTop.y);
|
|
1777
|
+
var nodes = this.getAllNodes();
|
|
1778
|
+
var node;
|
|
1779
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
1780
|
+
node = nodes[i];
|
|
1781
|
+
node.transform(trans);
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
};
|
|
1786
|
+
Layout.prototype.positionNodesRandomly = function(graph) {
|
|
1787
|
+
if (graph == void 0) {
|
|
1788
|
+
this.positionNodesRandomly(this.getGraphManager().getRoot());
|
|
1789
|
+
this.getGraphManager().getRoot().updateBounds(true);
|
|
1790
|
+
} else {
|
|
1791
|
+
var lNode;
|
|
1792
|
+
var childGraph;
|
|
1793
|
+
var nodes = graph.getNodes();
|
|
1794
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
1795
|
+
lNode = nodes[i];
|
|
1796
|
+
childGraph = lNode.getChild();
|
|
1797
|
+
if (childGraph == null) lNode.scatter();
|
|
1798
|
+
else if (childGraph.getNodes().length == 0) lNode.scatter();
|
|
1799
|
+
else {
|
|
1800
|
+
this.positionNodesRandomly(childGraph);
|
|
1801
|
+
lNode.updateBounds();
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
};
|
|
1806
|
+
/**
|
|
1807
|
+
* This method returns a list of trees where each tree is represented as a
|
|
1808
|
+
* list of l-nodes. The method returns a list of size 0 when:
|
|
1809
|
+
* - The graph is not flat or
|
|
1810
|
+
* - One of the component(s) of the graph is not a tree.
|
|
1811
|
+
*/
|
|
1812
|
+
Layout.prototype.getFlatForest = function() {
|
|
1813
|
+
var flatForest = [];
|
|
1814
|
+
var isForest = true;
|
|
1815
|
+
var allNodes = this.graphManager.getRoot().getNodes();
|
|
1816
|
+
var isFlat = true;
|
|
1817
|
+
for (var i = 0; i < allNodes.length; i++) if (allNodes[i].getChild() != null) isFlat = false;
|
|
1818
|
+
if (!isFlat) return flatForest;
|
|
1819
|
+
var visited = /* @__PURE__ */ new Set();
|
|
1820
|
+
var toBeVisited = [];
|
|
1821
|
+
var parents = /* @__PURE__ */ new Map();
|
|
1822
|
+
var unProcessedNodes = [];
|
|
1823
|
+
unProcessedNodes = unProcessedNodes.concat(allNodes);
|
|
1824
|
+
while (unProcessedNodes.length > 0 && isForest) {
|
|
1825
|
+
toBeVisited.push(unProcessedNodes[0]);
|
|
1826
|
+
while (toBeVisited.length > 0 && isForest) {
|
|
1827
|
+
var currentNode = toBeVisited[0];
|
|
1828
|
+
toBeVisited.splice(0, 1);
|
|
1829
|
+
visited.add(currentNode);
|
|
1830
|
+
var neighborEdges = currentNode.getEdges();
|
|
1831
|
+
for (var i = 0; i < neighborEdges.length; i++) {
|
|
1832
|
+
var currentNeighbor = neighborEdges[i].getOtherEnd(currentNode);
|
|
1833
|
+
if (parents.get(currentNode) != currentNeighbor) if (!visited.has(currentNeighbor)) {
|
|
1834
|
+
toBeVisited.push(currentNeighbor);
|
|
1835
|
+
parents.set(currentNeighbor, currentNode);
|
|
1836
|
+
} else {
|
|
1837
|
+
isForest = false;
|
|
1838
|
+
break;
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
if (!isForest) flatForest = [];
|
|
1843
|
+
else {
|
|
1844
|
+
var temp = [].concat(_toConsumableArray(visited));
|
|
1845
|
+
flatForest.push(temp);
|
|
1846
|
+
for (var i = 0; i < temp.length; i++) {
|
|
1847
|
+
var value = temp[i];
|
|
1848
|
+
var index = unProcessedNodes.indexOf(value);
|
|
1849
|
+
if (index > -1) unProcessedNodes.splice(index, 1);
|
|
1850
|
+
}
|
|
1851
|
+
visited = /* @__PURE__ */ new Set();
|
|
1852
|
+
parents = /* @__PURE__ */ new Map();
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
return flatForest;
|
|
1856
|
+
};
|
|
1857
|
+
/**
|
|
1858
|
+
* This method creates dummy nodes (an l-level node with minimal dimensions)
|
|
1859
|
+
* for the given edge (one per bendpoint). The existing l-level structure
|
|
1860
|
+
* is updated accordingly.
|
|
1861
|
+
*/
|
|
1862
|
+
Layout.prototype.createDummyNodesForBendpoints = function(edge) {
|
|
1863
|
+
var dummyNodes = [];
|
|
1864
|
+
var prev = edge.source;
|
|
1865
|
+
var graph = this.graphManager.calcLowestCommonAncestor(edge.source, edge.target);
|
|
1866
|
+
for (var i = 0; i < edge.bendpoints.length; i++) {
|
|
1867
|
+
var dummyNode = this.newNode(null);
|
|
1868
|
+
dummyNode.setRect(new Point(0, 0), new Dimension(1, 1));
|
|
1869
|
+
graph.add(dummyNode);
|
|
1870
|
+
var dummyEdge = this.newEdge(null);
|
|
1871
|
+
this.graphManager.add(dummyEdge, prev, dummyNode);
|
|
1872
|
+
dummyNodes.add(dummyNode);
|
|
1873
|
+
prev = dummyNode;
|
|
1874
|
+
}
|
|
1875
|
+
var dummyEdge = this.newEdge(null);
|
|
1876
|
+
this.graphManager.add(dummyEdge, prev, edge.target);
|
|
1877
|
+
this.edgeToDummyNodes.set(edge, dummyNodes);
|
|
1878
|
+
if (edge.isInterGraph()) this.graphManager.remove(edge);
|
|
1879
|
+
else graph.remove(edge);
|
|
1880
|
+
return dummyNodes;
|
|
1881
|
+
};
|
|
1882
|
+
/**
|
|
1883
|
+
* This method creates bendpoints for edges from the dummy nodes
|
|
1884
|
+
* at l-level.
|
|
1885
|
+
*/
|
|
1886
|
+
Layout.prototype.createBendpointsFromDummyNodes = function() {
|
|
1887
|
+
var edges = [];
|
|
1888
|
+
edges = edges.concat(this.graphManager.getAllEdges());
|
|
1889
|
+
edges = [].concat(_toConsumableArray(this.edgeToDummyNodes.keys())).concat(edges);
|
|
1890
|
+
for (var k = 0; k < edges.length; k++) {
|
|
1891
|
+
var lEdge = edges[k];
|
|
1892
|
+
if (lEdge.bendpoints.length > 0) {
|
|
1893
|
+
var path = this.edgeToDummyNodes.get(lEdge);
|
|
1894
|
+
for (var i = 0; i < path.length; i++) {
|
|
1895
|
+
var dummyNode = path[i];
|
|
1896
|
+
var p = new PointD(dummyNode.getCenterX(), dummyNode.getCenterY());
|
|
1897
|
+
var ebp = lEdge.bendpoints.get(i);
|
|
1898
|
+
ebp.x = p.x;
|
|
1899
|
+
ebp.y = p.y;
|
|
1900
|
+
dummyNode.getOwner().remove(dummyNode);
|
|
1901
|
+
}
|
|
1902
|
+
this.graphManager.add(lEdge, lEdge.source, lEdge.target);
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
};
|
|
1906
|
+
Layout.transform = function(sliderValue, defaultValue, minDiv, maxMul) {
|
|
1907
|
+
if (minDiv != void 0 && maxMul != void 0) {
|
|
1908
|
+
var value = defaultValue;
|
|
1909
|
+
if (sliderValue <= 50) {
|
|
1910
|
+
var minValue = defaultValue / minDiv;
|
|
1911
|
+
value -= (defaultValue - minValue) / 50 * (50 - sliderValue);
|
|
1912
|
+
} else {
|
|
1913
|
+
var maxValue = defaultValue * maxMul;
|
|
1914
|
+
value += (maxValue - defaultValue) / 50 * (sliderValue - 50);
|
|
1915
|
+
}
|
|
1916
|
+
return value;
|
|
1917
|
+
} else {
|
|
1918
|
+
var a, b;
|
|
1919
|
+
if (sliderValue <= 50) {
|
|
1920
|
+
a = 9 * defaultValue / 500;
|
|
1921
|
+
b = defaultValue / 10;
|
|
1922
|
+
} else {
|
|
1923
|
+
a = 9 * defaultValue / 50;
|
|
1924
|
+
b = -8 * defaultValue;
|
|
1925
|
+
}
|
|
1926
|
+
return a * sliderValue + b;
|
|
1927
|
+
}
|
|
1928
|
+
};
|
|
1929
|
+
/**
|
|
1930
|
+
* This method finds and returns the center of the given nodes, assuming
|
|
1931
|
+
* that the given nodes form a tree in themselves.
|
|
1932
|
+
*/
|
|
1933
|
+
Layout.findCenterOfTree = function(nodes) {
|
|
1934
|
+
var list = [];
|
|
1935
|
+
list = list.concat(nodes);
|
|
1936
|
+
var removedNodes = [];
|
|
1937
|
+
var remainingDegrees = /* @__PURE__ */ new Map();
|
|
1938
|
+
var foundCenter = false;
|
|
1939
|
+
var centerNode = null;
|
|
1940
|
+
if (list.length == 1 || list.length == 2) {
|
|
1941
|
+
foundCenter = true;
|
|
1942
|
+
centerNode = list[0];
|
|
1943
|
+
}
|
|
1944
|
+
for (var i = 0; i < list.length; i++) {
|
|
1945
|
+
var node = list[i];
|
|
1946
|
+
var degree = node.getNeighborsList().size;
|
|
1947
|
+
remainingDegrees.set(node, node.getNeighborsList().size);
|
|
1948
|
+
if (degree == 1) removedNodes.push(node);
|
|
1949
|
+
}
|
|
1950
|
+
var tempList = [];
|
|
1951
|
+
tempList = tempList.concat(removedNodes);
|
|
1952
|
+
while (!foundCenter) {
|
|
1953
|
+
var tempList2 = [];
|
|
1954
|
+
tempList2 = tempList2.concat(tempList);
|
|
1955
|
+
tempList = [];
|
|
1956
|
+
for (var i = 0; i < list.length; i++) {
|
|
1957
|
+
var node = list[i];
|
|
1958
|
+
var index = list.indexOf(node);
|
|
1959
|
+
if (index >= 0) list.splice(index, 1);
|
|
1960
|
+
node.getNeighborsList().forEach(function(neighbour) {
|
|
1961
|
+
if (removedNodes.indexOf(neighbour) < 0) {
|
|
1962
|
+
var newDegree = remainingDegrees.get(neighbour) - 1;
|
|
1963
|
+
if (newDegree == 1) tempList.push(neighbour);
|
|
1964
|
+
remainingDegrees.set(neighbour, newDegree);
|
|
1965
|
+
}
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
removedNodes = removedNodes.concat(tempList);
|
|
1969
|
+
if (list.length == 1 || list.length == 2) {
|
|
1970
|
+
foundCenter = true;
|
|
1971
|
+
centerNode = list[0];
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
return centerNode;
|
|
1975
|
+
};
|
|
1976
|
+
/**
|
|
1977
|
+
* During the coarsening process, this layout may be referenced by two graph managers
|
|
1978
|
+
* this setter function grants access to change the currently being used graph manager
|
|
1979
|
+
*/
|
|
1980
|
+
Layout.prototype.setGraphManager = function(gm) {
|
|
1981
|
+
this.graphManager = gm;
|
|
1982
|
+
};
|
|
1983
|
+
module$32.exports = Layout;
|
|
1984
|
+
}),
|
|
1985
|
+
(function(module$33, exports$30, __webpack_require__) {
|
|
1986
|
+
"use strict";
|
|
1987
|
+
function RandomSeed() {}
|
|
1988
|
+
RandomSeed.seed = 1;
|
|
1989
|
+
RandomSeed.x = 0;
|
|
1990
|
+
RandomSeed.nextDouble = function() {
|
|
1991
|
+
RandomSeed.x = Math.sin(RandomSeed.seed++) * 1e4;
|
|
1992
|
+
return RandomSeed.x - Math.floor(RandomSeed.x);
|
|
1993
|
+
};
|
|
1994
|
+
module$33.exports = RandomSeed;
|
|
1995
|
+
}),
|
|
1996
|
+
(function(module$34, exports$31, __webpack_require__) {
|
|
1997
|
+
"use strict";
|
|
1998
|
+
var PointD = __webpack_require__(4);
|
|
1999
|
+
function Transform(x, y) {
|
|
2000
|
+
this.lworldOrgX = 0;
|
|
2001
|
+
this.lworldOrgY = 0;
|
|
2002
|
+
this.ldeviceOrgX = 0;
|
|
2003
|
+
this.ldeviceOrgY = 0;
|
|
2004
|
+
this.lworldExtX = 1;
|
|
2005
|
+
this.lworldExtY = 1;
|
|
2006
|
+
this.ldeviceExtX = 1;
|
|
2007
|
+
this.ldeviceExtY = 1;
|
|
2008
|
+
}
|
|
2009
|
+
Transform.prototype.getWorldOrgX = function() {
|
|
2010
|
+
return this.lworldOrgX;
|
|
2011
|
+
};
|
|
2012
|
+
Transform.prototype.setWorldOrgX = function(wox) {
|
|
2013
|
+
this.lworldOrgX = wox;
|
|
2014
|
+
};
|
|
2015
|
+
Transform.prototype.getWorldOrgY = function() {
|
|
2016
|
+
return this.lworldOrgY;
|
|
2017
|
+
};
|
|
2018
|
+
Transform.prototype.setWorldOrgY = function(woy) {
|
|
2019
|
+
this.lworldOrgY = woy;
|
|
2020
|
+
};
|
|
2021
|
+
Transform.prototype.getWorldExtX = function() {
|
|
2022
|
+
return this.lworldExtX;
|
|
2023
|
+
};
|
|
2024
|
+
Transform.prototype.setWorldExtX = function(wex) {
|
|
2025
|
+
this.lworldExtX = wex;
|
|
2026
|
+
};
|
|
2027
|
+
Transform.prototype.getWorldExtY = function() {
|
|
2028
|
+
return this.lworldExtY;
|
|
2029
|
+
};
|
|
2030
|
+
Transform.prototype.setWorldExtY = function(wey) {
|
|
2031
|
+
this.lworldExtY = wey;
|
|
2032
|
+
};
|
|
2033
|
+
Transform.prototype.getDeviceOrgX = function() {
|
|
2034
|
+
return this.ldeviceOrgX;
|
|
2035
|
+
};
|
|
2036
|
+
Transform.prototype.setDeviceOrgX = function(dox) {
|
|
2037
|
+
this.ldeviceOrgX = dox;
|
|
2038
|
+
};
|
|
2039
|
+
Transform.prototype.getDeviceOrgY = function() {
|
|
2040
|
+
return this.ldeviceOrgY;
|
|
2041
|
+
};
|
|
2042
|
+
Transform.prototype.setDeviceOrgY = function(doy) {
|
|
2043
|
+
this.ldeviceOrgY = doy;
|
|
2044
|
+
};
|
|
2045
|
+
Transform.prototype.getDeviceExtX = function() {
|
|
2046
|
+
return this.ldeviceExtX;
|
|
2047
|
+
};
|
|
2048
|
+
Transform.prototype.setDeviceExtX = function(dex) {
|
|
2049
|
+
this.ldeviceExtX = dex;
|
|
2050
|
+
};
|
|
2051
|
+
Transform.prototype.getDeviceExtY = function() {
|
|
2052
|
+
return this.ldeviceExtY;
|
|
2053
|
+
};
|
|
2054
|
+
Transform.prototype.setDeviceExtY = function(dey) {
|
|
2055
|
+
this.ldeviceExtY = dey;
|
|
2056
|
+
};
|
|
2057
|
+
Transform.prototype.transformX = function(x) {
|
|
2058
|
+
var xDevice = 0;
|
|
2059
|
+
var worldExtX = this.lworldExtX;
|
|
2060
|
+
if (worldExtX != 0) xDevice = this.ldeviceOrgX + (x - this.lworldOrgX) * this.ldeviceExtX / worldExtX;
|
|
2061
|
+
return xDevice;
|
|
2062
|
+
};
|
|
2063
|
+
Transform.prototype.transformY = function(y) {
|
|
2064
|
+
var yDevice = 0;
|
|
2065
|
+
var worldExtY = this.lworldExtY;
|
|
2066
|
+
if (worldExtY != 0) yDevice = this.ldeviceOrgY + (y - this.lworldOrgY) * this.ldeviceExtY / worldExtY;
|
|
2067
|
+
return yDevice;
|
|
2068
|
+
};
|
|
2069
|
+
Transform.prototype.inverseTransformX = function(x) {
|
|
2070
|
+
var xWorld = 0;
|
|
2071
|
+
var deviceExtX = this.ldeviceExtX;
|
|
2072
|
+
if (deviceExtX != 0) xWorld = this.lworldOrgX + (x - this.ldeviceOrgX) * this.lworldExtX / deviceExtX;
|
|
2073
|
+
return xWorld;
|
|
2074
|
+
};
|
|
2075
|
+
Transform.prototype.inverseTransformY = function(y) {
|
|
2076
|
+
var yWorld = 0;
|
|
2077
|
+
var deviceExtY = this.ldeviceExtY;
|
|
2078
|
+
if (deviceExtY != 0) yWorld = this.lworldOrgY + (y - this.ldeviceOrgY) * this.lworldExtY / deviceExtY;
|
|
2079
|
+
return yWorld;
|
|
2080
|
+
};
|
|
2081
|
+
Transform.prototype.inverseTransformPoint = function(inPoint) {
|
|
2082
|
+
return new PointD(this.inverseTransformX(inPoint.x), this.inverseTransformY(inPoint.y));
|
|
2083
|
+
};
|
|
2084
|
+
module$34.exports = Transform;
|
|
2085
|
+
}),
|
|
2086
|
+
(function(module$35, exports$32, __webpack_require__) {
|
|
2087
|
+
"use strict";
|
|
2088
|
+
function _toConsumableArray(arr) {
|
|
2089
|
+
if (Array.isArray(arr)) {
|
|
2090
|
+
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
|
2091
|
+
return arr2;
|
|
2092
|
+
} else return Array.from(arr);
|
|
2093
|
+
}
|
|
2094
|
+
var Layout = __webpack_require__(15);
|
|
2095
|
+
var FDLayoutConstants = __webpack_require__(7);
|
|
2096
|
+
var LayoutConstants = __webpack_require__(0);
|
|
2097
|
+
var IGeometry = __webpack_require__(8);
|
|
2098
|
+
var IMath = __webpack_require__(9);
|
|
2099
|
+
function FDLayout() {
|
|
2100
|
+
Layout.call(this);
|
|
2101
|
+
this.useSmartIdealEdgeLengthCalculation = FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION;
|
|
2102
|
+
this.idealEdgeLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH;
|
|
2103
|
+
this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH;
|
|
2104
|
+
this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH;
|
|
2105
|
+
this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH;
|
|
2106
|
+
this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH;
|
|
2107
|
+
this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR;
|
|
2108
|
+
this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR;
|
|
2109
|
+
this.displacementThresholdPerNode = 3 * FDLayoutConstants.DEFAULT_EDGE_LENGTH / 100;
|
|
2110
|
+
this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL;
|
|
2111
|
+
this.initialCoolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL;
|
|
2112
|
+
this.totalDisplacement = 0;
|
|
2113
|
+
this.oldTotalDisplacement = 0;
|
|
2114
|
+
this.maxIterations = FDLayoutConstants.MAX_ITERATIONS;
|
|
2115
|
+
}
|
|
2116
|
+
FDLayout.prototype = Object.create(Layout.prototype);
|
|
2117
|
+
for (var prop in Layout) FDLayout[prop] = Layout[prop];
|
|
2118
|
+
FDLayout.prototype.initParameters = function() {
|
|
2119
|
+
Layout.prototype.initParameters.call(this, arguments);
|
|
2120
|
+
this.totalIterations = 0;
|
|
2121
|
+
this.notAnimatedIterations = 0;
|
|
2122
|
+
this.useFRGridVariant = FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION;
|
|
2123
|
+
this.grid = [];
|
|
2124
|
+
};
|
|
2125
|
+
FDLayout.prototype.calcIdealEdgeLengths = function() {
|
|
2126
|
+
var edge;
|
|
2127
|
+
var lcaDepth;
|
|
2128
|
+
var source;
|
|
2129
|
+
var target;
|
|
2130
|
+
var sizeOfSourceInLca;
|
|
2131
|
+
var sizeOfTargetInLca;
|
|
2132
|
+
var allEdges = this.getGraphManager().getAllEdges();
|
|
2133
|
+
for (var i = 0; i < allEdges.length; i++) {
|
|
2134
|
+
edge = allEdges[i];
|
|
2135
|
+
edge.idealLength = this.idealEdgeLength;
|
|
2136
|
+
if (edge.isInterGraph) {
|
|
2137
|
+
source = edge.getSource();
|
|
2138
|
+
target = edge.getTarget();
|
|
2139
|
+
sizeOfSourceInLca = edge.getSourceInLca().getEstimatedSize();
|
|
2140
|
+
sizeOfTargetInLca = edge.getTargetInLca().getEstimatedSize();
|
|
2141
|
+
if (this.useSmartIdealEdgeLengthCalculation) edge.idealLength += sizeOfSourceInLca + sizeOfTargetInLca - 2 * LayoutConstants.SIMPLE_NODE_SIZE;
|
|
2142
|
+
lcaDepth = edge.getLca().getInclusionTreeDepth();
|
|
2143
|
+
edge.idealLength += FDLayoutConstants.DEFAULT_EDGE_LENGTH * FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR * (source.getInclusionTreeDepth() + target.getInclusionTreeDepth() - 2 * lcaDepth);
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
};
|
|
2147
|
+
FDLayout.prototype.initSpringEmbedder = function() {
|
|
2148
|
+
var s = this.getAllNodes().length;
|
|
2149
|
+
if (this.incremental) {
|
|
2150
|
+
if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) this.coolingFactor = Math.max(this.coolingFactor * FDLayoutConstants.COOLING_ADAPTATION_FACTOR, this.coolingFactor - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * this.coolingFactor * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR));
|
|
2151
|
+
this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL;
|
|
2152
|
+
} else {
|
|
2153
|
+
if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) this.coolingFactor = Math.max(FDLayoutConstants.COOLING_ADAPTATION_FACTOR, 1 - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR));
|
|
2154
|
+
else this.coolingFactor = 1;
|
|
2155
|
+
this.initialCoolingFactor = this.coolingFactor;
|
|
2156
|
+
this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT;
|
|
2157
|
+
}
|
|
2158
|
+
this.maxIterations = Math.max(this.getAllNodes().length * 5, this.maxIterations);
|
|
2159
|
+
this.totalDisplacementThreshold = this.displacementThresholdPerNode * this.getAllNodes().length;
|
|
2160
|
+
this.repulsionRange = this.calcRepulsionRange();
|
|
2161
|
+
};
|
|
2162
|
+
FDLayout.prototype.calcSpringForces = function() {
|
|
2163
|
+
var lEdges = this.getAllEdges();
|
|
2164
|
+
var edge;
|
|
2165
|
+
for (var i = 0; i < lEdges.length; i++) {
|
|
2166
|
+
edge = lEdges[i];
|
|
2167
|
+
this.calcSpringForce(edge, edge.idealLength);
|
|
2168
|
+
}
|
|
2169
|
+
};
|
|
2170
|
+
FDLayout.prototype.calcRepulsionForces = function() {
|
|
2171
|
+
var gridUpdateAllowed = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
2172
|
+
var forceToNodeSurroundingUpdate = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
2173
|
+
var i, j;
|
|
2174
|
+
var nodeA, nodeB;
|
|
2175
|
+
var lNodes = this.getAllNodes();
|
|
2176
|
+
var processedNodeSet;
|
|
2177
|
+
if (this.useFRGridVariant) {
|
|
2178
|
+
if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed) this.updateGrid();
|
|
2179
|
+
processedNodeSet = /* @__PURE__ */ new Set();
|
|
2180
|
+
for (i = 0; i < lNodes.length; i++) {
|
|
2181
|
+
nodeA = lNodes[i];
|
|
2182
|
+
this.calculateRepulsionForceOfANode(nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate);
|
|
2183
|
+
processedNodeSet.add(nodeA);
|
|
2184
|
+
}
|
|
2185
|
+
} else for (i = 0; i < lNodes.length; i++) {
|
|
2186
|
+
nodeA = lNodes[i];
|
|
2187
|
+
for (j = i + 1; j < lNodes.length; j++) {
|
|
2188
|
+
nodeB = lNodes[j];
|
|
2189
|
+
if (nodeA.getOwner() != nodeB.getOwner()) continue;
|
|
2190
|
+
this.calcRepulsionForce(nodeA, nodeB);
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
};
|
|
2194
|
+
FDLayout.prototype.calcGravitationalForces = function() {
|
|
2195
|
+
var node;
|
|
2196
|
+
var lNodes = this.getAllNodesToApplyGravitation();
|
|
2197
|
+
for (var i = 0; i < lNodes.length; i++) {
|
|
2198
|
+
node = lNodes[i];
|
|
2199
|
+
this.calcGravitationalForce(node);
|
|
2200
|
+
}
|
|
2201
|
+
};
|
|
2202
|
+
FDLayout.prototype.moveNodes = function() {
|
|
2203
|
+
var lNodes = this.getAllNodes();
|
|
2204
|
+
var node;
|
|
2205
|
+
for (var i = 0; i < lNodes.length; i++) {
|
|
2206
|
+
node = lNodes[i];
|
|
2207
|
+
node.move();
|
|
2208
|
+
}
|
|
2209
|
+
};
|
|
2210
|
+
FDLayout.prototype.calcSpringForce = function(edge, idealLength) {
|
|
2211
|
+
var sourceNode = edge.getSource();
|
|
2212
|
+
var targetNode = edge.getTarget();
|
|
2213
|
+
var length;
|
|
2214
|
+
var springForce;
|
|
2215
|
+
var springForceX;
|
|
2216
|
+
var springForceY;
|
|
2217
|
+
if (this.uniformLeafNodeSizes && sourceNode.getChild() == null && targetNode.getChild() == null) edge.updateLengthSimple();
|
|
2218
|
+
else {
|
|
2219
|
+
edge.updateLength();
|
|
2220
|
+
if (edge.isOverlapingSourceAndTarget) return;
|
|
2221
|
+
}
|
|
2222
|
+
length = edge.getLength();
|
|
2223
|
+
if (length == 0) return;
|
|
2224
|
+
springForce = this.springConstant * (length - idealLength);
|
|
2225
|
+
springForceX = springForce * (edge.lengthX / length);
|
|
2226
|
+
springForceY = springForce * (edge.lengthY / length);
|
|
2227
|
+
sourceNode.springForceX += springForceX;
|
|
2228
|
+
sourceNode.springForceY += springForceY;
|
|
2229
|
+
targetNode.springForceX -= springForceX;
|
|
2230
|
+
targetNode.springForceY -= springForceY;
|
|
2231
|
+
};
|
|
2232
|
+
FDLayout.prototype.calcRepulsionForce = function(nodeA, nodeB) {
|
|
2233
|
+
var rectA = nodeA.getRect();
|
|
2234
|
+
var rectB = nodeB.getRect();
|
|
2235
|
+
var overlapAmount = new Array(2);
|
|
2236
|
+
var clipPoints = new Array(4);
|
|
2237
|
+
var distanceX;
|
|
2238
|
+
var distanceY;
|
|
2239
|
+
var distanceSquared;
|
|
2240
|
+
var distance;
|
|
2241
|
+
var repulsionForce;
|
|
2242
|
+
var repulsionForceX;
|
|
2243
|
+
var repulsionForceY;
|
|
2244
|
+
if (rectA.intersects(rectB)) {
|
|
2245
|
+
IGeometry.calcSeparationAmount(rectA, rectB, overlapAmount, FDLayoutConstants.DEFAULT_EDGE_LENGTH / 2);
|
|
2246
|
+
repulsionForceX = 2 * overlapAmount[0];
|
|
2247
|
+
repulsionForceY = 2 * overlapAmount[1];
|
|
2248
|
+
var childrenConstant = nodeA.noOfChildren * nodeB.noOfChildren / (nodeA.noOfChildren + nodeB.noOfChildren);
|
|
2249
|
+
nodeA.repulsionForceX -= childrenConstant * repulsionForceX;
|
|
2250
|
+
nodeA.repulsionForceY -= childrenConstant * repulsionForceY;
|
|
2251
|
+
nodeB.repulsionForceX += childrenConstant * repulsionForceX;
|
|
2252
|
+
nodeB.repulsionForceY += childrenConstant * repulsionForceY;
|
|
2253
|
+
} else {
|
|
2254
|
+
if (this.uniformLeafNodeSizes && nodeA.getChild() == null && nodeB.getChild() == null) {
|
|
2255
|
+
distanceX = rectB.getCenterX() - rectA.getCenterX();
|
|
2256
|
+
distanceY = rectB.getCenterY() - rectA.getCenterY();
|
|
2257
|
+
} else {
|
|
2258
|
+
IGeometry.getIntersection(rectA, rectB, clipPoints);
|
|
2259
|
+
distanceX = clipPoints[2] - clipPoints[0];
|
|
2260
|
+
distanceY = clipPoints[3] - clipPoints[1];
|
|
2261
|
+
}
|
|
2262
|
+
if (Math.abs(distanceX) < FDLayoutConstants.MIN_REPULSION_DIST) distanceX = IMath.sign(distanceX) * FDLayoutConstants.MIN_REPULSION_DIST;
|
|
2263
|
+
if (Math.abs(distanceY) < FDLayoutConstants.MIN_REPULSION_DIST) distanceY = IMath.sign(distanceY) * FDLayoutConstants.MIN_REPULSION_DIST;
|
|
2264
|
+
distanceSquared = distanceX * distanceX + distanceY * distanceY;
|
|
2265
|
+
distance = Math.sqrt(distanceSquared);
|
|
2266
|
+
repulsionForce = this.repulsionConstant * nodeA.noOfChildren * nodeB.noOfChildren / distanceSquared;
|
|
2267
|
+
repulsionForceX = repulsionForce * distanceX / distance;
|
|
2268
|
+
repulsionForceY = repulsionForce * distanceY / distance;
|
|
2269
|
+
nodeA.repulsionForceX -= repulsionForceX;
|
|
2270
|
+
nodeA.repulsionForceY -= repulsionForceY;
|
|
2271
|
+
nodeB.repulsionForceX += repulsionForceX;
|
|
2272
|
+
nodeB.repulsionForceY += repulsionForceY;
|
|
2273
|
+
}
|
|
2274
|
+
};
|
|
2275
|
+
FDLayout.prototype.calcGravitationalForce = function(node) {
|
|
2276
|
+
var ownerGraph;
|
|
2277
|
+
var ownerCenterX;
|
|
2278
|
+
var ownerCenterY;
|
|
2279
|
+
var distanceX;
|
|
2280
|
+
var distanceY;
|
|
2281
|
+
var absDistanceX;
|
|
2282
|
+
var absDistanceY;
|
|
2283
|
+
var estimatedSize;
|
|
2284
|
+
ownerGraph = node.getOwner();
|
|
2285
|
+
ownerCenterX = (ownerGraph.getRight() + ownerGraph.getLeft()) / 2;
|
|
2286
|
+
ownerCenterY = (ownerGraph.getTop() + ownerGraph.getBottom()) / 2;
|
|
2287
|
+
distanceX = node.getCenterX() - ownerCenterX;
|
|
2288
|
+
distanceY = node.getCenterY() - ownerCenterY;
|
|
2289
|
+
absDistanceX = Math.abs(distanceX) + node.getWidth() / 2;
|
|
2290
|
+
absDistanceY = Math.abs(distanceY) + node.getHeight() / 2;
|
|
2291
|
+
if (node.getOwner() == this.graphManager.getRoot()) {
|
|
2292
|
+
estimatedSize = ownerGraph.getEstimatedSize() * this.gravityRangeFactor;
|
|
2293
|
+
if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) {
|
|
2294
|
+
node.gravitationForceX = -this.gravityConstant * distanceX;
|
|
2295
|
+
node.gravitationForceY = -this.gravityConstant * distanceY;
|
|
2296
|
+
}
|
|
2297
|
+
} else {
|
|
2298
|
+
estimatedSize = ownerGraph.getEstimatedSize() * this.compoundGravityRangeFactor;
|
|
2299
|
+
if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) {
|
|
2300
|
+
node.gravitationForceX = -this.gravityConstant * distanceX * this.compoundGravityConstant;
|
|
2301
|
+
node.gravitationForceY = -this.gravityConstant * distanceY * this.compoundGravityConstant;
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
FDLayout.prototype.isConverged = function() {
|
|
2306
|
+
var converged;
|
|
2307
|
+
var oscilating = false;
|
|
2308
|
+
if (this.totalIterations > this.maxIterations / 3) oscilating = Math.abs(this.totalDisplacement - this.oldTotalDisplacement) < 2;
|
|
2309
|
+
converged = this.totalDisplacement < this.totalDisplacementThreshold;
|
|
2310
|
+
this.oldTotalDisplacement = this.totalDisplacement;
|
|
2311
|
+
return converged || oscilating;
|
|
2312
|
+
};
|
|
2313
|
+
FDLayout.prototype.animate = function() {
|
|
2314
|
+
if (this.animationDuringLayout && !this.isSubLayout) if (this.notAnimatedIterations == this.animationPeriod) {
|
|
2315
|
+
this.update();
|
|
2316
|
+
this.notAnimatedIterations = 0;
|
|
2317
|
+
} else this.notAnimatedIterations++;
|
|
2318
|
+
};
|
|
2319
|
+
FDLayout.prototype.calcNoOfChildrenForAllNodes = function() {
|
|
2320
|
+
var node;
|
|
2321
|
+
var allNodes = this.graphManager.getAllNodes();
|
|
2322
|
+
for (var i = 0; i < allNodes.length; i++) {
|
|
2323
|
+
node = allNodes[i];
|
|
2324
|
+
node.noOfChildren = node.getNoOfChildren();
|
|
2325
|
+
}
|
|
2326
|
+
};
|
|
2327
|
+
FDLayout.prototype.calcGrid = function(graph) {
|
|
2328
|
+
var sizeX = 0;
|
|
2329
|
+
var sizeY = 0;
|
|
2330
|
+
sizeX = parseInt(Math.ceil((graph.getRight() - graph.getLeft()) / this.repulsionRange));
|
|
2331
|
+
sizeY = parseInt(Math.ceil((graph.getBottom() - graph.getTop()) / this.repulsionRange));
|
|
2332
|
+
var grid = new Array(sizeX);
|
|
2333
|
+
for (var i = 0; i < sizeX; i++) grid[i] = new Array(sizeY);
|
|
2334
|
+
for (var i = 0; i < sizeX; i++) for (var j = 0; j < sizeY; j++) grid[i][j] = new Array();
|
|
2335
|
+
return grid;
|
|
2336
|
+
};
|
|
2337
|
+
FDLayout.prototype.addNodeToGrid = function(v, left, top) {
|
|
2338
|
+
var startX = 0;
|
|
2339
|
+
var finishX = 0;
|
|
2340
|
+
var startY = 0;
|
|
2341
|
+
var finishY = 0;
|
|
2342
|
+
startX = parseInt(Math.floor((v.getRect().x - left) / this.repulsionRange));
|
|
2343
|
+
finishX = parseInt(Math.floor((v.getRect().width + v.getRect().x - left) / this.repulsionRange));
|
|
2344
|
+
startY = parseInt(Math.floor((v.getRect().y - top) / this.repulsionRange));
|
|
2345
|
+
finishY = parseInt(Math.floor((v.getRect().height + v.getRect().y - top) / this.repulsionRange));
|
|
2346
|
+
for (var i = startX; i <= finishX; i++) for (var j = startY; j <= finishY; j++) {
|
|
2347
|
+
this.grid[i][j].push(v);
|
|
2348
|
+
v.setGridCoordinates(startX, finishX, startY, finishY);
|
|
2349
|
+
}
|
|
2350
|
+
};
|
|
2351
|
+
FDLayout.prototype.updateGrid = function() {
|
|
2352
|
+
var i;
|
|
2353
|
+
var nodeA;
|
|
2354
|
+
var lNodes = this.getAllNodes();
|
|
2355
|
+
this.grid = this.calcGrid(this.graphManager.getRoot());
|
|
2356
|
+
for (i = 0; i < lNodes.length; i++) {
|
|
2357
|
+
nodeA = lNodes[i];
|
|
2358
|
+
this.addNodeToGrid(nodeA, this.graphManager.getRoot().getLeft(), this.graphManager.getRoot().getTop());
|
|
2359
|
+
}
|
|
2360
|
+
};
|
|
2361
|
+
FDLayout.prototype.calculateRepulsionForceOfANode = function(nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate) {
|
|
2362
|
+
if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed || forceToNodeSurroundingUpdate) {
|
|
2363
|
+
var surrounding = /* @__PURE__ */ new Set();
|
|
2364
|
+
nodeA.surrounding = new Array();
|
|
2365
|
+
var nodeB;
|
|
2366
|
+
var grid = this.grid;
|
|
2367
|
+
for (var i = nodeA.startX - 1; i < nodeA.finishX + 2; i++) for (var j = nodeA.startY - 1; j < nodeA.finishY + 2; j++) if (!(i < 0 || j < 0 || i >= grid.length || j >= grid[0].length)) for (var k = 0; k < grid[i][j].length; k++) {
|
|
2368
|
+
nodeB = grid[i][j][k];
|
|
2369
|
+
if (nodeA.getOwner() != nodeB.getOwner() || nodeA == nodeB) continue;
|
|
2370
|
+
if (!processedNodeSet.has(nodeB) && !surrounding.has(nodeB)) {
|
|
2371
|
+
var distanceX = Math.abs(nodeA.getCenterX() - nodeB.getCenterX()) - (nodeA.getWidth() / 2 + nodeB.getWidth() / 2);
|
|
2372
|
+
var distanceY = Math.abs(nodeA.getCenterY() - nodeB.getCenterY()) - (nodeA.getHeight() / 2 + nodeB.getHeight() / 2);
|
|
2373
|
+
if (distanceX <= this.repulsionRange && distanceY <= this.repulsionRange) surrounding.add(nodeB);
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
nodeA.surrounding = [].concat(_toConsumableArray(surrounding));
|
|
2377
|
+
}
|
|
2378
|
+
for (i = 0; i < nodeA.surrounding.length; i++) this.calcRepulsionForce(nodeA, nodeA.surrounding[i]);
|
|
2379
|
+
};
|
|
2380
|
+
FDLayout.prototype.calcRepulsionRange = function() {
|
|
2381
|
+
return 0;
|
|
2382
|
+
};
|
|
2383
|
+
module$35.exports = FDLayout;
|
|
2384
|
+
}),
|
|
2385
|
+
(function(module$36, exports$33, __webpack_require__) {
|
|
2386
|
+
"use strict";
|
|
2387
|
+
var LEdge = __webpack_require__(1);
|
|
2388
|
+
var FDLayoutConstants = __webpack_require__(7);
|
|
2389
|
+
function FDLayoutEdge(source, target, vEdge) {
|
|
2390
|
+
LEdge.call(this, source, target, vEdge);
|
|
2391
|
+
this.idealLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH;
|
|
2392
|
+
}
|
|
2393
|
+
FDLayoutEdge.prototype = Object.create(LEdge.prototype);
|
|
2394
|
+
for (var prop in LEdge) FDLayoutEdge[prop] = LEdge[prop];
|
|
2395
|
+
module$36.exports = FDLayoutEdge;
|
|
2396
|
+
}),
|
|
2397
|
+
(function(module$37, exports$34, __webpack_require__) {
|
|
2398
|
+
"use strict";
|
|
2399
|
+
var LNode = __webpack_require__(3);
|
|
2400
|
+
function FDLayoutNode(gm, loc, size, vNode) {
|
|
2401
|
+
LNode.call(this, gm, loc, size, vNode);
|
|
2402
|
+
this.springForceX = 0;
|
|
2403
|
+
this.springForceY = 0;
|
|
2404
|
+
this.repulsionForceX = 0;
|
|
2405
|
+
this.repulsionForceY = 0;
|
|
2406
|
+
this.gravitationForceX = 0;
|
|
2407
|
+
this.gravitationForceY = 0;
|
|
2408
|
+
this.displacementX = 0;
|
|
2409
|
+
this.displacementY = 0;
|
|
2410
|
+
this.startX = 0;
|
|
2411
|
+
this.finishX = 0;
|
|
2412
|
+
this.startY = 0;
|
|
2413
|
+
this.finishY = 0;
|
|
2414
|
+
this.surrounding = [];
|
|
2415
|
+
}
|
|
2416
|
+
FDLayoutNode.prototype = Object.create(LNode.prototype);
|
|
2417
|
+
for (var prop in LNode) FDLayoutNode[prop] = LNode[prop];
|
|
2418
|
+
FDLayoutNode.prototype.setGridCoordinates = function(_startX, _finishX, _startY, _finishY) {
|
|
2419
|
+
this.startX = _startX;
|
|
2420
|
+
this.finishX = _finishX;
|
|
2421
|
+
this.startY = _startY;
|
|
2422
|
+
this.finishY = _finishY;
|
|
2423
|
+
};
|
|
2424
|
+
module$37.exports = FDLayoutNode;
|
|
2425
|
+
}),
|
|
2426
|
+
(function(module$38, exports$35, __webpack_require__) {
|
|
2427
|
+
"use strict";
|
|
2428
|
+
function DimensionD(width, height) {
|
|
2429
|
+
this.width = 0;
|
|
2430
|
+
this.height = 0;
|
|
2431
|
+
if (width !== null && height !== null) {
|
|
2432
|
+
this.height = height;
|
|
2433
|
+
this.width = width;
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
DimensionD.prototype.getWidth = function() {
|
|
2437
|
+
return this.width;
|
|
2438
|
+
};
|
|
2439
|
+
DimensionD.prototype.setWidth = function(width) {
|
|
2440
|
+
this.width = width;
|
|
2441
|
+
};
|
|
2442
|
+
DimensionD.prototype.getHeight = function() {
|
|
2443
|
+
return this.height;
|
|
2444
|
+
};
|
|
2445
|
+
DimensionD.prototype.setHeight = function(height) {
|
|
2446
|
+
this.height = height;
|
|
2447
|
+
};
|
|
2448
|
+
module$38.exports = DimensionD;
|
|
2449
|
+
}),
|
|
2450
|
+
(function(module$39, exports$36, __webpack_require__) {
|
|
2451
|
+
"use strict";
|
|
2452
|
+
var UniqueIDGeneretor = __webpack_require__(14);
|
|
2453
|
+
function HashMap() {
|
|
2454
|
+
this.map = {};
|
|
2455
|
+
this.keys = [];
|
|
2456
|
+
}
|
|
2457
|
+
HashMap.prototype.put = function(key, value) {
|
|
2458
|
+
var theId = UniqueIDGeneretor.createID(key);
|
|
2459
|
+
if (!this.contains(theId)) {
|
|
2460
|
+
this.map[theId] = value;
|
|
2461
|
+
this.keys.push(key);
|
|
2462
|
+
}
|
|
2463
|
+
};
|
|
2464
|
+
HashMap.prototype.contains = function(key) {
|
|
2465
|
+
UniqueIDGeneretor.createID(key);
|
|
2466
|
+
return this.map[key] != null;
|
|
2467
|
+
};
|
|
2468
|
+
HashMap.prototype.get = function(key) {
|
|
2469
|
+
var theId = UniqueIDGeneretor.createID(key);
|
|
2470
|
+
return this.map[theId];
|
|
2471
|
+
};
|
|
2472
|
+
HashMap.prototype.keySet = function() {
|
|
2473
|
+
return this.keys;
|
|
2474
|
+
};
|
|
2475
|
+
module$39.exports = HashMap;
|
|
2476
|
+
}),
|
|
2477
|
+
(function(module$40, exports$37, __webpack_require__) {
|
|
2478
|
+
"use strict";
|
|
2479
|
+
var UniqueIDGeneretor = __webpack_require__(14);
|
|
2480
|
+
function HashSet() {
|
|
2481
|
+
this.set = {};
|
|
2482
|
+
}
|
|
2483
|
+
HashSet.prototype.add = function(obj) {
|
|
2484
|
+
var theId = UniqueIDGeneretor.createID(obj);
|
|
2485
|
+
if (!this.contains(theId)) this.set[theId] = obj;
|
|
2486
|
+
};
|
|
2487
|
+
HashSet.prototype.remove = function(obj) {
|
|
2488
|
+
delete this.set[UniqueIDGeneretor.createID(obj)];
|
|
2489
|
+
};
|
|
2490
|
+
HashSet.prototype.clear = function() {
|
|
2491
|
+
this.set = {};
|
|
2492
|
+
};
|
|
2493
|
+
HashSet.prototype.contains = function(obj) {
|
|
2494
|
+
return this.set[UniqueIDGeneretor.createID(obj)] == obj;
|
|
2495
|
+
};
|
|
2496
|
+
HashSet.prototype.isEmpty = function() {
|
|
2497
|
+
return this.size() === 0;
|
|
2498
|
+
};
|
|
2499
|
+
HashSet.prototype.size = function() {
|
|
2500
|
+
return Object.keys(this.set).length;
|
|
2501
|
+
};
|
|
2502
|
+
HashSet.prototype.addAllTo = function(list) {
|
|
2503
|
+
var keys = Object.keys(this.set);
|
|
2504
|
+
var length = keys.length;
|
|
2505
|
+
for (var i = 0; i < length; i++) list.push(this.set[keys[i]]);
|
|
2506
|
+
};
|
|
2507
|
+
HashSet.prototype.size = function() {
|
|
2508
|
+
return Object.keys(this.set).length;
|
|
2509
|
+
};
|
|
2510
|
+
HashSet.prototype.addAll = function(list) {
|
|
2511
|
+
var s = list.length;
|
|
2512
|
+
for (var i = 0; i < s; i++) {
|
|
2513
|
+
var v = list[i];
|
|
2514
|
+
this.add(v);
|
|
2515
|
+
}
|
|
2516
|
+
};
|
|
2517
|
+
module$40.exports = HashSet;
|
|
2518
|
+
}),
|
|
2519
|
+
(function(module$41, exports$38, __webpack_require__) {
|
|
2520
|
+
"use strict";
|
|
2521
|
+
var _createClass = function() {
|
|
2522
|
+
function defineProperties(target, props) {
|
|
2523
|
+
for (var i = 0; i < props.length; i++) {
|
|
2524
|
+
var descriptor = props[i];
|
|
2525
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
2526
|
+
descriptor.configurable = true;
|
|
2527
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2528
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
return function(Constructor, protoProps, staticProps) {
|
|
2532
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
2533
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
2534
|
+
return Constructor;
|
|
2535
|
+
};
|
|
2536
|
+
}();
|
|
2537
|
+
function _classCallCheck(instance, Constructor) {
|
|
2538
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
2539
|
+
}
|
|
2540
|
+
/**
|
|
2541
|
+
* A classic Quicksort algorithm with Hoare's partition
|
|
2542
|
+
* - Works also on LinkedList objects
|
|
2543
|
+
*
|
|
2544
|
+
* Copyright: i-Vis Research Group, Bilkent University, 2007 - present
|
|
2545
|
+
*/
|
|
2546
|
+
var LinkedList = __webpack_require__(11);
|
|
2547
|
+
module$41.exports = function() {
|
|
2548
|
+
function Quicksort(A, compareFunction) {
|
|
2549
|
+
_classCallCheck(this, Quicksort);
|
|
2550
|
+
if (compareFunction !== null || compareFunction !== void 0) this.compareFunction = this._defaultCompareFunction;
|
|
2551
|
+
var length = void 0;
|
|
2552
|
+
if (A instanceof LinkedList) length = A.size();
|
|
2553
|
+
else length = A.length;
|
|
2554
|
+
this._quicksort(A, 0, length - 1);
|
|
2555
|
+
}
|
|
2556
|
+
_createClass(Quicksort, [
|
|
2557
|
+
{
|
|
2558
|
+
key: "_quicksort",
|
|
2559
|
+
value: function _quicksort(A, p, r) {
|
|
2560
|
+
if (p < r) {
|
|
2561
|
+
var q = this._partition(A, p, r);
|
|
2562
|
+
this._quicksort(A, p, q);
|
|
2563
|
+
this._quicksort(A, q + 1, r);
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
},
|
|
2567
|
+
{
|
|
2568
|
+
key: "_partition",
|
|
2569
|
+
value: function _partition(A, p, r) {
|
|
2570
|
+
var x = this._get(A, p);
|
|
2571
|
+
var i = p;
|
|
2572
|
+
var j = r;
|
|
2573
|
+
while (true) {
|
|
2574
|
+
while (this.compareFunction(x, this._get(A, j))) j--;
|
|
2575
|
+
while (this.compareFunction(this._get(A, i), x)) i++;
|
|
2576
|
+
if (i < j) {
|
|
2577
|
+
this._swap(A, i, j);
|
|
2578
|
+
i++;
|
|
2579
|
+
j--;
|
|
2580
|
+
} else return j;
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
},
|
|
2584
|
+
{
|
|
2585
|
+
key: "_get",
|
|
2586
|
+
value: function _get(object, index) {
|
|
2587
|
+
if (object instanceof LinkedList) return object.get_object_at(index);
|
|
2588
|
+
else return object[index];
|
|
2589
|
+
}
|
|
2590
|
+
},
|
|
2591
|
+
{
|
|
2592
|
+
key: "_set",
|
|
2593
|
+
value: function _set(object, index, value) {
|
|
2594
|
+
if (object instanceof LinkedList) object.set_object_at(index, value);
|
|
2595
|
+
else object[index] = value;
|
|
2596
|
+
}
|
|
2597
|
+
},
|
|
2598
|
+
{
|
|
2599
|
+
key: "_swap",
|
|
2600
|
+
value: function _swap(A, i, j) {
|
|
2601
|
+
var temp = this._get(A, i);
|
|
2602
|
+
this._set(A, i, this._get(A, j));
|
|
2603
|
+
this._set(A, j, temp);
|
|
2604
|
+
}
|
|
2605
|
+
},
|
|
2606
|
+
{
|
|
2607
|
+
key: "_defaultCompareFunction",
|
|
2608
|
+
value: function _defaultCompareFunction(a, b) {
|
|
2609
|
+
return b > a;
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
]);
|
|
2613
|
+
return Quicksort;
|
|
2614
|
+
}();
|
|
2615
|
+
}),
|
|
2616
|
+
(function(module$42, exports$39, __webpack_require__) {
|
|
2617
|
+
"use strict";
|
|
2618
|
+
var _createClass = function() {
|
|
2619
|
+
function defineProperties(target, props) {
|
|
2620
|
+
for (var i = 0; i < props.length; i++) {
|
|
2621
|
+
var descriptor = props[i];
|
|
2622
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
2623
|
+
descriptor.configurable = true;
|
|
2624
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2625
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
return function(Constructor, protoProps, staticProps) {
|
|
2629
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
2630
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
2631
|
+
return Constructor;
|
|
2632
|
+
};
|
|
2633
|
+
}();
|
|
2634
|
+
function _classCallCheck(instance, Constructor) {
|
|
2635
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
2636
|
+
}
|
|
2637
|
+
module$42.exports = function() {
|
|
2638
|
+
function NeedlemanWunsch(sequence1, sequence2) {
|
|
2639
|
+
var match_score = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
|
|
2640
|
+
var mismatch_penalty = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : -1;
|
|
2641
|
+
var gap_penalty = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : -1;
|
|
2642
|
+
_classCallCheck(this, NeedlemanWunsch);
|
|
2643
|
+
this.sequence1 = sequence1;
|
|
2644
|
+
this.sequence2 = sequence2;
|
|
2645
|
+
this.match_score = match_score;
|
|
2646
|
+
this.mismatch_penalty = mismatch_penalty;
|
|
2647
|
+
this.gap_penalty = gap_penalty;
|
|
2648
|
+
this.iMax = sequence1.length + 1;
|
|
2649
|
+
this.jMax = sequence2.length + 1;
|
|
2650
|
+
this.grid = new Array(this.iMax);
|
|
2651
|
+
for (var i = 0; i < this.iMax; i++) {
|
|
2652
|
+
this.grid[i] = new Array(this.jMax);
|
|
2653
|
+
for (var j = 0; j < this.jMax; j++) this.grid[i][j] = 0;
|
|
2654
|
+
}
|
|
2655
|
+
this.tracebackGrid = new Array(this.iMax);
|
|
2656
|
+
for (var _i = 0; _i < this.iMax; _i++) {
|
|
2657
|
+
this.tracebackGrid[_i] = new Array(this.jMax);
|
|
2658
|
+
for (var _j = 0; _j < this.jMax; _j++) this.tracebackGrid[_i][_j] = [
|
|
2659
|
+
null,
|
|
2660
|
+
null,
|
|
2661
|
+
null
|
|
2662
|
+
];
|
|
2663
|
+
}
|
|
2664
|
+
this.alignments = [];
|
|
2665
|
+
this.score = -1;
|
|
2666
|
+
this.computeGrids();
|
|
2667
|
+
}
|
|
2668
|
+
_createClass(NeedlemanWunsch, [
|
|
2669
|
+
{
|
|
2670
|
+
key: "getScore",
|
|
2671
|
+
value: function getScore() {
|
|
2672
|
+
return this.score;
|
|
2673
|
+
}
|
|
2674
|
+
},
|
|
2675
|
+
{
|
|
2676
|
+
key: "getAlignments",
|
|
2677
|
+
value: function getAlignments() {
|
|
2678
|
+
return this.alignments;
|
|
2679
|
+
}
|
|
2680
|
+
},
|
|
2681
|
+
{
|
|
2682
|
+
key: "computeGrids",
|
|
2683
|
+
value: function computeGrids() {
|
|
2684
|
+
for (var j = 1; j < this.jMax; j++) {
|
|
2685
|
+
this.grid[0][j] = this.grid[0][j - 1] + this.gap_penalty;
|
|
2686
|
+
this.tracebackGrid[0][j] = [
|
|
2687
|
+
false,
|
|
2688
|
+
false,
|
|
2689
|
+
true
|
|
2690
|
+
];
|
|
2691
|
+
}
|
|
2692
|
+
for (var i = 1; i < this.iMax; i++) {
|
|
2693
|
+
this.grid[i][0] = this.grid[i - 1][0] + this.gap_penalty;
|
|
2694
|
+
this.tracebackGrid[i][0] = [
|
|
2695
|
+
false,
|
|
2696
|
+
true,
|
|
2697
|
+
false
|
|
2698
|
+
];
|
|
2699
|
+
}
|
|
2700
|
+
for (var _i2 = 1; _i2 < this.iMax; _i2++) for (var _j2 = 1; _j2 < this.jMax; _j2++) {
|
|
2701
|
+
var diag = void 0;
|
|
2702
|
+
if (this.sequence1[_i2 - 1] === this.sequence2[_j2 - 1]) diag = this.grid[_i2 - 1][_j2 - 1] + this.match_score;
|
|
2703
|
+
else diag = this.grid[_i2 - 1][_j2 - 1] + this.mismatch_penalty;
|
|
2704
|
+
var up = this.grid[_i2 - 1][_j2] + this.gap_penalty;
|
|
2705
|
+
var left = this.grid[_i2][_j2 - 1] + this.gap_penalty;
|
|
2706
|
+
var maxOf = [
|
|
2707
|
+
diag,
|
|
2708
|
+
up,
|
|
2709
|
+
left
|
|
2710
|
+
];
|
|
2711
|
+
var indices = this.arrayAllMaxIndexes(maxOf);
|
|
2712
|
+
this.grid[_i2][_j2] = maxOf[indices[0]];
|
|
2713
|
+
this.tracebackGrid[_i2][_j2] = [
|
|
2714
|
+
indices.includes(0),
|
|
2715
|
+
indices.includes(1),
|
|
2716
|
+
indices.includes(2)
|
|
2717
|
+
];
|
|
2718
|
+
}
|
|
2719
|
+
this.score = this.grid[this.iMax - 1][this.jMax - 1];
|
|
2720
|
+
}
|
|
2721
|
+
},
|
|
2722
|
+
{
|
|
2723
|
+
key: "alignmentTraceback",
|
|
2724
|
+
value: function alignmentTraceback() {
|
|
2725
|
+
var inProcessAlignments = [];
|
|
2726
|
+
inProcessAlignments.push({
|
|
2727
|
+
pos: [this.sequence1.length, this.sequence2.length],
|
|
2728
|
+
seq1: "",
|
|
2729
|
+
seq2: ""
|
|
2730
|
+
});
|
|
2731
|
+
while (inProcessAlignments[0]) {
|
|
2732
|
+
var current = inProcessAlignments[0];
|
|
2733
|
+
var directions = this.tracebackGrid[current.pos[0]][current.pos[1]];
|
|
2734
|
+
if (directions[0]) inProcessAlignments.push({
|
|
2735
|
+
pos: [current.pos[0] - 1, current.pos[1] - 1],
|
|
2736
|
+
seq1: this.sequence1[current.pos[0] - 1] + current.seq1,
|
|
2737
|
+
seq2: this.sequence2[current.pos[1] - 1] + current.seq2
|
|
2738
|
+
});
|
|
2739
|
+
if (directions[1]) inProcessAlignments.push({
|
|
2740
|
+
pos: [current.pos[0] - 1, current.pos[1]],
|
|
2741
|
+
seq1: this.sequence1[current.pos[0] - 1] + current.seq1,
|
|
2742
|
+
seq2: "-" + current.seq2
|
|
2743
|
+
});
|
|
2744
|
+
if (directions[2]) inProcessAlignments.push({
|
|
2745
|
+
pos: [current.pos[0], current.pos[1] - 1],
|
|
2746
|
+
seq1: "-" + current.seq1,
|
|
2747
|
+
seq2: this.sequence2[current.pos[1] - 1] + current.seq2
|
|
2748
|
+
});
|
|
2749
|
+
if (current.pos[0] === 0 && current.pos[1] === 0) this.alignments.push({
|
|
2750
|
+
sequence1: current.seq1,
|
|
2751
|
+
sequence2: current.seq2
|
|
2752
|
+
});
|
|
2753
|
+
inProcessAlignments.shift();
|
|
2754
|
+
}
|
|
2755
|
+
return this.alignments;
|
|
2756
|
+
}
|
|
2757
|
+
},
|
|
2758
|
+
{
|
|
2759
|
+
key: "getAllIndexes",
|
|
2760
|
+
value: function getAllIndexes(arr, val) {
|
|
2761
|
+
var indexes = [], i = -1;
|
|
2762
|
+
while ((i = arr.indexOf(val, i + 1)) !== -1) indexes.push(i);
|
|
2763
|
+
return indexes;
|
|
2764
|
+
}
|
|
2765
|
+
},
|
|
2766
|
+
{
|
|
2767
|
+
key: "arrayAllMaxIndexes",
|
|
2768
|
+
value: function arrayAllMaxIndexes(array) {
|
|
2769
|
+
return this.getAllIndexes(array, Math.max.apply(null, array));
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
]);
|
|
2773
|
+
return NeedlemanWunsch;
|
|
2774
|
+
}();
|
|
2775
|
+
}),
|
|
2776
|
+
(function(module$43, exports$40, __webpack_require__) {
|
|
2777
|
+
"use strict";
|
|
2778
|
+
var layoutBase = function layoutBase() {};
|
|
2779
|
+
layoutBase.FDLayout = __webpack_require__(18);
|
|
2780
|
+
layoutBase.FDLayoutConstants = __webpack_require__(7);
|
|
2781
|
+
layoutBase.FDLayoutEdge = __webpack_require__(19);
|
|
2782
|
+
layoutBase.FDLayoutNode = __webpack_require__(20);
|
|
2783
|
+
layoutBase.DimensionD = __webpack_require__(21);
|
|
2784
|
+
layoutBase.HashMap = __webpack_require__(22);
|
|
2785
|
+
layoutBase.HashSet = __webpack_require__(23);
|
|
2786
|
+
layoutBase.IGeometry = __webpack_require__(8);
|
|
2787
|
+
layoutBase.IMath = __webpack_require__(9);
|
|
2788
|
+
layoutBase.Integer = __webpack_require__(10);
|
|
2789
|
+
layoutBase.Point = __webpack_require__(12);
|
|
2790
|
+
layoutBase.PointD = __webpack_require__(4);
|
|
2791
|
+
layoutBase.RandomSeed = __webpack_require__(16);
|
|
2792
|
+
layoutBase.RectangleD = __webpack_require__(13);
|
|
2793
|
+
layoutBase.Transform = __webpack_require__(17);
|
|
2794
|
+
layoutBase.UniqueIDGeneretor = __webpack_require__(14);
|
|
2795
|
+
layoutBase.Quicksort = __webpack_require__(24);
|
|
2796
|
+
layoutBase.LinkedList = __webpack_require__(11);
|
|
2797
|
+
layoutBase.LGraphObject = __webpack_require__(2);
|
|
2798
|
+
layoutBase.LGraph = __webpack_require__(5);
|
|
2799
|
+
layoutBase.LEdge = __webpack_require__(1);
|
|
2800
|
+
layoutBase.LGraphManager = __webpack_require__(6);
|
|
2801
|
+
layoutBase.LNode = __webpack_require__(3);
|
|
2802
|
+
layoutBase.Layout = __webpack_require__(15);
|
|
2803
|
+
layoutBase.LayoutConstants = __webpack_require__(0);
|
|
2804
|
+
layoutBase.NeedlemanWunsch = __webpack_require__(25);
|
|
2805
|
+
module$43.exports = layoutBase;
|
|
2806
|
+
}),
|
|
2807
|
+
(function(module$44, exports$41, __webpack_require__) {
|
|
2808
|
+
"use strict";
|
|
2809
|
+
function Emitter() {
|
|
2810
|
+
this.listeners = [];
|
|
2811
|
+
}
|
|
2812
|
+
var p = Emitter.prototype;
|
|
2813
|
+
p.addListener = function(event, callback) {
|
|
2814
|
+
this.listeners.push({
|
|
2815
|
+
event,
|
|
2816
|
+
callback
|
|
2817
|
+
});
|
|
2818
|
+
};
|
|
2819
|
+
p.removeListener = function(event, callback) {
|
|
2820
|
+
for (var i = this.listeners.length; i >= 0; i--) {
|
|
2821
|
+
var l = this.listeners[i];
|
|
2822
|
+
if (l.event === event && l.callback === callback) this.listeners.splice(i, 1);
|
|
2823
|
+
}
|
|
2824
|
+
};
|
|
2825
|
+
p.emit = function(event, data) {
|
|
2826
|
+
for (var i = 0; i < this.listeners.length; i++) {
|
|
2827
|
+
var l = this.listeners[i];
|
|
2828
|
+
if (event === l.event) l.callback(data);
|
|
2829
|
+
}
|
|
2830
|
+
};
|
|
2831
|
+
module$44.exports = Emitter;
|
|
2832
|
+
})
|
|
2833
|
+
]);
|
|
2834
|
+
});
|
|
2835
|
+
}));
|
|
2836
|
+
|
|
2837
|
+
//#endregion
|
|
2838
|
+
//#region ../../node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js
|
|
2839
|
+
var require_cose_base = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2840
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2841
|
+
if (typeof exports === "object" && typeof module === "object") module.exports = factory(require_layout_base());
|
|
2842
|
+
else if (typeof define === "function" && define.amd) define(["layout-base"], factory);
|
|
2843
|
+
else if (typeof exports === "object") exports["coseBase"] = factory(require_layout_base());
|
|
2844
|
+
else root["coseBase"] = factory(root["layoutBase"]);
|
|
2845
|
+
})(exports, function(__WEBPACK_EXTERNAL_MODULE_0__) {
|
|
2846
|
+
return (function(modules) {
|
|
2847
|
+
var installedModules = {};
|
|
2848
|
+
function __webpack_require__(moduleId) {
|
|
2849
|
+
if (installedModules[moduleId]) return installedModules[moduleId].exports;
|
|
2850
|
+
var module$5 = installedModules[moduleId] = {
|
|
2851
|
+
i: moduleId,
|
|
2852
|
+
l: false,
|
|
2853
|
+
exports: {}
|
|
2854
|
+
};
|
|
2855
|
+
modules[moduleId].call(module$5.exports, module$5, module$5.exports, __webpack_require__);
|
|
2856
|
+
module$5.l = true;
|
|
2857
|
+
return module$5.exports;
|
|
2858
|
+
}
|
|
2859
|
+
__webpack_require__.m = modules;
|
|
2860
|
+
__webpack_require__.c = installedModules;
|
|
2861
|
+
__webpack_require__.i = function(value) {
|
|
2862
|
+
return value;
|
|
2863
|
+
};
|
|
2864
|
+
__webpack_require__.d = function(exports$4, name, getter) {
|
|
2865
|
+
if (!__webpack_require__.o(exports$4, name)) Object.defineProperty(exports$4, name, {
|
|
2866
|
+
configurable: false,
|
|
2867
|
+
enumerable: true,
|
|
2868
|
+
get: getter
|
|
2869
|
+
});
|
|
2870
|
+
};
|
|
2871
|
+
__webpack_require__.n = function(module$6) {
|
|
2872
|
+
var getter = module$6 && module$6.__esModule ? function getDefault() {
|
|
2873
|
+
return module$6["default"];
|
|
2874
|
+
} : function getModuleExports() {
|
|
2875
|
+
return module$6;
|
|
2876
|
+
};
|
|
2877
|
+
__webpack_require__.d(getter, "a", getter);
|
|
2878
|
+
return getter;
|
|
2879
|
+
};
|
|
2880
|
+
__webpack_require__.o = function(object, property) {
|
|
2881
|
+
return Object.prototype.hasOwnProperty.call(object, property);
|
|
2882
|
+
};
|
|
2883
|
+
__webpack_require__.p = "";
|
|
2884
|
+
return __webpack_require__(__webpack_require__.s = 7);
|
|
2885
|
+
})([
|
|
2886
|
+
(function(module$7, exports$5) {
|
|
2887
|
+
module$7.exports = __WEBPACK_EXTERNAL_MODULE_0__;
|
|
2888
|
+
}),
|
|
2889
|
+
(function(module$8, exports$6, __webpack_require__) {
|
|
2890
|
+
"use strict";
|
|
2891
|
+
var FDLayoutConstants = __webpack_require__(0).FDLayoutConstants;
|
|
2892
|
+
function CoSEConstants() {}
|
|
2893
|
+
for (var prop in FDLayoutConstants) CoSEConstants[prop] = FDLayoutConstants[prop];
|
|
2894
|
+
CoSEConstants.DEFAULT_USE_MULTI_LEVEL_SCALING = false;
|
|
2895
|
+
CoSEConstants.DEFAULT_RADIAL_SEPARATION = FDLayoutConstants.DEFAULT_EDGE_LENGTH;
|
|
2896
|
+
CoSEConstants.DEFAULT_COMPONENT_SEPERATION = 60;
|
|
2897
|
+
CoSEConstants.TILE = true;
|
|
2898
|
+
CoSEConstants.TILING_PADDING_VERTICAL = 10;
|
|
2899
|
+
CoSEConstants.TILING_PADDING_HORIZONTAL = 10;
|
|
2900
|
+
CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = false;
|
|
2901
|
+
module$8.exports = CoSEConstants;
|
|
2902
|
+
}),
|
|
2903
|
+
(function(module$9, exports$7, __webpack_require__) {
|
|
2904
|
+
"use strict";
|
|
2905
|
+
var FDLayoutEdge = __webpack_require__(0).FDLayoutEdge;
|
|
2906
|
+
function CoSEEdge(source, target, vEdge) {
|
|
2907
|
+
FDLayoutEdge.call(this, source, target, vEdge);
|
|
2908
|
+
}
|
|
2909
|
+
CoSEEdge.prototype = Object.create(FDLayoutEdge.prototype);
|
|
2910
|
+
for (var prop in FDLayoutEdge) CoSEEdge[prop] = FDLayoutEdge[prop];
|
|
2911
|
+
module$9.exports = CoSEEdge;
|
|
2912
|
+
}),
|
|
2913
|
+
(function(module$10, exports$8, __webpack_require__) {
|
|
2914
|
+
"use strict";
|
|
2915
|
+
var LGraph = __webpack_require__(0).LGraph;
|
|
2916
|
+
function CoSEGraph(parent, graphMgr, vGraph) {
|
|
2917
|
+
LGraph.call(this, parent, graphMgr, vGraph);
|
|
2918
|
+
}
|
|
2919
|
+
CoSEGraph.prototype = Object.create(LGraph.prototype);
|
|
2920
|
+
for (var prop in LGraph) CoSEGraph[prop] = LGraph[prop];
|
|
2921
|
+
module$10.exports = CoSEGraph;
|
|
2922
|
+
}),
|
|
2923
|
+
(function(module$11, exports$9, __webpack_require__) {
|
|
2924
|
+
"use strict";
|
|
2925
|
+
var LGraphManager = __webpack_require__(0).LGraphManager;
|
|
2926
|
+
function CoSEGraphManager(layout) {
|
|
2927
|
+
LGraphManager.call(this, layout);
|
|
2928
|
+
}
|
|
2929
|
+
CoSEGraphManager.prototype = Object.create(LGraphManager.prototype);
|
|
2930
|
+
for (var prop in LGraphManager) CoSEGraphManager[prop] = LGraphManager[prop];
|
|
2931
|
+
module$11.exports = CoSEGraphManager;
|
|
2932
|
+
}),
|
|
2933
|
+
(function(module$12, exports$10, __webpack_require__) {
|
|
2934
|
+
"use strict";
|
|
2935
|
+
var FDLayoutNode = __webpack_require__(0).FDLayoutNode;
|
|
2936
|
+
var IMath = __webpack_require__(0).IMath;
|
|
2937
|
+
function CoSENode(gm, loc, size, vNode) {
|
|
2938
|
+
FDLayoutNode.call(this, gm, loc, size, vNode);
|
|
2939
|
+
}
|
|
2940
|
+
CoSENode.prototype = Object.create(FDLayoutNode.prototype);
|
|
2941
|
+
for (var prop in FDLayoutNode) CoSENode[prop] = FDLayoutNode[prop];
|
|
2942
|
+
CoSENode.prototype.move = function() {
|
|
2943
|
+
var layout = this.graphManager.getLayout();
|
|
2944
|
+
this.displacementX = layout.coolingFactor * (this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.noOfChildren;
|
|
2945
|
+
this.displacementY = layout.coolingFactor * (this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.noOfChildren;
|
|
2946
|
+
if (Math.abs(this.displacementX) > layout.coolingFactor * layout.maxNodeDisplacement) this.displacementX = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementX);
|
|
2947
|
+
if (Math.abs(this.displacementY) > layout.coolingFactor * layout.maxNodeDisplacement) this.displacementY = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementY);
|
|
2948
|
+
if (this.child == null) this.moveBy(this.displacementX, this.displacementY);
|
|
2949
|
+
else if (this.child.getNodes().length == 0) this.moveBy(this.displacementX, this.displacementY);
|
|
2950
|
+
else this.propogateDisplacementToChildren(this.displacementX, this.displacementY);
|
|
2951
|
+
layout.totalDisplacement += Math.abs(this.displacementX) + Math.abs(this.displacementY);
|
|
2952
|
+
this.springForceX = 0;
|
|
2953
|
+
this.springForceY = 0;
|
|
2954
|
+
this.repulsionForceX = 0;
|
|
2955
|
+
this.repulsionForceY = 0;
|
|
2956
|
+
this.gravitationForceX = 0;
|
|
2957
|
+
this.gravitationForceY = 0;
|
|
2958
|
+
this.displacementX = 0;
|
|
2959
|
+
this.displacementY = 0;
|
|
2960
|
+
};
|
|
2961
|
+
CoSENode.prototype.propogateDisplacementToChildren = function(dX, dY) {
|
|
2962
|
+
var nodes = this.getChild().getNodes();
|
|
2963
|
+
var node;
|
|
2964
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
2965
|
+
node = nodes[i];
|
|
2966
|
+
if (node.getChild() == null) {
|
|
2967
|
+
node.moveBy(dX, dY);
|
|
2968
|
+
node.displacementX += dX;
|
|
2969
|
+
node.displacementY += dY;
|
|
2970
|
+
} else node.propogateDisplacementToChildren(dX, dY);
|
|
2971
|
+
}
|
|
2972
|
+
};
|
|
2973
|
+
CoSENode.prototype.setPred1 = function(pred1) {
|
|
2974
|
+
this.pred1 = pred1;
|
|
2975
|
+
};
|
|
2976
|
+
CoSENode.prototype.getPred1 = function() {
|
|
2977
|
+
return pred1;
|
|
2978
|
+
};
|
|
2979
|
+
CoSENode.prototype.getPred2 = function() {
|
|
2980
|
+
return pred2;
|
|
2981
|
+
};
|
|
2982
|
+
CoSENode.prototype.setNext = function(next) {
|
|
2983
|
+
this.next = next;
|
|
2984
|
+
};
|
|
2985
|
+
CoSENode.prototype.getNext = function() {
|
|
2986
|
+
return next;
|
|
2987
|
+
};
|
|
2988
|
+
CoSENode.prototype.setProcessed = function(processed) {
|
|
2989
|
+
this.processed = processed;
|
|
2990
|
+
};
|
|
2991
|
+
CoSENode.prototype.isProcessed = function() {
|
|
2992
|
+
return processed;
|
|
2993
|
+
};
|
|
2994
|
+
module$12.exports = CoSENode;
|
|
2995
|
+
}),
|
|
2996
|
+
(function(module$13, exports$11, __webpack_require__) {
|
|
2997
|
+
"use strict";
|
|
2998
|
+
var FDLayout = __webpack_require__(0).FDLayout;
|
|
2999
|
+
var CoSEGraphManager = __webpack_require__(4);
|
|
3000
|
+
var CoSEGraph = __webpack_require__(3);
|
|
3001
|
+
var CoSENode = __webpack_require__(5);
|
|
3002
|
+
var CoSEEdge = __webpack_require__(2);
|
|
3003
|
+
var CoSEConstants = __webpack_require__(1);
|
|
3004
|
+
var FDLayoutConstants = __webpack_require__(0).FDLayoutConstants;
|
|
3005
|
+
var LayoutConstants = __webpack_require__(0).LayoutConstants;
|
|
3006
|
+
var Point = __webpack_require__(0).Point;
|
|
3007
|
+
var PointD = __webpack_require__(0).PointD;
|
|
3008
|
+
var Layout = __webpack_require__(0).Layout;
|
|
3009
|
+
var Integer = __webpack_require__(0).Integer;
|
|
3010
|
+
var IGeometry = __webpack_require__(0).IGeometry;
|
|
3011
|
+
var LGraph = __webpack_require__(0).LGraph;
|
|
3012
|
+
var Transform = __webpack_require__(0).Transform;
|
|
3013
|
+
function CoSELayout() {
|
|
3014
|
+
FDLayout.call(this);
|
|
3015
|
+
this.toBeTiled = {};
|
|
3016
|
+
}
|
|
3017
|
+
CoSELayout.prototype = Object.create(FDLayout.prototype);
|
|
3018
|
+
for (var prop in FDLayout) CoSELayout[prop] = FDLayout[prop];
|
|
3019
|
+
CoSELayout.prototype.newGraphManager = function() {
|
|
3020
|
+
var gm = new CoSEGraphManager(this);
|
|
3021
|
+
this.graphManager = gm;
|
|
3022
|
+
return gm;
|
|
3023
|
+
};
|
|
3024
|
+
CoSELayout.prototype.newGraph = function(vGraph) {
|
|
3025
|
+
return new CoSEGraph(null, this.graphManager, vGraph);
|
|
3026
|
+
};
|
|
3027
|
+
CoSELayout.prototype.newNode = function(vNode) {
|
|
3028
|
+
return new CoSENode(this.graphManager, vNode);
|
|
3029
|
+
};
|
|
3030
|
+
CoSELayout.prototype.newEdge = function(vEdge) {
|
|
3031
|
+
return new CoSEEdge(null, null, vEdge);
|
|
3032
|
+
};
|
|
3033
|
+
CoSELayout.prototype.initParameters = function() {
|
|
3034
|
+
FDLayout.prototype.initParameters.call(this, arguments);
|
|
3035
|
+
if (!this.isSubLayout) {
|
|
3036
|
+
if (CoSEConstants.DEFAULT_EDGE_LENGTH < 10) this.idealEdgeLength = 10;
|
|
3037
|
+
else this.idealEdgeLength = CoSEConstants.DEFAULT_EDGE_LENGTH;
|
|
3038
|
+
this.useSmartIdealEdgeLengthCalculation = CoSEConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION;
|
|
3039
|
+
this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH;
|
|
3040
|
+
this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH;
|
|
3041
|
+
this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH;
|
|
3042
|
+
this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH;
|
|
3043
|
+
this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR;
|
|
3044
|
+
this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR;
|
|
3045
|
+
this.prunedNodesAll = [];
|
|
3046
|
+
this.growTreeIterations = 0;
|
|
3047
|
+
this.afterGrowthIterations = 0;
|
|
3048
|
+
this.isTreeGrowing = false;
|
|
3049
|
+
this.isGrowthFinished = false;
|
|
3050
|
+
this.coolingCycle = 0;
|
|
3051
|
+
this.maxCoolingCycle = this.maxIterations / FDLayoutConstants.CONVERGENCE_CHECK_PERIOD;
|
|
3052
|
+
this.finalTemperature = FDLayoutConstants.CONVERGENCE_CHECK_PERIOD / this.maxIterations;
|
|
3053
|
+
this.coolingAdjuster = 1;
|
|
3054
|
+
}
|
|
3055
|
+
};
|
|
3056
|
+
CoSELayout.prototype.layout = function() {
|
|
3057
|
+
if (LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED) {
|
|
3058
|
+
this.createBendpoints();
|
|
3059
|
+
this.graphManager.resetAllEdges();
|
|
3060
|
+
}
|
|
3061
|
+
this.level = 0;
|
|
3062
|
+
return this.classicLayout();
|
|
3063
|
+
};
|
|
3064
|
+
CoSELayout.prototype.classicLayout = function() {
|
|
3065
|
+
this.nodesWithGravity = this.calculateNodesToApplyGravitationTo();
|
|
3066
|
+
this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity);
|
|
3067
|
+
this.calcNoOfChildrenForAllNodes();
|
|
3068
|
+
this.graphManager.calcLowestCommonAncestors();
|
|
3069
|
+
this.graphManager.calcInclusionTreeDepths();
|
|
3070
|
+
this.graphManager.getRoot().calcEstimatedSize();
|
|
3071
|
+
this.calcIdealEdgeLengths();
|
|
3072
|
+
if (!this.incremental) {
|
|
3073
|
+
var forest = this.getFlatForest();
|
|
3074
|
+
if (forest.length > 0) this.positionNodesRadially(forest);
|
|
3075
|
+
else {
|
|
3076
|
+
this.reduceTrees();
|
|
3077
|
+
this.graphManager.resetAllNodesToApplyGravitation();
|
|
3078
|
+
var allNodes = new Set(this.getAllNodes());
|
|
3079
|
+
var intersection = this.nodesWithGravity.filter(function(x) {
|
|
3080
|
+
return allNodes.has(x);
|
|
3081
|
+
});
|
|
3082
|
+
this.graphManager.setAllNodesToApplyGravitation(intersection);
|
|
3083
|
+
this.positionNodesRandomly();
|
|
3084
|
+
}
|
|
3085
|
+
} else if (CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL) {
|
|
3086
|
+
this.reduceTrees();
|
|
3087
|
+
this.graphManager.resetAllNodesToApplyGravitation();
|
|
3088
|
+
var allNodes = new Set(this.getAllNodes());
|
|
3089
|
+
var intersection = this.nodesWithGravity.filter(function(x) {
|
|
3090
|
+
return allNodes.has(x);
|
|
3091
|
+
});
|
|
3092
|
+
this.graphManager.setAllNodesToApplyGravitation(intersection);
|
|
3093
|
+
}
|
|
3094
|
+
this.initSpringEmbedder();
|
|
3095
|
+
this.runSpringEmbedder();
|
|
3096
|
+
return true;
|
|
3097
|
+
};
|
|
3098
|
+
CoSELayout.prototype.tick = function() {
|
|
3099
|
+
this.totalIterations++;
|
|
3100
|
+
if (this.totalIterations === this.maxIterations && !this.isTreeGrowing && !this.isGrowthFinished) if (this.prunedNodesAll.length > 0) this.isTreeGrowing = true;
|
|
3101
|
+
else return true;
|
|
3102
|
+
if (this.totalIterations % FDLayoutConstants.CONVERGENCE_CHECK_PERIOD == 0 && !this.isTreeGrowing && !this.isGrowthFinished) {
|
|
3103
|
+
if (this.isConverged()) if (this.prunedNodesAll.length > 0) this.isTreeGrowing = true;
|
|
3104
|
+
else return true;
|
|
3105
|
+
this.coolingCycle++;
|
|
3106
|
+
if (this.layoutQuality == 0) this.coolingAdjuster = this.coolingCycle;
|
|
3107
|
+
else if (this.layoutQuality == 1) this.coolingAdjuster = this.coolingCycle / 3;
|
|
3108
|
+
this.coolingFactor = Math.max(this.initialCoolingFactor - Math.pow(this.coolingCycle, Math.log(100 * (this.initialCoolingFactor - this.finalTemperature)) / Math.log(this.maxCoolingCycle)) / 100 * this.coolingAdjuster, this.finalTemperature);
|
|
3109
|
+
this.animationPeriod = Math.ceil(this.initialAnimationPeriod * Math.sqrt(this.coolingFactor));
|
|
3110
|
+
}
|
|
3111
|
+
if (this.isTreeGrowing) {
|
|
3112
|
+
if (this.growTreeIterations % 10 == 0) if (this.prunedNodesAll.length > 0) {
|
|
3113
|
+
this.graphManager.updateBounds();
|
|
3114
|
+
this.updateGrid();
|
|
3115
|
+
this.growTree(this.prunedNodesAll);
|
|
3116
|
+
this.graphManager.resetAllNodesToApplyGravitation();
|
|
3117
|
+
var allNodes = new Set(this.getAllNodes());
|
|
3118
|
+
var intersection = this.nodesWithGravity.filter(function(x) {
|
|
3119
|
+
return allNodes.has(x);
|
|
3120
|
+
});
|
|
3121
|
+
this.graphManager.setAllNodesToApplyGravitation(intersection);
|
|
3122
|
+
this.graphManager.updateBounds();
|
|
3123
|
+
this.updateGrid();
|
|
3124
|
+
this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL;
|
|
3125
|
+
} else {
|
|
3126
|
+
this.isTreeGrowing = false;
|
|
3127
|
+
this.isGrowthFinished = true;
|
|
3128
|
+
}
|
|
3129
|
+
this.growTreeIterations++;
|
|
3130
|
+
}
|
|
3131
|
+
if (this.isGrowthFinished) {
|
|
3132
|
+
if (this.isConverged()) return true;
|
|
3133
|
+
if (this.afterGrowthIterations % 10 == 0) {
|
|
3134
|
+
this.graphManager.updateBounds();
|
|
3135
|
+
this.updateGrid();
|
|
3136
|
+
}
|
|
3137
|
+
this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL * ((100 - this.afterGrowthIterations) / 100);
|
|
3138
|
+
this.afterGrowthIterations++;
|
|
3139
|
+
}
|
|
3140
|
+
var gridUpdateAllowed = !this.isTreeGrowing && !this.isGrowthFinished;
|
|
3141
|
+
var forceToNodeSurroundingUpdate = this.growTreeIterations % 10 == 1 && this.isTreeGrowing || this.afterGrowthIterations % 10 == 1 && this.isGrowthFinished;
|
|
3142
|
+
this.totalDisplacement = 0;
|
|
3143
|
+
this.graphManager.updateBounds();
|
|
3144
|
+
this.calcSpringForces();
|
|
3145
|
+
this.calcRepulsionForces(gridUpdateAllowed, forceToNodeSurroundingUpdate);
|
|
3146
|
+
this.calcGravitationalForces();
|
|
3147
|
+
this.moveNodes();
|
|
3148
|
+
this.animate();
|
|
3149
|
+
return false;
|
|
3150
|
+
};
|
|
3151
|
+
CoSELayout.prototype.getPositionsData = function() {
|
|
3152
|
+
var allNodes = this.graphManager.getAllNodes();
|
|
3153
|
+
var pData = {};
|
|
3154
|
+
for (var i = 0; i < allNodes.length; i++) {
|
|
3155
|
+
var rect = allNodes[i].rect;
|
|
3156
|
+
var id = allNodes[i].id;
|
|
3157
|
+
pData[id] = {
|
|
3158
|
+
id,
|
|
3159
|
+
x: rect.getCenterX(),
|
|
3160
|
+
y: rect.getCenterY(),
|
|
3161
|
+
w: rect.width,
|
|
3162
|
+
h: rect.height
|
|
3163
|
+
};
|
|
3164
|
+
}
|
|
3165
|
+
return pData;
|
|
3166
|
+
};
|
|
3167
|
+
CoSELayout.prototype.runSpringEmbedder = function() {
|
|
3168
|
+
this.initialAnimationPeriod = 25;
|
|
3169
|
+
this.animationPeriod = this.initialAnimationPeriod;
|
|
3170
|
+
var layoutEnded = false;
|
|
3171
|
+
if (FDLayoutConstants.ANIMATE === "during") this.emit("layoutstarted");
|
|
3172
|
+
else {
|
|
3173
|
+
while (!layoutEnded) layoutEnded = this.tick();
|
|
3174
|
+
this.graphManager.updateBounds();
|
|
3175
|
+
}
|
|
3176
|
+
};
|
|
3177
|
+
CoSELayout.prototype.calculateNodesToApplyGravitationTo = function() {
|
|
3178
|
+
var nodeList = [];
|
|
3179
|
+
var graph;
|
|
3180
|
+
var graphs = this.graphManager.getGraphs();
|
|
3181
|
+
var size = graphs.length;
|
|
3182
|
+
var i;
|
|
3183
|
+
for (i = 0; i < size; i++) {
|
|
3184
|
+
graph = graphs[i];
|
|
3185
|
+
graph.updateConnected();
|
|
3186
|
+
if (!graph.isConnected) nodeList = nodeList.concat(graph.getNodes());
|
|
3187
|
+
}
|
|
3188
|
+
return nodeList;
|
|
3189
|
+
};
|
|
3190
|
+
CoSELayout.prototype.createBendpoints = function() {
|
|
3191
|
+
var edges = [];
|
|
3192
|
+
edges = edges.concat(this.graphManager.getAllEdges());
|
|
3193
|
+
var visited = /* @__PURE__ */ new Set();
|
|
3194
|
+
var i;
|
|
3195
|
+
for (i = 0; i < edges.length; i++) {
|
|
3196
|
+
var edge = edges[i];
|
|
3197
|
+
if (!visited.has(edge)) {
|
|
3198
|
+
var source = edge.getSource();
|
|
3199
|
+
var target = edge.getTarget();
|
|
3200
|
+
if (source == target) {
|
|
3201
|
+
edge.getBendpoints().push(new PointD());
|
|
3202
|
+
edge.getBendpoints().push(new PointD());
|
|
3203
|
+
this.createDummyNodesForBendpoints(edge);
|
|
3204
|
+
visited.add(edge);
|
|
3205
|
+
} else {
|
|
3206
|
+
var edgeList = [];
|
|
3207
|
+
edgeList = edgeList.concat(source.getEdgeListToNode(target));
|
|
3208
|
+
edgeList = edgeList.concat(target.getEdgeListToNode(source));
|
|
3209
|
+
if (!visited.has(edgeList[0])) {
|
|
3210
|
+
if (edgeList.length > 1) {
|
|
3211
|
+
var k;
|
|
3212
|
+
for (k = 0; k < edgeList.length; k++) {
|
|
3213
|
+
var multiEdge = edgeList[k];
|
|
3214
|
+
multiEdge.getBendpoints().push(new PointD());
|
|
3215
|
+
this.createDummyNodesForBendpoints(multiEdge);
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
edgeList.forEach(function(edge) {
|
|
3219
|
+
visited.add(edge);
|
|
3220
|
+
});
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
if (visited.size == edges.length) break;
|
|
3225
|
+
}
|
|
3226
|
+
};
|
|
3227
|
+
CoSELayout.prototype.positionNodesRadially = function(forest) {
|
|
3228
|
+
var currentStartingPoint = new Point(0, 0);
|
|
3229
|
+
var numberOfColumns = Math.ceil(Math.sqrt(forest.length));
|
|
3230
|
+
var height = 0;
|
|
3231
|
+
var currentY = 0;
|
|
3232
|
+
var currentX = 0;
|
|
3233
|
+
var point = new PointD(0, 0);
|
|
3234
|
+
for (var i = 0; i < forest.length; i++) {
|
|
3235
|
+
if (i % numberOfColumns == 0) {
|
|
3236
|
+
currentX = 0;
|
|
3237
|
+
currentY = height;
|
|
3238
|
+
if (i != 0) currentY += CoSEConstants.DEFAULT_COMPONENT_SEPERATION;
|
|
3239
|
+
height = 0;
|
|
3240
|
+
}
|
|
3241
|
+
var tree = forest[i];
|
|
3242
|
+
var centerNode = Layout.findCenterOfTree(tree);
|
|
3243
|
+
currentStartingPoint.x = currentX;
|
|
3244
|
+
currentStartingPoint.y = currentY;
|
|
3245
|
+
point = CoSELayout.radialLayout(tree, centerNode, currentStartingPoint);
|
|
3246
|
+
if (point.y > height) height = Math.floor(point.y);
|
|
3247
|
+
currentX = Math.floor(point.x + CoSEConstants.DEFAULT_COMPONENT_SEPERATION);
|
|
3248
|
+
}
|
|
3249
|
+
this.transform(new PointD(LayoutConstants.WORLD_CENTER_X - point.x / 2, LayoutConstants.WORLD_CENTER_Y - point.y / 2));
|
|
3250
|
+
};
|
|
3251
|
+
CoSELayout.radialLayout = function(tree, centerNode, startingPoint) {
|
|
3252
|
+
var radialSep = Math.max(this.maxDiagonalInTree(tree), CoSEConstants.DEFAULT_RADIAL_SEPARATION);
|
|
3253
|
+
CoSELayout.branchRadialLayout(centerNode, null, 0, 359, 0, radialSep);
|
|
3254
|
+
var bounds = LGraph.calculateBounds(tree);
|
|
3255
|
+
var transform = new Transform();
|
|
3256
|
+
transform.setDeviceOrgX(bounds.getMinX());
|
|
3257
|
+
transform.setDeviceOrgY(bounds.getMinY());
|
|
3258
|
+
transform.setWorldOrgX(startingPoint.x);
|
|
3259
|
+
transform.setWorldOrgY(startingPoint.y);
|
|
3260
|
+
for (var i = 0; i < tree.length; i++) tree[i].transform(transform);
|
|
3261
|
+
var bottomRight = new PointD(bounds.getMaxX(), bounds.getMaxY());
|
|
3262
|
+
return transform.inverseTransformPoint(bottomRight);
|
|
3263
|
+
};
|
|
3264
|
+
CoSELayout.branchRadialLayout = function(node, parentOfNode, startAngle, endAngle, distance, radialSeparation) {
|
|
3265
|
+
var halfInterval = (endAngle - startAngle + 1) / 2;
|
|
3266
|
+
if (halfInterval < 0) halfInterval += 180;
|
|
3267
|
+
var teta = (halfInterval + startAngle) % 360 * IGeometry.TWO_PI / 360;
|
|
3268
|
+
var x_ = distance * Math.cos(teta);
|
|
3269
|
+
var y_ = distance * Math.sin(teta);
|
|
3270
|
+
node.setCenter(x_, y_);
|
|
3271
|
+
var neighborEdges = [];
|
|
3272
|
+
neighborEdges = neighborEdges.concat(node.getEdges());
|
|
3273
|
+
var childCount = neighborEdges.length;
|
|
3274
|
+
if (parentOfNode != null) childCount--;
|
|
3275
|
+
var branchCount = 0;
|
|
3276
|
+
var incEdgesCount = neighborEdges.length;
|
|
3277
|
+
var startIndex;
|
|
3278
|
+
var edges = node.getEdgesBetween(parentOfNode);
|
|
3279
|
+
while (edges.length > 1) {
|
|
3280
|
+
var temp = edges[0];
|
|
3281
|
+
edges.splice(0, 1);
|
|
3282
|
+
var index = neighborEdges.indexOf(temp);
|
|
3283
|
+
if (index >= 0) neighborEdges.splice(index, 1);
|
|
3284
|
+
incEdgesCount--;
|
|
3285
|
+
childCount--;
|
|
3286
|
+
}
|
|
3287
|
+
if (parentOfNode != null) startIndex = (neighborEdges.indexOf(edges[0]) + 1) % incEdgesCount;
|
|
3288
|
+
else startIndex = 0;
|
|
3289
|
+
var stepAngle = Math.abs(endAngle - startAngle) / childCount;
|
|
3290
|
+
for (var i = startIndex; branchCount != childCount; i = ++i % incEdgesCount) {
|
|
3291
|
+
var currentNeighbor = neighborEdges[i].getOtherEnd(node);
|
|
3292
|
+
if (currentNeighbor == parentOfNode) continue;
|
|
3293
|
+
var childStartAngle = (startAngle + branchCount * stepAngle) % 360;
|
|
3294
|
+
var childEndAngle = (childStartAngle + stepAngle) % 360;
|
|
3295
|
+
CoSELayout.branchRadialLayout(currentNeighbor, node, childStartAngle, childEndAngle, distance + radialSeparation, radialSeparation);
|
|
3296
|
+
branchCount++;
|
|
3297
|
+
}
|
|
3298
|
+
};
|
|
3299
|
+
CoSELayout.maxDiagonalInTree = function(tree) {
|
|
3300
|
+
var maxDiagonal = Integer.MIN_VALUE;
|
|
3301
|
+
for (var i = 0; i < tree.length; i++) {
|
|
3302
|
+
var diagonal = tree[i].getDiagonal();
|
|
3303
|
+
if (diagonal > maxDiagonal) maxDiagonal = diagonal;
|
|
3304
|
+
}
|
|
3305
|
+
return maxDiagonal;
|
|
3306
|
+
};
|
|
3307
|
+
CoSELayout.prototype.calcRepulsionRange = function() {
|
|
3308
|
+
return 2 * (this.level + 1) * this.idealEdgeLength;
|
|
3309
|
+
};
|
|
3310
|
+
CoSELayout.prototype.groupZeroDegreeMembers = function() {
|
|
3311
|
+
var self = this;
|
|
3312
|
+
var tempMemberGroups = {};
|
|
3313
|
+
this.memberGroups = {};
|
|
3314
|
+
this.idToDummyNode = {};
|
|
3315
|
+
var zeroDegree = [];
|
|
3316
|
+
var allNodes = this.graphManager.getAllNodes();
|
|
3317
|
+
for (var i = 0; i < allNodes.length; i++) {
|
|
3318
|
+
var node = allNodes[i];
|
|
3319
|
+
var parent = node.getParent();
|
|
3320
|
+
if (this.getNodeDegreeWithChildren(node) === 0 && (parent.id == void 0 || !this.getToBeTiled(parent))) zeroDegree.push(node);
|
|
3321
|
+
}
|
|
3322
|
+
for (var i = 0; i < zeroDegree.length; i++) {
|
|
3323
|
+
var node = zeroDegree[i];
|
|
3324
|
+
var p_id = node.getParent().id;
|
|
3325
|
+
if (typeof tempMemberGroups[p_id] === "undefined") tempMemberGroups[p_id] = [];
|
|
3326
|
+
tempMemberGroups[p_id] = tempMemberGroups[p_id].concat(node);
|
|
3327
|
+
}
|
|
3328
|
+
Object.keys(tempMemberGroups).forEach(function(p_id) {
|
|
3329
|
+
if (tempMemberGroups[p_id].length > 1) {
|
|
3330
|
+
var dummyCompoundId = "DummyCompound_" + p_id;
|
|
3331
|
+
self.memberGroups[dummyCompoundId] = tempMemberGroups[p_id];
|
|
3332
|
+
var parent = tempMemberGroups[p_id][0].getParent();
|
|
3333
|
+
var dummyCompound = new CoSENode(self.graphManager);
|
|
3334
|
+
dummyCompound.id = dummyCompoundId;
|
|
3335
|
+
dummyCompound.paddingLeft = parent.paddingLeft || 0;
|
|
3336
|
+
dummyCompound.paddingRight = parent.paddingRight || 0;
|
|
3337
|
+
dummyCompound.paddingBottom = parent.paddingBottom || 0;
|
|
3338
|
+
dummyCompound.paddingTop = parent.paddingTop || 0;
|
|
3339
|
+
self.idToDummyNode[dummyCompoundId] = dummyCompound;
|
|
3340
|
+
var dummyParentGraph = self.getGraphManager().add(self.newGraph(), dummyCompound);
|
|
3341
|
+
var parentGraph = parent.getChild();
|
|
3342
|
+
parentGraph.add(dummyCompound);
|
|
3343
|
+
for (var i = 0; i < tempMemberGroups[p_id].length; i++) {
|
|
3344
|
+
var node = tempMemberGroups[p_id][i];
|
|
3345
|
+
parentGraph.remove(node);
|
|
3346
|
+
dummyParentGraph.add(node);
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
});
|
|
3350
|
+
};
|
|
3351
|
+
CoSELayout.prototype.clearCompounds = function() {
|
|
3352
|
+
var childGraphMap = {};
|
|
3353
|
+
var idToNode = {};
|
|
3354
|
+
this.performDFSOnCompounds();
|
|
3355
|
+
for (var i = 0; i < this.compoundOrder.length; i++) {
|
|
3356
|
+
idToNode[this.compoundOrder[i].id] = this.compoundOrder[i];
|
|
3357
|
+
childGraphMap[this.compoundOrder[i].id] = [].concat(this.compoundOrder[i].getChild().getNodes());
|
|
3358
|
+
this.graphManager.remove(this.compoundOrder[i].getChild());
|
|
3359
|
+
this.compoundOrder[i].child = null;
|
|
3360
|
+
}
|
|
3361
|
+
this.graphManager.resetAllNodes();
|
|
3362
|
+
this.tileCompoundMembers(childGraphMap, idToNode);
|
|
3363
|
+
};
|
|
3364
|
+
CoSELayout.prototype.clearZeroDegreeMembers = function() {
|
|
3365
|
+
var self = this;
|
|
3366
|
+
var tiledZeroDegreePack = this.tiledZeroDegreePack = [];
|
|
3367
|
+
Object.keys(this.memberGroups).forEach(function(id) {
|
|
3368
|
+
var compoundNode = self.idToDummyNode[id];
|
|
3369
|
+
tiledZeroDegreePack[id] = self.tileNodes(self.memberGroups[id], compoundNode.paddingLeft + compoundNode.paddingRight);
|
|
3370
|
+
compoundNode.rect.width = tiledZeroDegreePack[id].width;
|
|
3371
|
+
compoundNode.rect.height = tiledZeroDegreePack[id].height;
|
|
3372
|
+
});
|
|
3373
|
+
};
|
|
3374
|
+
CoSELayout.prototype.repopulateCompounds = function() {
|
|
3375
|
+
for (var i = this.compoundOrder.length - 1; i >= 0; i--) {
|
|
3376
|
+
var lCompoundNode = this.compoundOrder[i];
|
|
3377
|
+
var id = lCompoundNode.id;
|
|
3378
|
+
var horizontalMargin = lCompoundNode.paddingLeft;
|
|
3379
|
+
var verticalMargin = lCompoundNode.paddingTop;
|
|
3380
|
+
this.adjustLocations(this.tiledMemberPack[id], lCompoundNode.rect.x, lCompoundNode.rect.y, horizontalMargin, verticalMargin);
|
|
3381
|
+
}
|
|
3382
|
+
};
|
|
3383
|
+
CoSELayout.prototype.repopulateZeroDegreeMembers = function() {
|
|
3384
|
+
var self = this;
|
|
3385
|
+
var tiledPack = this.tiledZeroDegreePack;
|
|
3386
|
+
Object.keys(tiledPack).forEach(function(id) {
|
|
3387
|
+
var compoundNode = self.idToDummyNode[id];
|
|
3388
|
+
var horizontalMargin = compoundNode.paddingLeft;
|
|
3389
|
+
var verticalMargin = compoundNode.paddingTop;
|
|
3390
|
+
self.adjustLocations(tiledPack[id], compoundNode.rect.x, compoundNode.rect.y, horizontalMargin, verticalMargin);
|
|
3391
|
+
});
|
|
3392
|
+
};
|
|
3393
|
+
CoSELayout.prototype.getToBeTiled = function(node) {
|
|
3394
|
+
var id = node.id;
|
|
3395
|
+
if (this.toBeTiled[id] != null) return this.toBeTiled[id];
|
|
3396
|
+
var childGraph = node.getChild();
|
|
3397
|
+
if (childGraph == null) {
|
|
3398
|
+
this.toBeTiled[id] = false;
|
|
3399
|
+
return false;
|
|
3400
|
+
}
|
|
3401
|
+
var children = childGraph.getNodes();
|
|
3402
|
+
for (var i = 0; i < children.length; i++) {
|
|
3403
|
+
var theChild = children[i];
|
|
3404
|
+
if (this.getNodeDegree(theChild) > 0) {
|
|
3405
|
+
this.toBeTiled[id] = false;
|
|
3406
|
+
return false;
|
|
3407
|
+
}
|
|
3408
|
+
if (theChild.getChild() == null) {
|
|
3409
|
+
this.toBeTiled[theChild.id] = false;
|
|
3410
|
+
continue;
|
|
3411
|
+
}
|
|
3412
|
+
if (!this.getToBeTiled(theChild)) {
|
|
3413
|
+
this.toBeTiled[id] = false;
|
|
3414
|
+
return false;
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
this.toBeTiled[id] = true;
|
|
3418
|
+
return true;
|
|
3419
|
+
};
|
|
3420
|
+
CoSELayout.prototype.getNodeDegree = function(node) {
|
|
3421
|
+
node.id;
|
|
3422
|
+
var edges = node.getEdges();
|
|
3423
|
+
var degree = 0;
|
|
3424
|
+
for (var i = 0; i < edges.length; i++) {
|
|
3425
|
+
var edge = edges[i];
|
|
3426
|
+
if (edge.getSource().id !== edge.getTarget().id) degree = degree + 1;
|
|
3427
|
+
}
|
|
3428
|
+
return degree;
|
|
3429
|
+
};
|
|
3430
|
+
CoSELayout.prototype.getNodeDegreeWithChildren = function(node) {
|
|
3431
|
+
var degree = this.getNodeDegree(node);
|
|
3432
|
+
if (node.getChild() == null) return degree;
|
|
3433
|
+
var children = node.getChild().getNodes();
|
|
3434
|
+
for (var i = 0; i < children.length; i++) {
|
|
3435
|
+
var child = children[i];
|
|
3436
|
+
degree += this.getNodeDegreeWithChildren(child);
|
|
3437
|
+
}
|
|
3438
|
+
return degree;
|
|
3439
|
+
};
|
|
3440
|
+
CoSELayout.prototype.performDFSOnCompounds = function() {
|
|
3441
|
+
this.compoundOrder = [];
|
|
3442
|
+
this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes());
|
|
3443
|
+
};
|
|
3444
|
+
CoSELayout.prototype.fillCompexOrderByDFS = function(children) {
|
|
3445
|
+
for (var i = 0; i < children.length; i++) {
|
|
3446
|
+
var child = children[i];
|
|
3447
|
+
if (child.getChild() != null) this.fillCompexOrderByDFS(child.getChild().getNodes());
|
|
3448
|
+
if (this.getToBeTiled(child)) this.compoundOrder.push(child);
|
|
3449
|
+
}
|
|
3450
|
+
};
|
|
3451
|
+
/**
|
|
3452
|
+
* This method places each zero degree member wrt given (x,y) coordinates (top left).
|
|
3453
|
+
*/
|
|
3454
|
+
CoSELayout.prototype.adjustLocations = function(organization, x, y, compoundHorizontalMargin, compoundVerticalMargin) {
|
|
3455
|
+
x += compoundHorizontalMargin;
|
|
3456
|
+
y += compoundVerticalMargin;
|
|
3457
|
+
var left = x;
|
|
3458
|
+
for (var i = 0; i < organization.rows.length; i++) {
|
|
3459
|
+
var row = organization.rows[i];
|
|
3460
|
+
x = left;
|
|
3461
|
+
var maxHeight = 0;
|
|
3462
|
+
for (var j = 0; j < row.length; j++) {
|
|
3463
|
+
var lnode = row[j];
|
|
3464
|
+
lnode.rect.x = x;
|
|
3465
|
+
lnode.rect.y = y;
|
|
3466
|
+
x += lnode.rect.width + organization.horizontalPadding;
|
|
3467
|
+
if (lnode.rect.height > maxHeight) maxHeight = lnode.rect.height;
|
|
3468
|
+
}
|
|
3469
|
+
y += maxHeight + organization.verticalPadding;
|
|
3470
|
+
}
|
|
3471
|
+
};
|
|
3472
|
+
CoSELayout.prototype.tileCompoundMembers = function(childGraphMap, idToNode) {
|
|
3473
|
+
var self = this;
|
|
3474
|
+
this.tiledMemberPack = [];
|
|
3475
|
+
Object.keys(childGraphMap).forEach(function(id) {
|
|
3476
|
+
var compoundNode = idToNode[id];
|
|
3477
|
+
self.tiledMemberPack[id] = self.tileNodes(childGraphMap[id], compoundNode.paddingLeft + compoundNode.paddingRight);
|
|
3478
|
+
compoundNode.rect.width = self.tiledMemberPack[id].width;
|
|
3479
|
+
compoundNode.rect.height = self.tiledMemberPack[id].height;
|
|
3480
|
+
});
|
|
3481
|
+
};
|
|
3482
|
+
CoSELayout.prototype.tileNodes = function(nodes, minWidth) {
|
|
3483
|
+
var organization = {
|
|
3484
|
+
rows: [],
|
|
3485
|
+
rowWidth: [],
|
|
3486
|
+
rowHeight: [],
|
|
3487
|
+
width: 0,
|
|
3488
|
+
height: minWidth,
|
|
3489
|
+
verticalPadding: CoSEConstants.TILING_PADDING_VERTICAL,
|
|
3490
|
+
horizontalPadding: CoSEConstants.TILING_PADDING_HORIZONTAL
|
|
3491
|
+
};
|
|
3492
|
+
nodes.sort(function(n1, n2) {
|
|
3493
|
+
if (n1.rect.width * n1.rect.height > n2.rect.width * n2.rect.height) return -1;
|
|
3494
|
+
if (n1.rect.width * n1.rect.height < n2.rect.width * n2.rect.height) return 1;
|
|
3495
|
+
return 0;
|
|
3496
|
+
});
|
|
3497
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
3498
|
+
var lNode = nodes[i];
|
|
3499
|
+
if (organization.rows.length == 0) this.insertNodeToRow(organization, lNode, 0, minWidth);
|
|
3500
|
+
else if (this.canAddHorizontal(organization, lNode.rect.width, lNode.rect.height)) this.insertNodeToRow(organization, lNode, this.getShortestRowIndex(organization), minWidth);
|
|
3501
|
+
else this.insertNodeToRow(organization, lNode, organization.rows.length, minWidth);
|
|
3502
|
+
this.shiftToLastRow(organization);
|
|
3503
|
+
}
|
|
3504
|
+
return organization;
|
|
3505
|
+
};
|
|
3506
|
+
CoSELayout.prototype.insertNodeToRow = function(organization, node, rowIndex, minWidth) {
|
|
3507
|
+
var minCompoundSize = minWidth;
|
|
3508
|
+
if (rowIndex == organization.rows.length) {
|
|
3509
|
+
organization.rows.push([]);
|
|
3510
|
+
organization.rowWidth.push(minCompoundSize);
|
|
3511
|
+
organization.rowHeight.push(0);
|
|
3512
|
+
}
|
|
3513
|
+
var w = organization.rowWidth[rowIndex] + node.rect.width;
|
|
3514
|
+
if (organization.rows[rowIndex].length > 0) w += organization.horizontalPadding;
|
|
3515
|
+
organization.rowWidth[rowIndex] = w;
|
|
3516
|
+
if (organization.width < w) organization.width = w;
|
|
3517
|
+
var h = node.rect.height;
|
|
3518
|
+
if (rowIndex > 0) h += organization.verticalPadding;
|
|
3519
|
+
var extraHeight = 0;
|
|
3520
|
+
if (h > organization.rowHeight[rowIndex]) {
|
|
3521
|
+
extraHeight = organization.rowHeight[rowIndex];
|
|
3522
|
+
organization.rowHeight[rowIndex] = h;
|
|
3523
|
+
extraHeight = organization.rowHeight[rowIndex] - extraHeight;
|
|
3524
|
+
}
|
|
3525
|
+
organization.height += extraHeight;
|
|
3526
|
+
organization.rows[rowIndex].push(node);
|
|
3527
|
+
};
|
|
3528
|
+
CoSELayout.prototype.getShortestRowIndex = function(organization) {
|
|
3529
|
+
var r = -1;
|
|
3530
|
+
var min = Number.MAX_VALUE;
|
|
3531
|
+
for (var i = 0; i < organization.rows.length; i++) if (organization.rowWidth[i] < min) {
|
|
3532
|
+
r = i;
|
|
3533
|
+
min = organization.rowWidth[i];
|
|
3534
|
+
}
|
|
3535
|
+
return r;
|
|
3536
|
+
};
|
|
3537
|
+
CoSELayout.prototype.getLongestRowIndex = function(organization) {
|
|
3538
|
+
var r = -1;
|
|
3539
|
+
var max = Number.MIN_VALUE;
|
|
3540
|
+
for (var i = 0; i < organization.rows.length; i++) if (organization.rowWidth[i] > max) {
|
|
3541
|
+
r = i;
|
|
3542
|
+
max = organization.rowWidth[i];
|
|
3543
|
+
}
|
|
3544
|
+
return r;
|
|
3545
|
+
};
|
|
3546
|
+
/**
|
|
3547
|
+
* This method checks whether adding extra width to the organization violates
|
|
3548
|
+
* the aspect ratio(1) or not.
|
|
3549
|
+
*/
|
|
3550
|
+
CoSELayout.prototype.canAddHorizontal = function(organization, extraWidth, extraHeight) {
|
|
3551
|
+
var sri = this.getShortestRowIndex(organization);
|
|
3552
|
+
if (sri < 0) return true;
|
|
3553
|
+
var min = organization.rowWidth[sri];
|
|
3554
|
+
if (min + organization.horizontalPadding + extraWidth <= organization.width) return true;
|
|
3555
|
+
var hDiff = 0;
|
|
3556
|
+
if (organization.rowHeight[sri] < extraHeight) {
|
|
3557
|
+
if (sri > 0) hDiff = extraHeight + organization.verticalPadding - organization.rowHeight[sri];
|
|
3558
|
+
}
|
|
3559
|
+
var add_to_row_ratio;
|
|
3560
|
+
if (organization.width - min >= extraWidth + organization.horizontalPadding) add_to_row_ratio = (organization.height + hDiff) / (min + extraWidth + organization.horizontalPadding);
|
|
3561
|
+
else add_to_row_ratio = (organization.height + hDiff) / organization.width;
|
|
3562
|
+
hDiff = extraHeight + organization.verticalPadding;
|
|
3563
|
+
var add_new_row_ratio;
|
|
3564
|
+
if (organization.width < extraWidth) add_new_row_ratio = (organization.height + hDiff) / extraWidth;
|
|
3565
|
+
else add_new_row_ratio = (organization.height + hDiff) / organization.width;
|
|
3566
|
+
if (add_new_row_ratio < 1) add_new_row_ratio = 1 / add_new_row_ratio;
|
|
3567
|
+
if (add_to_row_ratio < 1) add_to_row_ratio = 1 / add_to_row_ratio;
|
|
3568
|
+
return add_to_row_ratio < add_new_row_ratio;
|
|
3569
|
+
};
|
|
3570
|
+
CoSELayout.prototype.shiftToLastRow = function(organization) {
|
|
3571
|
+
var longest = this.getLongestRowIndex(organization);
|
|
3572
|
+
var last = organization.rowWidth.length - 1;
|
|
3573
|
+
var row = organization.rows[longest];
|
|
3574
|
+
var node = row[row.length - 1];
|
|
3575
|
+
var diff = node.width + organization.horizontalPadding;
|
|
3576
|
+
if (organization.width - organization.rowWidth[last] > diff && longest != last) {
|
|
3577
|
+
row.splice(-1, 1);
|
|
3578
|
+
organization.rows[last].push(node);
|
|
3579
|
+
organization.rowWidth[longest] = organization.rowWidth[longest] - diff;
|
|
3580
|
+
organization.rowWidth[last] = organization.rowWidth[last] + diff;
|
|
3581
|
+
organization.width = organization.rowWidth[instance.getLongestRowIndex(organization)];
|
|
3582
|
+
var maxHeight = Number.MIN_VALUE;
|
|
3583
|
+
for (var i = 0; i < row.length; i++) if (row[i].height > maxHeight) maxHeight = row[i].height;
|
|
3584
|
+
if (longest > 0) maxHeight += organization.verticalPadding;
|
|
3585
|
+
var prevTotal = organization.rowHeight[longest] + organization.rowHeight[last];
|
|
3586
|
+
organization.rowHeight[longest] = maxHeight;
|
|
3587
|
+
if (organization.rowHeight[last] < node.height + organization.verticalPadding) organization.rowHeight[last] = node.height + organization.verticalPadding;
|
|
3588
|
+
var finalTotal = organization.rowHeight[longest] + organization.rowHeight[last];
|
|
3589
|
+
organization.height += finalTotal - prevTotal;
|
|
3590
|
+
this.shiftToLastRow(organization);
|
|
3591
|
+
}
|
|
3592
|
+
};
|
|
3593
|
+
CoSELayout.prototype.tilingPreLayout = function() {
|
|
3594
|
+
if (CoSEConstants.TILE) {
|
|
3595
|
+
this.groupZeroDegreeMembers();
|
|
3596
|
+
this.clearCompounds();
|
|
3597
|
+
this.clearZeroDegreeMembers();
|
|
3598
|
+
}
|
|
3599
|
+
};
|
|
3600
|
+
CoSELayout.prototype.tilingPostLayout = function() {
|
|
3601
|
+
if (CoSEConstants.TILE) {
|
|
3602
|
+
this.repopulateZeroDegreeMembers();
|
|
3603
|
+
this.repopulateCompounds();
|
|
3604
|
+
}
|
|
3605
|
+
};
|
|
3606
|
+
CoSELayout.prototype.reduceTrees = function() {
|
|
3607
|
+
var prunedNodesAll = [];
|
|
3608
|
+
var containsLeaf = true;
|
|
3609
|
+
var node;
|
|
3610
|
+
while (containsLeaf) {
|
|
3611
|
+
var allNodes = this.graphManager.getAllNodes();
|
|
3612
|
+
var prunedNodesInStepTemp = [];
|
|
3613
|
+
containsLeaf = false;
|
|
3614
|
+
for (var i = 0; i < allNodes.length; i++) {
|
|
3615
|
+
node = allNodes[i];
|
|
3616
|
+
if (node.getEdges().length == 1 && !node.getEdges()[0].isInterGraph && node.getChild() == null) {
|
|
3617
|
+
prunedNodesInStepTemp.push([
|
|
3618
|
+
node,
|
|
3619
|
+
node.getEdges()[0],
|
|
3620
|
+
node.getOwner()
|
|
3621
|
+
]);
|
|
3622
|
+
containsLeaf = true;
|
|
3623
|
+
}
|
|
3624
|
+
}
|
|
3625
|
+
if (containsLeaf == true) {
|
|
3626
|
+
var prunedNodesInStep = [];
|
|
3627
|
+
for (var j = 0; j < prunedNodesInStepTemp.length; j++) if (prunedNodesInStepTemp[j][0].getEdges().length == 1) {
|
|
3628
|
+
prunedNodesInStep.push(prunedNodesInStepTemp[j]);
|
|
3629
|
+
prunedNodesInStepTemp[j][0].getOwner().remove(prunedNodesInStepTemp[j][0]);
|
|
3630
|
+
}
|
|
3631
|
+
prunedNodesAll.push(prunedNodesInStep);
|
|
3632
|
+
this.graphManager.resetAllNodes();
|
|
3633
|
+
this.graphManager.resetAllEdges();
|
|
3634
|
+
}
|
|
3635
|
+
}
|
|
3636
|
+
this.prunedNodesAll = prunedNodesAll;
|
|
3637
|
+
};
|
|
3638
|
+
CoSELayout.prototype.growTree = function(prunedNodesAll) {
|
|
3639
|
+
var prunedNodesInStep = prunedNodesAll[prunedNodesAll.length - 1];
|
|
3640
|
+
var nodeData;
|
|
3641
|
+
for (var i = 0; i < prunedNodesInStep.length; i++) {
|
|
3642
|
+
nodeData = prunedNodesInStep[i];
|
|
3643
|
+
this.findPlaceforPrunedNode(nodeData);
|
|
3644
|
+
nodeData[2].add(nodeData[0]);
|
|
3645
|
+
nodeData[2].add(nodeData[1], nodeData[1].source, nodeData[1].target);
|
|
3646
|
+
}
|
|
3647
|
+
prunedNodesAll.splice(prunedNodesAll.length - 1, 1);
|
|
3648
|
+
this.graphManager.resetAllNodes();
|
|
3649
|
+
this.graphManager.resetAllEdges();
|
|
3650
|
+
};
|
|
3651
|
+
CoSELayout.prototype.findPlaceforPrunedNode = function(nodeData) {
|
|
3652
|
+
var gridForPrunedNode;
|
|
3653
|
+
var nodeToConnect;
|
|
3654
|
+
var prunedNode = nodeData[0];
|
|
3655
|
+
if (prunedNode == nodeData[1].source) nodeToConnect = nodeData[1].target;
|
|
3656
|
+
else nodeToConnect = nodeData[1].source;
|
|
3657
|
+
var startGridX = nodeToConnect.startX;
|
|
3658
|
+
var finishGridX = nodeToConnect.finishX;
|
|
3659
|
+
var startGridY = nodeToConnect.startY;
|
|
3660
|
+
var finishGridY = nodeToConnect.finishY;
|
|
3661
|
+
var controlRegions = [
|
|
3662
|
+
0,
|
|
3663
|
+
0,
|
|
3664
|
+
0,
|
|
3665
|
+
0
|
|
3666
|
+
];
|
|
3667
|
+
if (startGridY > 0) for (var i = startGridX; i <= finishGridX; i++) controlRegions[0] += this.grid[i][startGridY - 1].length + this.grid[i][startGridY].length - 1;
|
|
3668
|
+
if (finishGridX < this.grid.length - 1) for (var i = startGridY; i <= finishGridY; i++) controlRegions[1] += this.grid[finishGridX + 1][i].length + this.grid[finishGridX][i].length - 1;
|
|
3669
|
+
if (finishGridY < this.grid[0].length - 1) for (var i = startGridX; i <= finishGridX; i++) controlRegions[2] += this.grid[i][finishGridY + 1].length + this.grid[i][finishGridY].length - 1;
|
|
3670
|
+
if (startGridX > 0) for (var i = startGridY; i <= finishGridY; i++) controlRegions[3] += this.grid[startGridX - 1][i].length + this.grid[startGridX][i].length - 1;
|
|
3671
|
+
var min = Integer.MAX_VALUE;
|
|
3672
|
+
var minCount;
|
|
3673
|
+
var minIndex;
|
|
3674
|
+
for (var j = 0; j < controlRegions.length; j++) if (controlRegions[j] < min) {
|
|
3675
|
+
min = controlRegions[j];
|
|
3676
|
+
minCount = 1;
|
|
3677
|
+
minIndex = j;
|
|
3678
|
+
} else if (controlRegions[j] == min) minCount++;
|
|
3679
|
+
if (minCount == 3 && min == 0) {
|
|
3680
|
+
if (controlRegions[0] == 0 && controlRegions[1] == 0 && controlRegions[2] == 0) gridForPrunedNode = 1;
|
|
3681
|
+
else if (controlRegions[0] == 0 && controlRegions[1] == 0 && controlRegions[3] == 0) gridForPrunedNode = 0;
|
|
3682
|
+
else if (controlRegions[0] == 0 && controlRegions[2] == 0 && controlRegions[3] == 0) gridForPrunedNode = 3;
|
|
3683
|
+
else if (controlRegions[1] == 0 && controlRegions[2] == 0 && controlRegions[3] == 0) gridForPrunedNode = 2;
|
|
3684
|
+
} else if (minCount == 2 && min == 0) {
|
|
3685
|
+
var random = Math.floor(Math.random() * 2);
|
|
3686
|
+
if (controlRegions[0] == 0 && controlRegions[1] == 0) if (random == 0) gridForPrunedNode = 0;
|
|
3687
|
+
else gridForPrunedNode = 1;
|
|
3688
|
+
else if (controlRegions[0] == 0 && controlRegions[2] == 0) if (random == 0) gridForPrunedNode = 0;
|
|
3689
|
+
else gridForPrunedNode = 2;
|
|
3690
|
+
else if (controlRegions[0] == 0 && controlRegions[3] == 0) if (random == 0) gridForPrunedNode = 0;
|
|
3691
|
+
else gridForPrunedNode = 3;
|
|
3692
|
+
else if (controlRegions[1] == 0 && controlRegions[2] == 0) if (random == 0) gridForPrunedNode = 1;
|
|
3693
|
+
else gridForPrunedNode = 2;
|
|
3694
|
+
else if (controlRegions[1] == 0 && controlRegions[3] == 0) if (random == 0) gridForPrunedNode = 1;
|
|
3695
|
+
else gridForPrunedNode = 3;
|
|
3696
|
+
else if (random == 0) gridForPrunedNode = 2;
|
|
3697
|
+
else gridForPrunedNode = 3;
|
|
3698
|
+
} else if (minCount == 4 && min == 0) {
|
|
3699
|
+
var random = Math.floor(Math.random() * 4);
|
|
3700
|
+
gridForPrunedNode = random;
|
|
3701
|
+
} else gridForPrunedNode = minIndex;
|
|
3702
|
+
if (gridForPrunedNode == 0) prunedNode.setCenter(nodeToConnect.getCenterX(), nodeToConnect.getCenterY() - nodeToConnect.getHeight() / 2 - FDLayoutConstants.DEFAULT_EDGE_LENGTH - prunedNode.getHeight() / 2);
|
|
3703
|
+
else if (gridForPrunedNode == 1) prunedNode.setCenter(nodeToConnect.getCenterX() + nodeToConnect.getWidth() / 2 + FDLayoutConstants.DEFAULT_EDGE_LENGTH + prunedNode.getWidth() / 2, nodeToConnect.getCenterY());
|
|
3704
|
+
else if (gridForPrunedNode == 2) prunedNode.setCenter(nodeToConnect.getCenterX(), nodeToConnect.getCenterY() + nodeToConnect.getHeight() / 2 + FDLayoutConstants.DEFAULT_EDGE_LENGTH + prunedNode.getHeight() / 2);
|
|
3705
|
+
else prunedNode.setCenter(nodeToConnect.getCenterX() - nodeToConnect.getWidth() / 2 - FDLayoutConstants.DEFAULT_EDGE_LENGTH - prunedNode.getWidth() / 2, nodeToConnect.getCenterY());
|
|
3706
|
+
};
|
|
3707
|
+
module$13.exports = CoSELayout;
|
|
3708
|
+
}),
|
|
3709
|
+
(function(module$14, exports$12, __webpack_require__) {
|
|
3710
|
+
"use strict";
|
|
3711
|
+
var coseBase = {};
|
|
3712
|
+
coseBase.layoutBase = __webpack_require__(0);
|
|
3713
|
+
coseBase.CoSEConstants = __webpack_require__(1);
|
|
3714
|
+
coseBase.CoSEEdge = __webpack_require__(2);
|
|
3715
|
+
coseBase.CoSEGraph = __webpack_require__(3);
|
|
3716
|
+
coseBase.CoSEGraphManager = __webpack_require__(4);
|
|
3717
|
+
coseBase.CoSELayout = __webpack_require__(6);
|
|
3718
|
+
coseBase.CoSENode = __webpack_require__(5);
|
|
3719
|
+
module$14.exports = coseBase;
|
|
3720
|
+
})
|
|
3721
|
+
]);
|
|
3722
|
+
});
|
|
3723
|
+
}));
|
|
3724
|
+
|
|
3725
|
+
//#endregion
|
|
3726
|
+
//#region ../../node_modules/.pnpm/cytoscape-cose-bilkent@4.1.0_cytoscape@3.34.3/node_modules/cytoscape-cose-bilkent/cytoscape-cose-bilkent.js
|
|
3727
|
+
var require_cytoscape_cose_bilkent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3728
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3729
|
+
if (typeof exports === "object" && typeof module === "object") module.exports = factory(require_cose_base());
|
|
3730
|
+
else if (typeof define === "function" && define.amd) define(["cose-base"], factory);
|
|
3731
|
+
else if (typeof exports === "object") exports["cytoscapeCoseBilkent"] = factory(require_cose_base());
|
|
3732
|
+
else root["cytoscapeCoseBilkent"] = factory(root["coseBase"]);
|
|
3733
|
+
})(exports, function(__WEBPACK_EXTERNAL_MODULE_0__) {
|
|
3734
|
+
return (function(modules) {
|
|
3735
|
+
var installedModules = {};
|
|
3736
|
+
function __webpack_require__(moduleId) {
|
|
3737
|
+
if (installedModules[moduleId]) return installedModules[moduleId].exports;
|
|
3738
|
+
var module$1 = installedModules[moduleId] = {
|
|
3739
|
+
i: moduleId,
|
|
3740
|
+
l: false,
|
|
3741
|
+
exports: {}
|
|
3742
|
+
};
|
|
3743
|
+
modules[moduleId].call(module$1.exports, module$1, module$1.exports, __webpack_require__);
|
|
3744
|
+
module$1.l = true;
|
|
3745
|
+
return module$1.exports;
|
|
3746
|
+
}
|
|
3747
|
+
__webpack_require__.m = modules;
|
|
3748
|
+
__webpack_require__.c = installedModules;
|
|
3749
|
+
__webpack_require__.i = function(value) {
|
|
3750
|
+
return value;
|
|
3751
|
+
};
|
|
3752
|
+
__webpack_require__.d = function(exports$1, name, getter) {
|
|
3753
|
+
if (!__webpack_require__.o(exports$1, name)) Object.defineProperty(exports$1, name, {
|
|
3754
|
+
configurable: false,
|
|
3755
|
+
enumerable: true,
|
|
3756
|
+
get: getter
|
|
3757
|
+
});
|
|
3758
|
+
};
|
|
3759
|
+
__webpack_require__.n = function(module$2) {
|
|
3760
|
+
var getter = module$2 && module$2.__esModule ? function getDefault() {
|
|
3761
|
+
return module$2["default"];
|
|
3762
|
+
} : function getModuleExports() {
|
|
3763
|
+
return module$2;
|
|
3764
|
+
};
|
|
3765
|
+
__webpack_require__.d(getter, "a", getter);
|
|
3766
|
+
return getter;
|
|
3767
|
+
};
|
|
3768
|
+
__webpack_require__.o = function(object, property) {
|
|
3769
|
+
return Object.prototype.hasOwnProperty.call(object, property);
|
|
3770
|
+
};
|
|
3771
|
+
__webpack_require__.p = "";
|
|
3772
|
+
return __webpack_require__(__webpack_require__.s = 1);
|
|
3773
|
+
})([(function(module$3, exports$2) {
|
|
3774
|
+
module$3.exports = __WEBPACK_EXTERNAL_MODULE_0__;
|
|
3775
|
+
}), (function(module$4, exports$3, __webpack_require__) {
|
|
3776
|
+
"use strict";
|
|
3777
|
+
var LayoutConstants = __webpack_require__(0).layoutBase.LayoutConstants;
|
|
3778
|
+
var FDLayoutConstants = __webpack_require__(0).layoutBase.FDLayoutConstants;
|
|
3779
|
+
var CoSEConstants = __webpack_require__(0).CoSEConstants;
|
|
3780
|
+
var CoSELayout = __webpack_require__(0).CoSELayout;
|
|
3781
|
+
var CoSENode = __webpack_require__(0).CoSENode;
|
|
3782
|
+
var PointD = __webpack_require__(0).layoutBase.PointD;
|
|
3783
|
+
var DimensionD = __webpack_require__(0).layoutBase.DimensionD;
|
|
3784
|
+
var defaults = {
|
|
3785
|
+
ready: function ready() {},
|
|
3786
|
+
stop: function stop() {},
|
|
3787
|
+
quality: "default",
|
|
3788
|
+
nodeDimensionsIncludeLabels: false,
|
|
3789
|
+
refresh: 30,
|
|
3790
|
+
fit: true,
|
|
3791
|
+
padding: 10,
|
|
3792
|
+
randomize: true,
|
|
3793
|
+
nodeRepulsion: 4500,
|
|
3794
|
+
idealEdgeLength: 50,
|
|
3795
|
+
edgeElasticity: .45,
|
|
3796
|
+
nestingFactor: .1,
|
|
3797
|
+
gravity: .25,
|
|
3798
|
+
numIter: 2500,
|
|
3799
|
+
tile: true,
|
|
3800
|
+
animate: "end",
|
|
3801
|
+
animationDuration: 500,
|
|
3802
|
+
tilingPaddingVertical: 10,
|
|
3803
|
+
tilingPaddingHorizontal: 10,
|
|
3804
|
+
gravityRangeCompound: 1.5,
|
|
3805
|
+
gravityCompound: 1,
|
|
3806
|
+
gravityRange: 3.8,
|
|
3807
|
+
initialEnergyOnIncremental: .5
|
|
3808
|
+
};
|
|
3809
|
+
function extend(defaults, options) {
|
|
3810
|
+
var obj = {};
|
|
3811
|
+
for (var i in defaults) obj[i] = defaults[i];
|
|
3812
|
+
for (var i in options) obj[i] = options[i];
|
|
3813
|
+
return obj;
|
|
3814
|
+
}
|
|
3815
|
+
function _CoSELayout(_options) {
|
|
3816
|
+
this.options = extend(defaults, _options);
|
|
3817
|
+
getUserOptions(this.options);
|
|
3818
|
+
}
|
|
3819
|
+
var getUserOptions = function getUserOptions(options) {
|
|
3820
|
+
if (options.nodeRepulsion != null) CoSEConstants.DEFAULT_REPULSION_STRENGTH = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = options.nodeRepulsion;
|
|
3821
|
+
if (options.idealEdgeLength != null) CoSEConstants.DEFAULT_EDGE_LENGTH = FDLayoutConstants.DEFAULT_EDGE_LENGTH = options.idealEdgeLength;
|
|
3822
|
+
if (options.edgeElasticity != null) CoSEConstants.DEFAULT_SPRING_STRENGTH = FDLayoutConstants.DEFAULT_SPRING_STRENGTH = options.edgeElasticity;
|
|
3823
|
+
if (options.nestingFactor != null) CoSEConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = options.nestingFactor;
|
|
3824
|
+
if (options.gravity != null) CoSEConstants.DEFAULT_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = options.gravity;
|
|
3825
|
+
if (options.numIter != null) CoSEConstants.MAX_ITERATIONS = FDLayoutConstants.MAX_ITERATIONS = options.numIter;
|
|
3826
|
+
if (options.gravityRange != null) CoSEConstants.DEFAULT_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = options.gravityRange;
|
|
3827
|
+
if (options.gravityCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = options.gravityCompound;
|
|
3828
|
+
if (options.gravityRangeCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = options.gravityRangeCompound;
|
|
3829
|
+
if (options.initialEnergyOnIncremental != null) CoSEConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = options.initialEnergyOnIncremental;
|
|
3830
|
+
if (options.quality == "draft") LayoutConstants.QUALITY = 0;
|
|
3831
|
+
else if (options.quality == "proof") LayoutConstants.QUALITY = 2;
|
|
3832
|
+
else LayoutConstants.QUALITY = 1;
|
|
3833
|
+
CoSEConstants.NODE_DIMENSIONS_INCLUDE_LABELS = FDLayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = options.nodeDimensionsIncludeLabels;
|
|
3834
|
+
CoSEConstants.DEFAULT_INCREMENTAL = FDLayoutConstants.DEFAULT_INCREMENTAL = LayoutConstants.DEFAULT_INCREMENTAL = !options.randomize;
|
|
3835
|
+
CoSEConstants.ANIMATE = FDLayoutConstants.ANIMATE = LayoutConstants.ANIMATE = options.animate;
|
|
3836
|
+
CoSEConstants.TILE = options.tile;
|
|
3837
|
+
CoSEConstants.TILING_PADDING_VERTICAL = typeof options.tilingPaddingVertical === "function" ? options.tilingPaddingVertical.call() : options.tilingPaddingVertical;
|
|
3838
|
+
CoSEConstants.TILING_PADDING_HORIZONTAL = typeof options.tilingPaddingHorizontal === "function" ? options.tilingPaddingHorizontal.call() : options.tilingPaddingHorizontal;
|
|
3839
|
+
};
|
|
3840
|
+
_CoSELayout.prototype.run = function() {
|
|
3841
|
+
var ready;
|
|
3842
|
+
var frameId;
|
|
3843
|
+
var options = this.options;
|
|
3844
|
+
this.idToLNode = {};
|
|
3845
|
+
var layout = this.layout = new CoSELayout();
|
|
3846
|
+
var self = this;
|
|
3847
|
+
self.stopped = false;
|
|
3848
|
+
this.cy = this.options.cy;
|
|
3849
|
+
this.cy.trigger({
|
|
3850
|
+
type: "layoutstart",
|
|
3851
|
+
layout: this
|
|
3852
|
+
});
|
|
3853
|
+
var gm = layout.newGraphManager();
|
|
3854
|
+
this.gm = gm;
|
|
3855
|
+
var nodes = this.options.eles.nodes();
|
|
3856
|
+
var edges = this.options.eles.edges();
|
|
3857
|
+
this.root = gm.addRoot();
|
|
3858
|
+
this.processChildrenList(this.root, this.getTopMostNodes(nodes), layout);
|
|
3859
|
+
for (var i = 0; i < edges.length; i++) {
|
|
3860
|
+
var edge = edges[i];
|
|
3861
|
+
var sourceNode = this.idToLNode[edge.data("source")];
|
|
3862
|
+
var targetNode = this.idToLNode[edge.data("target")];
|
|
3863
|
+
if (sourceNode !== targetNode && sourceNode.getEdgesBetween(targetNode).length == 0) {
|
|
3864
|
+
var e1 = gm.add(layout.newEdge(), sourceNode, targetNode);
|
|
3865
|
+
e1.id = edge.id();
|
|
3866
|
+
}
|
|
3867
|
+
}
|
|
3868
|
+
var getPositions = function getPositions(ele, i) {
|
|
3869
|
+
if (typeof ele === "number") ele = i;
|
|
3870
|
+
var theId = ele.data("id");
|
|
3871
|
+
var lNode = self.idToLNode[theId];
|
|
3872
|
+
return {
|
|
3873
|
+
x: lNode.getRect().getCenterX(),
|
|
3874
|
+
y: lNode.getRect().getCenterY()
|
|
3875
|
+
};
|
|
3876
|
+
};
|
|
3877
|
+
var iterateAnimated = function iterateAnimated() {
|
|
3878
|
+
var afterReposition = function afterReposition() {
|
|
3879
|
+
if (options.fit) options.cy.fit(options.eles, options.padding);
|
|
3880
|
+
if (!ready) {
|
|
3881
|
+
ready = true;
|
|
3882
|
+
self.cy.one("layoutready", options.ready);
|
|
3883
|
+
self.cy.trigger({
|
|
3884
|
+
type: "layoutready",
|
|
3885
|
+
layout: self
|
|
3886
|
+
});
|
|
3887
|
+
}
|
|
3888
|
+
};
|
|
3889
|
+
var ticksPerFrame = self.options.refresh;
|
|
3890
|
+
var isDone;
|
|
3891
|
+
for (var i = 0; i < ticksPerFrame && !isDone; i++) isDone = self.stopped || self.layout.tick();
|
|
3892
|
+
if (isDone) {
|
|
3893
|
+
if (layout.checkLayoutSuccess() && !layout.isSubLayout) layout.doPostLayout();
|
|
3894
|
+
if (layout.tilingPostLayout) layout.tilingPostLayout();
|
|
3895
|
+
layout.isLayoutFinished = true;
|
|
3896
|
+
self.options.eles.nodes().positions(getPositions);
|
|
3897
|
+
afterReposition();
|
|
3898
|
+
self.cy.one("layoutstop", self.options.stop);
|
|
3899
|
+
self.cy.trigger({
|
|
3900
|
+
type: "layoutstop",
|
|
3901
|
+
layout: self
|
|
3902
|
+
});
|
|
3903
|
+
if (frameId) cancelAnimationFrame(frameId);
|
|
3904
|
+
ready = false;
|
|
3905
|
+
return;
|
|
3906
|
+
}
|
|
3907
|
+
var animationData = self.layout.getPositionsData();
|
|
3908
|
+
options.eles.nodes().positions(function(ele, i) {
|
|
3909
|
+
if (typeof ele === "number") ele = i;
|
|
3910
|
+
if (!ele.isParent()) {
|
|
3911
|
+
var theId = ele.id();
|
|
3912
|
+
var pNode = animationData[theId];
|
|
3913
|
+
var temp = ele;
|
|
3914
|
+
while (pNode == null) {
|
|
3915
|
+
pNode = animationData[temp.data("parent")] || animationData["DummyCompound_" + temp.data("parent")];
|
|
3916
|
+
animationData[theId] = pNode;
|
|
3917
|
+
temp = temp.parent()[0];
|
|
3918
|
+
if (temp == void 0) break;
|
|
3919
|
+
}
|
|
3920
|
+
if (pNode != null) return {
|
|
3921
|
+
x: pNode.x,
|
|
3922
|
+
y: pNode.y
|
|
3923
|
+
};
|
|
3924
|
+
else return {
|
|
3925
|
+
x: ele.position("x"),
|
|
3926
|
+
y: ele.position("y")
|
|
3927
|
+
};
|
|
3928
|
+
}
|
|
3929
|
+
});
|
|
3930
|
+
afterReposition();
|
|
3931
|
+
frameId = requestAnimationFrame(iterateAnimated);
|
|
3932
|
+
};
|
|
3933
|
+
layout.addListener("layoutstarted", function() {
|
|
3934
|
+
if (self.options.animate === "during") frameId = requestAnimationFrame(iterateAnimated);
|
|
3935
|
+
});
|
|
3936
|
+
layout.runLayout();
|
|
3937
|
+
if (this.options.animate !== "during") {
|
|
3938
|
+
self.options.eles.nodes().not(":parent").layoutPositions(self, self.options, getPositions);
|
|
3939
|
+
ready = false;
|
|
3940
|
+
}
|
|
3941
|
+
return this;
|
|
3942
|
+
};
|
|
3943
|
+
_CoSELayout.prototype.getTopMostNodes = function(nodes) {
|
|
3944
|
+
var nodesMap = {};
|
|
3945
|
+
for (var i = 0; i < nodes.length; i++) nodesMap[nodes[i].id()] = true;
|
|
3946
|
+
return nodes.filter(function(ele, i) {
|
|
3947
|
+
if (typeof ele === "number") ele = i;
|
|
3948
|
+
var parent = ele.parent()[0];
|
|
3949
|
+
while (parent != null) {
|
|
3950
|
+
if (nodesMap[parent.id()]) return false;
|
|
3951
|
+
parent = parent.parent()[0];
|
|
3952
|
+
}
|
|
3953
|
+
return true;
|
|
3954
|
+
});
|
|
3955
|
+
};
|
|
3956
|
+
_CoSELayout.prototype.processChildrenList = function(parent, children, layout) {
|
|
3957
|
+
var size = children.length;
|
|
3958
|
+
for (var i = 0; i < size; i++) {
|
|
3959
|
+
var theChild = children[i];
|
|
3960
|
+
var children_of_children = theChild.children();
|
|
3961
|
+
var theNode;
|
|
3962
|
+
var dimensions = theChild.layoutDimensions({ nodeDimensionsIncludeLabels: this.options.nodeDimensionsIncludeLabels });
|
|
3963
|
+
if (theChild.outerWidth() != null && theChild.outerHeight() != null) theNode = parent.add(new CoSENode(layout.graphManager, new PointD(theChild.position("x") - dimensions.w / 2, theChild.position("y") - dimensions.h / 2), new DimensionD(parseFloat(dimensions.w), parseFloat(dimensions.h))));
|
|
3964
|
+
else theNode = parent.add(new CoSENode(this.graphManager));
|
|
3965
|
+
theNode.id = theChild.data("id");
|
|
3966
|
+
theNode.paddingLeft = parseInt(theChild.css("padding"));
|
|
3967
|
+
theNode.paddingTop = parseInt(theChild.css("padding"));
|
|
3968
|
+
theNode.paddingRight = parseInt(theChild.css("padding"));
|
|
3969
|
+
theNode.paddingBottom = parseInt(theChild.css("padding"));
|
|
3970
|
+
if (this.options.nodeDimensionsIncludeLabels) {
|
|
3971
|
+
if (theChild.isParent()) {
|
|
3972
|
+
var labelWidth = theChild.boundingBox({
|
|
3973
|
+
includeLabels: true,
|
|
3974
|
+
includeNodes: false
|
|
3975
|
+
}).w;
|
|
3976
|
+
var labelHeight = theChild.boundingBox({
|
|
3977
|
+
includeLabels: true,
|
|
3978
|
+
includeNodes: false
|
|
3979
|
+
}).h;
|
|
3980
|
+
var labelPos = theChild.css("text-halign");
|
|
3981
|
+
theNode.labelWidth = labelWidth;
|
|
3982
|
+
theNode.labelHeight = labelHeight;
|
|
3983
|
+
theNode.labelPos = labelPos;
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3986
|
+
this.idToLNode[theChild.data("id")] = theNode;
|
|
3987
|
+
if (isNaN(theNode.rect.x)) theNode.rect.x = 0;
|
|
3988
|
+
if (isNaN(theNode.rect.y)) theNode.rect.y = 0;
|
|
3989
|
+
if (children_of_children != null && children_of_children.length > 0) {
|
|
3990
|
+
var theNewGraph = layout.getGraphManager().add(layout.newGraph(), theNode);
|
|
3991
|
+
this.processChildrenList(theNewGraph, children_of_children, layout);
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
};
|
|
3995
|
+
/**
|
|
3996
|
+
* @brief : called on continuous layouts to stop them before they finish
|
|
3997
|
+
*/
|
|
3998
|
+
_CoSELayout.prototype.stop = function() {
|
|
3999
|
+
this.stopped = true;
|
|
4000
|
+
return this;
|
|
4001
|
+
};
|
|
4002
|
+
var register = function register(cytoscape) {
|
|
4003
|
+
cytoscape("layout", "cose-bilkent", _CoSELayout);
|
|
4004
|
+
};
|
|
4005
|
+
if (typeof cytoscape !== "undefined") register(cytoscape);
|
|
4006
|
+
module$4.exports = register;
|
|
4007
|
+
})]);
|
|
4008
|
+
});
|
|
4009
|
+
}));
|
|
4010
|
+
|
|
4011
|
+
//#endregion
|
|
4012
|
+
//#region ../../node_modules/.pnpm/mermaid@12.0.0/node_modules/mermaid/dist/chunks/mermaid.core/cose-bilkent-JH36ORCC.mjs
|
|
4013
|
+
var import_cytoscape_cose_bilkent = /* @__PURE__ */ __toESM(require_cytoscape_cose_bilkent(), 1);
|
|
4014
|
+
cytoscape$1.use(import_cytoscape_cose_bilkent.default);
|
|
4015
|
+
function addNodes(nodes, cy) {
|
|
4016
|
+
nodes.forEach((node) => {
|
|
4017
|
+
const nodeData = {
|
|
4018
|
+
id: node.id,
|
|
4019
|
+
labelText: node.label,
|
|
4020
|
+
height: node.height,
|
|
4021
|
+
width: node.width,
|
|
4022
|
+
padding: node.padding ?? 0
|
|
4023
|
+
};
|
|
4024
|
+
Object.keys(node).forEach((key) => {
|
|
4025
|
+
if (![
|
|
4026
|
+
"id",
|
|
4027
|
+
"label",
|
|
4028
|
+
"height",
|
|
4029
|
+
"width",
|
|
4030
|
+
"padding",
|
|
4031
|
+
"x",
|
|
4032
|
+
"y"
|
|
4033
|
+
].includes(key)) nodeData[key] = node[key];
|
|
4034
|
+
});
|
|
4035
|
+
cy.add({
|
|
4036
|
+
group: "nodes",
|
|
4037
|
+
data: nodeData,
|
|
4038
|
+
position: {
|
|
4039
|
+
x: node.x ?? 0,
|
|
4040
|
+
y: node.y ?? 0
|
|
4041
|
+
}
|
|
4042
|
+
});
|
|
4043
|
+
});
|
|
4044
|
+
}
|
|
4045
|
+
__name(addNodes, "addNodes");
|
|
4046
|
+
function addEdges(edges, cy) {
|
|
4047
|
+
edges.forEach((edge) => {
|
|
4048
|
+
const edgeData = {
|
|
4049
|
+
id: edge.id,
|
|
4050
|
+
source: edge.start,
|
|
4051
|
+
target: edge.end
|
|
4052
|
+
};
|
|
4053
|
+
Object.keys(edge).forEach((key) => {
|
|
4054
|
+
if (![
|
|
4055
|
+
"id",
|
|
4056
|
+
"start",
|
|
4057
|
+
"end"
|
|
4058
|
+
].includes(key)) edgeData[key] = edge[key];
|
|
4059
|
+
});
|
|
4060
|
+
cy.add({
|
|
4061
|
+
group: "edges",
|
|
4062
|
+
data: edgeData
|
|
4063
|
+
});
|
|
4064
|
+
});
|
|
4065
|
+
}
|
|
4066
|
+
__name(addEdges, "addEdges");
|
|
4067
|
+
function createCytoscapeInstance(data) {
|
|
4068
|
+
return new Promise((resolve) => {
|
|
4069
|
+
const renderEl = select_default("body").append("div").attr("id", "cy").attr("style", "display:none");
|
|
4070
|
+
const cy = cytoscape$1({
|
|
4071
|
+
container: document.getElementById("cy"),
|
|
4072
|
+
style: [{
|
|
4073
|
+
selector: "edge",
|
|
4074
|
+
style: { "curve-style": "bezier" }
|
|
4075
|
+
}]
|
|
4076
|
+
});
|
|
4077
|
+
renderEl.remove();
|
|
4078
|
+
addNodes(data.nodes, cy);
|
|
4079
|
+
addEdges(data.edges, cy);
|
|
4080
|
+
cy.nodes().forEach(function(n) {
|
|
4081
|
+
n.layoutDimensions = () => {
|
|
4082
|
+
const nodeData = n.data();
|
|
4083
|
+
return {
|
|
4084
|
+
w: nodeData.width,
|
|
4085
|
+
h: nodeData.height
|
|
4086
|
+
};
|
|
4087
|
+
};
|
|
4088
|
+
});
|
|
4089
|
+
cy.layout({
|
|
4090
|
+
name: "cose-bilkent",
|
|
4091
|
+
quality: "proof",
|
|
4092
|
+
styleEnabled: false,
|
|
4093
|
+
animate: false
|
|
4094
|
+
}).run();
|
|
4095
|
+
cy.ready((e) => {
|
|
4096
|
+
log.info("Cytoscape ready", e);
|
|
4097
|
+
resolve(cy);
|
|
4098
|
+
});
|
|
4099
|
+
});
|
|
4100
|
+
}
|
|
4101
|
+
__name(createCytoscapeInstance, "createCytoscapeInstance");
|
|
4102
|
+
function extractPositionedNodes(cy) {
|
|
4103
|
+
return cy.nodes().map((node) => {
|
|
4104
|
+
const data = node.data();
|
|
4105
|
+
const position = node.position();
|
|
4106
|
+
const positionedNode = {
|
|
4107
|
+
id: data.id,
|
|
4108
|
+
x: position.x,
|
|
4109
|
+
y: position.y
|
|
4110
|
+
};
|
|
4111
|
+
Object.keys(data).forEach((key) => {
|
|
4112
|
+
if (key !== "id") positionedNode[key] = data[key];
|
|
4113
|
+
});
|
|
4114
|
+
return positionedNode;
|
|
4115
|
+
});
|
|
4116
|
+
}
|
|
4117
|
+
__name(extractPositionedNodes, "extractPositionedNodes");
|
|
4118
|
+
function extractPositionedEdges(cy) {
|
|
4119
|
+
return cy.edges().map((edge) => {
|
|
4120
|
+
const data = edge.data();
|
|
4121
|
+
const rscratch = edge._private.rscratch;
|
|
4122
|
+
const positionedEdge = {
|
|
4123
|
+
id: data.id,
|
|
4124
|
+
source: data.source,
|
|
4125
|
+
target: data.target,
|
|
4126
|
+
startX: rscratch.startX,
|
|
4127
|
+
startY: rscratch.startY,
|
|
4128
|
+
midX: rscratch.midX,
|
|
4129
|
+
midY: rscratch.midY,
|
|
4130
|
+
endX: rscratch.endX,
|
|
4131
|
+
endY: rscratch.endY
|
|
4132
|
+
};
|
|
4133
|
+
Object.keys(data).forEach((key) => {
|
|
4134
|
+
if (![
|
|
4135
|
+
"id",
|
|
4136
|
+
"source",
|
|
4137
|
+
"target"
|
|
4138
|
+
].includes(key)) positionedEdge[key] = data[key];
|
|
4139
|
+
});
|
|
4140
|
+
return positionedEdge;
|
|
4141
|
+
});
|
|
4142
|
+
}
|
|
4143
|
+
__name(extractPositionedEdges, "extractPositionedEdges");
|
|
4144
|
+
async function executeCoseBilkentLayout(data, _config) {
|
|
4145
|
+
log.debug("Starting cose-bilkent layout algorithm");
|
|
4146
|
+
try {
|
|
4147
|
+
validateLayoutData(data);
|
|
4148
|
+
const cy = await createCytoscapeInstance(data);
|
|
4149
|
+
const positionedNodes = extractPositionedNodes(cy);
|
|
4150
|
+
const positionedEdges = extractPositionedEdges(cy);
|
|
4151
|
+
log.debug(`Layout completed: ${positionedNodes.length} nodes, ${positionedEdges.length} edges`);
|
|
4152
|
+
return {
|
|
4153
|
+
nodes: positionedNodes,
|
|
4154
|
+
edges: positionedEdges
|
|
4155
|
+
};
|
|
4156
|
+
} catch (error) {
|
|
4157
|
+
log.error("Error in cose-bilkent layout algorithm:", error);
|
|
4158
|
+
throw error;
|
|
4159
|
+
}
|
|
4160
|
+
}
|
|
4161
|
+
__name(executeCoseBilkentLayout, "executeCoseBilkentLayout");
|
|
4162
|
+
function validateLayoutData(data) {
|
|
4163
|
+
if (!data) throw new Error("Layout data is required");
|
|
4164
|
+
if (!data.config) throw new Error("Configuration is required in layout data");
|
|
4165
|
+
if (!data.rootNode) throw new Error("Root node is required");
|
|
4166
|
+
if (!data.nodes || !Array.isArray(data.nodes)) throw new Error("No nodes found in layout data");
|
|
4167
|
+
if (!Array.isArray(data.edges)) throw new Error("Edges array is required in layout data");
|
|
4168
|
+
return true;
|
|
4169
|
+
}
|
|
4170
|
+
__name(validateLayoutData, "validateLayoutData");
|
|
4171
|
+
var render2 = /* @__PURE__ */ __name(async (data4Layout, svg, { insertCluster, insertEdge, insertEdgeLabel, insertMarkers, insertNode, log: log2, positionEdgeLabel }, { algorithm: _algorithm }) => {
|
|
4172
|
+
const nodeDb = {};
|
|
4173
|
+
const clusterDb = {};
|
|
4174
|
+
const element = svg.select("g");
|
|
4175
|
+
insertMarkers(element, data4Layout.markers, data4Layout.type, data4Layout.diagramId);
|
|
4176
|
+
const subGraphsEl = element.insert("g").attr("class", "subgraphs");
|
|
4177
|
+
const edgePaths = element.insert("g").attr("class", "edgePaths");
|
|
4178
|
+
const edgeLabels = element.insert("g").attr("class", "edgeLabels");
|
|
4179
|
+
const nodes = element.insert("g").attr("class", "nodes");
|
|
4180
|
+
log2.debug("Inserting nodes into DOM for dimension calculation");
|
|
4181
|
+
await Promise.all(data4Layout.nodes.map(async (node) => {
|
|
4182
|
+
if (node.isGroup) {
|
|
4183
|
+
const clusterNode = { ...node };
|
|
4184
|
+
clusterDb[node.id] = clusterNode;
|
|
4185
|
+
nodeDb[node.id] = clusterNode;
|
|
4186
|
+
await insertCluster(subGraphsEl, node);
|
|
4187
|
+
} else {
|
|
4188
|
+
const nodeWithPosition = { ...node };
|
|
4189
|
+
nodeDb[node.id] = nodeWithPosition;
|
|
4190
|
+
const nodeEl = await insertNode(nodes, node, {
|
|
4191
|
+
config: data4Layout.config,
|
|
4192
|
+
dir: data4Layout.direction || "TB"
|
|
4193
|
+
});
|
|
4194
|
+
const boundingBox = nodeEl.node().getBBox();
|
|
4195
|
+
nodeWithPosition.width = boundingBox.width;
|
|
4196
|
+
nodeWithPosition.height = boundingBox.height;
|
|
4197
|
+
nodeWithPosition.domId = nodeEl;
|
|
4198
|
+
log2.debug(`Node ${node.id} dimensions: ${boundingBox.width}x${boundingBox.height}`);
|
|
4199
|
+
}
|
|
4200
|
+
}));
|
|
4201
|
+
log2.debug("Running cose-bilkent layout algorithm");
|
|
4202
|
+
const layoutResult = await executeCoseBilkentLayout({
|
|
4203
|
+
...data4Layout,
|
|
4204
|
+
nodes: data4Layout.nodes.map((node) => {
|
|
4205
|
+
const nodeWithDimensions = nodeDb[node.id];
|
|
4206
|
+
return {
|
|
4207
|
+
...node,
|
|
4208
|
+
width: nodeWithDimensions.width,
|
|
4209
|
+
height: nodeWithDimensions.height
|
|
4210
|
+
};
|
|
4211
|
+
})
|
|
4212
|
+
}, data4Layout.config);
|
|
4213
|
+
log2.debug("Positioning nodes based on layout results");
|
|
4214
|
+
layoutResult.nodes.forEach((positionedNode) => {
|
|
4215
|
+
const node = nodeDb[positionedNode.id];
|
|
4216
|
+
if (node?.domId) {
|
|
4217
|
+
node.domId.attr("transform", `translate(${positionedNode.x}, ${positionedNode.y})`);
|
|
4218
|
+
node.x = positionedNode.x;
|
|
4219
|
+
node.y = positionedNode.y;
|
|
4220
|
+
log2.debug(`Positioned node ${node.id} at center (${positionedNode.x}, ${positionedNode.y})`);
|
|
4221
|
+
}
|
|
4222
|
+
});
|
|
4223
|
+
layoutResult.edges.forEach((positionedEdge) => {
|
|
4224
|
+
const edge = data4Layout.edges.find((e) => e.id === positionedEdge.id);
|
|
4225
|
+
if (edge) edge.points = [
|
|
4226
|
+
{
|
|
4227
|
+
x: positionedEdge.startX,
|
|
4228
|
+
y: positionedEdge.startY
|
|
4229
|
+
},
|
|
4230
|
+
{
|
|
4231
|
+
x: positionedEdge.midX,
|
|
4232
|
+
y: positionedEdge.midY
|
|
4233
|
+
},
|
|
4234
|
+
{
|
|
4235
|
+
x: positionedEdge.endX,
|
|
4236
|
+
y: positionedEdge.endY
|
|
4237
|
+
}
|
|
4238
|
+
];
|
|
4239
|
+
});
|
|
4240
|
+
log2.debug("Inserting and positioning edges");
|
|
4241
|
+
await Promise.all(data4Layout.edges.map(async (edge) => {
|
|
4242
|
+
await insertEdgeLabel(edgeLabels, edge);
|
|
4243
|
+
const startNode = nodeDb[edge.start ?? ""];
|
|
4244
|
+
const endNode = nodeDb[edge.end ?? ""];
|
|
4245
|
+
if (startNode && endNode) {
|
|
4246
|
+
const positionedEdge = layoutResult.edges.find((e) => e.id === edge.id);
|
|
4247
|
+
if (positionedEdge) {
|
|
4248
|
+
log2.debug("APA01 positionedEdge", positionedEdge);
|
|
4249
|
+
const edgeWithPath = { ...edge };
|
|
4250
|
+
positionEdgeLabel(edgeWithPath, insertEdge(edgePaths, edgeWithPath, clusterDb, data4Layout.type, startNode, endNode, data4Layout.diagramId));
|
|
4251
|
+
} else {
|
|
4252
|
+
const edgeWithPath = {
|
|
4253
|
+
...edge,
|
|
4254
|
+
points: [{
|
|
4255
|
+
x: startNode.x || 0,
|
|
4256
|
+
y: startNode.y || 0
|
|
4257
|
+
}, {
|
|
4258
|
+
x: endNode.x || 0,
|
|
4259
|
+
y: endNode.y || 0
|
|
4260
|
+
}]
|
|
4261
|
+
};
|
|
4262
|
+
positionEdgeLabel(edgeWithPath, insertEdge(edgePaths, edgeWithPath, clusterDb, data4Layout.type, startNode, endNode, data4Layout.diagramId));
|
|
4263
|
+
}
|
|
4264
|
+
}
|
|
4265
|
+
}));
|
|
4266
|
+
log2.debug("Cose-bilkent rendering completed");
|
|
4267
|
+
}, "render");
|
|
4268
|
+
|
|
4269
|
+
//#endregion
|
|
4270
|
+
export { render2 as render };
|