NShape Concepts
Automatic Layouting

<< Click to Display Table of Contents >>

Navigation:  Concepts >

NShape Concepts
Automatic Layouting

Previous pageReturn to chapter overviewNext page

The NShape framework includes classes for automatic layouting. Some of these classes are still in an experimental state but can nevertheless deliver good results in many cases.

The layout algorithms are implemented in classes derived from ILayouter and Layouter. There is also a dialog window for interactive automatic layouting called LayoutDialog. Automatic layouting usually requires multiple steps with different algorithms to produce a good result. For example in order to layout an UML diagram you might want do the following:

1.Use the cluster layouter to disentangle the diagram.

2.Use the alignment layouter to neatly position the shapes.

3.Use the expansion layouter to fit the diagram in the desired size.

In code this is done by creating the respective layouter classes, set the parameter properties and call their Execute method one after another. If you want the user to be able to undo the layouting, you must also call the CreateLayoutCommand method and execute the returned command.

On the user interface you can open the layout control window, choose the desired layout algorithm, set the layout parameters and do the layouting either in one step or stepwise. If you set the operation mode to immediate, you can move the sliders for the layouting parameters (very slowly if there are many shapes selected) and directly see how the parameters influence the result. Choose the setting where the result pleases you most.

Cluster Layouter

The cluster layouter pushes shapes in general apart but connected shapes attract each other. This way shapes are distributed on the diagram such that connected shapes are near to each other and unconnected shapes are far from each other. The result can be improved by applying the alignment layouter.

Flow Layouter

The flow layouter groups the shapes into layers such that a main flow direction is visible, e.g. from top layers to bottom layers. There must be connecting arrows between the shapes for the flow layouter to work. Arrows are lines that connect shapes via a shape-to-shape connection (i.e. not connected to a specific connection point of the shape) and whose start cap is different from the end cap. Arrows always point from the line start (with the start cap) to the line end (with the end cap) even if the start cap is for example an arrow head and there is no end cap.

Expansion Layouter

The expansion layouter is used for growing or shrinking a layout maintaining the relative positions of the shapes.