@eclipse-glsp/layout-elk 0.9.0-next.0193b16.17
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/LICENSE +642 -0
- package/README.md +9 -0
- package/lib/di.config.d.ts +47 -0
- package/lib/di.config.d.ts.map +1 -0
- package/lib/di.config.js +78 -0
- package/lib/di.config.js.map +1 -0
- package/lib/di.config.spec.d.ts +2 -0
- package/lib/di.config.spec.d.ts.map +1 -0
- package/lib/di.config.spec.js +97 -0
- package/lib/di.config.spec.js.map +1 -0
- package/lib/element-filter.d.ts +45 -0
- package/lib/element-filter.d.ts.map +1 -0
- package/lib/element-filter.js +84 -0
- package/lib/element-filter.js.map +1 -0
- package/lib/glsp-elk-layout-engine.d.ts +53 -0
- package/lib/glsp-elk-layout-engine.d.ts.map +1 -0
- package/lib/glsp-elk-layout-engine.js +303 -0
- package/lib/glsp-elk-layout-engine.js.map +1 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +33 -0
- package/lib/index.js.map +1 -0
- package/lib/layout-configurator.d.ts +57 -0
- package/lib/layout-configurator.d.ts.map +1 -0
- package/lib/layout-configurator.js +99 -0
- package/lib/layout-configurator.js.map +1 -0
- package/lib/sprotty-elk.d.ts +18 -0
- package/lib/sprotty-elk.d.ts.map +1 -0
- package/lib/sprotty-elk.js +6 -0
- package/lib/sprotty-elk.js.map +1 -0
- package/package.json +61 -0
- package/src/di.config.spec.ts +89 -0
- package/src/di.config.ts +104 -0
- package/src/element-filter.ts +84 -0
- package/src/glsp-elk-layout-engine.ts +332 -0
- package/src/index.ts +20 -0
- package/src/layout-configurator.ts +101 -0
- package/src/sprotty-elk.ts +18 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { GEdge, GGraph, GLabel, GModelElement, GNode, GPort, ModelState } from '@eclipse-glsp/server-node';
|
|
17
|
+
import { inject, injectable } from 'inversify';
|
|
18
|
+
import { LayoutOptions } from './sprotty-elk';
|
|
19
|
+
|
|
20
|
+
export const LayoutConfigurator = Symbol('LayoutConfigurator');
|
|
21
|
+
/**
|
|
22
|
+
* Configurator for ELK layout algorithms; provides mappings of layout options for each model element.
|
|
23
|
+
* For a list of all available layout options checkout the official ELK documentation:
|
|
24
|
+
* {@link https://www.eclipse.org/elk/reference/options.html}
|
|
25
|
+
*/
|
|
26
|
+
export interface LayoutConfigurator {
|
|
27
|
+
/**
|
|
28
|
+
* Computes the {@link LayoutOptions} for the given {@link GModelElement}.
|
|
29
|
+
* @param element The element for which the layout options should be computed.
|
|
30
|
+
* @returns The set of layout options for the given element or `undefined`.
|
|
31
|
+
*/
|
|
32
|
+
apply(element: GModelElement): LayoutOptions | undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Abstract default implementation of {@link LayoutConfigurator}.
|
|
37
|
+
* A minimal configuration should at least specify the `elk.algorithm` option as
|
|
38
|
+
* return value of {@link DefaultLayoutConfigurator.graphOptions}.
|
|
39
|
+
*/
|
|
40
|
+
@injectable()
|
|
41
|
+
export abstract class AbstractLayoutConfigurator implements LayoutConfigurator {
|
|
42
|
+
@inject(ModelState)
|
|
43
|
+
protected modelState: ModelState;
|
|
44
|
+
|
|
45
|
+
apply(element: GModelElement): LayoutOptions | undefined {
|
|
46
|
+
if (element instanceof GGraph) {
|
|
47
|
+
return this.graphOptions(element);
|
|
48
|
+
} else if (element instanceof GNode) {
|
|
49
|
+
return this.nodeOptions(element);
|
|
50
|
+
} else if (element instanceof GEdge) {
|
|
51
|
+
return this.edgeOptions(element);
|
|
52
|
+
} else if (element instanceof GLabel) {
|
|
53
|
+
this.labelOptions(element);
|
|
54
|
+
} else if (element instanceof GPort) {
|
|
55
|
+
this.portOptions(element);
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected graphOptions(graph: GGraph): LayoutOptions | undefined {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected nodeOptions(node: GNode): LayoutOptions | undefined {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
protected edgeOptions(edge: GEdge): LayoutOptions | undefined {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
protected labelOptions(label: GLabel): LayoutOptions | undefined {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
protected portOptions(sport: GPort): LayoutOptions | undefined {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A fallback configurator that is used in the `configureELKLayoutModule` utility method.
|
|
83
|
+
* If no explicit layout configurator binding is provided a new instance of the fallback configurator is
|
|
84
|
+
* bound as replacement. Basic layout options for the root graph element are derived from the
|
|
85
|
+
* configuration parameters that haven been passed to the `configureELKLayoutModule` function.
|
|
86
|
+
*/
|
|
87
|
+
@injectable()
|
|
88
|
+
export class FallbackLayoutConfigurator extends AbstractLayoutConfigurator {
|
|
89
|
+
protected fallbackGraphOptions: LayoutOptions;
|
|
90
|
+
constructor(algorithms: string[], defaultLayoutOptions: LayoutOptions = {}) {
|
|
91
|
+
super();
|
|
92
|
+
this.fallbackGraphOptions = {
|
|
93
|
+
'elk.algorithm': algorithms[0],
|
|
94
|
+
...defaultLayoutOptions
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
protected override graphOptions(sgraph: GGraph): LayoutOptions | undefined {
|
|
99
|
+
return this.fallbackGraphOptions;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
// Reexport of the relevant sprotty-elk typings
|
|
17
|
+
export { LayoutOptions } from 'elkjs';
|
|
18
|
+
export { ElkFactory } from 'sprotty-elk/lib/inversify';
|