A layout module serves as a convenient means for interactively configuring and launching a yFiles layout algorithm. Layout modules inherit from abstract classes LayoutModule and YModule, respectively.
The following methods from LayoutModule can be used to invoke a yFiles layout algorithm:
API Excerpt 3.1. Methods from abstract class LayoutModule
// Invoking the layout algorithm. void Start(ILookup newContext) void Start(LayoutGraph layoutGraph)
The Start method that takes an ILookup as parameter allows to invoke a layout algorithm when there is no LayoutGraph object readily available. For example, to use an IGraph instance a setup similar to Example 3.5, “Using an IGraph for layout invocation” can be used.
Note that when layout morphing is enabled via the layout module's LayoutMorphingEnabled property, a GraphControl is expected being available in the ILookup, too. It is used to determine the actual canvas where morphing should take place.
Example 3.5. Using an IGraph for layout invocation
// 'myGraph' is of type yWorks.yFiles.UI.Model.IGraph. // 'myGraphControl' is of type yWorks.yFiles.UI.GraphControl. // Setting up an ILookup object. DictionaryLookup context = new DictionaryLookup(); context.Put(typeof (IGraph), myGraph); // Enables layout morphing. context.Put(typeof (GraphControl), myGraphControl); // Invoking a layout algorithm via its layout module. someLayoutModule.LayoutMorphingEnabled = true; someLayoutModule.Start(context);
Table 3.1, “Layout modules” lists the layout modules available with yFiles.NET. Similar to setting up layout morphing functionality as described above, some of the layout algorithms encapsulated by a layout module expect a CanvasControl object being available in the ILookup.
Table 3.1. Layout modules
| Layout Module(s) | Description |
|---|---|
| CircularLayoutModule | Circular layout. |
| OrthogonalLayoutModule, CompactOrthogonalLayoutModule, and DirectedOrthogonalLayoutModule | Orthogonal layout. |
| IncrementalHierarchicLayoutModule | Hierarchical layout. |
| SmartOrganicLayoutModule | Organic layout. Note that SmartOrganicLayouter expects a CanvasControl object available in the ILookup. |
| TreeLayoutModule | Covers the yFiles tree layout algorithms, including ARTreeLayouter, BalloonLayouter, HVTreeLayouter, and TreeLayouter. Note that ARTreeLayouter expects a CanvasControl object available in the ILookup. |
| ComponentLayoutModule | Component layout. Note that the layouter expects a CanvasControl object available in the ILookup. |
| PartialLayoutModule | Partial layout. |
| LabelingModule | Automatic label placement. |
| OrganicEdgeRouterModule | Organic edge routing. |
| OrthogonalEdgeRouterModule, ChannelEdgeRouterModule, and BusRouterModule | Orthogonal edge routing. |
| GraphTransformerModule | Enables scaling, rotating, and mirroring of graphs. Note that some options expect a CanvasControl object available in the ILookup. |
Tutorial demo application LayoutModulesForm shows how to use the layout modules in an application context.
|
Copyright ©2004-2011, yWorks GmbH. All rights reserved. |