Make HierarchicLayouter Preserve Space for Node Labels |
| Applies to: yFiles 2.4, yFiles 2.3, yFiles 2.2, yFiles 2.1, yFiles 2.0, yFiles.NET 2.4, yFiles.NET 2.3, yFiles.NET 2.2 |
Type: Tips & Tricks
Categories this article belongs to:
| yFiles for Java | > yFiles Layout | > Automatic Graph Layout | > Hierarchical Layout |
HierarchicLayouter
by default does not consider node labels at all. This article describes how to customize the Drawer
implementation in order to preserve space for node labels.
HierarchicLayouter makes use of different sub modules that are responsible for assigning nodes to layers, sequencing layers, and assigning coordinates to nodes. The node assignment is performed by classes implementing the Drawer
interface.
The most popular implementations of this interface are SimplexDrawer
, MedianLinearSegmentDrawer
, and MedianDrawerWrapper
. Those implementations take space requirements into account that are provided by the main layout algorithm through DataProviders
that are bound to the graph using the Drawer.NODE_BORDER_LEFT
and Drawer.NODE_BORDER_RIGHT
dataprovider keys.
The attached example class NodeLabelSpaceDrawer can be used to wrap the Drawer implementation as follows:
This will preserve sufficient space between neighbouring nodes so that node labels will not overlap with each other anymore.
The most popular implementations of this interface are SimplexDrawer
The attached example class NodeLabelSpaceDrawer can be used to wrap the Drawer implementation as follows:
//create the layouter HierarchicLayouter hl = new HierarchicLayouter(); //set an appropriate drawer hl.setDrawer(new SimplexDrawer()); //wrap the drawer hl.setDrawer(new NodeLabelSpaceDrawer(hl.getDrawer())); |
| Note |
| yFiles 2.3 provides IncrementalHierarchicLayouter |
| Resources: |
| Keywords: | HierarchicLayouter - customize - preserve - space - labels - NodeLabel - side - Drawer - NODE_BORDER_LEFT - NODE_BORDER_RIGHT - wrap |


