Edge label positioning#533
Draft
Wagner-Laranjeiras wants to merge 2 commits into
Draft
Conversation
Signed-off-by: Wagner Laranjeiras <wagner.laranjeiras@typefox.io>
Contributor
|
Hi @Wagner-Laranjeiras , thanks for the contribution. This is a good start. However the approach completely bypasses the post-processing if the label has been placed by ELK. This create the issue that rotation and bounding to the edge are not preserved (making every label "free"). Ideally this should also be layout engine agnostic and not depend on sprotty-elk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #514: respect external positions for edge labels
Summary
When using the ELK layout integration, edge labels were rendered at the position
computed by Sprotty's
EdgeLayoutPostprocessorinstead of the position chosen byELK. This PR introduces a small cross-package marker that lets a layout engine
declare "this label's position is final, please don't recompute it," and routes
the rendering pipeline accordingly.
Fixes #514.
Changes
sprotty-protocol— adds a newExternallyPositionedinterface so layoutengines and the framework can speak about externally-set positions.
sprotty-elk—applyEdgenow marks every edge label it positions withexternallyPositioned: true.sprotty—EdgeLayoutPostprocessorskips externally-positioned labels;LocationPostprocessor(the default position applier) is updated to handlethem instead, so they still get a transform reflecting ELK's coordinates.
checkExternallyPositionedtype guard infeatures/edge-layout/model.tsmirrors the existing
checkEdgePlacementpattern.The fix is opt-in: only labels positioned by an external engine are affected.
Existing diagrams that rely on
EdgeLayoutPostprocessor's default behavior areunchanged.
Testing
packages/sprotty-elk/src/elk-layout.spec.tsverifies thatthe ELK adapter marks edge labels as
externallyPositioned.random-graphexample withNODES = 2, EDGES = 1and an edge label, mirroring the issue's reproduction. With the fix applied,
the label appears at ELK's chosen position; reverting the marker assignment
reproduces the original bug.