How to place two edge labels on opposite sides of an edge

Questions & Answers

Summary

Shows how to keep labels on opposite sides of an edge.
For a better user experience, please go to the integrated documentation viewer to read this article.

Description

To keep labels on opposite sides of an edge you need to assign different "positions" to them.

For example, the following position assignment will place EdgeLabel l1 above or left to the edge and EdgeLabel l2 below or right to the edge.

l1.setModel(EdgeLabel.SIX_POS);
l1.setPosition(EdgeLabel.HEAD);

l2.setModel(EdgeLabel.SIX_POS);
l2.setPosition(EdgeLabel.TAIL);

On the other hand, the preferredPlacement attribute of a label serves as a hint for automatic labeling algorithms, only.

Categories this article belongs to:
yFiles for Java > yFiles Viewer > Displaying and Editing Graphs > Realizer-Related Features
Applies to:
yFiles for Java 2: 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10, 2.11, 2.12, 2.13, 2.14, 2.15, 2.16, 2.17, 2.18
Keywords:
edge label placment - labeling - label position - label model - preferredPlacement