Custom Node Alignment for HierarchicLayouter |
| Applies to: 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 |
This article describes how HierarchicLayouter
can be customized to produce different node alignments.
yFiles HierarchicLayouter
provides no default means for specifying the alignment of nodes within a common layer but always places them in the center of the layer.
However the layout algorithm has been implemented in a modular fashion and different stages of the layout can be customized completely.
In order to modify the node alignment the drawer stage
can be wrapped with a custom implementation.
Copy the attached java source file to your application, compile it and use the following lines of code to reconfigure HierarchicLayouter to work with the customization class:
The provided implementation provides different default alignment modes. For a top-level alignment (in LayoutOrientation.TOP_TO_BOTTOM
style) you can use the following code to configure the customization:
However the layout algorithm has been implemented in a modular fashion and different stages of the layout can be customized completely.
In order to modify the node alignment the drawer stage
Copy the attached java source file to your application, compile it and use the following lines of code to reconfigure HierarchicLayouter to work with the customization class:
// wrap the default drawer implemenation hierarchicLayouter.setDrawer( new AlignmentDrawer(hierarchicLayouter.getDrawer())); |
//register a DataProvider, providing alignment data for each node graph.addDataProvider( AlignmentDrawer.NODE_ALIGNMENT_POINT_DPKEY, new AlignmentDrawer.TopAlignmentDataProvider()); |
| Warning |
| These DataProvider implementations will only work properly if the layout is performed in buffered mode. |
| Note |
| Note that IncrementalHierarchicLayouter |
| Resources: |
| Keywords: | HierarchicLayouter - layer - center - nodes - alignment - customization - align - top - bottom - HierarchicGroupLayouter - Drawer |


