How to Instruct the OrganicLayouter to Fix Some Node Positions |
| Applies to: yFiles 2.6, yFiles WPF 1.0, yFiles.NET 3.1 |
Type: Questions & Answers
Categories this article belongs to:
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.
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:
In order to specify the subset to be laid out, bind a boolean DataProvider
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); |
| Note |
| Both OrganicLayouter and SmartOrganicLayouter have to instructed to make use of the information bound to the graphs. This can be achieved by invoking either the OrganicLayouter.setSphereOfAction(byte) |
| Note |
| The positions of the nodes that belong the fixed subset may still be changed by the ComponentLayouter The ComponentLayouter instance can of course be disabled or customized to your needs. |
| Note |
|
When using SmartOrganicLayouter to layout a subset of nodes, its feature nodeOverlapsAllowed |
| Keywords: | SmartOrganicLayouter - fix positions - incremental layout - OrganicLayouter - node subset - ComponentLayouter |


