@linkurious/ogma-linkurious-parser 3.1.13 → 4.0.1

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.
Files changed (39) hide show
  1. package/dist/captions/captions.js +42 -54
  2. package/dist/captions/captions.js.map +1 -1
  3. package/dist/filters/filters.d.ts +1 -1
  4. package/dist/filters/filters.js +55 -76
  5. package/dist/filters/filters.js.map +1 -1
  6. package/dist/index.js +34 -33
  7. package/dist/index.js.map +1 -1
  8. package/dist/ogma/features/OgmaStore.js +16 -30
  9. package/dist/ogma/features/OgmaStore.js.map +1 -1
  10. package/dist/ogma/features/captions.js +43 -87
  11. package/dist/ogma/features/captions.js.map +1 -1
  12. package/dist/ogma/features/reactive.js +58 -75
  13. package/dist/ogma/features/reactive.js.map +1 -1
  14. package/dist/ogma/features/selectors.d.ts +5 -5
  15. package/dist/ogma/features/selectors.js +25 -16
  16. package/dist/ogma/features/selectors.js.map +1 -1
  17. package/dist/ogma/features/styles.js +115 -137
  18. package/dist/ogma/features/styles.js.map +1 -1
  19. package/dist/ogma/features/transformations.js +39 -87
  20. package/dist/ogma/features/transformations.js.map +1 -1
  21. package/dist/ogma/index.js +140 -230
  22. package/dist/ogma/index.js.map +1 -1
  23. package/dist/styles/edgeAttributes.js +31 -47
  24. package/dist/styles/edgeAttributes.js.map +1 -1
  25. package/dist/styles/itemAttributes.js +33 -42
  26. package/dist/styles/itemAttributes.js.map +1 -1
  27. package/dist/styles/nodeAttributes.js +49 -71
  28. package/dist/styles/nodeAttributes.js.map +1 -1
  29. package/dist/styles/styleRule.js +57 -68
  30. package/dist/styles/styleRule.js.map +1 -1
  31. package/dist/styles/styleRules.js +150 -192
  32. package/dist/styles/styleRules.js.map +1 -1
  33. package/dist/tools/colorPalette.js +1 -0
  34. package/dist/tools/colorPalette.js.map +1 -1
  35. package/dist/tools/ogmaTool.js +28 -30
  36. package/dist/tools/ogmaTool.js.map +1 -1
  37. package/dist/tools/tools.js +88 -91
  38. package/dist/tools/tools.js.map +1 -1
  39. package/package.json +7 -7
@@ -1,28 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __assign = (this && this.__assign) || function () {
16
- __assign = Object.assign || function(t) {
17
- for (var s, i = 1, n = arguments.length; i < n; i++) {
18
- s = arguments[i];
19
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
- t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -32,61 +8,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
33
9
  });
34
10
  };
35
- var __generator = (this && this.__generator) || function (thisArg, body) {
36
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
37
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
38
- function verb(n) { return function (v) { return step([n, v]); }; }
39
- function step(op) {
40
- if (f) throw new TypeError("Generator is already executing.");
41
- while (_) try {
42
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
43
- if (y = 0, t) op = [op[0] & 2, t.value];
44
- switch (op[0]) {
45
- case 0: case 1: t = op; break;
46
- case 4: _.label++; return { value: op[1], done: false };
47
- case 5: _.label++; y = op[1]; op = [0]; continue;
48
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
49
- default:
50
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
51
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
52
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
53
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
54
- if (t[2]) _.ops.pop();
55
- _.trys.pop(); continue;
56
- }
57
- op = body.call(thisArg, _);
58
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
59
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
60
- }
61
- };
62
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
63
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
64
13
  };
65
14
  Object.defineProperty(exports, "__esModule", { value: true });
66
- var rest_client_1 = require("@linkurious/rest-client");
67
- var ogma_1 = __importDefault(require("@linkurious/ogma"));
68
- var __1 = require("..");
69
- var tools_1 = require("../tools/tools");
70
- var styles_1 = require("./features/styles");
71
- var transformations_1 = require("./features/transformations");
72
- var captions_1 = require("./features/captions");
73
- var reactive_1 = require("./features/reactive");
15
+ exports.LKOgma = exports.ANIMATION_DURATION = exports.Ogma = void 0;
16
+ const rest_client_1 = require("@linkurious/rest-client");
17
+ const ogma_1 = __importDefault(require("@linkurious/ogma"));
18
+ const __1 = require("..");
19
+ const tools_1 = require("../tools/tools");
20
+ const styles_1 = require("./features/styles");
21
+ const transformations_1 = require("./features/transformations");
22
+ const captions_1 = require("./features/captions");
23
+ const reactive_1 = require("./features/reactive");
74
24
  var ogma_2 = require("@linkurious/ogma");
75
- exports.Ogma = ogma_2.default;
25
+ Object.defineProperty(exports, "Ogma", { enumerable: true, get: function () { return __importDefault(ogma_2).default; } });
76
26
  exports.ANIMATION_DURATION = 750;
