1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var __extends = (this && this.__extends) || (function () {
|
7 | var extendStatics = function (d, b) {
|
8 | extendStatics = Object.setPrototypeOf ||
|
9 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
10 | function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
11 | return extendStatics(d, b);
|
12 | };
|
13 | return function (d, b) {
|
14 | extendStatics(d, b);
|
15 | function __() { this.constructor = d; }
|
16 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
17 | };
|
18 | })();
|
19 | Object.defineProperty(exports, "__esModule", { value: true });
|
20 | exports.RandomLayout = void 0;
|
21 | var base_1 = require("./base");
|
22 |
|
23 |
|
24 |
|
25 | var RandomLayout = (function (_super) {
|
26 | __extends(RandomLayout, _super);
|
27 | function RandomLayout(options) {
|
28 | var _this = _super.call(this) || this;
|
29 |
|
30 | _this.center = [0, 0];
|
31 |
|
32 | _this.width = 300;
|
33 |
|
34 | _this.height = 300;
|
35 | _this.nodes = [];
|
36 | _this.edges = [];
|
37 | _this.updateCfg(options);
|
38 | return _this;
|
39 | }
|
40 | RandomLayout.prototype.getDefaultCfg = function () {
|
41 | return {
|
42 | center: [0, 0],
|
43 | width: 300,
|
44 | height: 300,
|
45 | };
|
46 | };
|
47 | |
48 |
|
49 |
|
50 | RandomLayout.prototype.execute = function () {
|
51 | var self = this;
|
52 | var nodes = self.nodes;
|
53 | var layoutScale = 0.9;
|
54 | var center = self.center;
|
55 | if (!self.width && typeof window !== 'undefined') {
|
56 | self.width = window.innerWidth;
|
57 | }
|
58 | if (!self.height && typeof window !== 'undefined') {
|
59 | self.height = window.innerHeight;
|
60 | }
|
61 | if (nodes) {
|
62 | nodes.forEach(function (node) {
|
63 | node.x = (Math.random() - 0.5) * layoutScale * self.width + center[0];
|
64 | node.y = (Math.random() - 0.5) * layoutScale * self.height + center[1];
|
65 | });
|
66 | }
|
67 | return {
|
68 | nodes: nodes,
|
69 | edges: this.edges,
|
70 | };
|
71 | };
|
72 | RandomLayout.prototype.getType = function () {
|
73 | return 'random';
|
74 | };
|
75 | return RandomLayout;
|
76 | }(base_1.Base));
|
77 | exports.RandomLayout = RandomLayout;
|
78 |
|
\ | No newline at end of file |