Skip to content

Edge label positioning#533

Open
Wagner-Laranjeiras wants to merge 2 commits into
eclipse-sprotty:masterfrom
Wagner-Laranjeiras:wagner-laranjeiras/514/edge-label-positioning
Open

Edge label positioning#533
Wagner-Laranjeiras wants to merge 2 commits into
eclipse-sprotty:masterfrom
Wagner-Laranjeiras:wagner-laranjeiras/514/edge-label-positioning

Conversation

@Wagner-Laranjeiras

@Wagner-Laranjeiras Wagner-Laranjeiras commented Jun 3, 2026

Copy link
Copy Markdown

Summary

Fixes #514: edge labels positioned by a layout engine (e.g. ELK) were being
re-placed at the edge's geometric midpoint at render time, ignoring the
engine's coordinates.

EdgeLayoutPostprocessor now honors an engine-assigned position: when a
non-moveable edge label with no explicit edgePlacement carries a non-origin
position, its center is projected onto the edge (deriving the anchor and
tangent) and the existing rotation/alignment pipeline is applied. Labels that
were never positioned still fall back to the previous midpoint behavior.

The change is engine-agnostic (it reads the label's own model position, with
no dependency on sprotty-elk) and preserves rotation and edge-binding, as
requested in the review.

Changes

  • packages/sprotty/src/features/edge-layout/edge-layout.ts: project the label
    center onto the edge for engine-positioned labels; extract the shared
    applyRotationAndAlignment helper.

Tests

  • Unit tests for EdgeLayoutPostprocessor covering the fix, the no-regression
    paths (unpositioned/moveable/explicit edgePlacement), the origin sentinel,
    and the nested-nodes "free space" case.
  • ELK integration tests asserting the engine assigns a non-origin position to an
    edge label, including a nested-nodes scenario where the label lands in the free
    space between containers rather than at the edge midpoint.

@Wagner-Laranjeiras Wagner-Laranjeiras changed the title Wagner laranjeiras/514/edge label positioning Edge label positioning Jun 3, 2026
@gfontorbe

Copy link
Copy Markdown
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

…positions instead of the edge midpoint (eclipse-sprotty#514)

Signed-off-by: Wagner Laranjeiras <wagner.laranjeiras@typefox.io>
@Wagner-Laranjeiras
Wagner-Laranjeiras force-pushed the wagner-laranjeiras/514/edge-label-positioning branch from 1e995d8 to 8aeaf9f Compare July 17, 2026 05:56
@Wagner-Laranjeiras
Wagner-Laranjeiras marked this pull request as ready for review July 17, 2026 05:58
@Wagner-Laranjeiras

Copy link
Copy Markdown
Author

thank you for your review @gfontorbe ! I worked on it. Here's the updated commit. 😄

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.

ELK Edge Label is not positioned correctly

2 participants