77
- var LKOgma = /** @class */ (function (_super) {
78
- __extends(LKOgma, _super);
79
- function LKOgma(_configuration) {
80
- var _newTarget = this.constructor;
81
- var _this =
27
+ class LKOgma extends ogma_1.default {
28
+ constructor(_configuration) {
82
29
  // set Ogma global configuration
83
- _super.call(this, _configuration) || this;
84
- _this._configuration = _configuration;
85
- Object.setPrototypeOf(_this, _newTarget.prototype);
86
- _this.initOgmaLinkuriousParser(true);
87
- return _this;
30
+ super(_configuration);
31
+ this._configuration = _configuration;
32
+ Object.setPrototypeOf(this, new.target.prototype);
33
+ this.initOgmaLinkuriousParser(true);
88
34
  }
89
- LKOgma.prototype.initOgmaLinkuriousParser = function (init) {
35
+ initOgmaLinkuriousParser(init) {
90
36
  this.nodeCategoriesWatcher = this.schema.watchNodeNonObjectProperty({
91
37
  path: 'categories',
92
38
  unwindArrays: true,
@@ -100,7 +46,7 @@ var LKOgma = /** @class */ (function (_super) {
100
46
  this.setOptions({
101
47
  interactions: {
102
48
  zoom: {
103
- maxValue: function (params) {
49
+ maxValue: (params) => {
104
50
  return 128 / params.smallestNodeSize;
105
51
  }
106
52
  },
@@ -125,22 +71,21 @@ var LKOgma = /** @class */ (function (_super) {
125
71
  this.LKStyles.setEdgesDefaultHalo();
126
72
  this.LKStyles.setBadgeRule();
127
73
  this.LKStyles.setFilterClass();
128
- };
74
+ }
129
75
  /**
130
76
  * Initialize selection behavior
131
77
  */
132
- LKOgma.prototype.initSelection = function () {
133
- var _this = this;
134
- this.events.onClick(function (e) {
78
+ initSelection() {
79
+ this.events.onClick((e) => {
135
80
  if (e !== undefined && e.button === 'left') {
136
81
  if (e.target !== null) {
137
- var multiSelectionKey = navigator.platform === 'MacIntel' ? 'cmd' : 'ctrl';
138
- if (_this.keyboard.isKeyPressed(multiSelectionKey)) {
139
- if (e.target.isNode && _this.getSelectedEdges().size > 0) {
140
- _this.getSelectedEdges().setSelected(false);
82
+ const multiSelectionKey = navigator.platform === 'MacIntel' ? 'cmd' : 'ctrl';
83
+ if (this.keyboard.isKeyPressed(multiSelectionKey)) {
84
+ if (e.target.isNode && this.getSelectedEdges().size > 0) {
85
+ this.getSelectedEdges().setSelected(false);
141
86
  }
142
- if (!e.target.isNode && _this.getSelectedNodes().size > 0) {
143
- _this.getSelectedNodes().setSelected(false);
87
+ if (!e.target.isNode && this.getSelectedNodes().size > 0) {
88
+ this.getSelectedNodes().setSelected(false);
144
89
  }
145
90
  if (e.target.isSelected()) {
146
91
  e.target.setSelected(false);
@@ -150,39 +95,38 @@ var LKOgma = /** @class */ (function (_super) {
150
95
  }
151
96
  }
152
97
  else {
153
- _this.getSelectedNodes().setSelected(false);
154
- _this.getSelectedEdges().setSelected(false);
98
+ this.getSelectedNodes().setSelected(false);
99
+ this.getSelectedEdges().setSelected(false);
155
100
  e.target.setSelected(true);
156
101
  }
157
102
  }
158
103
  else {
159
- _this.getSelectedNodes().setSelected(false);
160
- _this.getSelectedEdges().setSelected(false);
104
+ this.getSelectedNodes().setSelected(false);
105
+ this.getSelectedEdges().setSelected(false);
161
106
  }
162
107
  }
163
108
  });
164
- };
165
- LKOgma.prototype.setStyles = function (configuration) {
166
- var _a, _b, _c, _d, _e, _f;
109
+ }
110
+ setStyles(configuration) {
111
+ var _a, _b, _c, _d;
167
112
  this.LKStyles = new styles_1.StylesViz(this, {
168
- node: ((_c = (_b = (_a = configuration) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.styles) === null || _c === void 0 ? void 0 : _c.node) || {},
169
- edge: ((_f = (_e = (_d = configuration) === null || _d === void 0 ? void 0 : _d.options) === null || _e === void 0 ? void 0 : _e.styles) === null || _f === void 0 ? void 0 : _f.edge) || {}
113
+ node: ((_b = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.options) === null || _a === void 0 ? void 0 : _a.styles) === null || _b === void 0 ? void 0 : _b.node) || {},
114
+ edge: ((_d = (_c = configuration === null || configuration === void 0 ? void 0 : configuration.options) === null || _c === void 0 ? void 0 : _c.styles) === null || _d === void 0 ? void 0 : _d.edge) || {}
170
115
  });
171
116
  this.LKStyles.setNodesDefaultStyles();
172
117
  this.LKStyles.setEdgesDefaultStyles();
173
- };
174
- LKOgma.prototype.setCaptions = function (configuration) {
175
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
176
- var nodeMaxTextLength = (_e = (_d = (_c = (_b = (_a = configuration) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.styles) === null || _c === void 0 ? void 0 : _c.node) === null || _d === void 0 ? void 0 : _d.text) === null || _e === void 0 ? void 0 : _e.maxTextLength;
177
- var edgeMaxTextLength = (_k = (_j = (_h = (_g = (_f = configuration) === null || _f === void 0 ? void 0 : _f.options) === null || _g === void 0 ? void 0 : _g.styles) === null || _h === void 0 ? void 0 : _h.edge) === null || _j === void 0 ? void 0 : _j.text) === null || _k === void 0 ? void 0 : _k.maxTextLength;
118
+ }
119
+ setCaptions(configuration) {
120
+ var _a, _b, _c, _d, _e, _f, _g, _h;
121
+ const nodeMaxTextLength = (_d = (_c = (_b = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.options) === null || _a === void 0 ? void 0 : _a.styles) === null || _b === void 0 ? void 0 : _b.node) === null || _c === void 0 ? void 0 : _c.text) === null || _d === void 0 ? void 0 : _d.maxTextLength;
122
+ const edgeMaxTextLength = (_h = (_g = (_f = (_e = configuration === null || configuration === void 0 ? void 0 : configuration.options) === null || _e === void 0 ? void 0 : _e.styles) === null || _f === void 0 ? void 0 : _f.edge) === null || _g === void 0 ? void 0 : _g.text) === null || _h === void 0 ? void 0 : _h.maxTextLength;
178
123
  this.LKCaptions = new captions_1.CaptionsViz(this, nodeMaxTextLength, edgeMaxTextLength);
179
- };
124
+ }
180
125
  /**
181
126
  * Returns Ogma Layout parameters according to visualization layout settings
182
127
  * */
183
- LKOgma.prototype.getForceLayoutParams = function (mode, duration) {
184
- if (duration === void 0) { duration = 0; }
185
- var dynamicSteps = 300 - ((300 - 40) / 5000) * this.getNodes().size;
128
+ getForceLayoutParams(mode, duration = 0) {
129
+ let dynamicSteps = 300 - ((300 - 40) / 5000) * this.getNodes().size;
186
130
  if (dynamicSteps < 40) {
187
131
  dynamicSteps = 40;
188
132
  }
@@ -194,9 +138,8 @@ var LKOgma = /** @class */ (function (_super) {
194
138
  gravity: 0.08,
195
139
  theta: this.getNodes().size > 100 ? 0.8 : 0.34
196
140
  };
197
- };
198
- LKOgma.prototype.getRadialLayoutParams = function (rootNode, duration) {
199
- if (duration === void 0) { duration = 0; }
141
+ }
142
+ getRadialLayoutParams(rootNode, duration = 0) {
200
143
  return {
201
144
  centralNode: rootNode,
202
145
  radiusDelta: 1,
@@ -204,197 +147,164 @@ var LKOgma = /** @class */ (function (_super) {
204
147
  repulsion: this.getNodes().size > 80 ? 1 : 6,
205
148
  duration: duration
206
149
  };
207
- };
208
- LKOgma.prototype.getHierarchicalLayoutParams = function (mode, rootNode, duration) {
209
- if (duration === void 0) { duration = 0; }
150
+ }
151
+ getHierarchicalLayoutParams(mode, rootNode, duration = 0) {
210
152
  return {
211
153
  direction: mode,
212
154
  roots: [rootNode],
213
155
  duration: duration
214
156
  };
215
- };
157
+ }
216
158
  /**
217
159
  * Initialize graph.
218
160
  * add nodes and edges to the viz and init the selection.
219
161
  */
220
- LKOgma.prototype.init = function (visualization) {
221
- return __awaiter(this, void 0, void 0, function () {
222
- var selectedEntityType, selectedElements, fixedNodes, fixedEdges;
223
- return __generator(this, function (_a) {
224
- switch (_a.label) {
225
- case 0:
226
- this.clearGraph();
227
- selectedEntityType = undefined;
228
- selectedElements = [];
229
- fixedNodes = visualization.nodes.map(function (node) {
230
- if (node.attributes.selected) {
231
- selectedEntityType = rest_client_1.EntityType.NODE;
232
- selectedElements.push(node.id);
233
- }
234
- delete node.attributes.selected;
235
- return node;
236
- });
237
- fixedEdges = visualization.edges.map(function (edge) {
238
- if (edge.attributes !== undefined) {
239
- if (edge.attributes.selected) {
240
- if (selectedEntityType === undefined || selectedEntityType === rest_client_1.EntityType.NODE) {
241
- selectedEntityType = rest_client_1.EntityType.EDGE;
242
- selectedElements = [];
243
- }
244
- selectedElements.push(edge.id);
245
- }
246
- delete edge.attributes.selected;
247
- }
248
- return edge;
249
- });
250
- return [4 /*yield*/, this.addGraphAfterValidation({
251
- nodes: fixedNodes,
252
- edges: fixedEdges
253
- })];
254
- case 1:
255
- _a.sent();
256
- if (selectedEntityType === rest_client_1.EntityType.NODE) {
257
- this.getNodes(selectedElements).setSelected(true);
258
- }
259
- else if (selectedEntityType === rest_client_1.EntityType.EDGE) {
260
- this.getEdges(selectedElements).setSelected(true);
162
+ init(visualization) {
163
+ return __awaiter(this, void 0, void 0, function* () {
164
+ this.clearGraph();
165
+ let selectedEntityType = undefined;
166
+ let selectedElements = [];
167
+ // need to remove selected in every items before adding them to Ogma
168
+ const fixedNodes = visualization.nodes.map((node) => {
169
+ if (node.attributes.selected) {
170
+ selectedEntityType = rest_client_1.EntityType.NODE;
171
+ selectedElements.push(node.id);
172
+ }
173
+ delete node.attributes.selected;
174
+ return node;
175
+ });
176
+ const fixedEdges = visualization.edges.map((edge) => {
177
+ if (edge.attributes !== undefined) {
178
+ if (edge.attributes.selected) {
179
+ if (selectedEntityType === undefined || selectedEntityType === rest_client_1.EntityType.NODE) {
180
+ selectedEntityType = rest_client_1.EntityType.EDGE;
181
+ selectedElements = [];
261
182
  }
262
- return [2 /*return*/];
183
+ selectedElements.push(edge.id);
184
+ }
185
+ delete edge.attributes.selected;
263
186
  }
187
+ return edge;
188
+ });
189
+ yield this.addGraphAfterValidation({
190
+ nodes: fixedNodes,
191
+ edges: fixedEdges
264
192
  });
193
+ if (selectedEntityType === rest_client_1.EntityType.NODE) {
194
+ this.getNodes(selectedElements).setSelected(true);
195
+ }
196
+ else if (selectedEntityType === rest_client_1.EntityType.EDGE) {
197
+ this.getEdges(selectedElements).setSelected(true);
198
+ }
265
199
  });
266
- };
267
- LKOgma.prototype.initVisualization = function (visualization) {
268
- return __awaiter(this, void 0, void 0, function () {
269
- var styles;
270
- return __generator(this, function (_a) {
271
- switch (_a.label) {
272
- case 0: return [4 /*yield*/, this.init(visualization)];
273
- case 1:
274
- _a.sent();
275
- styles = __1.StyleRules.sanitizeStylesIndex(visualization.design.styles);
276
- this.LKStyles.initNodeColors(styles.node);
277
- this.LKStyles.initNodesIcons(styles.node);
278
- this.LKStyles.initNodesSizes(styles.node);
279
- this.LKStyles.initNodesShapes(styles.node);
280
- this.LKStyles.initEdgesWidth(styles.edge);
281
- this.LKStyles.initEdgesShape(styles.edge);
282
- this.LKStyles.initEdgesColor(styles.edge);
283
- return [4 /*yield*/, this.LKCaptions.initVizCaptions({
284
- node: visualization.nodeFields.captions || {},
285
- edge: visualization.edgeFields.captions || {}
286
- })];
287
- case 2:
288
- _a.sent();
289
- this.LKTransformation.groupedEdges = visualization.edgeGrouping;
290
- return [4 /*yield*/, this.LKTransformation.initTransformation()];
291
- case 3:
292
- _a.sent();
293
- this.LKTransformation.initEdgeGroupingStyle();
294
- return [2 /*return*/];
295
- }
200
+ }
201
+ initVisualization(visualization) {
202
+ return __awaiter(this, void 0, void 0, function* () {
203
+ yield this.init(visualization);
204
+ const styles = __1.StyleRules.sanitizeStylesIndex(visualization.design.styles);
205
+ this.LKStyles.initNodeColors(styles.node);
206
+ this.LKStyles.initNodesIcons(styles.node);
207
+ this.LKStyles.initNodesSizes(styles.node);
208
+ this.LKStyles.initNodesShapes(styles.node);
209
+ this.LKStyles.initEdgesWidth(styles.edge);
210
+ this.LKStyles.initEdgesShape(styles.edge);
211
+ this.LKStyles.initEdgesColor(styles.edge);
212
+ yield this.LKCaptions.initVizCaptions({
213
+ node: visualization.nodeFields.captions || {},
214
+ edge: visualization.edgeFields.captions || {}
296
215
  });
216
+ this.LKTransformation.groupedEdges = visualization.edgeGrouping;
217
+ yield this.LKTransformation.initTransformation();
218
+ this.LKTransformation.initEdgeGroupingStyle();
297
219
  });
298
- };
220
+ }
299
221
  /**
300
222
  * Adding nodes then adding edges to the graph
301
223
  */
302
- LKOgma.prototype.addGraphAfterValidation = function (graph) {
303
- return __awaiter(this, void 0, void 0, function () {
304
- var addedNodes, addedEdges;
305
- return __generator(this, function (_a) {
306
- switch (_a.label) {
307
- case 0: return [4 /*yield*/, this.addNodes(graph.nodes)];
308
- case 1:
309
- addedNodes = _a.sent();
310
- return [4 /*yield*/, this.addEdges(graph.edges)];
311
- case 2:
312
- addedEdges = _a.sent();
313
- return [2 /*return*/, {
314
- nodes: addedNodes,
315
- edges: addedEdges
316
- }];
317
- }
318
- });
224
+ addGraphAfterValidation(graph) {
225
+ return __awaiter(this, void 0, void 0, function* () {
226
+ const addedNodes = yield this.addNodes(graph.nodes);
227
+ const addedEdges = yield this.addEdges(graph.edges);
228
+ return {
229
+ nodes: addedNodes,
230
+ edges: addedEdges
231
+ };
319
232
  });
320
- };
233
+ }
321
234
  /**
322
235
  * Adding edges to the graph after filtering disconnected ones
323
236
  */
324
- LKOgma.prototype.addEdges = function (edges, options) {
325
- var _this = this;
326
- var filteredEdges = edges.filter(function (edge) {
327
- return _this.getNode(edge.source) !== undefined && _this.getNode(edge.target) !== undefined;
237
+ addEdges(edges, options) {
238
+ const filteredEdges = edges.filter((edge) => {
239
+ return this.getNode(edge.source) !== undefined && this.getNode(edge.target) !== undefined;
328
240
  });
329
- return _super.prototype.addEdges.call(this, filteredEdges, options);
330
- };
241
+ return super.addEdges(filteredEdges, options);
242
+ }
331
243
  /**
332
244
  * Return the list of non filtered nodes
333
245
  */
334
- LKOgma.prototype.getNonFilteredNodes = function (items) {
246
+ getNonFilteredNodes(items) {
335
247
  return tools_1.Tools.isDefined(items)
336
- ? this.getNodes(items).filter(function (i) { return !i.hasClass('filtered'); })
337
- : this.getNodes().filter(function (i) { return !i.hasClass('filtered'); });
338
- };
248
+ ? this.getNodes(items).filter((i) => !i.hasClass('filtered'))
249
+ : this.getNodes().filter((i) => !i.hasClass('filtered'));
250
+ }
339
251
  /**
340
252
  * Return the list of filtered nodes
341
253
  */
342
- LKOgma.prototype.getFilteredNodes = function (items) {
254
+ getFilteredNodes(items) {
343
255
  return tools_1.Tools.isDefined(items)
344
- ? this.getNodes(items).filter(function (i) { return i.hasClass('filtered'); })
345
- : this.getNodes().filter(function (i) { return i.hasClass('filtered'); });
346
- };
256
+ ? this.getNodes(items).filter((i) => i.hasClass('filtered'))
257
+ : this.getNodes().filter((i) => i.hasClass('filtered'));
258
+ }
347
259
  /**
348
260
  * Return the list of non filtered edges
349
261
  */
350
- LKOgma.prototype.getNonFilteredEdges = function (items) {
262
+ getNonFilteredEdges(items) {
351
263
  return tools_1.Tools.isDefined(items)
352
- ? this.getEdges(items).filter(function (i) { return !i.hasClass('filtered'); })
353
- : this.getEdges('raw').filter(function (i) { return !i.hasClass('filtered'); });
354
- };
264
+ ? this.getEdges(items).filter((i) => !i.hasClass('filtered'))
265
+ : this.getEdges('raw').filter((i) => !i.hasClass('filtered'));
266
+ }
355
267
  /**
356
268
  * Return the list of filtered edges
357
269
  */
358
- LKOgma.prototype.getFilteredEdges = function (items, filter) {
359
- if (filter === void 0) { filter = 'raw'; }
270
+ getFilteredEdges(items, filter = 'raw') {
360
271
  return tools_1.Tools.isDefined(items)
361
- ? this.getEdges(items).filter(function (i) { return i.hasClass('filtered'); })
362
- : this.getEdges(filter).filter(function (i) { return i.hasClass('filtered'); });
363
- };
272
+ ? this.getEdges(items).filter((i) => i.hasClass('filtered'))
273
+ : this.getEdges(filter).filter((i) => i.hasClass('filtered'));
274
+ }
364
275
  /**
365
276
  * Do a full reset on ogma and streams of ogma
366
277
  */
367
- LKOgma.prototype.shutDown = function () {
278
+ shutDown() {
368
279
  this.destroy();
369
280
  if (this.store) {
370
281
  this.store.clear();
371
282
  }
372
- };
283
+ }
373
284
  /**
374
285
  * Reset the Ogma instance so that it can be used fresh in the next visulization
375
286
  */
376
- LKOgma.prototype.clearOgmaState = function () {
287
+ clearOgmaState() {
377
288
  this.reset();
378
289
  if (this.store) {
379
290
  this.store.clear();
380
291
  }
381
292
  this.initOgmaLinkuriousParser();
382
- };
293
+ }
383
294
  /**
384
295
  * Updates the Ogma config when config changes in LKE. If init, options were already set by the Ogma.reset()
385
296
  */
386
- LKOgma.prototype.setConfigOgma = function (configuration, init) {
297
+ setConfigOgma(configuration, init) {
387
298
  if (configuration) {
388
299
  // here we make sure that the internal config object is updated and we have the correct one when resetting
389
300
  this._configuration = configuration;
390
301
  }
391
302
  if (!init) {
392
- this.setOptions(__assign(__assign({}, this._configuration.options), { renderer: this._configuration.renderer }));
303
+ this.setOptions(Object.assign(Object.assign({}, this._configuration.options), { renderer: this._configuration.renderer }));
393
304
  }
394
305
  this.setStyles(this._configuration);
395
306
  this.setCaptions(this._configuration);
396
- };
397
- return LKOgma;
398
- }(ogma_1.default));
307
+ }
308
+ }
399
309
  exports.LKOgma = LKOgma;
400
310
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ogma/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAUiC;AACjC,0DAU0B;AAE1B,wBAA8B;AAC9B,wCAAqC;AAErC,4CAA4C;AAC5C,8DAA8D;AAC9D,gDAAgD;AAChD,gDAA0C;AAG1C,yCAAiD;AAAzC,sBAAA,OAAO,CAAQ;AACV,QAAA,kBAAkB,GAAG,GAAG,CAAC;AAOtC;IAA4B,0BAA4B;IAWtD,gBAAoB,cAA2B;;QAA/C;QACE,gCAAgC;QAChC,kBAAM,cAAc,CAAC,SAGtB;QALmB,oBAAc,GAAd,cAAc,CAAa;QAG7C,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,WAAW,SAAS,CAAC,CAAC;QAClD,KAAI,CAAC,wBAAwB,CAAC,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KAAK,CAAC,KAAK,EAAE,CAAC;SACpB;IACH,CAAC;IAED;;OAEG;IACI,+BAAc,GAArB;QACE,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;SACpB;QACD,IAAI,CAAC,wBAAwB,EAAE,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,8BAAa,GAApB,UAAqB,aAA2B,EAAE,IAAc;QAC9D,IAAI,aAAa,EAAE;YACjB,0GAA0G;YAC1G,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;SACrC;QACD,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,CAAC,UAAU,uBACV,IAAI,CAAC,cAAc,CAAC,OAAO,KAC9B,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,IACtC,CAAC;SACJ;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACpC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC;IACH,aAAC;AAAD,CAAC,AA3TD,CAA4B,cAAI,GA2T/B;AA3TY,wBAAM","sourcesContent":["import {\n EntityType,\n ForceLayoutMode,\n HierarchicalLayoutMode,\n IOgmaConfig,\n LkEdgeData,\n LkNodeData,\n PopulatedVisualization,\n VizEdge,\n VizNode\n} from '@linkurious/rest-client';\nimport Ogma, {\n EdgeList,\n ForceLayoutOptions,\n HierarchicalLayoutOptions,\n NodeList,\n NonObjectPropertyWatcher,\n RadialLayoutOptions,\n RawEdge,\n RawGraph,\n RawNode\n} from '@linkurious/ogma';\n\nimport {StyleRules} from '..';\nimport {Tools} from '../tools/tools';\n\nimport {StylesViz} from './features/styles';\nimport {TransformationsViz} from './features/transformations';\nimport {CaptionsViz} from './features/captions';\nimport {RxViz} from './features/reactive';\nimport {OgmaStore} from './features/OgmaStore';\n\nexport {default as Ogma} from '@linkurious/ogma';\nexport const ANIMATION_DURATION = 750;\n\ninterface AddItemOptions {\n batchSize?: number;\n virtual?: boolean;\n}\n\nexport class LKOgma extends Ogma<LkNodeData, LkEdgeData> {\n public LKStyles!: StylesViz;\n public LKCaptions!: CaptionsViz;\n public LKTransformation!: TransformationsViz;\n // Trigger an event with node category changes\n public nodeCategoriesWatcher!: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;\n // Trigger an event with edge type changes\n public edgeTypeWatcher!: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;\n public store!: OgmaStore;\n private _reactive!: RxViz;\n\n constructor(private _configuration: IOgmaConfig) {\n // set Ogma global configuration\n super(_configuration);\n Object.setPrototypeOf(this, new.target.prototype);\n this.initOgmaLinkuriousParser(true);\n }\n\n private initOgmaLinkuriousParser(init?: boolean): void {\n this.nodeCategoriesWatcher = this.schema.watchNodeNonObjectProperty({\n path: 'categories',\n unwindArrays: true,\n filter: 'all'\n });\n this.edgeTypeWatcher = this.schema.watchEdgeNonObjectProperty({\n path: 'type',\n filter: 'all'\n });\n // set ogma max zoom value and selection with mouse option (false?)\n this.setOptions({\n interactions: {\n zoom: {\n maxValue: (params: any) => {\n return 128 / params.smallestNodeSize;\n }\n },\n selection: {\n enabled: false\n }\n }\n });\n\n // only instantiate the store once when app is starting\n if (this._reactive === undefined) {\n this._reactive = new RxViz(this);\n this.store = this._reactive.store;\n } else {\n // if store already exist, but ogma was reset, create new ogma event listener\n this._reactive.listenToSelectionEvents();\n }\n this.initSelection();\n this.setConfigOgma(this._configuration, init);\n this.LKTransformation = new TransformationsViz(this);\n\n this.LKStyles.setNodesDefaultHalo();\n this.LKStyles.setEdgesDefaultHalo();\n this.LKStyles.setBadgeRule();\n this.LKStyles.setFilterClass();\n }\n\n /**\n * Initialize selection behavior\n */\n public initSelection(): void {\n this.events.onClick((e) => {\n if (e !== undefined && e.button === 'left') {\n if (e.target !== null) {\n const multiSelectionKey = navigator.platform === 'MacIntel' ? 'cmd' : 'ctrl';\n if (this.keyboard.isKeyPressed(multiSelectionKey)) {\n if (e.target.isNode && this.getSelectedEdges().size > 0) {\n this.getSelectedEdges().setSelected(false);\n }\n if (!e.target.isNode && this.getSelectedNodes().size > 0) {\n this.getSelectedNodes().setSelected(false);\n }\n if (e.target.isSelected()) {\n e.target.setSelected(false);\n } else {\n e.target.setSelected(true);\n }\n } else {\n this.getSelectedNodes().setSelected(false);\n this.getSelectedEdges().setSelected(false);\n e.target.setSelected(true);\n }\n } else {\n this.getSelectedNodes().setSelected(false);\n this.getSelectedEdges().setSelected(false);\n }\n }\n });\n }\n\n private setStyles(configuration: IOgmaConfig): void {\n this.LKStyles = new StylesViz(this, {\n node: configuration?.options?.styles?.node || {},\n edge: configuration?.options?.styles?.edge || {}\n });\n this.LKStyles.setNodesDefaultStyles();\n this.LKStyles.setEdgesDefaultStyles();\n }\n\n private setCaptions(configuration: IOgmaConfig): void {\n const nodeMaxTextLength = configuration?.options?.styles?.node?.text?.maxTextLength;\n const edgeMaxTextLength = configuration?.options?.styles?.edge?.text?.maxTextLength;\n this.LKCaptions = new CaptionsViz(this, nodeMaxTextLength, edgeMaxTextLength);\n }\n\n /**\n * Returns Ogma Layout parameters according to visualization layout settings\n * */\n public getForceLayoutParams(mode: ForceLayoutMode, duration = 0): ForceLayoutOptions {\n let dynamicSteps = 300 - ((300 - 40) / 5000) * this.getNodes().size;\n if (dynamicSteps < 40) {\n dynamicSteps = 40;\n }\n return {\n steps: mode === ForceLayoutMode.FAST ? dynamicSteps : 300,\n alignSiblings: this.getNodes().size > 3,\n duration: duration,\n charge: 20,\n gravity: 0.08,\n theta: this.getNodes().size > 100 ? 0.8 : 0.34\n };\n }\n\n public getRadialLayoutParams(\n rootNode: string,\n duration = 0\n ): RadialLayoutOptions<unknown, unknown> {\n return {\n centralNode: rootNode,\n radiusDelta: 1,\n nodeGap: 10,\n repulsion: this.getNodes().size > 80 ? 1 : 6,\n duration: duration\n };\n }\n\n public getHierarchicalLayoutParams(\n mode: HierarchicalLayoutMode,\n rootNode: string,\n duration = 0\n ): HierarchicalLayoutOptions {\n return {\n direction: mode,\n roots: [rootNode],\n duration: duration\n };\n }\n\n /**\n * Initialize graph.\n * add nodes and edges to the viz and init the selection.\n */\n public async init(visualization: {nodes: Array<VizNode>; edges: Array<VizEdge>}): Promise<void> {\n this.clearGraph();\n let selectedEntityType: EntityType | undefined = undefined;\n let selectedElements: Array<string> = [];\n // need to remove selected in every items before adding them to Ogma\n const fixedNodes = visualization.nodes.map((node) => {\n if (node.attributes.selected) {\n selectedEntityType = EntityType.NODE;\n selectedElements.push(node.id);\n }\n delete node.attributes.selected;\n return node;\n });\n const fixedEdges = visualization.edges.map((edge) => {\n if (edge.attributes !== undefined) {\n if (edge.attributes.selected) {\n if (selectedEntityType === undefined || selectedEntityType === EntityType.NODE) {\n selectedEntityType = EntityType.EDGE;\n selectedElements = [];\n }\n selectedElements.push(edge.id);\n }\n delete edge.attributes.selected;\n }\n return edge;\n });\n await this.addGraphAfterValidation({\n nodes: fixedNodes as Array<RawNode<LkNodeData>>,\n edges: fixedEdges as Array<RawEdge<LkEdgeData>>\n });\n if (selectedEntityType === EntityType.NODE) {\n this.getNodes(selectedElements).setSelected(true);\n } else if (selectedEntityType === EntityType.EDGE) {\n this.getEdges(selectedElements).setSelected(true);\n }\n }\n\n public async initVisualization(visualization: PopulatedVisualization): Promise<void> {\n await this.init(visualization);\n const styles = StyleRules.sanitizeStylesIndex(visualization.design.styles);\n this.LKStyles.initNodeColors(styles.node);\n this.LKStyles.initNodesIcons(styles.node);\n this.LKStyles.initNodesSizes(styles.node);\n this.LKStyles.initNodesShapes(styles.node);\n this.LKStyles.initEdgesWidth(styles.edge);\n this.LKStyles.initEdgesShape(styles.edge);\n this.LKStyles.initEdgesColor(styles.edge);\n await this.LKCaptions.initVizCaptions({\n node: visualization.nodeFields.captions || {},\n edge: visualization.edgeFields.captions || {}\n });\n this.LKTransformation.groupedEdges = visualization.edgeGrouping;\n await this.LKTransformation.initTransformation();\n this.LKTransformation.initEdgeGroupingStyle();\n }\n\n /**\n * Adding nodes then adding edges to the graph\n */\n public async addGraphAfterValidation(\n graph: RawGraph<LkNodeData, LkEdgeData>\n ): Promise<{\n nodes: NodeList<LkNodeData>;\n edges: EdgeList<LkEdgeData>;\n }> {\n const addedNodes = await this.addNodes(graph.nodes);\n const addedEdges = await this.addEdges(graph.edges);\n return {\n nodes: addedNodes,\n edges: addedEdges\n };\n }\n\n /**\n * Adding edges to the graph after filtering disconnected ones\n */\n public addEdges(edges: Array<RawEdge<LkEdgeData>>, options?: AddItemOptions): Promise<EdgeList> {\n const filteredEdges = edges.filter((edge) => {\n return this.getNode(edge.source) !== undefined && this.getNode(edge.target) !== undefined;\n });\n return super.addEdges(filteredEdges, options);\n }\n\n /**\n * Return the list of non filtered nodes\n */\n public getNonFilteredNodes(items?: Array<any>): NodeList<LkNodeData, LkEdgeData> {\n return Tools.isDefined(items)\n ? this.getNodes(items).filter((i) => !i.hasClass('filtered'))\n : this.getNodes().filter((i) => !i.hasClass('filtered'));\n }\n\n /**\n * Return the list of filtered nodes\n */\n public getFilteredNodes(items?: Array<any>): NodeList<LkNodeData, LkEdgeData> {\n return Tools.isDefined(items)\n ? this.getNodes(items).filter((i) => i.hasClass('filtered'))\n : this.getNodes().filter((i) => i.hasClass('filtered'));\n }\n\n /**\n * Return the list of non filtered edges\n */\n public getNonFilteredEdges(items?: Array<any>): EdgeList<LkEdgeData, LkNodeData> {\n return Tools.isDefined(items)\n ? this.getEdges(items).filter((i) => !i.hasClass('filtered'))\n : this.getEdges('raw').filter((i) => !i.hasClass('filtered'));\n }\n\n /**\n * Return the list of filtered edges\n */\n public getFilteredEdges(\n items?: Array<any>,\n filter: 'visible' | 'raw' | 'all' = 'raw'\n ): EdgeList<LkEdgeData, LkNodeData> {\n return Tools.isDefined(items)\n ? this.getEdges(items).filter((i) => i.hasClass('filtered'))\n : this.getEdges(filter).filter((i) => i.hasClass('filtered'));\n }\n\n /**\n * Do a full reset on ogma and streams of ogma\n */\n public shutDown(): void {\n this.destroy();\n if (this.store) {\n this.store.clear();\n }\n }\n\n /**\n * Reset the Ogma instance so that it can be used fresh in the next visulization\n */\n public clearOgmaState(): void {\n this.reset();\n if (this.store) {\n this.store.clear();\n }\n this.initOgmaLinkuriousParser();\n }\n\n /**\n * Updates the Ogma config when config changes in LKE. If init, options were already set by the Ogma.reset()\n */\n public setConfigOgma(configuration?: IOgmaConfig, init?: boolean): void {\n if (configuration) {\n // here we make sure that the internal config object is updated and we have the correct one when resetting\n this._configuration = configuration;\n }\n if (!init) {\n this.setOptions({\n ...this._configuration.options,\n renderer: this._configuration.renderer\n });\n }\n this.setStyles(this._configuration);\n this.setCaptions(this._configuration);\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ogma/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yDAUiC;AACjC,4DAU0B;AAE1B,0BAA8B;AAC9B,0CAAqC;AAErC,8CAA4C;AAC5C,gEAA8D;AAC9D,kDAAgD;AAChD,kDAA0C;AAG1C,yCAAiD;AAAzC,6GAAA,OAAO,OAAQ;AACV,QAAA,kBAAkB,GAAG,GAAG,CAAC;AAOtC,MAAa,MAAO,SAAQ,cAA4B;IAWtD,YAAoB,cAA2B;QAC7C,gCAAgC;QAChC,KAAK,CAAC,cAAc,CAAC,CAAC;QAFJ,mBAAc,GAAd,cAAc,CAAa;QAG7C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAEO,wBAAwB,CAAC,IAAc;QAC7C,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC;YAClE,IAAI,EAAE,YAAY;YAClB,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QACH,IAAI,CAAC,eAAe,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AAC,IAAI,EAAE;YACT,IAAI,CAAC,UAAU,iCACV,IAAI,CAAC,cAAc,CAAC,OAAO,KAC9B,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,IACtC,CAAC;SACJ;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACpC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC;CACF;AA3TD,wBA2TC","sourcesContent":["import {\n EntityType,\n ForceLayoutMode,\n HierarchicalLayoutMode,\n IOgmaConfig,\n LkEdgeData,\n LkNodeData,\n PopulatedVisualization,\n VizEdge,\n VizNode\n} from '@linkurious/rest-client';\nimport Ogma, {\n EdgeList,\n ForceLayoutOptions,\n HierarchicalLayoutOptions,\n NodeList,\n NonObjectPropertyWatcher,\n RadialLayoutOptions,\n RawEdge,\n RawGraph,\n RawNode\n} from '@linkurious/ogma';\n\nimport {StyleRules} from '..';\nimport {Tools} from '../tools/tools';\n\nimport {StylesViz} from './features/styles';\nimport {TransformationsViz} from './features/transformations';\nimport {CaptionsViz} from './features/captions';\nimport {RxViz} from './features/reactive';\nimport {OgmaStore} from './features/OgmaStore';\n\nexport {default as Ogma} from '@linkurious/ogma';\nexport const ANIMATION_DURATION = 750;\n\ninterface AddItemOptions {\n batchSize?: number;\n virtual?: boolean;\n}\n\nexport class LKOgma extends Ogma<LkNodeData, LkEdgeData> {\n public LKStyles!: StylesViz;\n public LKCaptions!: CaptionsViz;\n public LKTransformation!: TransformationsViz;\n // Trigger an event with node category changes\n public nodeCategoriesWatcher!: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;\n // Trigger an event with edge type changes\n public edgeTypeWatcher!: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;\n public store!: OgmaStore;\n private _reactive!: RxViz;\n\n constructor(private _configuration: IOgmaConfig) {\n // set Ogma global configuration\n super(_configuration);\n Object.setPrototypeOf(this, new.target.prototype);\n this.initOgmaLinkuriousParser(true);\n }\n\n private initOgmaLinkuriousParser(init?: boolean): void {\n this.nodeCategoriesWatcher = this.schema.watchNodeNonObjectProperty({\n path: 'categories',\n unwindArrays: true,\n filter: 'all'\n });\n this.edgeTypeWatcher = this.schema.watchEdgeNonObjectProperty({\n path: 'type',\n filter: 'all'\n });\n // set ogma max zoom value and selection with mouse option (false?)\n this.setOptions({\n interactions: {\n zoom: {\n maxValue: (params: any) => {\n return 128 / params.smallestNodeSize;\n }\n },\n selection: {\n enabled: false\n }\n }\n });\n\n // only instantiate the store once when app is starting\n if (this._reactive === undefined) {\n this._reactive = new RxViz(this);\n this.store = this._reactive.store;\n } else {\n // if store already exist, but ogma was reset, create new ogma event listener\n this._reactive.listenToSelectionEvents();\n }\n this.initSelection();\n this.setConfigOgma(this._configuration, init);\n this.LKTransformation = new TransformationsViz(this);\n\n this.LKStyles.setNodesDefaultHalo();\n this.LKStyles.setEdgesDefaultHalo();\n this.LKStyles.setBadgeRule();\n this.LKStyles.setFilterClass();\n }\n\n /**\n * Initialize selection behavior\n */\n public initSelection(): void {\n this.events.onClick((e) => {\n if (e !== undefined && e.button === 'left') {\n if (e.target !== null) {\n const multiSelectionKey = navigator.platform === 'MacIntel' ? 'cmd' : 'ctrl';\n if (this.keyboard.isKeyPressed(multiSelectionKey)) {\n if (e.target.isNode && this.getSelectedEdges().size > 0) {\n this.getSelectedEdges().setSelected(false);\n }\n if (!e.target.isNode && this.getSelectedNodes().size > 0) {\n this.getSelectedNodes().setSelected(false);\n }\n if (e.target.isSelected()) {\n e.target.setSelected(false);\n } else {\n e.target.setSelected(true);\n }\n } else {\n this.getSelectedNodes().setSelected(false);\n this.getSelectedEdges().setSelected(false);\n e.target.setSelected(true);\n }\n } else {\n this.getSelectedNodes().setSelected(false);\n this.getSelectedEdges().setSelected(false);\n }\n }\n });\n }\n\n private setStyles(configuration: IOgmaConfig): void {\n this.LKStyles = new StylesViz(this, {\n node: configuration?.options?.styles?.node || {},\n edge: configuration?.options?.styles?.edge || {}\n });\n this.LKStyles.setNodesDefaultStyles();\n this.LKStyles.setEdgesDefaultStyles();\n }\n\n private setCaptions(configuration: IOgmaConfig): void {\n const nodeMaxTextLength = configuration?.options?.styles?.node?.text?.maxTextLength;\n const edgeMaxTextLength = configuration?.options?.styles?.edge?.text?.maxTextLength;\n this.LKCaptions = new CaptionsViz(this, nodeMaxTextLength, edgeMaxTextLength);\n }\n\n /**\n * Returns Ogma Layout parameters according to visualization layout settings\n * */\n public getForceLayoutParams(mode: ForceLayoutMode, duration = 0): ForceLayoutOptions {\n let dynamicSteps = 300 - ((300 - 40) / 5000) * this.getNodes().size;\n if (dynamicSteps < 40) {\n dynamicSteps = 40;\n }\n return {\n steps: mode === ForceLayoutMode.FAST ? dynamicSteps : 300,\n alignSiblings: this.getNodes().size > 3,\n duration: duration,\n charge: 20,\n gravity: 0.08,\n theta: this.getNodes().size > 100 ? 0.8 : 0.34\n };\n }\n\n public getRadialLayoutParams(\n rootNode: string,\n duration = 0\n ): RadialLayoutOptions<unknown, unknown> {\n return {\n centralNode: rootNode,\n radiusDelta: 1,\n nodeGap: 10,\n repulsion: this.getNodes().size > 80 ? 1 : 6,\n duration: duration\n };\n }\n\n public getHierarchicalLayoutParams(\n mode: HierarchicalLayoutMode,\n rootNode: string,\n duration = 0\n ): HierarchicalLayoutOptions {\n return {\n direction: mode,\n roots: [rootNode],\n duration: duration\n };\n }\n\n /**\n * Initialize graph.\n * add nodes and edges to the viz and init the selection.\n */\n public async init(visualization: {nodes: Array<VizNode>; edges: Array<VizEdge>}): Promise<void> {\n this.clearGraph();\n let selectedEntityType: EntityType | undefined = undefined;\n let selectedElements: Array<string> = [];\n // need to remove selected in every items before adding them to Ogma\n const fixedNodes = visualization.nodes.map((node) => {\n if (node.attributes.selected) {\n selectedEntityType = EntityType.NODE;\n selectedElements.push(node.id);\n }\n delete node.attributes.selected;\n return node;\n });\n const fixedEdges = visualization.edges.map((edge) => {\n if (edge.attributes !== undefined) {\n if (edge.attributes.selected) {\n if (selectedEntityType === undefined || selectedEntityType === EntityType.NODE) {\n selectedEntityType = EntityType.EDGE;\n selectedElements = [];\n }\n selectedElements.push(edge.id);\n }\n delete edge.attributes.selected;\n }\n return edge;\n });\n await this.addGraphAfterValidation({\n nodes: fixedNodes as Array<RawNode<LkNodeData>>,\n edges: fixedEdges as Array<RawEdge<LkEdgeData>>\n });\n if (selectedEntityType === EntityType.NODE) {\n this.getNodes(selectedElements).setSelected(true);\n } else if (selectedEntityType === EntityType.EDGE) {\n this.getEdges(selectedElements).setSelected(true);\n }\n }\n\n public async initVisualization(visualization: PopulatedVisualization): Promise<void> {\n await this.init(visualization);\n const styles = StyleRules.sanitizeStylesIndex(visualization.design.styles);\n this.LKStyles.initNodeColors(styles.node);\n this.LKStyles.initNodesIcons(styles.node);\n this.LKStyles.initNodesSizes(styles.node);\n this.LKStyles.initNodesShapes(styles.node);\n this.LKStyles.initEdgesWidth(styles.edge);\n this.LKStyles.initEdgesShape(styles.edge);\n this.LKStyles.initEdgesColor(styles.edge);\n await this.LKCaptions.initVizCaptions({\n node: visualization.nodeFields.captions || {},\n edge: visualization.edgeFields.captions || {}\n });\n this.LKTransformation.groupedEdges = visualization.edgeGrouping;\n await this.LKTransformation.initTransformation();\n this.LKTransformation.initEdgeGroupingStyle();\n }\n\n /**\n * Adding nodes then adding edges to the graph\n */\n public async addGraphAfterValidation(\n graph: RawGraph<LkNodeData, LkEdgeData>\n ): Promise<{\n nodes: NodeList<LkNodeData>;\n edges: EdgeList<LkEdgeData>;\n }> {\n const addedNodes = await this.addNodes(graph.nodes);\n const addedEdges = await this.addEdges(graph.edges);\n return {\n nodes: addedNodes,\n edges: addedEdges\n };\n }\n\n /**\n * Adding edges to the graph after filtering disconnected ones\n */\n public addEdges(edges: Array<RawEdge<LkEdgeData>>, options?: AddItemOptions): Promise<EdgeList> {\n const filteredEdges = edges.filter((edge) => {\n return this.getNode(edge.source) !== undefined && this.getNode(edge.target) !== undefined;\n });\n return super.addEdges(filteredEdges, options);\n }\n\n /**\n * Return the list of non filtered nodes\n */\n public getNonFilteredNodes(items?: Array<any>): NodeList<LkNodeData, LkEdgeData> {\n return Tools.isDefined(items)\n ? this.getNodes(items).filter((i) => !i.hasClass('filtered'))\n : this.getNodes().filter((i) => !i.hasClass('filtered'));\n }\n\n /**\n * Return the list of filtered nodes\n */\n public getFilteredNodes(items?: Array<any>): NodeList<LkNodeData, LkEdgeData> {\n return Tools.isDefined(items)\n ? this.getNodes(items).filter((i) => i.hasClass('filtered'))\n : this.getNodes().filter((i) => i.hasClass('filtered'));\n }\n\n /**\n * Return the list of non filtered edges\n */\n public getNonFilteredEdges(items?: Array<any>): EdgeList<LkEdgeData, LkNodeData> {\n return Tools.isDefined(items)\n ? this.getEdges(items).filter((i) => !i.hasClass('filtered'))\n : this.getEdges('raw').filter((i) => !i.hasClass('filtered'));\n }\n\n /**\n * Return the list of filtered edges\n */\n public getFilteredEdges(\n items?: Array<any>,\n filter: 'visible' | 'raw' | 'all' = 'raw'\n ): EdgeList<LkEdgeData, LkNodeData> {\n return Tools.isDefined(items)\n ? this.getEdges(items).filter((i) => i.hasClass('filtered'))\n : this.getEdges(filter).filter((i) => i.hasClass('filtered'));\n }\n\n /**\n * Do a full reset on ogma and streams of ogma\n */\n public shutDown(): void {\n this.destroy();\n if (this.store) {\n this.store.clear();\n }\n }\n\n /**\n * Reset the Ogma instance so that it can be used fresh in the next visulization\n */\n public clearOgmaState(): void {\n this.reset();\n if (this.store) {\n this.store.clear();\n }\n this.initOgmaLinkuriousParser();\n }\n\n /**\n * Updates the Ogma config when config changes in LKE. If init, options were already set by the Ogma.reset()\n */\n public setConfigOgma(configuration?: IOgmaConfig, init?: boolean): void {\n if (configuration) {\n // here we make sure that the internal config object is updated and we have the correct one when resetting\n this._configuration = configuration;\n }\n if (!init) {\n this.setOptions({\n ...this._configuration.options,\n renderer: this._configuration.renderer\n });\n }\n this.setStyles(this._configuration);\n this.setCaptions(this._configuration);\n }\n}\n"]}