How to Instruct the OrganicLayouter to Fix Some Node Positions
Questions & AnswersSummary
This article describes how the suite of organic layout algorithms can be instructed to fix the positions of a subset of nodes. It applies to both the SmartOrganicLayouter and the OrganicLayouter, both in flat mode and hierarchically nested mode.
Description
It is often useful to specify a subset of nodes that should be laid out only or a subset of nodes that should not be laid out during a layout run. Both OrganicLayouter and SmartOrganicLayouter support this feature, even if the two subsets are in the same graph component.
In order to specify the subset to be laid out, bind a boolean DataProvider to the graph using a predefined DataProvider key.
This article describes different ways of how to pass data to layout algorithms.
The following piece of code uses the current selection to specify those nodes to be laid out by the layout algorithm:
//Add the DataProvider to the graph
graph2d.addDataProvider(SmartOrganicLayouter.NODE_SUBSET_DATA,
Selections.createSelectionNodeMap(graph2d));
//Configure the algorithm to use the data
smartOrganicLayouter.setScope(SmartOrganicLayouter.SCOPE_SUBSET);
//and run the layout
//(buffered in this case)
new BufferedLayouter(smartOrganicLayouter).doLayout(graph2d);
//remove the DataProvider after the layout
graph2d.removeDataProvider(SmartOrganicLayouter.NODE_SUBSET_DATA);
Categories this article belongs to:
yFiles for Java > yFiles Layout > Automatic Graph Layout > Organic Layout
yFiles WPF > yFiles WPF Algorithms > Automatic Graph Layout > Organic Layout
yFiles.NET > yFiles.NET Algorithms > Automatic Graph Layout > Organic Layout
Applies to:
yFiles for Java 2: 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
yFiles.NET: 3.1, 3.2
yFiles WPF: 1.0
Keywords:
SmartOrganicLayouter - fix positions - incremental layout - OrganicLayouter - node subset - ComponentLayouter