Achieving Non-Overlapping Node and Edge Labeling
Applies to: yFiles 2.6, yFiles 2.5, yFiles 2.4, yFiles 2.3, yFiles 2.2, yFiles 2.1, yFiles 2.0 print article email article

Type: Questions & Answers

Automatically placing node and edge labels that do not overlap other graph elements.

Support for automatic label placement is provided by the yFiles library in two ways. First, the generic approach where the graph elements themselves are left untouched, but only the labels are moved. And second, the integrated variant where the labels are placed while a graph layout is calculated.

Package y.layout.labeling contains the algorithms for the generic approach, e.g., class GreedyMISLabeling. The layout algorithms that have label placement seamlessly integrated are HierarchicLayouter, HierarchicGroupLayouter, IncrementalHierarchicLayouter, and OrthogonalLayouter.

Generic Label Placement

The algorithms that follow the generic approach try to find label positions that do not overlap other graph elements. To this end, they can choose from a set of predefined label positions, that have been associated with a label by means of a so-called "label model."

Node labels and edge labels provide several type-specific label models, each having a predefined set of valid label positions. With class NodeLabel, for example, label model NodeLabel.CORNERS has four valid label positions. These are at the corners of a node, i.e., outside its bounds.

The tutorial source code demos LabelingDemo.java and LabelingModule.java show how to use these labeling algorithms.

Integrated Label Placement

The layout algorithms where labeling is integrated into the layout process itself can calculate a graph layout with respect to label position and size. That way, non-overlapping label positions can be guaranteed.

The tutorial source code demo HierarchicLayoutModule.java shows how to configure both generic approach as well as integrated edge labeling for class HierarchicLayouter.


Keywords: automatic - label - placement - non-overlapping - labeling - node - edge - generic - integrated - overlap - minimize

Provide feedback:
How useful was this article?    less 1 2 3 4 5 more
Email address (optional):
COPYRIGHT © 2008 yWorks · ALL RIGHTS RESERVED imprint | top | home