Layout Modules

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.

Note that the layout modules are part of the source code demos. They are not part of the yFiles for Silverlight library.

Figure 8.1. Layout modules type hierarchy

Layout modules type hierarchy.

The following methods from LayoutModule can be used to invoke a yFiles layout algorithm:

API Excerpt 8.1. Methods from abstract class LayoutModule

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 8.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 8.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;

Table 8.1, “Layout modules” lists the layout modules available with yFiles for Silverlight. 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 8.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 LayoutModulesWindow shows how to use the layout modules in an application context.