@eclipse-glsp/layout-elk 0.9.0-next.397cddd.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/LICENSE +642 -0
  2. package/README.md +9 -0
  3. package/lib/basic-type-mapper.d.ts +26 -0
  4. package/lib/basic-type-mapper.d.ts.map +1 -0
  5. package/lib/basic-type-mapper.js +97 -0
  6. package/lib/basic-type-mapper.js.map +1 -0
  7. package/lib/di.config.d.ts +53 -0
  8. package/lib/di.config.d.ts.map +1 -0
  9. package/lib/di.config.js +90 -0
  10. package/lib/di.config.js.map +1 -0
  11. package/lib/di.config.spec.d.ts +2 -0
  12. package/lib/di.config.spec.d.ts.map +1 -0
  13. package/lib/di.config.spec.js +100 -0
  14. package/lib/di.config.spec.js.map +1 -0
  15. package/lib/glsp-element-filter.d.ts +17 -0
  16. package/lib/glsp-element-filter.d.ts.map +1 -0
  17. package/lib/glsp-element-filter.js +53 -0
  18. package/lib/glsp-element-filter.js.map +1 -0
  19. package/lib/glsp-elk-layout-engine.d.ts +39 -0
  20. package/lib/glsp-elk-layout-engine.d.ts.map +1 -0
  21. package/lib/glsp-elk-layout-engine.js +80 -0
  22. package/lib/glsp-elk-layout-engine.js.map +1 -0
  23. package/lib/glsp-layout-configurator.d.ts +43 -0
  24. package/lib/glsp-layout-configurator.d.ts.map +1 -0
  25. package/lib/glsp-layout-configurator.js +57 -0
  26. package/lib/glsp-layout-configurator.js.map +1 -0
  27. package/lib/index.d.ts +23 -0
  28. package/lib/index.d.ts.map +1 -0
  29. package/lib/index.js +36 -0
  30. package/lib/index.js.map +1 -0
  31. package/package.json +61 -0
  32. package/src/basic-type-mapper.ts +73 -0
  33. package/src/di.config.spec.ts +92 -0
  34. package/src/di.config.ts +117 -0
  35. package/src/glsp-element-filter.ts +38 -0
  36. package/src/glsp-elk-layout-engine.ts +57 -0
  37. package/src/glsp-layout-configurator.ts +59 -0
  38. package/src/index.ts +22 -0
@@ -0,0 +1,59 @@
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 { LayoutOptions } from 'elkjs';
17
+ import { inject, injectable } from 'inversify';
18
+ import { DefaultLayoutConfigurator } from 'sprotty-elk';
19
+ import { SGraph, SModelElement, SModelIndex } from 'sprotty-protocol';
20
+ import { BasicTypeMapper } from './basic-type-mapper';
21
+
22
+ /**
23
+ * Configurator for ELK layout algorithms; provides mappings of layout options for each model element.
24
+ * For a list of all available layout options checkout the official ELK documentation.
25
+ * A minimal configuration should at least specify the `elk.algorithm` option as
26
+ * return value of {@link GlspLayoutConfigurator.graphOptions}.
27
+ * {@link https://www.eclipse.org/elk/reference/options.html}
28
+ */
29
+ @injectable()
30
+ export class GlspLayoutConfigurator extends DefaultLayoutConfigurator {
31
+ @inject(BasicTypeMapper)
32
+ protected typeMapper: BasicTypeMapper;
33
+
34
+ protected getBasicType(smodel: SModelElement): string {
35
+ return this.typeMapper.getBasicType(smodel);
36
+ }
37
+ }
38
+
39
+ /**
40
+ * A fallback configurator that is used in the `configureELKLayoutModule` utility method.
41
+ * If no explicit layout configurator binding is provided a new instance of the fallback configurator is
42
+ * bound as replacement. Basic layout options for the root graph element are derived from the
43
+ * configuration parameters that haven been passed to the `configureELKLayoutModule` function.
44
+ */
45
+ @injectable()
46
+ export class FallbackGlspLayoutConfigurator extends GlspLayoutConfigurator {
47
+ protected fallbackGraphOptions: LayoutOptions;
48
+ constructor(protected typeMapper: BasicTypeMapper, algorithms: string[], defaultLayoutOptions: LayoutOptions = {}) {
49
+ super();
50
+ this.fallbackGraphOptions = {
51
+ 'elk.algorithm': algorithms[0],
52
+ ...defaultLayoutOptions
53
+ };
54
+ }
55
+
56
+ protected graphOptions(sgraph: SGraph, index: SModelIndex): LayoutOptions | undefined {
57
+ return this.fallbackGraphOptions;
58
+ }
59
+ }
package/src/index.ts ADDED
@@ -0,0 +1,22 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2022 EclipseSource 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
+ export * from 'sprotty-elk';
17
+ export { SModelIndex } from 'sprotty-protocol/lib/utils/model-utils';
18
+ export * from './basic-type-mapper';
19
+ export * from './di.config';
20
+ export * from './glsp-element-filter';
21
+ export * from './glsp-elk-layout-engine';
22
+ export * from './glsp-layout-configurator';