@linkurious/ogma-linkurious-parser 4.0.24 → 4.0.25
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/README.md +37 -33
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/ogma/features/captions.js +3 -1
- package/dist/ogma/features/captions.js.map +1 -1
- package/dist/ogma/features/nodeGrouping.d.ts +68 -0
- package/dist/ogma/features/nodeGrouping.js +247 -0
- package/dist/ogma/features/nodeGrouping.js.map +1 -0
- package/dist/ogma/features/styles.d.ts +1 -0
- package/dist/ogma/features/styles.js +24 -6
- package/dist/ogma/features/styles.js.map +1 -1
- package/dist/ogma/features/transformations.js +8 -3
- package/dist/ogma/features/transformations.js.map +1 -1
- package/dist/ogma/index.d.ts +22 -5
- package/dist/ogma/index.js +31 -12
- package/dist/ogma/index.js.map +1 -1
- package/dist/styles/nodeAttributes.d.ts +8 -1
- package/dist/styles/nodeAttributes.js +18 -4
- package/dist/styles/nodeAttributes.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# Ogma-Linkurious-Parser
|
|
1
|
+
# Ogma-Linkurious-Parser
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
Ogma-Linkurious-Parser is an official library maintained by the Linkurious team that allows you to quickly parse and load a Linkurious Enterprise visualization in Ogma with one line of code and apply different Linkurious Enterprise styles, filters, captions and more.
|
|
5
5
|
|
|
6
6
|
### Prerequisites
|
|
7
7
|
- Linkurious Enterprise 2.10.x or above
|
|
8
|
-
- An existing visualization to export
|
|
8
|
+
- An existing visualization to export
|
|
9
9
|
- An Ogma license
|
|
10
10
|
|
|
11
11
|
# Installation
|
|
@@ -22,8 +22,7 @@ In order to create an Ogma visualization with your Linkurious styles:
|
|
|
22
22
|
|
|
23
23
|
3. If you need to reproduce the same caption styles, get graph schema using [Linkurious Enterprise REST API](https://doc.linkurious.com/server-sdk/latest/apidoc/#api-Schema-getTypes).
|
|
24
24
|
|
|
25
|
-
4. Initialize `LKOgma` and call `initVisualization` with the configuration and the visualization data from the previous steps.
|
|
26
|
-
|
|
25
|
+
4. Initialize `LKOgma` and call `initVisualization` with the configuration and the visualization data from the previous steps. You can also pass a base url as second parameter in case you are using relative paths in your image style urls.
|
|
27
26
|
|
|
28
27
|
A full working example using the [Linkurious Enterprise REST API](https://github.com/Linkurious/linkurious-rest-client/) library:
|
|
29
28
|
|
|
@@ -32,7 +31,7 @@ const {RestClient} = require('@linkurious/rest-client');
|
|
|
32
31
|
const {LKOgma} = require('@linkurious/ogma-linkurious-parser');
|
|
33
32
|
|
|
34
33
|
async function main() {
|
|
35
|
-
|
|
34
|
+
|
|
36
35
|
// Initialize the rest client
|
|
37
36
|
const rc = new RestClient({baseUrl: 'http://localhost:3000'});
|
|
38
37
|
// Log in
|
|
@@ -44,38 +43,43 @@ async function main() {
|
|
|
44
43
|
const linkuriousConfigurationResponse = await rc.config.getConfiguration();
|
|
45
44
|
// Get the visualisation configuration response
|
|
46
45
|
const visualizationResponse = await rc
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
.visualization.getVisualization({
|
|
47
|
+
sourceKey: 'e7900d9b',
|
|
48
|
+
id: 3
|
|
49
|
+
});
|
|
51
50
|
const nodeTypesResponse = await this.rc.graphSchema.getTypesWithAccess({
|
|
52
51
|
entityType: 'node'
|
|
53
52
|
});
|
|
54
53
|
const edgeTypesResponse = await this.rc.graphSchema.getTypesWithAccess({
|
|
55
54
|
entityType: 'edge'
|
|
56
55
|
});
|
|
57
|
-
|
|
58
|
-
if (linkuriousConfigurationResponse.isSuccess() && visualizationResponse.isSuccess() && nodeTypesResponse.isSuccess() && edgeTypesResponse.isSuccess) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
56
|
+
|
|
57
|
+
if (linkuriousConfigurationResponse.isSuccess() && visualizationResponse.isSuccess() && nodeTypesResponse.isSuccess() && edgeTypesResponse.isSuccess()) {
|
|
58
|
+
const ogmaConfiguration = linkuriousConfigurationResponse.body.ogma;
|
|
59
|
+
const lkeServerBaseUrl = linkuriousConfigurationResponse.body.url;
|
|
60
|
+
const graphSchema = {
|
|
61
|
+
node: nodeTypesResponse.body.node.results,
|
|
62
|
+
edge: edgeTypesResponse.body.edge.results
|
|
63
|
+
}
|
|
64
|
+
const visualizationConfiguration = visualizationResponse.body;
|
|
65
|
+
// Initialize ogma object
|
|
66
|
+
const ogma = new LKOgma(
|
|
67
|
+
{
|
|
68
|
+
...ogmaConfiguration,
|
|
69
|
+
options: {
|
|
70
|
+
...ogmaConfiguration.options,
|
|
71
|
+
backgroundColor: 'rgba(240, 240, 240)'
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
// the base url is an optional parameter
|
|
75
|
+
lkeServerBaseUrl
|
|
76
|
+
);
|
|
77
|
+
// Set HTML container where Ogma will be rendered
|
|
78
|
+
ogma.setContainer('graph-container');
|
|
79
|
+
// Set graphSchema that will be used in defining caption styles
|
|
80
|
+
ogma.LKCaptions.graphSchema = graphSchema;
|
|
81
|
+
// Initialize the visualization content & styles
|
|
82
|
+
await ogma.initVisualization(visualizationConfiguration);
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
|
|
@@ -87,8 +91,8 @@ main();
|
|
|
87
91
|
-->
|
|
88
92
|
|
|
89
93
|
You can use any other Ogma feature you would like to apply to the visualization.
|
|
90
|
-
|
|
94
|
+
|
|
91
95
|
> To learn more about Ogma check our [official documentation](https://doc.linkurious.com/ogma/latest/).
|
|
92
|
-
|
|
96
|
+
|
|
93
97
|
## Licensing
|
|
94
98
|
The Ogma-Linkurious-parser is licensed under the Apache License, Version 2.0. See [LICENSE](/LICENSE) for the full license text.
|
package/dist/index.d.ts
CHANGED
|
@@ -16,3 +16,4 @@ export { OgmaStore } from './ogma/features/OgmaStore';
|
|
|
16
16
|
export { getSelectionSize, getSelectionState, getSelectionEntity, getUniqSelection, getUniqSelectionTypes, getUniqSelectionEntity, getSelectionProperties, hasSelectionProperties } from './ogma/features/selectors';
|
|
17
17
|
export { LKOgma, ANIMATION_DURATION } from './ogma';
|
|
18
18
|
export { Tools } from './tools/tools';
|
|
19
|
+
export { LKE_NODE_GROUPING_EDGE } from './ogma/features/nodeGrouping';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Tools = exports.ANIMATION_DURATION = exports.LKOgma = exports.hasSelectionProperties = exports.getSelectionProperties = exports.getUniqSelectionEntity = exports.getUniqSelectionTypes = exports.getUniqSelection = exports.getSelectionEntity = exports.getSelectionState = exports.getSelectionSize = exports.OgmaStore = exports.Filters = exports.HTML_COLORS = exports.OgmaTools = exports.CaptionsViz = exports.TransformationsViz = exports.FILTER_OPACITY = exports.StylesViz = exports.StyleType = exports.StyleRules = exports.StyleRuleType = exports.StyleRule = exports.NodeAttributes = exports.EdgeAttributes = exports.PALETTE = exports.BASE_GREY = exports.ItemAttributes = exports.Captions = exports.NodeList = exports.Node = exports.EdgeList = exports.Edge = void 0;
|
|
3
|
+
exports.LKE_NODE_GROUPING_EDGE = exports.Tools = exports.ANIMATION_DURATION = exports.LKOgma = exports.hasSelectionProperties = exports.getSelectionProperties = exports.getUniqSelectionEntity = exports.getUniqSelectionTypes = exports.getUniqSelection = exports.getSelectionEntity = exports.getSelectionState = exports.getSelectionSize = exports.OgmaStore = exports.Filters = exports.HTML_COLORS = exports.OgmaTools = exports.CaptionsViz = exports.TransformationsViz = exports.FILTER_OPACITY = exports.StylesViz = exports.StyleType = exports.StyleRules = exports.StyleRuleType = exports.StyleRule = exports.NodeAttributes = exports.EdgeAttributes = exports.PALETTE = exports.BASE_GREY = exports.ItemAttributes = exports.Captions = exports.NodeList = exports.Node = exports.EdgeList = exports.Edge = void 0;
|
|
4
4
|
var ogma_1 = require("@linkurious/ogma");
|
|
5
5
|
Object.defineProperty(exports, "Edge", { enumerable: true, get: function () { return ogma_1.Edge; } });
|
|
6
6
|
Object.defineProperty(exports, "EdgeList", { enumerable: true, get: function () { return ogma_1.EdgeList; } });
|
|
@@ -51,4 +51,6 @@ Object.defineProperty(exports, "LKOgma", { enumerable: true, get: function () {
|
|
|
51
51
|
Object.defineProperty(exports, "ANIMATION_DURATION", { enumerable: true, get: function () { return ogma_2.ANIMATION_DURATION; } });
|
|
52
52
|
var tools_1 = require("./tools/tools");
|
|
53
53
|
Object.defineProperty(exports, "Tools", { enumerable: true, get: function () { return tools_1.Tools; } });
|
|
54
|
+
var nodeGrouping_1 = require("./ogma/features/nodeGrouping");
|
|
55
|
+
Object.defineProperty(exports, "LKE_NODE_GROUPING_EDGE", { enumerable: true, get: function () { return nodeGrouping_1.LKE_NODE_GROUPING_EDGE; } });
|
|
54
56
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yCAsB0B;AArBxB,4FAAA,IAAI,OAAA;AACJ,gGAAA,QAAQ,OAAA;AACR,4FAAA,IAAI,OAAA;AACJ,gGAAA,QAAQ,OAAA;AAoBV,gDAA6C;AAArC,oGAAA,QAAQ,OAAA;AAChB,0DAA2E;AAAnE,gHAAA,cAAc,OAAA;AAAE,2GAAA,SAAS,OAAA;AAAE,yGAAA,OAAO,OAAA;AAC1C,0DAAuD;AAA/C,gHAAA,cAAc,OAAA;AACtB,0DAAuD;AAA/C,gHAAA,cAAc,OAAA;AACtB,gDAA4D;AAApD,sGAAA,SAAS,OAAA;AAAE,0GAAA,aAAa,OAAA;AAChC,kDAAkE;AAA1D,wGAAA,UAAU,OAAA;AAAE,uGAAA,SAAS,OAAA;AAC7B,iDAA+E;AAAvE,mGAAA,SAAS,OAAA;AAAgB,wGAAA,cAAc,OAAA;AAC/C,mEAAmE;AAA3D,qHAAA,kBAAkB,OAAA;AAC1B,qDAAmE;AAA3D,uGAAA,WAAW,OAAA;AAEnB,6CAA2C;AAAnC,qGAAA,SAAS,OAAA;AACjB,qDAAiD;AAAzC,2GAAA,WAAW,OAAA;AACnB,6CAA0C;AAAlC,kGAAA,OAAO,OAAA;AACf,uDAAoD;AAA5C,sGAAA,SAAS,OAAA;AACjB,uDASmC;AARjC,6GAAA,gBAAgB,OAAA;AAChB,8GAAA,iBAAiB,OAAA;AACjB,+GAAA,kBAAkB,OAAA;AAClB,6GAAA,gBAAgB,OAAA;AAChB,kHAAA,qBAAqB,OAAA;AACrB,mHAAA,sBAAsB,OAAA;AACtB,mHAAA,sBAAsB,OAAA;AACtB,mHAAA,sBAAsB,OAAA;AAExB,+BAAkD;AAA1C,8FAAA,MAAM,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAClC,uCAAoC;AAA5B,8FAAA,KAAK,OAAA","sourcesContent":["'use strict';\n\nexport {\n Edge,\n EdgeList,\n Node,\n NodeList,\n EdgeId,\n NodeId,\n RawEdge,\n RawItem,\n RawNode,\n PropertyPath,\n Item,\n ItemId,\n EdgeStyle,\n PixelSize,\n EdgeExtremity,\n EdgeType,\n GeoModeOptions,\n EdgesDataEvent,\n NodesDataEvent,\n NodesDragEndEvent,\n NodesEvent\n} from '@linkurious/ogma';\n\nexport {Captions} from './captions/captions';\nexport {ItemAttributes, BASE_GREY, PALETTE} from './styles/itemAttributes';\nexport {EdgeAttributes} from './styles/edgeAttributes';\nexport {NodeAttributes} from './styles/nodeAttributes';\nexport {StyleRule, StyleRuleType} from './styles/styleRule';\nexport {StyleRules, StyleType, Legend} from './styles/styleRules';\nexport {StylesViz, StylesConfig, FILTER_OPACITY} from './ogma/features/styles';\nexport {TransformationsViz} from './ogma/features/transformations';\nexport {CaptionsViz, CaptionState} from './ogma/features/captions';\nexport {OgmaState} from './ogma/features/reactive';\nexport {OgmaTools} from './tools/ogmaTool';\nexport {HTML_COLORS} from './tools/colorPalette';\nexport {Filters} from './filters/filters';\nexport {OgmaStore} from './ogma/features/OgmaStore';\nexport {\n getSelectionSize,\n getSelectionState,\n getSelectionEntity,\n getUniqSelection,\n getUniqSelectionTypes,\n getUniqSelectionEntity,\n getSelectionProperties,\n hasSelectionProperties\n} from './ogma/features/selectors';\nexport {LKOgma, ANIMATION_DURATION} from './ogma';\nexport {Tools} from './tools/tools';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yCAsB0B;AArBxB,4FAAA,IAAI,OAAA;AACJ,gGAAA,QAAQ,OAAA;AACR,4FAAA,IAAI,OAAA;AACJ,gGAAA,QAAQ,OAAA;AAoBV,gDAA6C;AAArC,oGAAA,QAAQ,OAAA;AAChB,0DAA2E;AAAnE,gHAAA,cAAc,OAAA;AAAE,2GAAA,SAAS,OAAA;AAAE,yGAAA,OAAO,OAAA;AAC1C,0DAAuD;AAA/C,gHAAA,cAAc,OAAA;AACtB,0DAAuD;AAA/C,gHAAA,cAAc,OAAA;AACtB,gDAA4D;AAApD,sGAAA,SAAS,OAAA;AAAE,0GAAA,aAAa,OAAA;AAChC,kDAAkE;AAA1D,wGAAA,UAAU,OAAA;AAAE,uGAAA,SAAS,OAAA;AAC7B,iDAA+E;AAAvE,mGAAA,SAAS,OAAA;AAAgB,wGAAA,cAAc,OAAA;AAC/C,mEAAmE;AAA3D,qHAAA,kBAAkB,OAAA;AAC1B,qDAAmE;AAA3D,uGAAA,WAAW,OAAA;AAEnB,6CAA2C;AAAnC,qGAAA,SAAS,OAAA;AACjB,qDAAiD;AAAzC,2GAAA,WAAW,OAAA;AACnB,6CAA0C;AAAlC,kGAAA,OAAO,OAAA;AACf,uDAAoD;AAA5C,sGAAA,SAAS,OAAA;AACjB,uDASmC;AARjC,6GAAA,gBAAgB,OAAA;AAChB,8GAAA,iBAAiB,OAAA;AACjB,+GAAA,kBAAkB,OAAA;AAClB,6GAAA,gBAAgB,OAAA;AAChB,kHAAA,qBAAqB,OAAA;AACrB,mHAAA,sBAAsB,OAAA;AACtB,mHAAA,sBAAsB,OAAA;AACtB,mHAAA,sBAAsB,OAAA;AAExB,+BAAkD;AAA1C,8FAAA,MAAM,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAClC,uCAAoC;AAA5B,8FAAA,KAAK,OAAA;AAEb,6DAAoE;AAA5D,sHAAA,sBAAsB,OAAA","sourcesContent":["'use strict';\n\nexport {\n Edge,\n EdgeList,\n Node,\n NodeList,\n EdgeId,\n NodeId,\n RawEdge,\n RawItem,\n RawNode,\n PropertyPath,\n Item,\n ItemId,\n EdgeStyle,\n PixelSize,\n EdgeExtremity,\n EdgeType,\n GeoModeOptions,\n EdgesDataEvent,\n NodesDataEvent,\n NodesDragEndEvent,\n NodesEvent\n} from '@linkurious/ogma';\n\nexport {Captions} from './captions/captions';\nexport {ItemAttributes, BASE_GREY, PALETTE} from './styles/itemAttributes';\nexport {EdgeAttributes} from './styles/edgeAttributes';\nexport {NodeAttributes} from './styles/nodeAttributes';\nexport {StyleRule, StyleRuleType} from './styles/styleRule';\nexport {StyleRules, StyleType, Legend} from './styles/styleRules';\nexport {StylesViz, StylesConfig, FILTER_OPACITY} from './ogma/features/styles';\nexport {TransformationsViz} from './ogma/features/transformations';\nexport {CaptionsViz, CaptionState} from './ogma/features/captions';\nexport {OgmaState} from './ogma/features/reactive';\nexport {OgmaTools} from './tools/ogmaTool';\nexport {HTML_COLORS} from './tools/colorPalette';\nexport {Filters} from './filters/filters';\nexport {OgmaStore} from './ogma/features/OgmaStore';\nexport {\n getSelectionSize,\n getSelectionState,\n getSelectionEntity,\n getUniqSelection,\n getUniqSelectionTypes,\n getUniqSelectionEntity,\n getSelectionProperties,\n hasSelectionProperties\n} from './ogma/features/selectors';\nexport {LKOgma, ANIMATION_DURATION} from './ogma';\nexport {Tools} from './tools/tools';\n\nexport {LKE_NODE_GROUPING_EDGE} from './ogma/features/nodeGrouping';\n"]}
|
|
@@ -72,6 +72,8 @@ class CaptionsViz {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
|
+
// We ignore virtual nodes as they have their proper caption
|
|
76
|
+
nodeSelector: (node) => !node.isVirtual(),
|
|
75
77
|
nodeDependencies: { self: { data: true } }
|
|
76
78
|
});
|
|
77
79
|
}
|
|
@@ -101,7 +103,7 @@ class CaptionsViz {
|
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
},
|
|
104
|
-
edgeSelector: (edge) => !edge.isVirtual()
|
|
106
|
+
edgeSelector: (edge) => !edge.isVirtual(),
|
|
105
107
|
// ogma will trigger the rendering if data change or the shape change (to trigger the rendering when edges are grouped)
|
|
106
108
|
edgeDependencies: { self: { data: true, attributes: ['shape.style'] } }
|
|
107
109
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"captions.js","sourceRoot":"","sources":["../../../src/ogma/features/captions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;AAKb,6BAAuC;AACvC,6CAAwC;AAOxC,MAAa,WAAW;IAUtB,YACE,IAAY,EACJ,kBAAsC,EACtC,kBAAsC;QADtC,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,uBAAkB,GAAlB,kBAAkB,CAAoB;QATxC,mBAAc,GAAiB,EAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAC,CAAC;QACpD,iBAAY,GAGhB,EAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAC,CAAC;QAOvB,IAAI,CAAC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AuH;gBACvH,gBAAgB,EAAE,EAAC,IAAI,EAAE,EAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,aAAa,CAAC,EAAC,EAAC;aACpE,CAAC,CAAC;SACJ;aAAM;YACL,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;SACzC;IACH,CAAC;CACF;AAvHD,kCAuHC","sourcesContent":["'use strict';\n\nimport * as Ogma from '@linkurious/ogma';\nimport {GraphSchemaTypeWithAccess, ItemFieldsCaptions} from '@linkurious/rest-client';\n\nimport {Captions, LKOgma} from '../..';\nimport {Tools} from '../../tools/tools';\n\nexport interface CaptionState {\n node: ItemFieldsCaptions;\n edge: ItemFieldsCaptions;\n}\n\nexport class CaptionsViz {\n public nodesCaptionsRule!: Ogma.StyleRule;\n public edgesCaptionsRule!: Ogma.StyleRule;\n private _ogma: LKOgma;\n private _captionSchema: CaptionState = {node: {}, edge: {}};\n private _graphSchema: {\n node: Array<GraphSchemaTypeWithAccess>;\n edge: Array<GraphSchemaTypeWithAccess>;\n } = {node: [], edge: []};\n\n constructor(\n ogma: LKOgma,\n private _nodeMaxTextLength: number | undefined,\n private _edgeMaxTextLength: number | undefined\n ) {\n this._ogma = ogma;\n }\n\n public set graphSchema(graphSchema: {\n node: Array<GraphSchemaTypeWithAccess>;\n edge: Array<GraphSchemaTypeWithAccess>;\n }) {\n this._graphSchema = graphSchema;\n }\n\n /**\n * Refresh the schema\n */\n public refreshSchema(schema: CaptionState): void {\n this._captionSchema = schema;\n }\n\n /**\n * Refresh visualization captions rules\n */\n public async initVizCaptions(schema: CaptionState): Promise<void> {\n if (this._ogma.LKCaptions.nodesCaptionsRule) {\n this._ogma.LKCaptions.refreshSchema(schema);\n await this._ogma.LKCaptions.updateNodeCaptions();\n } else {\n this._ogma.LKCaptions.updateNodeCaptions(schema.node);\n }\n if (this._ogma.LKCaptions.edgesCaptionsRule) {\n this._ogma.LKCaptions.refreshSchema(schema);\n await this._ogma.LKCaptions.updateEdgeCaptions();\n } else {\n this._ogma.LKCaptions.updateEdgeCaptions(schema.edge);\n }\n }\n\n /**\n * Create or update nodeCaptionRule\n */\n public updateNodeCaptions(schema?: ItemFieldsCaptions): Promise<void> | void {\n if (schema) {\n this._captionSchema.node = schema;\n }\n if (!Tools.isDefined(this.nodesCaptionsRule)) {\n this.nodesCaptionsRule = this._ogma.styles.addRule({\n nodeAttributes: {\n text: {\n content: (node: Ogma.Node | undefined) => {\n if (node === undefined) {\n return ``;\n }\n const value = Captions.getText(\n node.getData(),\n this._captionSchema.node,\n this._graphSchema.node\n );\n return Tools.isDefined(this._nodeMaxTextLength)\n ? Tools.truncate(value, 'middle', this._nodeMaxTextLength)\n : value;\n }\n }\n },\n // We ignore virtual nodes as they have their proper caption\n nodeSelector: (node) => !node.isVirtual(),\n nodeDependencies: {self: {data: true}}\n });\n } else {\n return this.nodesCaptionsRule.refresh();\n }\n }\n\n /**\n * Create or update edgeCaptionRule\n */\n public updateEdgeCaptions(schema?: ItemFieldsCaptions): Promise<void> | void {\n if (schema) {\n this._captionSchema.edge = schema;\n }\n if (!Tools.isDefined(this.edgesCaptionsRule)) {\n this.edgesCaptionsRule = this._ogma.styles.addRule({\n edgeAttributes: {\n text: {\n content: (edge: Ogma.Edge | undefined) => {\n if (edge === undefined || edge.getData() === undefined) {\n return ``;\n }\n const value = Captions.getText(\n edge.getData(),\n this._captionSchema.edge,\n this._graphSchema.edge\n );\n return Tools.isDefined(this._edgeMaxTextLength)\n ? Tools.truncate(value, 'middle', this._edgeMaxTextLength)\n : value;\n }\n }\n },\n edgeSelector: (edge) => !edge.isVirtual(),\n // ogma will trigger the rendering if data change or the shape change (to trigger the rendering when edges are grouped)\n edgeDependencies: {self: {data: true, attributes: ['shape.style']}}\n });\n } else {\n return this.edgesCaptionsRule.refresh();\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Transformation } from '@linkurious/ogma';
|
|
2
|
+
import { LkEdgeData, LkNodeData, NodeGroupingRule } from '@linkurious/rest-client';
|
|
3
|
+
import { LKOgma } from '../index';
|
|
4
|
+
export declare const LKE_NODE_GROUPING_EDGE = "LKE_NODE_GROUPING_EDGE";
|
|
5
|
+
export declare const LKE_NODE_GROUPING_NODE = "LKE_NODE_GROUPING_NODE";
|
|
6
|
+
export declare class NodeGroupingTransformation {
|
|
7
|
+
transformation?: Transformation<LkNodeData, LkEdgeData>;
|
|
8
|
+
groupRule?: NodeGroupingRule;
|
|
9
|
+
private _ogma;
|
|
10
|
+
constructor(ogma: LKOgma);
|
|
11
|
+
/**
|
|
12
|
+
* Set the grouping rule
|
|
13
|
+
* @param rule of grouping
|
|
14
|
+
*/
|
|
15
|
+
setGroupingRule(rule: NodeGroupingRule | undefined): void;
|
|
16
|
+
/**
|
|
17
|
+
* create a node grouping transformation
|
|
18
|
+
* It uses groupRule to define the rule
|
|
19
|
+
* Group the nodes based on a category type and a property value
|
|
20
|
+
*/
|
|
21
|
+
initTransformation(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* refresh the transformation
|
|
24
|
+
* Called when there is a change in the rule
|
|
25
|
+
*/
|
|
26
|
+
refreshTransformation(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* init node grouping style
|
|
29
|
+
*/
|
|
30
|
+
initNodeGroupingStyle(): void;
|
|
31
|
+
/**
|
|
32
|
+
* run layout on all subnodes of virtual nodes
|
|
33
|
+
*/
|
|
34
|
+
runLayoutOnAllSubNodes(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Run the layout on the subnodes of the virtual node
|
|
37
|
+
* @param subNodes nodes part of a virtual node
|
|
38
|
+
*/
|
|
39
|
+
private _runSubNodesLayout;
|
|
40
|
+
/**
|
|
41
|
+
* Return the caption of a virtual node
|
|
42
|
+
* @param node reference to the virtual node
|
|
43
|
+
*/
|
|
44
|
+
private _getNodeGroupingCaption;
|
|
45
|
+
/**
|
|
46
|
+
* Run the circle pack layout on the subnodes
|
|
47
|
+
* @param subNodes
|
|
48
|
+
*/
|
|
49
|
+
private _runCirclePack;
|
|
50
|
+
private _runForceLayout;
|
|
51
|
+
private _isRuleNotApplicableToNode;
|
|
52
|
+
/**
|
|
53
|
+
* Unpin list of nodes
|
|
54
|
+
* @param nodes
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
private _unpinNodes;
|
|
58
|
+
/**
|
|
59
|
+
* Get all the raw nodes part of the transformation
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
private _getAllTransformationRawNodes;
|
|
63
|
+
/**
|
|
64
|
+
* Get the virtual nodes of the transformation
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
private _getVirtualNodesOfTransformation;
|
|
68
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NodeGroupingTransformation = exports.LKE_NODE_GROUPING_NODE = exports.LKE_NODE_GROUPING_EDGE = void 0;
|
|
13
|
+
const index_1 = require("../index");
|
|
14
|
+
const tools_1 = require("../../tools/tools");
|
|
15
|
+
exports.LKE_NODE_GROUPING_EDGE = 'LKE_NODE_GROUPING_EDGE';
|
|
16
|
+
exports.LKE_NODE_GROUPING_NODE = 'LKE_NODE_GROUPING_NODE';
|
|
17
|
+
class NodeGroupingTransformation {
|
|
18
|
+
constructor(ogma) {
|
|
19
|
+
this._ogma = ogma;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Set the grouping rule
|
|
23
|
+
* @param rule of grouping
|
|
24
|
+
*/
|
|
25
|
+
setGroupingRule(rule) {
|
|
26
|
+
this.groupRule = rule;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* create a node grouping transformation
|
|
30
|
+
* It uses groupRule to define the rule
|
|
31
|
+
* Group the nodes based on a category type and a property value
|
|
32
|
+
*/
|
|
33
|
+
initTransformation() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
if (this.transformation === undefined) {
|
|
36
|
+
this.transformation = this._ogma.transformations.addNodeGrouping({
|
|
37
|
+
groupIdFunction: (node) => {
|
|
38
|
+
var _a, _b, _c;
|
|
39
|
+
if (this._isRuleNotApplicableToNode(node)) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const propertyValue = node.getData([
|
|
44
|
+
'properties',
|
|
45
|
+
(_b = (_a = this.groupRule) === null || _a === void 0 ? void 0 : _a.groupingOptions.propertyKey) !== null && _b !== void 0 ? _b : ''
|
|
46
|
+
]);
|
|
47
|
+
// if the property value is of type conflict or invalid value we use the original value
|
|
48
|
+
const originalValue = typeof propertyValue === 'object'
|
|
49
|
+
? propertyValue.original
|
|
50
|
+
: propertyValue;
|
|
51
|
+
// groupRule is defined if not we returned undefined
|
|
52
|
+
// node with same value will be part of the same group
|
|
53
|
+
return `${(_c = this.groupRule) === null || _c === void 0 ? void 0 : _c.groupingOptions.itemType}-${originalValue}`
|
|
54
|
+
.toLowerCase()
|
|
55
|
+
.trim();
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
nodeGenerator: (nodes) => {
|
|
59
|
+
return {
|
|
60
|
+
data: {
|
|
61
|
+
// groupRule is defined as a virtual node only exist if the rule is defined
|
|
62
|
+
categories: [exports.LKE_NODE_GROUPING_NODE],
|
|
63
|
+
properties: {
|
|
64
|
+
size: nodes.size
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
edgeGenerator: () => {
|
|
70
|
+
return {
|
|
71
|
+
data: {
|
|
72
|
+
type: exports.LKE_NODE_GROUPING_EDGE
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
showContents: true,
|
|
77
|
+
duration: 300,
|
|
78
|
+
padding: 10
|
|
79
|
+
});
|
|
80
|
+
// TODO remove setTimeout when LKE-10453 is fixed
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
this.transformation.refresh();
|
|
83
|
+
}, 200);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
yield this.refreshTransformation();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* refresh the transformation
|
|
92
|
+
* Called when there is a change in the rule
|
|
93
|
+
*/
|
|
94
|
+
refreshTransformation() {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
if (this.transformation !== undefined) {
|
|
97
|
+
yield this.transformation.refresh();
|
|
98
|
+
yield this._unpinNodes(this._getAllTransformationRawNodes());
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
yield this.initTransformation();
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* init node grouping style
|
|
107
|
+
*/
|
|
108
|
+
initNodeGroupingStyle() {
|
|
109
|
+
this._ogma.styles.addRule({
|
|
110
|
+
nodeAttributes: {
|
|
111
|
+
// Any default style will go here
|
|
112
|
+
text: {
|
|
113
|
+
content: (node) => {
|
|
114
|
+
return this._getNodeGroupingCaption(node);
|
|
115
|
+
},
|
|
116
|
+
style: 'bold'
|
|
117
|
+
},
|
|
118
|
+
layer: -1,
|
|
119
|
+
color: 'rgba(240, 240, 240)',
|
|
120
|
+
innerStroke: {
|
|
121
|
+
color: '#7f7f7f',
|
|
122
|
+
width: 2
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
nodeSelector: (node) => {
|
|
126
|
+
return node.isVirtual();
|
|
127
|
+
},
|
|
128
|
+
// the style will be updated when data object is updated
|
|
129
|
+
nodeDependencies: { self: { data: true } }
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* run layout on all subnodes of virtual nodes
|
|
134
|
+
*/
|
|
135
|
+
runLayoutOnAllSubNodes() {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
yield this._ogma.transformations.afterNextUpdate();
|
|
138
|
+
const rawNodesList = this._getAllTransformationRawNodes();
|
|
139
|
+
const promisesList = [];
|
|
140
|
+
for (let i = 0; i < rawNodesList.length; i++) {
|
|
141
|
+
// rawNodesList[i] is not null because each group has at least one node
|
|
142
|
+
const subNodes = rawNodesList[i];
|
|
143
|
+
promisesList.push(this._runSubNodesLayout(subNodes));
|
|
144
|
+
}
|
|
145
|
+
yield Promise.all(promisesList);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Run the layout on the subnodes of the virtual node
|
|
150
|
+
* @param subNodes nodes part of a virtual node
|
|
151
|
+
*/
|
|
152
|
+
_runSubNodesLayout(subNodes) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
if (subNodes.size === 0) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const noEdges = subNodes.getAdjacentEdges({ bothExtremities: true }).size === 0;
|
|
158
|
+
if (noEdges) {
|
|
159
|
+
yield this._runCirclePack(subNodes);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
yield this._runForceLayout(subNodes);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Return the caption of a virtual node
|
|
168
|
+
* @param node reference to the virtual node
|
|
169
|
+
*/
|
|
170
|
+
_getNodeGroupingCaption(node) {
|
|
171
|
+
if (node !== undefined && node.isVirtual()) {
|
|
172
|
+
// get the property value of the first node of the group (all nodes share the same property value)
|
|
173
|
+
const propertyValue = node
|
|
174
|
+
.getSubNodes()
|
|
175
|
+
.get(0)
|
|
176
|
+
.getData(['properties', this.groupRule.groupingOptions.propertyKey]);
|
|
177
|
+
const size = node.getSubNodes().filter((e) => !e.hasClass('filtered')).size;
|
|
178
|
+
return `${propertyValue} (${size})`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Run the circle pack layout on the subnodes
|
|
183
|
+
* @param subNodes
|
|
184
|
+
*/
|
|
185
|
+
_runCirclePack(subNodes) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
yield this._ogma.algorithms.circlePack({
|
|
188
|
+
nodes: subNodes,
|
|
189
|
+
margin: 10,
|
|
190
|
+
sort: 'asc'
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
_runForceLayout(subNodes) {
|
|
195
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
+
yield this._ogma.layouts.force(Object.assign({ nodes: subNodes }, index_1.FORCE_LAYOUT_CONFIG));
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
_isRuleNotApplicableToNode(node) {
|
|
200
|
+
var _a, _b;
|
|
201
|
+
const propertyValue = node.getData([
|
|
202
|
+
'properties',
|
|
203
|
+
(_b = (_a = this.groupRule) === null || _a === void 0 ? void 0 : _a.groupingOptions.propertyKey) !== null && _b !== void 0 ? _b : ''
|
|
204
|
+
]);
|
|
205
|
+
return (
|
|
206
|
+
// if the group rule is not defined
|
|
207
|
+
this.groupRule === undefined ||
|
|
208
|
+
// if rule is applied to a different category
|
|
209
|
+
!node.getData('categories').includes(this.groupRule.groupingOptions.itemType) ||
|
|
210
|
+
// if the property value is not defined
|
|
211
|
+
!tools_1.Tools.isDefined(propertyValue) ||
|
|
212
|
+
// if the property value is missing
|
|
213
|
+
(typeof propertyValue === 'object' && propertyValue.status === 'missing'));
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Unpin list of nodes
|
|
217
|
+
* @param nodes
|
|
218
|
+
* @private
|
|
219
|
+
*/
|
|
220
|
+
_unpinNodes(nodes) {
|
|
221
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
222
|
+
yield Promise.all(nodes.map((nodeList) => {
|
|
223
|
+
if (nodeList !== null) {
|
|
224
|
+
return nodeList.setAttribute('layoutable', true);
|
|
225
|
+
}
|
|
226
|
+
}));
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Get all the raw nodes part of the transformation
|
|
231
|
+
* @private
|
|
232
|
+
*/
|
|
233
|
+
_getAllTransformationRawNodes() {
|
|
234
|
+
const virtualNodes = this._getVirtualNodesOfTransformation();
|
|
235
|
+
return virtualNodes.getSubNodes();
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Get the virtual nodes of the transformation
|
|
239
|
+
* @private
|
|
240
|
+
*/
|
|
241
|
+
_getVirtualNodesOfTransformation() {
|
|
242
|
+
// @ts-ignore getContext exists on the transformation but hidden by the types
|
|
243
|
+
return this.transformation.getContext().virtualNodes;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
exports.NodeGroupingTransformation = NodeGroupingTransformation;
|
|
247
|
+
//# sourceMappingURL=nodeGrouping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeGrouping.js","sourceRoot":"","sources":["../../../src/ogma/features/nodeGrouping.ts"],"names":[],"mappings":";;;;;;;;;;;;AASA,oCAAqD;AACrD,6CAAwC;AAE3B,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAClD,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D,MAAa,0BAA0B;IAKrC,YAAY,IAAY;QACtB,IAAI,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,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACrB,IAAI,QAAQ,KAAK,IAAI,EAAE;oBACrB,OAAO,QAAQ,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;iBAClD;YACH,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;KAAA;IAED;;;OAGG;IACK,6BAA6B;QACnC,MAAM,YAAY,GAAG,IAAI,CAAC,gCAAgC,EAAE,CAAC;QAC7D,OAAO,YAAY,CAAC,WAAW,EAAE,CAAC;IACpC,CAAC;IAED;;;OAGG;IACK,gCAAgC;QACtC,6EAA6E;QAC7E,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC,YAAY,CAAC;IACvD,CAAC;CACF;AAzOD,gEAyOC","sourcesContent":["import {Transformation, Node, NodeList} from '@linkurious/ogma';\nimport {\n ConflictValue,\n LkEdgeData,\n LkNodeData,\n MissingValue,\n NodeGroupingRule\n} from '@linkurious/rest-client';\n\nimport {FORCE_LAYOUT_CONFIG, LKOgma} from '../index';\nimport {Tools} from '../../tools/tools';\n\nexport const LKE_NODE_GROUPING_EDGE = 'LKE_NODE_GROUPING_EDGE';\nexport const LKE_NODE_GROUPING_NODE = 'LKE_NODE_GROUPING_NODE';\n\nexport class NodeGroupingTransformation {\n public transformation?: Transformation<LkNodeData, LkEdgeData>;\n public groupRule?: NodeGroupingRule;\n private _ogma: LKOgma;\n\n constructor(ogma: LKOgma) {\n this._ogma = ogma;\n }\n\n /**\n * Set the grouping rule\n * @param rule of grouping\n */\n public setGroupingRule(rule: NodeGroupingRule | undefined): void {\n this.groupRule = rule;\n }\n\n /**\n * create a node grouping transformation\n * It uses groupRule to define the rule\n * Group the nodes based on a category type and a property value\n */\n public async initTransformation(): Promise<void> {\n if (this.transformation === undefined) {\n this.transformation = this._ogma.transformations.addNodeGrouping({\n groupIdFunction: (node) => {\n if (this._isRuleNotApplicableToNode(node)) {\n return undefined;\n } else {\n const propertyValue = node.getData([\n 'properties',\n this.groupRule?.groupingOptions.propertyKey ?? ''\n ]);\n // if the property value is of type conflict or invalid value we use the original value\n const originalValue =\n typeof propertyValue === 'object'\n ? (propertyValue as ConflictValue).original\n : propertyValue;\n // groupRule is defined if not we returned undefined\n // node with same value will be part of the same group\n return `${this.groupRule?.groupingOptions.itemType}-${originalValue}`\n .toLowerCase()\n .trim();\n }\n },\n nodeGenerator: (nodes) => {\n return {\n data: {\n // groupRule is defined as a virtual node only exist if the rule is defined\n categories: [LKE_NODE_GROUPING_NODE],\n properties: {\n size: nodes.size\n }\n }\n };\n },\n edgeGenerator: () => {\n return {\n data: {\n type: LKE_NODE_GROUPING_EDGE\n }\n };\n },\n showContents: true,\n duration: 300,\n padding: 10\n });\n // TODO remove setTimeout when LKE-10453 is fixed\n setTimeout(() => {\n this.transformation!.refresh();\n }, 200);\n } else {\n await this.refreshTransformation();\n }\n }\n\n /**\n * refresh the transformation\n * Called when there is a change in the rule\n */\n public async refreshTransformation(): Promise<void> {\n if (this.transformation !== undefined) {\n await this.transformation.refresh();\n await this._unpinNodes(this._getAllTransformationRawNodes());\n } else {\n await this.initTransformation();\n }\n }\n\n /**\n * init node grouping style\n */\n public initNodeGroupingStyle(): void {\n this._ogma.styles.addRule({\n nodeAttributes: {\n // Any default style will go here\n text: {\n content: (node: Node<LkNodeData> | undefined): string | undefined => {\n return this._getNodeGroupingCaption(node);\n },\n style: 'bold'\n },\n layer: -1,\n color: 'rgba(240, 240, 240)',\n innerStroke: {\n color: '#7f7f7f',\n width: 2\n }\n },\n nodeSelector: (node) => {\n return node.isVirtual();\n },\n // the style will be updated when data object is updated\n nodeDependencies: {self: {data: true}}\n });\n }\n\n /**\n * run layout on all subnodes of virtual nodes\n */\n public async runLayoutOnAllSubNodes(): Promise<void> {\n await this._ogma.transformations.afterNextUpdate();\n const rawNodesList = this._getAllTransformationRawNodes();\n const promisesList: Promise<void>[] = [];\n for (let i = 0; i < rawNodesList.length; i++) {\n // rawNodesList[i] is not null because each group has at least one node\n const subNodes = rawNodesList[i]!;\n promisesList.push(this._runSubNodesLayout(subNodes));\n }\n await Promise.all(promisesList);\n }\n\n /**\n * Run the layout on the subnodes of the virtual node\n * @param subNodes nodes part of a virtual node\n */\n private async _runSubNodesLayout(subNodes: NodeList<LkNodeData, LkEdgeData>): Promise<void> {\n if (subNodes.size === 0) {\n return;\n }\n\n const noEdges = subNodes.getAdjacentEdges({bothExtremities: true}).size === 0;\n if (noEdges) {\n await this._runCirclePack(subNodes);\n } else {\n await this._runForceLayout(subNodes);\n }\n }\n\n /**\n * Return the caption of a virtual node\n * @param node reference to the virtual node\n */\n private _getNodeGroupingCaption(node: Node<LkNodeData> | undefined): string | undefined {\n if (node !== undefined && node.isVirtual()) {\n // get the property value of the first node of the group (all nodes share the same property value)\n const propertyValue = node\n .getSubNodes()!\n .get(0)\n .getData(['properties', this.groupRule!.groupingOptions.propertyKey]);\n const size = node.getSubNodes()!.filter((e) => !e.hasClass('filtered')).size;\n return `${propertyValue} (${size})`;\n }\n }\n\n /**\n * Run the circle pack layout on the subnodes\n * @param subNodes\n */\n private async _runCirclePack(subNodes: NodeList<LkNodeData, LkEdgeData>): Promise<void> {\n await this._ogma.algorithms.circlePack({\n nodes: subNodes,\n margin: 10,\n sort: 'asc'\n });\n }\n\n private async _runForceLayout(subNodes: NodeList<LkNodeData, LkEdgeData>): Promise<void> {\n await this._ogma.layouts.force({\n nodes: subNodes,\n ...FORCE_LAYOUT_CONFIG\n });\n }\n\n private _isRuleNotApplicableToNode(node: Node<LkNodeData>): boolean {\n const propertyValue = node.getData([\n 'properties',\n this.groupRule?.groupingOptions.propertyKey ?? ''\n ]);\n return (\n // if the group rule is not defined\n this.groupRule === undefined ||\n // if rule is applied to a different category\n !node.getData('categories').includes(this.groupRule.groupingOptions.itemType) ||\n // if the property value is not defined\n !Tools.isDefined(propertyValue) ||\n // if the property value is missing\n (typeof propertyValue === 'object' && (propertyValue as MissingValue).status === 'missing')\n );\n }\n\n /**\n * Unpin list of nodes\n * @param nodes\n * @private\n */\n private async _unpinNodes(nodes: Array<NodeList | null>): Promise<void> {\n await Promise.all(\n nodes.map((nodeList) => {\n if (nodeList !== null) {\n return nodeList.setAttribute('layoutable', true);\n }\n })\n );\n }\n\n /**\n * Get all the raw nodes part of the transformation\n * @private\n */\n private _getAllTransformationRawNodes(): Array<NodeList | null> {\n const virtualNodes = this._getVirtualNodesOfTransformation();\n return virtualNodes.getSubNodes();\n }\n\n /**\n * Get the virtual nodes of the transformation\n * @private\n */\n private _getVirtualNodesOfTransformation(): NodeList<LkNodeData, LkEdgeData> {\n // @ts-ignore getContext exists on the transformation but hidden by the types\n return this.transformation.getContext().virtualNodes;\n }\n}\n"]}
|
|
@@ -43,6 +43,7 @@ class StylesViz {
|
|
|
43
43
|
this._edgeAttributes = new __1.EdgeAttributes({});
|
|
44
44
|
this._ogma = ogma;
|
|
45
45
|
this._defaultConfiguration = configuration;
|
|
46
|
+
this._nodeAttributes.setBaseUrl(configuration.baseUrl);
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
48
49
|
* Set nodes default styles based on the configuration
|
|
@@ -105,6 +106,7 @@ class StylesViz {
|
|
|
105
106
|
* Set edges default styles based on the configuration
|
|
106
107
|
*/
|
|
107
108
|
setEdgesDefaultStyles() {
|
|
109
|
+
var _a;
|
|
108
110
|
// setting selection and hover attributes
|
|
109
111
|
this._ogma.styles.setHoveredEdgeAttributes(HOVERED_SELECTED_EDGE_STYLE);
|
|
110
112
|
this._ogma.styles.setSelectedEdgeAttributes(HOVERED_SELECTED_EDGE_STYLE);
|
|
@@ -128,8 +130,7 @@ class StylesViz {
|
|
|
128
130
|
this._defaultConfiguration.edge.text.font !== undefined
|
|
129
131
|
? this._defaultConfiguration.edge.text.font
|
|
130
132
|
: "'roboto', sans-serif",
|
|
131
|
-
color: this._defaultConfiguration.edge !== undefined &&
|
|
132
|
-
this._defaultConfiguration.edge.text !== undefined &&
|
|
133
|
+
color: ((_a = this._defaultConfiguration.edge) === null || _a === void 0 ? void 0 : _a.text) !== undefined &&
|
|
133
134
|
this._defaultConfiguration.edge.text.color !== undefined
|
|
134
135
|
? this._defaultConfiguration.edge.text.color
|
|
135
136
|
: 'black',
|
|
@@ -242,7 +243,13 @@ class StylesViz {
|
|
|
242
243
|
name: 'filtered',
|
|
243
244
|
nodeAttributes: {
|
|
244
245
|
opacity: exports.FILTER_OPACITY,
|
|
245
|
-
layer:
|
|
246
|
+
layer: (node) => {
|
|
247
|
+
// if the node is part of a virtual node, it should be on top
|
|
248
|
+
if (node.getMetaNode() !== undefined) {
|
|
249
|
+
return 1;
|
|
250
|
+
}
|
|
251
|
+
return -1;
|
|
252
|
+
},
|
|
246
253
|
detectable: false,
|
|
247
254
|
badges: {
|
|
248
255
|
topRight: {
|
|
@@ -266,7 +273,17 @@ class StylesViz {
|
|
|
266
273
|
},
|
|
267
274
|
edgeAttributes: {
|
|
268
275
|
opacity: exports.FILTER_OPACITY,
|
|
269
|
-
layer:
|
|
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
|
+
},
|
|
270
287
|
detectable: false,
|
|
271
288
|
text: null,
|
|
272
289
|
color: __1.BASE_GREY,
|
|
@@ -490,7 +507,7 @@ class StylesViz {
|
|
|
490
507
|
}
|
|
491
508
|
},
|
|
492
509
|
image: (node) => {
|
|
493
|
-
if (node !== undefined) {
|
|
510
|
+
if (node !== undefined && !node.isVirtual()) {
|
|
494
511
|
return this._nodeAttributes.icon(node.getData()).image;
|
|
495
512
|
}
|
|
496
513
|
}
|
|
@@ -500,7 +517,7 @@ class StylesViz {
|
|
|
500
517
|
}
|
|
501
518
|
else {
|
|
502
519
|
this._nodeAttributes.refresh({ icon: iconStyleRules });
|
|
503
|
-
this._ogmaNodeIcon.refresh();
|
|
520
|
+
void this._ogmaNodeIcon.refresh();
|
|
504
521
|
}
|
|
505
522
|
}
|
|
506
523
|
/**
|
|
@@ -543,6 +560,7 @@ class StylesViz {
|
|
|
543
560
|
}
|
|
544
561
|
}
|
|
545
562
|
},
|
|
563
|
+
nodeSelector: (node) => node !== undefined && !node.isVirtual(),
|
|
546
564
|
nodeDependencies: { self: { data: true } }
|
|
547
565
|
});
|
|
548
566
|
}
|