-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#514 Refactor GlspElkLayoutEngine #5
Conversation
- Refactor the `GlspElkLayoutEngine` and related concepts to properly support layout computation for ports. In this process we also opted out of trying to reuse the existing `SprottyElkLayoutEngine` and instead implement a new layout engine specifically for the GLSP graphmodel. This implementation is more in line with the Java ELK-Layout Engine and implements similar features like automatic detection of common ancestors of edge source/targets to correctly transform them in the ELK graph. - Removes the no longer needed `BasicTypeMapper` Also: - Provide utility functions for querying parent elements of a given element that match a predicate. (gmodel-util.ts) - Only rerexport the the subset of types that are really needed from "sprotty-elk" to avoid unncessary naming clashes. - Add jsdoc for `GModelSerializer` - Fix implementation of `getAllEdges` in `GModelIndex` - Remove unused (and unset) `source` and `target` references in `GEdge` Contributed on behalf of STMicroelectronics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @tortmayr!
Changes look good. Just a few inline comments below.
elkGraph.edges = []; | ||
this.elkEdges.push(...(this.findChildren(graph, GEdge).map(child => this.transformToElk(child)) as ElkEdge[])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these edges not also be pushed into the elkGraph.edges
? Otherwise the array is always empty, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, edges need special handling. ELK expects that edges are always set in their respective parent container (either the graph or another node in case of nested diagrams). Otherwise edges want be layouted correctly. However, the same assumption is not true for the graphical model. If we have an edge between A and B the edge doesn't have to be a child of the container of A and B. It could be placed anywhere in the graph (e.g. as child of A).
Hence I implemented the same mechanism that is used in the Java LayoutEngine. (Store the edges in a temporary map and then in a postprocess step find the most suitable parent container). (
this.elkEdges.forEach(elkEdge => { |
elkNode.edges = []; | ||
this.elkEdges.push(...(this.findChildren(node, GEdge).map(child => this.transformToElk(child)) as ElkEdge[])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
* #514 Refactor GlspElkLayoutEngine - Refactor the `GlspElkLayoutEngine` and related concepts to properly support layout computation for ports. In this process we also opted out of trying to reuse the existing `SprottyElkLayoutEngine` and instead implement a new layout engine specifically for the GLSP graphmodel. This implementation is more in line with the Java ELK-Layout Engine and implements similar features like automatic detection of common ancestors of edge source/targets to correctly transform them in the ELK graph. - Removes the no longer needed `BasicTypeMapper` Also: - Provide utility functions for querying parent elements of a given element that match a predicate. (gmodel-util.ts) - Only rerexport the the subset of types that are really needed from "sprotty-elk" to avoid unncessary naming clashes. - Add jsdoc for `GModelSerializer` - Fix implementation of `getAllEdges` in `GModelIndex` - Remove unused (and unset) `source` and `target` references in `GEdge` Contributed on behalf of STMicroelectronics
Refactor the
GlspElkLayoutEngine
and related concepts to properly support layout computation for ports. In this process we also opted out of trying to reuse the existingSprottyElkLayoutEngine
and instead implement a new layout engine specifically for the GLSP graphmodel. This implementation is more in line with the Java ELK-Layout Engine and implements similar features like automatic detection of common ancestors of edge source/targets to correctly transform them in the ELK graph.Removes the no longer needed
BasicTypeMapper
Also:
GModelSerializer
getAllEdges
inGModelIndex
source
andtarget
references inGEdge
Contributed on behalf of STMicroelectronics