Skip to content
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

editor.diagram: Expose more ELK options #844

Merged
merged 64 commits into from
Jun 6, 2024

Conversation

alexanderpann
Copy link
Collaborator

@alexanderpann alexanderpann commented May 27, 2024

Support for 10 new layout algorithms was added. Most of the options of the ELK layouter (150 options) can be customized through style class items. All options can also be set in the inspector of the chosen layout algorithm in the diagram cell.
For our unstable layouting, the option interactive might be useful to not get so drastic changes when running the layouter again.
I tested all the wiring of the options to the layouters and the sandbox and checked that all options have the correct default values. From a review perspective, just playing around with the editor and checking the non-option-related code changes should be enough. We have to check that it is impossible that an error is thrown in the editor and that the editor breaks.

Reference:

The new features can be tested in the model de.itemis.mps.editor.diagram.demo.elk.sandbox:
Screenshot 2024-05-27 at 14 54 55

@alexanderpann alexanderpann force-pushed the feature/more_elk_options branch from a7c5cc8 to 428c4ed Compare May 28, 2024 06:49
@ratiud
Copy link
Contributor

ratiud commented May 28, 2024

@alexanderpann thank you for this extension !
I am playing with the examples and I get the following exception if direction is "undefined"

image

java.lang.RuntimeException: Unknown direction: UNDEFINED
at de.itemis.mps.editor.diagram.runtime.jgraph.ElkLayouter.createDummyPort(ElkLayouter.java:496)
at de.itemis.mps.editor.diagram.runtime.jgraph.ElkLayouter.buildElement(ElkLayouter.java:241)
at de.itemis.mps.editor.diagram.runtime.jgraph.ElkLayouter.buildElementIfRequired(ElkLayouter.java:213)
at de.itemis.mps.editor.diagram.runtime.jgraph.ElkLayouter.buildKGraph(ElkLayouter.java:286)
at de.itemis.mps.editor.diagram.runtime.jgraph.ElkLayouter.layoutOnce(ElkLayouter.java:187)
at de.itemis.mps.editor.diagram.runtime.jgraph.ElkLayouter.layout(ElkLayouter.java:150)
at de.itemis.mps.editor.diagram.runtime.jgraph.BaseDiagramDCell$1.run(BaseDiagramDCell.java:139)
at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:442)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:114)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$5(CoreProgressManager.java:493)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:252)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:608)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:683)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:639)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:607)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:252)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)

@alexanderpann
Copy link
Collaborator Author

alexanderpann commented May 28, 2024

I am not done yet with the PR but yes you are right, thanks. I'll fix it.

@alexanderpann alexanderpann marked this pull request as draft May 28, 2024 08:18
@ratiud
Copy link
Contributor

ratiud commented May 28, 2024

I tried to instantiate this editor on fasten GSN diagrams - there I have the following issues:

  1. many fields are red (the values are not set, we should if possible provide some defaults)
  2. I get a generation error (picture below)
    image

@alexanderpann
Copy link
Collaborator Author

Did you run the migration? The constructor of the layered configuration is probably not called, so the properties are not initialized.

@ratiud
Copy link
Contributor

ratiud commented May 28, 2024

Did you run the migration? The constructor of the layered configuration is probably not called, so the properties are not initialized.

no - I had not ran them ... thank you for pointing out!

@slisson
Copy link
Collaborator

slisson commented Jun 3, 2024

This adds lots of new style attributes and for some of them (e.g. core-padding) it's not clear that they are diagram specific. It makes the code completion menu difficult to read. I would add a common prefix (maybe "diagram-layout-") to all of them.

@alexanderpann
Copy link
Collaborator Author

alexanderpann commented Jun 3, 2024

@slisson anything else? Do you have a better idea for the implementation of ElkLayouter#getNodeConnectionPosition?  It works but I am not quite happy with the layout results. I can't find a better option though.

@slisson
Copy link
Collaborator

slisson commented Jun 6, 2024

Do you have a better idea for the implementation of ElkLayouter#getNodeConnectionPosition?  It works but I am not quite happy with the layout results. I can't find a better option though.

I don't understand well enough what the effect is to be able to suggest an alternative.

@slisson
Copy link
Collaborator

slisson commented Jun 6, 2024

One things that we maybe can improve is to reduce the code duplication. I see that all the subclasses of ElkLayouter basically just copy all the properties for the layout algorithm. The is the LayoutMetaDataService that provides information about the available algorithms and their properties. Maybe we can make use of it and have a generic implementation. This would also have the benefit, that new properties in future version of ELK are then automatically available.

@alexanderpann
Copy link
Collaborator Author

alexanderpann commented Jun 6, 2024

The idea was that with the dummy ports, edges from the same (dummy) ports get merged into one line (hyperedge) which might not always be the preferred. With the new diagram option "don't use dummy ports", the boxes are connected directly. We still need the right side of the box for the connecton similar to the approach with the ports, so I just set the start and end location of the edge section e.g.:

KVector position = getNodeConnectionPosition(fromKNode, true); 
edgeSection.setStartLocation(position.x, position.y);

The result looks slightly odd for some reason.

@alexanderpann
Copy link
Collaborator Author

I'll create followup tickets in case we need to improve those points.

@alexanderpann alexanderpann merged commit c2011b0 into maintenance/mps20222 Jun 6, 2024
1 check passed
@alexanderpann alexanderpann deleted the feature/more_elk_options branch June 6, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants