@linkurious/ogma-linkurious-parser 3.1.12 → 4.0.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/captions/captions.js +39 -50
- package/dist/captions/captions.js.map +1 -1
- package/dist/filters/filters.js +54 -76
- package/dist/filters/filters.js.map +1 -1
- package/dist/ogma/features/OgmaStore.js +15 -30
- package/dist/ogma/features/OgmaStore.js.map +1 -1
- package/dist/ogma/features/captions.js +42 -87
- package/dist/ogma/features/captions.js.map +1 -1
- package/dist/ogma/features/reactive.js +57 -75
- package/dist/ogma/features/reactive.js.map +1 -1
- package/dist/ogma/features/selectors.js +15 -15
- package/dist/ogma/features/selectors.js.map +1 -1
- package/dist/ogma/features/styles.js +114 -137
- package/dist/ogma/features/styles.js.map +1 -1
- package/dist/ogma/features/transformations.js +46 -94
- package/dist/ogma/features/transformations.js.map +1 -1
- package/dist/ogma/index.js +138 -221
- package/dist/ogma/index.js.map +1 -1
- package/dist/styles/edgeAttributes.js +30 -46
- package/dist/styles/edgeAttributes.js.map +1 -1
- package/dist/styles/itemAttributes.js +31 -41
- package/dist/styles/itemAttributes.js.map +1 -1
- package/dist/styles/nodeAttributes.js +48 -71
- package/dist/styles/nodeAttributes.js.map +1 -1
- package/dist/styles/styleRule.js +56 -68
- package/dist/styles/styleRule.js.map +1 -1
- package/dist/styles/styleRules.js +149 -192
- package/dist/styles/styleRules.js.map +1 -1
- package/dist/tools/ogmaTool.js +27 -30
- package/dist/tools/ogmaTool.js.map +1 -1
- package/dist/tools/tools.js +87 -91
- package/dist/tools/tools.js.map +1 -1
- package/package.json +5 -5
package/dist/ogma/index.js
CHANGED
|
@@ -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,30 @@ 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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
15
|
+
const rest_client_1 = require("@linkurious/rest-client");
|
|
16
|
+
const ogma_1 = __importDefault(require("@linkurious/ogma"));
|
|
17
|
+
const __1 = require("..");
|
|
18
|
+
const tools_1 = require("../tools/tools");
|
|
19
|
+
const styles_1 = require("./features/styles");
|
|
20
|
+
const transformations_1 = require("./features/transformations");
|
|
21
|
+
const captions_1 = require("./features/captions");
|
|
22
|
+
const reactive_1 = require("./features/reactive");
|
|
74
23
|
var ogma_2 = require("@linkurious/ogma");
|
|
75
24
|
exports.Ogma = ogma_2.default;
|
|
76
25
|
exports.ANIMATION_DURATION = 750;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
function LKOgma(_configuration) {
|
|
80
|
-
var _newTarget = this.constructor;
|
|
81
|
-
var _this =
|
|
26
|
+
class LKOgma extends ogma_1.default {
|
|
27
|
+
constructor(_configuration) {
|
|
82
28
|
// set Ogma global configuration
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Object.setPrototypeOf(
|
|
86
|
-
|
|
87
|
-
return _this;
|
|
29
|
+
super(_configuration);
|
|
30
|
+
this._configuration = _configuration;
|
|
31
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
32
|
+
this.initOgmaLinkuriousParser(true);
|
|
88
33
|
}
|
|
89
|
-
|
|
34
|
+
initOgmaLinkuriousParser(init) {
|
|
90
35
|
this.nodeCategoriesWatcher = this.schema.watchNodeNonObjectProperty({
|
|
91
36
|
path: 'categories',
|
|
92
37
|
unwindArrays: true,
|
|
@@ -100,7 +45,7 @@ var LKOgma = /** @class */ (function (_super) {
|
|
|
100
45
|
this.setOptions({
|
|
101
46
|
interactions: {
|
|
102
47
|
zoom: {
|
|
103
|
-
maxValue:
|
|
48
|
+
maxValue: (params) => {
|
|
104
49
|
return 128 / params.smallestNodeSize;
|
|
105
50
|
}
|
|
106
51
|
},
|
|
@@ -125,22 +70,21 @@ var LKOgma = /** @class */ (function (_super) {
|
|
|
125
70
|
this.LKStyles.setEdgesDefaultHalo();
|
|
126
71
|
this.LKStyles.setBadgeRule();
|
|
127
72
|
this.LKStyles.setFilterClass();
|
|
128
|
-
}
|
|
73
|
+
}
|
|
129
74
|
/**
|
|
130
75
|
* Initialize selection behavior
|
|
131
76
|
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.events.onClick(function (e) {
|
|
77
|
+
initSelection() {
|
|
78
|
+
this.events.onClick((e) => {
|
|
135
79
|
if (e !== undefined && e.button === 'left') {
|
|
136
80
|
if (e.target !== null) {
|
|
137
|
-
|
|
138
|
-
if (
|
|
139
|
-
if (e.target.isNode &&
|
|
140
|
-
|
|
81
|
+
const multiSelectionKey = navigator.platform === 'MacIntel' ? 'cmd' : 'ctrl';
|
|
82
|
+
if (this.keyboard.isKeyPressed(multiSelectionKey)) {
|
|
83
|
+
if (e.target.isNode && this.getSelectedEdges().size > 0) {
|
|
84
|
+
this.getSelectedEdges().setSelected(false);
|
|
141
85
|
}
|
|
142
|
-
if (!e.target.isNode &&
|
|
143
|
-
|
|
86
|
+
if (!e.target.isNode && this.getSelectedNodes().size > 0) {
|
|
87
|
+
this.getSelectedNodes().setSelected(false);
|
|
144
88
|
}
|
|
145
89
|
if (e.target.isSelected()) {
|
|
146
90
|
e.target.setSelected(false);
|
|
@@ -150,19 +94,19 @@ var LKOgma = /** @class */ (function (_super) {
|
|
|
150
94
|
}
|
|
151
95
|
}
|
|
152
96
|
else {
|
|
153
|
-
|
|
154
|
-
|
|
97
|
+
this.getSelectedNodes().setSelected(false);
|
|
98
|
+
this.getSelectedEdges().setSelected(false);
|
|
155
99
|
e.target.setSelected(true);
|
|
156
100
|
}
|
|
157
101
|
}
|
|
158
102
|
else {
|
|
159
|
-
|
|
160
|
-
|
|
103
|
+
this.getSelectedNodes().setSelected(false);
|
|
104
|
+
this.getSelectedEdges().setSelected(false);
|
|
161
105
|
}
|
|
162
106
|
}
|
|
163
107
|
});
|
|
164
|
-
}
|
|
165
|
-
|
|
108
|
+
}
|
|
109
|
+
setStyles(configuration) {
|
|
166
110
|
var _a, _b, _c, _d, _e, _f;
|
|
167
111
|
this.LKStyles = new styles_1.StylesViz(this, {
|
|
168
112
|
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) || {},
|
|
@@ -170,19 +114,18 @@ var LKOgma = /** @class */ (function (_super) {
|
|
|
170
114
|
});
|
|
171
115
|
this.LKStyles.setNodesDefaultStyles();
|
|
172
116
|
this.LKStyles.setEdgesDefaultStyles();
|
|
173
|
-
}
|
|
174
|
-
|
|
117
|
+
}
|
|
118
|
+
setCaptions(configuration) {
|
|
175
119
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
176
|
-
|
|
177
|
-
|
|
120
|
+
const 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;
|
|
121
|
+
const 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;
|
|
178
122
|
this.LKCaptions = new captions_1.CaptionsViz(this, nodeMaxTextLength, edgeMaxTextLength);
|
|
179
|
-
}
|
|
123
|
+
}
|
|
180
124
|
/**
|
|
181
125
|
* Returns Ogma Layout parameters according to visualization layout settings
|
|
182
126
|
* */
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
var dynamicSteps = 300 - ((300 - 40) / 5000) * this.getNodes().size;
|
|
127
|
+
getForceLayoutParams(mode, duration = 0) {
|
|
128
|
+
let dynamicSteps = 300 - ((300 - 40) / 5000) * this.getNodes().size;
|
|
186
129
|
if (dynamicSteps < 40) {
|
|
187
130
|
dynamicSteps = 40;
|
|
188
131
|
}
|
|
@@ -194,9 +137,8 @@ var LKOgma = /** @class */ (function (_super) {
|
|
|
194
137
|
gravity: 0.08,
|
|
195
138
|
theta: this.getNodes().size > 100 ? 0.8 : 0.34
|
|
196
139
|
};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (duration === void 0) { duration = 0; }
|
|
140
|
+
}
|
|
141
|
+
getRadialLayoutParams(rootNode, duration = 0) {
|
|
200
142
|
return {
|
|
201
143
|
centralNode: rootNode,
|
|
202
144
|
radiusDelta: 1,
|
|
@@ -204,194 +146,169 @@ var LKOgma = /** @class */ (function (_super) {
|
|
|
204
146
|
repulsion: this.getNodes().size > 80 ? 1 : 6,
|
|
205
147
|
duration: duration
|
|
206
148
|
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (duration === void 0) { duration = 0; }
|
|
149
|
+
}
|
|
150
|
+
getHierarchicalLayoutParams(mode, rootNode, duration = 0) {
|
|
210
151
|
return {
|
|
211
152
|
direction: mode,
|
|
212
153
|
roots: [rootNode],
|
|
213
154
|
duration: duration
|
|
214
155
|
};
|
|
215
|
-
}
|
|
156
|
+
}
|
|
216
157
|
/**
|
|
217
158
|
* Initialize graph.
|
|
218
159
|
* add nodes and edges to the viz and init the selection.
|
|
219
160
|
*/
|
|
220
|
-
|
|
221
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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);
|
|
161
|
+
init(visualization) {
|
|
162
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
this.clearGraph();
|
|
164
|
+
let selectedEntityType = undefined;
|
|
165
|
+
let selectedElements = [];
|
|
166
|
+
// need to remove selected in every items before adding them to Ogma
|
|
167
|
+
const fixedNodes = visualization.nodes.map((node) => {
|
|
168
|
+
if (node.attributes.selected) {
|
|
169
|
+
selectedEntityType = rest_client_1.EntityType.NODE;
|
|
170
|
+
selectedElements.push(node.id);
|
|
171
|
+
}
|
|
172
|
+
delete node.attributes.selected;
|
|
173
|
+
return node;
|
|
174
|
+
});
|
|
175
|
+
const fixedEdges = visualization.edges.map((edge) => {
|
|
176
|
+
if (edge.attributes !== undefined) {
|
|
177
|
+
if (edge.attributes.selected) {
|
|
178
|
+
if (selectedEntityType === undefined || selectedEntityType === rest_client_1.EntityType.NODE) {
|
|
179
|
+
selectedEntityType = rest_client_1.EntityType.EDGE;
|
|
180
|
+
selectedElements = [];
|
|
261
181
|
}
|
|
262
|
-
|
|
182
|
+
selectedElements.push(edge.id);
|
|
183
|
+
}
|
|
184
|
+
delete edge.attributes.selected;
|
|
263
185
|
}
|
|
186
|
+
return edge;
|
|
187
|
+
});
|
|
188
|
+
yield this.addGraphAfterValidation({
|
|
189
|
+
nodes: fixedNodes,
|
|
190
|
+
edges: fixedEdges
|
|
264
191
|
});
|
|
192
|
+
if (selectedEntityType === rest_client_1.EntityType.NODE) {
|
|
193
|
+
this.getNodes(selectedElements).setSelected(true);
|
|
194
|
+
}
|
|
195
|
+
else if (selectedEntityType === rest_client_1.EntityType.EDGE) {
|
|
196
|
+
this.getEdges(selectedElements).setSelected(true);
|
|
197
|
+
}
|
|
265
198
|
});
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
node: visualization.nodeFields.captions || {},
|
|
282
|
-
edge: visualization.edgeFields.captions || {}
|
|
283
|
-
});
|
|
284
|
-
this.LKTransformation.groupedEdges = visualization.edgeGrouping;
|
|
285
|
-
this.LKTransformation.initTransformation();
|
|
286
|
-
this.LKTransformation.initEdgeGroupingStyle();
|
|
287
|
-
return [2 /*return*/];
|
|
199
|
+
}
|
|
200
|
+
initVisualization(visualization) {
|
|
201
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
this.init(visualization);
|
|
203
|
+
const styles = __1.StyleRules.sanitizeStylesIndex(visualization.design.styles);
|
|
204
|
+
this.LKStyles.initNodeColors(styles.node);
|
|
205
|
+
this.LKStyles.initNodesIcons(styles.node);
|
|
206
|
+
this.LKStyles.initNodesSizes(styles.node);
|
|
207
|
+
this.LKStyles.initNodesShapes(styles.node);
|
|
208
|
+
this.LKStyles.initEdgesWidth(styles.edge);
|
|
209
|
+
this.LKStyles.initEdgesShape(styles.edge);
|
|
210
|
+
this.LKStyles.initEdgesColor(styles.edge);
|
|
211
|
+
this.LKCaptions.initVizCaptions({
|
|
212
|
+
node: visualization.nodeFields.captions || {},
|
|
213
|
+
edge: visualization.edgeFields.captions || {}
|
|
288
214
|
});
|
|
215
|
+
this.LKTransformation.groupedEdges = visualization.edgeGrouping;
|
|
216
|
+
this.LKTransformation.initTransformation();
|
|
217
|
+
this.LKTransformation.initEdgeGroupingStyle();
|
|
289
218
|
});
|
|
290
|
-
}
|
|
219
|
+
}
|
|
291
220
|
/**
|
|
292
221
|
* Adding nodes then adding edges to the graph
|
|
293
222
|
*/
|
|
294
|
-
|
|
295
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
return [4 /*yield*/, this.addEdges(graph.edges)];
|
|
303
|
-
case 2:
|
|
304
|
-
addedEdges = _a.sent();
|
|
305
|
-
return [2 /*return*/, {
|
|
306
|
-
nodes: addedNodes,
|
|
307
|
-
edges: addedEdges
|
|
308
|
-
}];
|
|
309
|
-
}
|
|
310
|
-
});
|
|
223
|
+
addGraphAfterValidation(graph) {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
225
|
+
const addedNodes = yield this.addNodes(graph.nodes);
|
|
226
|
+
const addedEdges = yield this.addEdges(graph.edges);
|
|
227
|
+
return {
|
|
228
|
+
nodes: addedNodes,
|
|
229
|
+
edges: addedEdges
|
|
230
|
+
};
|
|
311
231
|
});
|
|
312
|
-
}
|
|
232
|
+
}
|
|
313
233
|
/**
|
|
314
234
|
* Adding edges to the graph after filtering disconnected ones
|
|
315
235
|
*/
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
});
|
|
324
|
-
return [2 /*return*/, _super.prototype.addEdges.call(this, filteredEdges, options)];
|
|
236
|
+
addEdges(edges, options) {
|
|
237
|
+
const _super = Object.create(null, {
|
|
238
|
+
addEdges: { get: () => super.addEdges }
|
|
239
|
+
});
|
|
240
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
241
|
+
const filteredEdges = edges.filter((edge) => {
|
|
242
|
+
return this.getNode(edge.source) !== undefined && this.getNode(edge.target) !== undefined;
|
|
325
243
|
});
|
|
244
|
+
return _super.addEdges.call(this, filteredEdges, options);
|
|
326
245
|
});
|
|
327
|
-
}
|
|
246
|
+
}
|
|
328
247
|
/**
|
|
329
248
|
* Return the list of non filtered nodes
|
|
330
249
|
*/
|
|
331
|
-
|
|
250
|
+
getNonFilteredNodes(items) {
|
|
332
251
|
return tools_1.Tools.isDefined(items)
|
|
333
|
-
? this.getNodes(items).filter(
|
|
334
|
-
: this.getNodes().filter(
|
|
335
|
-
}
|
|
252
|
+
? this.getNodes(items).filter((i) => !i.hasClass('filtered'))
|
|
253
|
+
: this.getNodes().filter((i) => !i.hasClass('filtered'));
|
|
254
|
+
}
|
|
336
255
|
/**
|
|
337
256
|
* Return the list of filtered nodes
|
|
338
257
|
*/
|
|
339
|
-
|
|
258
|
+
getFilteredNodes(items) {
|
|
340
259
|
return tools_1.Tools.isDefined(items)
|
|
341
|
-
? this.getNodes(items).filter(
|
|
342
|
-
: this.getNodes().filter(
|
|
343
|
-
}
|
|
260
|
+
? this.getNodes(items).filter((i) => i.hasClass('filtered'))
|
|
261
|
+
: this.getNodes().filter((i) => i.hasClass('filtered'));
|
|
262
|
+
}
|
|
344
263
|
/**
|
|
345
264
|
* Return the list of non filtered edges
|
|
346
265
|
*/
|
|
347
|
-
|
|
266
|
+
getNonFilteredEdges(items) {
|
|
348
267
|
return tools_1.Tools.isDefined(items)
|
|
349
|
-
? this.getEdges(items).filter(
|
|
350
|
-
: this.getEdges('raw').filter(
|
|
351
|
-
}
|
|
268
|
+
? this.getEdges(items).filter((i) => !i.hasClass('filtered'))
|
|
269
|
+
: this.getEdges('raw').filter((i) => !i.hasClass('filtered'));
|
|
270
|
+
}
|
|
352
271
|
/**
|
|
353
272
|
* Return the list of filtered edges
|
|
354
273
|
*/
|
|
355
|
-
|
|
356
|
-
if (filter === void 0) { filter = 'raw'; }
|
|
274
|
+
getFilteredEdges(items, filter = 'raw') {
|
|
357
275
|
return tools_1.Tools.isDefined(items)
|
|
358
|
-
? this.getEdges(items).filter(
|
|
359
|
-
: this.getEdges(filter).filter(
|
|
360
|
-
}
|
|
276
|
+
? this.getEdges(items).filter((i) => i.hasClass('filtered'))
|
|
277
|
+
: this.getEdges(filter).filter((i) => i.hasClass('filtered'));
|
|
278
|
+
}
|
|
361
279
|
/**
|
|
362
280
|
* Do a full reset on ogma and streams of ogma
|
|
363
281
|
*/
|
|
364
|
-
|
|
282
|
+
shutDown() {
|
|
365
283
|
this.destroy();
|
|
366
284
|
if (this.store) {
|
|
367
285
|
this.store.clear();
|
|
368
286
|
}
|
|
369
|
-
}
|
|
287
|
+
}
|
|
370
288
|
/**
|
|
371
289
|
* Reset the Ogma instance so that it can be used fresh in the next visulization
|
|
372
290
|
*/
|
|
373
|
-
|
|
291
|
+
clearOgmaState() {
|
|
374
292
|
this.reset();
|
|
375
293
|
if (this.store) {
|
|
376
294
|
this.store.clear();
|
|
377
295
|
}
|
|
378
296
|
this.initOgmaLinkuriousParser();
|
|
379
|
-
}
|
|
297
|
+
}
|
|
380
298
|
/**
|
|
381
299
|
* Updates the Ogma config when config changes in LKE. If init, options were already set by the Ogma.reset()
|
|
382
300
|
*/
|
|
383
|
-
|
|
301
|
+
setConfigOgma(configuration, init) {
|
|
384
302
|
if (configuration) {
|
|
385
303
|
// here we make sure that the internal config object is updated and we have the correct one when resetting
|
|
386
304
|
this._configuration = configuration;
|
|
387
305
|
}
|
|
388
306
|
if (!init) {
|
|
389
|
-
this.setOptions(
|
|
307
|
+
this.setOptions(Object.assign(Object.assign({}, this._configuration.options), { renderer: this._configuration.renderer }));
|
|
390
308
|
}
|
|
391
309
|
this.setStyles(this._configuration);
|
|
392
310
|
this.setCaptions(this._configuration);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
}(ogma_1.default));
|
|
311
|
+
}
|
|
312
|
+
}
|
|
396
313
|
exports.LKOgma = LKOgma;
|
|
397
314
|
//# sourceMappingURL=index.js.map
|
package/dist/ogma/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","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utMode,\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) {\n 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 this.LKCaptions.initVizCaptions({\n node: visualization.nodeFields.captions || {},\n edge: visualization.edgeFields.captions || {}\n });\n this.LKTransformation.groupedEdges = visualization.edgeGrouping;\n 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 async addEdges(\n edges: Array<RawEdge<LkEdgeData>>,\n options?: AddItemOptions\n ): 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,sBAAA,OAAO,CAAQ;AACV,QAAA,kBAAkB,GAAG,GAAG,CAAC;AAOtC,MAAa,MAAO,SAAQ,cAA4B;IAWtD,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,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;SACpB;QACD,IAAI,CAAC,wBAAwB,EAAE,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,aAAa,CAAC,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,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;AA9TD,wBA8TC","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) {\n 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 this.LKCaptions.initVizCaptions({\n node: visualization.nodeFields.captions || {},\n edge: visualization.edgeFields.captions || {}\n });\n this.LKTransformation.groupedEdges = visualization.edgeGrouping;\n 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 async addEdges(\n edges: Array<RawEdge<LkEdgeData>>,\n options?: AddItemOptions\n ): 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"]}
|