@linkurious/ogma-linkurious-parser 4.1.6 → 4.1.8
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/index.cjs +4 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +4082 -0
- package/dist/index.mjs.map +1 -0
- package/dist/ogma/features/nodeGrouping.d.ts +15 -1
- package/dist/tools/ogmaTool.d.ts +3 -1
- package/package.json +23 -21
- package/dist/captions/captions.js +0 -115
- package/dist/captions/captions.js.map +0 -1
- package/dist/filters/filters.js +0 -167
- package/dist/filters/filters.js.map +0 -1
- package/dist/index.js +0 -56
- package/dist/index.js.map +0 -1
- package/dist/ogma/features/OgmaStore.js +0 -37
- package/dist/ogma/features/OgmaStore.js.map +0 -1
- package/dist/ogma/features/captions.js +0 -117
- package/dist/ogma/features/captions.js.map +0 -1
- package/dist/ogma/features/nodeGrouping.js +0 -283
- package/dist/ogma/features/nodeGrouping.js.map +0 -1
- package/dist/ogma/features/reactive.js +0 -132
- package/dist/ogma/features/reactive.js.map +0 -1
- package/dist/ogma/features/selectors.js +0 -97
- package/dist/ogma/features/selectors.js.map +0 -1
- package/dist/ogma/features/styles.js +0 -689
- package/dist/ogma/features/styles.js.map +0 -1
- package/dist/ogma/features/transformations.js +0 -86
- package/dist/ogma/features/transformations.js.map +0 -1
- package/dist/ogma/index.js +0 -326
- package/dist/ogma/index.js.map +0 -1
- package/dist/styles/edgeAttributes.js +0 -115
- package/dist/styles/edgeAttributes.js.map +0 -1
- package/dist/styles/itemAttributes.js +0 -133
- package/dist/styles/itemAttributes.js.map +0 -1
- package/dist/styles/nodeAttributes.js +0 -228
- package/dist/styles/nodeAttributes.js.map +0 -1
- package/dist/styles/styleRule.js +0 -194
- package/dist/styles/styleRule.js.map +0 -1
- package/dist/styles/styleRules.js +0 -292
- package/dist/styles/styleRules.js.map +0 -1
- package/dist/tools/colorPalette.js +0 -145
- package/dist/tools/colorPalette.js.map +0 -1
- package/dist/tools/ogmaTool.js +0 -86
- package/dist/tools/ogmaTool.js.map +0 -1
- package/dist/tools/tools.js +0 -409
- package/dist/tools/tools.js.map +0 -1
|
@@ -1,689 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StylesViz = exports.FILTER_OPACITY = void 0;
|
|
4
|
-
const __1 = require("../..");
|
|
5
|
-
const tools_1 = require("../../tools/tools");
|
|
6
|
-
const HOVERED_SELECTED_NODE_STYLE = {
|
|
7
|
-
text: {
|
|
8
|
-
style: 'bold',
|
|
9
|
-
backgroundColor: '#fff',
|
|
10
|
-
minVisibleSize: 0
|
|
11
|
-
},
|
|
12
|
-
outerStroke: { width: 2 },
|
|
13
|
-
outline: false
|
|
14
|
-
};
|
|
15
|
-
const HOVERED_SELECTED_EDGE_STYLE = {
|
|
16
|
-
text: {
|
|
17
|
-
style: 'bold',
|
|
18
|
-
backgroundColor: '#fff',
|
|
19
|
-
minVisibleSize: 0
|
|
20
|
-
},
|
|
21
|
-
outline: false
|
|
22
|
-
};
|
|
23
|
-
const NODE_HALO_CONFIGURATION = {
|
|
24
|
-
color: '#FFF',
|
|
25
|
-
width: 7,
|
|
26
|
-
scalingMethod: 'scaled',
|
|
27
|
-
strokeWidth: 0,
|
|
28
|
-
hideNonAdjacentEdges: false
|
|
29
|
-
};
|
|
30
|
-
const EDGE_HALO_CONFIGURATION = {
|
|
31
|
-
color: '#FFF',
|
|
32
|
-
scalingMethod: 'scaled',
|
|
33
|
-
width: 4
|
|
34
|
-
};
|
|
35
|
-
const DEFAULT_OGMA_FONT = "'roboto', sans-serif";
|
|
36
|
-
const DARK_FONT_COLOR = '#000';
|
|
37
|
-
const CLEAR_FONT_COLOR = '#FFF';
|
|
38
|
-
const ITEM_DEFAULT_COLOR = '#7f7f7f';
|
|
39
|
-
exports.FILTER_OPACITY = 0.2;
|
|
40
|
-
class StylesViz {
|
|
41
|
-
constructor(ogma, configuration) {
|
|
42
|
-
this._nodeAttributes = new __1.NodeAttributes({});
|
|
43
|
-
this._edgeAttributes = new __1.EdgeAttributes({});
|
|
44
|
-
this._ogma = ogma;
|
|
45
|
-
this._defaultConfiguration = configuration;
|
|
46
|
-
this._nodeAttributes.setBaseUrl(configuration.baseUrl);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Set nodes default styles based on the configuration
|
|
50
|
-
*/
|
|
51
|
-
setNodesDefaultStyles() {
|
|
52
|
-
// setting selection and hover attributes
|
|
53
|
-
this._ogma.styles.setHoveredNodeAttributes(HOVERED_SELECTED_NODE_STYLE);
|
|
54
|
-
this._ogma.styles.setSelectedNodeAttributes(HOVERED_SELECTED_NODE_STYLE);
|
|
55
|
-
// setting default styles
|
|
56
|
-
this._nodeDefaultStylesRules = this._ogma.styles.addRule({
|
|
57
|
-
nodeAttributes: {
|
|
58
|
-
text: {
|
|
59
|
-
padding: 5,
|
|
60
|
-
minVisibleSize: this._defaultConfiguration.node.text !== undefined &&
|
|
61
|
-
this._defaultConfiguration.node.text.minVisibleSize
|
|
62
|
-
? this._defaultConfiguration.node.text.minVisibleSize
|
|
63
|
-
: 12,
|
|
64
|
-
maxLineLength: this._defaultConfiguration.node.text !== undefined &&
|
|
65
|
-
this._defaultConfiguration.node.text.maxLineLength !== undefined
|
|
66
|
-
? this._defaultConfiguration.node.text.maxLineLength
|
|
67
|
-
: 30,
|
|
68
|
-
position: this._defaultConfiguration.node.text !== undefined &&
|
|
69
|
-
this._defaultConfiguration.node.text.nodePosition !== undefined
|
|
70
|
-
? this._defaultConfiguration.node.text.nodePosition
|
|
71
|
-
: 'bottom',
|
|
72
|
-
backgroundColor: this._defaultConfiguration.node.text !== undefined &&
|
|
73
|
-
this._defaultConfiguration.node.text.backgroundColor !== undefined
|
|
74
|
-
? this._defaultConfiguration.node.text.backgroundColor
|
|
75
|
-
: undefined,
|
|
76
|
-
font: this._defaultConfiguration.node.text !== undefined &&
|
|
77
|
-
this._defaultConfiguration.node.text.font !== undefined
|
|
78
|
-
? this._defaultConfiguration.node.text.font
|
|
79
|
-
: "'roboto', sans-serif",
|
|
80
|
-
color: this._defaultConfiguration.node.text !== undefined &&
|
|
81
|
-
this._defaultConfiguration.node.text.color !== undefined
|
|
82
|
-
? this._defaultConfiguration.node.text.color
|
|
83
|
-
: 'black',
|
|
84
|
-
size: this._defaultConfiguration.node.text !== undefined &&
|
|
85
|
-
this._defaultConfiguration.node.text.size !== undefined
|
|
86
|
-
? this._defaultConfiguration.node.text.size
|
|
87
|
-
: 14,
|
|
88
|
-
margin: 5
|
|
89
|
-
},
|
|
90
|
-
radius: this.defaultNodeRadius(this._defaultConfiguration.node),
|
|
91
|
-
icon: {
|
|
92
|
-
minVisibleSize: 15
|
|
93
|
-
},
|
|
94
|
-
color: ITEM_DEFAULT_COLOR,
|
|
95
|
-
shape: this._defaultConfiguration.node.shape !== undefined
|
|
96
|
-
? this._defaultConfiguration.node.shape
|
|
97
|
-
: 'circle',
|
|
98
|
-
innerStroke: {
|
|
99
|
-
width: 3
|
|
100
|
-
},
|
|
101
|
-
outline: false
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Set edges default styles based on the configuration
|
|
107
|
-
*/
|
|
108
|
-
setEdgesDefaultStyles() {
|
|
109
|
-
var _a;
|
|
110
|
-
// setting selection and hover attributes
|
|
111
|
-
this._ogma.styles.setHoveredEdgeAttributes(HOVERED_SELECTED_EDGE_STYLE);
|
|
112
|
-
this._ogma.styles.setSelectedEdgeAttributes(HOVERED_SELECTED_EDGE_STYLE);
|
|
113
|
-
// setting default styles
|
|
114
|
-
this._edgeDefaultStylesRules = this._ogma.styles.addRule({
|
|
115
|
-
edgeAttributes: {
|
|
116
|
-
text: {
|
|
117
|
-
minVisibleSize: this._defaultConfiguration.edge.text !== undefined &&
|
|
118
|
-
this._defaultConfiguration.edge.text.minVisibleSize
|
|
119
|
-
? this._defaultConfiguration.edge.text.minVisibleSize
|
|
120
|
-
: 3,
|
|
121
|
-
maxLineLength: this._defaultConfiguration.edge.text !== undefined &&
|
|
122
|
-
this._defaultConfiguration.edge.text.maxLineLength !== undefined
|
|
123
|
-
? this._defaultConfiguration.edge.text.maxLineLength
|
|
124
|
-
: 30,
|
|
125
|
-
backgroundColor: this._defaultConfiguration.edge.text !== undefined &&
|
|
126
|
-
this._defaultConfiguration.edge.text.backgroundColor !== undefined
|
|
127
|
-
? this._defaultConfiguration.edge.text.backgroundColor
|
|
128
|
-
: undefined,
|
|
129
|
-
font: this._defaultConfiguration.edge.text !== undefined &&
|
|
130
|
-
this._defaultConfiguration.edge.text.font !== undefined
|
|
131
|
-
? this._defaultConfiguration.edge.text.font
|
|
132
|
-
: "'roboto', sans-serif",
|
|
133
|
-
color: ((_a = this._defaultConfiguration.edge) === null || _a === void 0 ? void 0 : _a.text) !== undefined &&
|
|
134
|
-
this._defaultConfiguration.edge.text.color !== undefined
|
|
135
|
-
? this._defaultConfiguration.edge.text.color
|
|
136
|
-
: 'black',
|
|
137
|
-
size: this._defaultConfiguration.edge.text !== undefined &&
|
|
138
|
-
this._defaultConfiguration.edge.text.size !== undefined
|
|
139
|
-
? this._defaultConfiguration.edge.text.size
|
|
140
|
-
: 14
|
|
141
|
-
},
|
|
142
|
-
width: this.defaultEdgeWidth(this._defaultConfiguration.edge),
|
|
143
|
-
shape: this._defaultConfiguration.edge.shape !== undefined
|
|
144
|
-
? this._defaultConfiguration.edge.shape
|
|
145
|
-
: 'arrow',
|
|
146
|
-
color: ITEM_DEFAULT_COLOR
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Set nodes default styles based on the configuration
|
|
152
|
-
*/
|
|
153
|
-
setNodesDefaultHalo() {
|
|
154
|
-
// setting default halo style
|
|
155
|
-
this._nodeDefaultHaloRules = this._ogma.styles.addRule({
|
|
156
|
-
nodeSelector: (node) => node && !node.hasClass('filtered'),
|
|
157
|
-
nodeAttributes: {
|
|
158
|
-
halo: (node) => {
|
|
159
|
-
if (node !== undefined &&
|
|
160
|
-
!node.hasClass('filtered') &&
|
|
161
|
-
(node.isSelected() ||
|
|
162
|
-
node.getAdjacentNodes({}).isSelected().includes(true) ||
|
|
163
|
-
node.getAdjacentEdges().isSelected().includes(true))) {
|
|
164
|
-
return Object.assign(Object.assign({}, NODE_HALO_CONFIGURATION), { scalingMethod: this._ogma.geo.enabled() ? 'fixed' : 'scaled' });
|
|
165
|
-
}
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
// recalculate the rule *only* when itself or adjacent
|
|
170
|
-
// elements change their selection status
|
|
171
|
-
nodeDependencies: {
|
|
172
|
-
self: {
|
|
173
|
-
selection: true
|
|
174
|
-
},
|
|
175
|
-
adjacentNodes: {
|
|
176
|
-
selection: true
|
|
177
|
-
},
|
|
178
|
-
adjacentEdges: {
|
|
179
|
-
selection: true
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Set edges default styles based on the configuration
|
|
186
|
-
*/
|
|
187
|
-
setEdgesDefaultHalo() {
|
|
188
|
-
// setting default halo styles
|
|
189
|
-
this._edgeDefaultHaloRules = this._ogma.styles.addRule({
|
|
190
|
-
edgeSelector: (edge) => edge && edge.getSource() && edge.getTarget() && !edge.hasClass('filtered'),
|
|
191
|
-
edgeAttributes: {
|
|
192
|
-
halo: (edge) => {
|
|
193
|
-
if (edge &&
|
|
194
|
-
!edge.hasClass('filtered') &&
|
|
195
|
-
(edge.isSelected() || edge.getSource().isSelected() || edge.getTarget().isSelected())) {
|
|
196
|
-
return Object.assign(Object.assign({}, EDGE_HALO_CONFIGURATION), { scalingMethod: this._ogma.geo.enabled() ? 'fixed' : 'scaled' });
|
|
197
|
-
}
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
// this rule will only be invoked when the selection status
|
|
202
|
-
// of the edge or it's extremities is changed
|
|
203
|
-
edgeDependencies: {
|
|
204
|
-
self: {
|
|
205
|
-
selection: true
|
|
206
|
-
},
|
|
207
|
-
extremities: {
|
|
208
|
-
selection: true
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Return the default node radius set in configuration or 5
|
|
215
|
-
*
|
|
216
|
-
* @returns {number}
|
|
217
|
-
*/
|
|
218
|
-
defaultNodeRadius(styles) {
|
|
219
|
-
return this.defaultStylesHas(styles, ['nodeRadius']) ? styles.nodeRadius : 5;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Return the default edge width set in configuration or 1
|
|
223
|
-
*
|
|
224
|
-
* @returns {number}
|
|
225
|
-
*/
|
|
226
|
-
defaultEdgeWidth(styles) {
|
|
227
|
-
return this.defaultStylesHas(styles, ['edgeWidth']) ? styles.edgeWidth : 1;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Check if a style property exists in the default styles object
|
|
231
|
-
*/
|
|
232
|
-
defaultStylesHas(styles, propertyPath) {
|
|
233
|
-
if (!tools_1.Tools.isDefined(styles)) {
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
return tools_1.Tools.getIn(styles, propertyPath) !== undefined;
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Set styles for the class "filtered"
|
|
240
|
-
*/
|
|
241
|
-
setFilterClass() {
|
|
242
|
-
this._ogma.styles.createClass({
|
|
243
|
-
name: 'filtered',
|
|
244
|
-
nodeAttributes: {
|
|
245
|
-
opacity: exports.FILTER_OPACITY,
|
|
246
|
-
layer: (node) => {
|
|
247
|
-
// if the node is part of a virtual node, it should be on top
|
|
248
|
-
if (node.getMetaNode() !== null) {
|
|
249
|
-
return 1;
|
|
250
|
-
}
|
|
251
|
-
return -1;
|
|
252
|
-
},
|
|
253
|
-
detectable: false,
|
|
254
|
-
badges: {
|
|
255
|
-
topRight: {
|
|
256
|
-
text: null
|
|
257
|
-
},
|
|
258
|
-
bottomRight: {
|
|
259
|
-
text: null
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
text: null,
|
|
263
|
-
color: 'rgb(240, 240, 240)',
|
|
264
|
-
innerStroke: {
|
|
265
|
-
width: 1,
|
|
266
|
-
color: __1.BASE_GREY,
|
|
267
|
-
minVisibleSize: 1
|
|
268
|
-
},
|
|
269
|
-
shape: 'circle',
|
|
270
|
-
image: null,
|
|
271
|
-
icon: null,
|
|
272
|
-
radius: '50%'
|
|
273
|
-
},
|
|
274
|
-
edgeAttributes: {
|
|
275
|
-
opacity: exports.FILTER_OPACITY,
|
|
276
|
-
layer: (edge) => {
|
|
277
|
-
const isEdgeInsideNodeGroup = edge
|
|
278
|
-
.getExtremities()
|
|
279
|
-
.getMetaNode()
|
|
280
|
-
.some((node) => node !== null);
|
|
281
|
-
// if the edge is part of a virtual node, it should be on top
|
|
282
|
-
if (!edge.isVirtual() && isEdgeInsideNodeGroup) {
|
|
283
|
-
return 1;
|
|
284
|
-
}
|
|
285
|
-
return -1;
|
|
286
|
-
},
|
|
287
|
-
detectable: false,
|
|
288
|
-
text: null,
|
|
289
|
-
color: __1.BASE_GREY,
|
|
290
|
-
shape: 'line',
|
|
291
|
-
width: 0.2
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Set the class for exported nodes and edges
|
|
297
|
-
*/
|
|
298
|
-
setExportClass(textWrappingLength) {
|
|
299
|
-
if (!this._exportClass) {
|
|
300
|
-
this._exportClass = this._ogma.styles.createClass({
|
|
301
|
-
name: 'exported',
|
|
302
|
-
nodeAttributes: {
|
|
303
|
-
text: {
|
|
304
|
-
minVisibleSize: 0,
|
|
305
|
-
size: 12,
|
|
306
|
-
maxLineLength: textWrappingLength ? 30 : 0
|
|
307
|
-
},
|
|
308
|
-
halo: null
|
|
309
|
-
},
|
|
310
|
-
edgeAttributes: {
|
|
311
|
-
text: {
|
|
312
|
-
minVisibleSize: 0,
|
|
313
|
-
size: 12
|
|
314
|
-
},
|
|
315
|
-
halo: null
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
this._exportClass.update({
|
|
321
|
-
nodeAttributes: {
|
|
322
|
-
text: {
|
|
323
|
-
maxLineLength: textWrappingLength ? 30 : 0
|
|
324
|
-
},
|
|
325
|
-
halo: null
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Set the rule to display badges
|
|
332
|
-
*/
|
|
333
|
-
setBadgeRule() {
|
|
334
|
-
this._ogma.styles.createClass({
|
|
335
|
-
name: 'degreeIndicator',
|
|
336
|
-
nodeAttributes: {
|
|
337
|
-
badges: {
|
|
338
|
-
topRight: (node) => {
|
|
339
|
-
if (node !== undefined) {
|
|
340
|
-
const degree = tools_1.Tools.getHiddenNeighbors(node.toList());
|
|
341
|
-
const badgeContent = tools_1.Tools.formatNumber(degree);
|
|
342
|
-
if (degree > 0) {
|
|
343
|
-
const nodeColor = Array.isArray(node.getAttribute('color'))
|
|
344
|
-
? node.getAttribute('color')[0]
|
|
345
|
-
: node.getAttribute('color');
|
|
346
|
-
const textColor = __1.OgmaTools.isBright(nodeColor)
|
|
347
|
-
? DARK_FONT_COLOR
|
|
348
|
-
: CLEAR_FONT_COLOR;
|
|
349
|
-
const isSupernode = node.getData(['statistics', 'supernode']);
|
|
350
|
-
let content = null;
|
|
351
|
-
if (+badgeContent !== 0) {
|
|
352
|
-
content = isSupernode ? badgeContent + '+' : badgeContent;
|
|
353
|
-
}
|
|
354
|
-
return {
|
|
355
|
-
color: 'inherit',
|
|
356
|
-
minVisibleSize: 20,
|
|
357
|
-
stroke: {
|
|
358
|
-
width: 0,
|
|
359
|
-
color: null
|
|
360
|
-
},
|
|
361
|
-
text: {
|
|
362
|
-
font: this._defaultConfiguration.node.text !== undefined &&
|
|
363
|
-
this._defaultConfiguration.node.text.font !== undefined
|
|
364
|
-
? this._defaultConfiguration.node.text.font
|
|
365
|
-
: DEFAULT_OGMA_FONT,
|
|
366
|
-
scale: 0.4,
|
|
367
|
-
color: textColor,
|
|
368
|
-
content: content
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
this._ogma.styles.createClass({
|
|
378
|
-
name: 'pinnedIndicator',
|
|
379
|
-
nodeAttributes: {
|
|
380
|
-
badges: {
|
|
381
|
-
bottomRight: (node) => {
|
|
382
|
-
if (node !== undefined && !node.getAttribute('layoutable')) {
|
|
383
|
-
return {
|
|
384
|
-
color: this._findPinBadgeBackgroundColor(node),
|
|
385
|
-
minVisibleSize: 20,
|
|
386
|
-
scale: this._findPinBadgeScale(node),
|
|
387
|
-
stroke: {
|
|
388
|
-
width: 0,
|
|
389
|
-
color: null
|
|
390
|
-
},
|
|
391
|
-
text: {
|
|
392
|
-
font: 'FontAwesome',
|
|
393
|
-
scale: 0.4,
|
|
394
|
-
color: this._findPinBadgeTextColor(node),
|
|
395
|
-
content: node.getAttribute('layoutable') ? null : '\uf08d'
|
|
396
|
-
}
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
},
|
|
402
|
-
nodeDependencies: {
|
|
403
|
-
self: { attributes: ['layoutable'] }
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
this._ogma.events.on('addNodes', (nodesEvent) => nodesEvent.nodes.addClass('degreeIndicator'));
|
|
407
|
-
this._ogma.events.on('addNodes', (nodesEvent) => nodesEvent.nodes.addClass('pinnedIndicator'));
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Delete the rule to display badges
|
|
411
|
-
*/
|
|
412
|
-
deleteBadgeRule() {
|
|
413
|
-
this._ogma.getNodes().removeClasses(['degreeIndicator', 'pinnedIndicator'], 0);
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* set text overlap to true or false
|
|
417
|
-
*
|
|
418
|
-
* @param {boolean} overlap
|
|
419
|
-
*/
|
|
420
|
-
toggleTextOverlap(overlap) {
|
|
421
|
-
this._ogma.setOptions({ texts: { preventOverlap: overlap } });
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* refresh nodes and edge rules
|
|
425
|
-
*
|
|
426
|
-
*/
|
|
427
|
-
refreshRules() {
|
|
428
|
-
this._nodeDefaultStylesRules.refresh();
|
|
429
|
-
this._edgeDefaultStylesRules.refresh();
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
|
-
* Create / refresh an ogma rule for node colors
|
|
433
|
-
*/
|
|
434
|
-
refreshNodeColors(colorStyleRules) {
|
|
435
|
-
if (!tools_1.Tools.isDefined(this._ogmaNodeColor)) {
|
|
436
|
-
this._nodeAttributes.refresh({ color: colorStyleRules });
|
|
437
|
-
this._ogmaNodeColor = this._ogma.styles.addRule({
|
|
438
|
-
nodeAttributes: {
|
|
439
|
-
color: (node) => {
|
|
440
|
-
if (node !== undefined) {
|
|
441
|
-
return this._nodeAttributes.color(node.getData());
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
},
|
|
445
|
-
nodeDependencies: { self: { data: true } }
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
else {
|
|
449
|
-
this._nodeAttributes.refresh({ color: colorStyleRules });
|
|
450
|
-
this._ogmaNodeColor.refresh();
|
|
451
|
-
// TODO refresh node icons when moving the code from LKE
|
|
452
|
-
// this.refreshIconsColor();
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Return an array of StyleRules with only the style that need to be applied
|
|
457
|
-
*/
|
|
458
|
-
getStyleRule(state, styleType) {
|
|
459
|
-
return new __1.StyleRules(state)[styleType];
|
|
460
|
-
}
|
|
461
|
-
initNodeColors(nodeRules) {
|
|
462
|
-
const nodeColorRules = this.getStyleRule(nodeRules, __1.StyleType.COLOR);
|
|
463
|
-
this.refreshNodeColors(nodeColorRules);
|
|
464
|
-
}
|
|
465
|
-
initNodesIcons(nodeRules) {
|
|
466
|
-
const nodeIconsRules = this.getStyleRule(nodeRules, __1.StyleType.ICON);
|
|
467
|
-
this.refreshNodeIcons(nodeIconsRules);
|
|
468
|
-
}
|
|
469
|
-
initNodesSizes(nodeRules) {
|
|
470
|
-
const nodeSizeRules = this.getStyleRule(nodeRules, __1.StyleType.SIZE);
|
|
471
|
-
this.refreshNodeSize(nodeSizeRules);
|
|
472
|
-
}
|
|
473
|
-
initNodesShapes(nodeRules) {
|
|
474
|
-
const nodeShapesRules = this.getStyleRule(nodeRules, __1.StyleType.SHAPE);
|
|
475
|
-
this.refreshNodeShape(nodeShapesRules);
|
|
476
|
-
}
|
|
477
|
-
initEdgesWidth(edgeRules) {
|
|
478
|
-
const edgesWidthRules = this.getStyleRule(edgeRules, __1.StyleType.WIDTH);
|
|
479
|
-
this.refreshEdgeWidth(edgesWidthRules);
|
|
480
|
-
}
|
|
481
|
-
initEdgesShape(edgeRules) {
|
|
482
|
-
const edgesShapeRules = this.getStyleRule(edgeRules, __1.StyleType.SHAPE);
|
|
483
|
-
this.refreshEdgeShape(edgesShapeRules);
|
|
484
|
-
}
|
|
485
|
-
initEdgesColor(edgeRules) {
|
|
486
|
-
const edgesColorRules = this.getStyleRule(edgeRules, __1.StyleType.COLOR);
|
|
487
|
-
this.refreshEdgeColors(edgesColorRules);
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Create / refresh an ogma rule for node icons
|
|
491
|
-
*
|
|
492
|
-
* @param {Array<any>} iconStyleRules
|
|
493
|
-
*/
|
|
494
|
-
refreshNodeIcons(iconStyleRules) {
|
|
495
|
-
if (!tools_1.Tools.isDefined(this._ogmaNodeIcon)) {
|
|
496
|
-
this._nodeAttributes.refresh({ icon: iconStyleRules });
|
|
497
|
-
this._ogmaNodeIcon = this._ogma.styles.addRule({
|
|
498
|
-
nodeAttributes: {
|
|
499
|
-
icon: (node) => {
|
|
500
|
-
if (node !== undefined) {
|
|
501
|
-
return this._nodeAttributes.icon(node.getData()).icon;
|
|
502
|
-
}
|
|
503
|
-
},
|
|
504
|
-
image: (node) => {
|
|
505
|
-
if (node !== undefined && !node.isVirtual()) {
|
|
506
|
-
return this._nodeAttributes.icon(node.getData()).image;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
},
|
|
510
|
-
nodeDependencies: { self: { data: true } }
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
else {
|
|
514
|
-
this._nodeAttributes.refresh({ icon: iconStyleRules });
|
|
515
|
-
void this._ogmaNodeIcon.refresh();
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
/**
|
|
519
|
-
* Create / refresh an ogma rule for node sizes
|
|
520
|
-
*
|
|
521
|
-
* @param {Array<any>} sizeStyleRules
|
|
522
|
-
*/
|
|
523
|
-
refreshNodeSize(sizeStyleRules) {
|
|
524
|
-
if (!tools_1.Tools.isDefined(this._ogmaNodeSize)) {
|
|
525
|
-
this._nodeAttributes.refresh({ size: sizeStyleRules });
|
|
526
|
-
this._ogmaNodeSize = this._ogma.styles.addRule({
|
|
527
|
-
nodeAttributes: {
|
|
528
|
-
radius: (node) => {
|
|
529
|
-
if (node !== undefined) {
|
|
530
|
-
return this._nodeAttributes.size(node.getData());
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
},
|
|
534
|
-
nodeDependencies: { self: { data: true } }
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
else {
|
|
538
|
-
this._nodeAttributes.refresh({ size: sizeStyleRules });
|
|
539
|
-
this._ogmaNodeSize.refresh();
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
/**
|
|
543
|
-
* Create / refresh an ogma rule for node images
|
|
544
|
-
*
|
|
545
|
-
* @param {Array<any>} shapeStyleRules
|
|
546
|
-
*/
|
|
547
|
-
refreshNodeShape(shapeStyleRules) {
|
|
548
|
-
if (!tools_1.Tools.isDefined(this._ogmaNodeShape)) {
|
|
549
|
-
this._nodeAttributes.refresh({ shape: shapeStyleRules });
|
|
550
|
-
this._ogmaNodeShape = this._ogma.styles.addRule({
|
|
551
|
-
nodeAttributes: {
|
|
552
|
-
shape: (node) => {
|
|
553
|
-
if (node !== undefined) {
|
|
554
|
-
return this._nodeAttributes.shape(node.getData());
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
},
|
|
558
|
-
nodeSelector: (node) => node !== undefined && !node.isVirtual(),
|
|
559
|
-
nodeDependencies: { self: { data: true } }
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
else {
|
|
563
|
-
this._nodeAttributes.refresh({ shape: shapeStyleRules });
|
|
564
|
-
this._ogmaNodeShape.refresh();
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
/**
|
|
568
|
-
* Create / refresh an ogma rule for edge colors
|
|
569
|
-
*/
|
|
570
|
-
refreshEdgeColors(colorStyleRules) {
|
|
571
|
-
if (!tools_1.Tools.isDefined(this._ogmaEdgeColor)) {
|
|
572
|
-
this._edgeAttributes.refresh({ color: colorStyleRules });
|
|
573
|
-
this._ogmaEdgeColor = this._ogma.styles.addRule({
|
|
574
|
-
edgeAttributes: {
|
|
575
|
-
color: (edge) => {
|
|
576
|
-
if (edge !== undefined) {
|
|
577
|
-
return this._edgeAttributes.color(edge.getData());
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
},
|
|
581
|
-
edgeDependencies: { self: { data: true } }
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
else {
|
|
585
|
-
this._edgeAttributes.refresh({ color: colorStyleRules });
|
|
586
|
-
this._ogmaEdgeColor.refresh();
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
/**
|
|
590
|
-
* Create / refresh an ogma rule for edge width
|
|
591
|
-
*
|
|
592
|
-
* @param {Array<LKStyleRule>} widthStyleRules
|
|
593
|
-
*/
|
|
594
|
-
refreshEdgeWidth(widthStyleRules) {
|
|
595
|
-
if (!tools_1.Tools.isDefined(this._ogmaEdgeWidth)) {
|
|
596
|
-
this._edgeAttributes.refresh({ width: widthStyleRules });
|
|
597
|
-
this._ogmaEdgeWidth = this._ogma.styles.addRule({
|
|
598
|
-
edgeAttributes: {
|
|
599
|
-
width: (edge) => {
|
|
600
|
-
if (edge !== undefined) {
|
|
601
|
-
return this._edgeAttributes.width(edge.getData());
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
},
|
|
605
|
-
edgeDependencies: {
|
|
606
|
-
self: { data: true }
|
|
607
|
-
}
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
else {
|
|
611
|
-
this._edgeAttributes.refresh({ width: widthStyleRules });
|
|
612
|
-
this._ogmaEdgeWidth.refresh();
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* Create / refresh an ogma rule for edge width
|
|
617
|
-
*
|
|
618
|
-
* @param {Array<LKStyleRule>} shapeStyleRules
|
|
619
|
-
*/
|
|
620
|
-
refreshEdgeShape(shapeStyleRules) {
|
|
621
|
-
if (!tools_1.Tools.isDefined(this._ogmaEdgeShape)) {
|
|
622
|
-
this._edgeAttributes.refresh({ shape: shapeStyleRules });
|
|
623
|
-
this._ogmaEdgeShape = this._ogma.styles.addRule({
|
|
624
|
-
edgeAttributes: {
|
|
625
|
-
shape: (edge) => {
|
|
626
|
-
if (edge !== undefined) {
|
|
627
|
-
return this._edgeAttributes.shape(edge.getData());
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
},
|
|
631
|
-
edgeDependencies: { self: { data: true } }
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
else {
|
|
635
|
-
this._edgeAttributes.refresh({ shape: shapeStyleRules });
|
|
636
|
-
this._ogmaEdgeShape.refresh();
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Get node radius
|
|
641
|
-
* This is a workaround for an ogma issue where the radius of virtual nodes is always set to 5
|
|
642
|
-
* TODO: check if this is still needed after ogma release the new improvement for transformation v5.X
|
|
643
|
-
*/
|
|
644
|
-
_getNodeRadius(node) {
|
|
645
|
-
var _a;
|
|
646
|
-
if (!node.isVirtual()) {
|
|
647
|
-
return node.getAttribute('radius');
|
|
648
|
-
}
|
|
649
|
-
else {
|
|
650
|
-
// get the width and height of the box that contains the nodes inside the virtual node
|
|
651
|
-
const { width, height } = (_a = node.getSubNodes()) === null || _a === void 0 ? void 0 : _a.getBoundingBox();
|
|
652
|
-
return Math.max(width, height);
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* Calculate the scale of the pin badge related to the node radius
|
|
657
|
-
* This is useful when dealing wih huge nodes, and we don't want the badge to be big
|
|
658
|
-
* If the node is small enough, the badge will be 0.46 of the node radius
|
|
659
|
-
* Else it will be 5 / radius
|
|
660
|
-
*/
|
|
661
|
-
_findPinBadgeScale(node) {
|
|
662
|
-
// the maximum radius for the badge
|
|
663
|
-
const MAX = 5;
|
|
664
|
-
const defaultRatio = 0.46;
|
|
665
|
-
const bigNodeRatio = 0.17;
|
|
666
|
-
const radius = this._getNodeRadius(node);
|
|
667
|
-
return radius * defaultRatio > MAX ? bigNodeRatio : defaultRatio;
|
|
668
|
-
}
|
|
669
|
-
/**
|
|
670
|
-
* Find the color of the pin badge text
|
|
671
|
-
*/
|
|
672
|
-
_findPinBadgeTextColor(node) {
|
|
673
|
-
if (node.isVirtual()) {
|
|
674
|
-
return CLEAR_FONT_COLOR;
|
|
675
|
-
}
|
|
676
|
-
const nodeColor = Array.isArray(node.getAttribute('color'))
|
|
677
|
-
? node.getAttribute('color')[0]
|
|
678
|
-
: node.getAttribute('color');
|
|
679
|
-
return __1.OgmaTools.isBright(nodeColor) ? DARK_FONT_COLOR : CLEAR_FONT_COLOR;
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* Find the color of the pin badge background
|
|
683
|
-
*/
|
|
684
|
-
_findPinBadgeBackgroundColor(node) {
|
|
685
|
-
return node.isVirtual() ? __1.BASE_GREY : 'inherit';
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
exports.StylesViz = StylesViz;
|
|
689
|
-
//# sourceMappingURL=styles.js.map
|