Class ArrangingLayout

GoDiagram®
v10.0.12
by Northwoods Software®

A custom Layout that provides one way to have a layout of layouts. It partitions nodes and links into separate subnetworks, applies a primary layout to each subnetwork, and then arranges those results by an arranging layout. Any disconnected nodes are laid out later by a side layout, by default in a grid underneath the main body of subnetworks.

Namespace: Northwoods.Go.Layouts.Extensions
Assembly: ArrangingAvalonia.dll
Syntax
public class ArrangingLayout : NetworkLayout<ArrangingNetwork, ArrangingVertex, ArrangingEdge, ArrangingLayout>
Remarks

This layout uses three separate Layouts.

One is used for laying out nodes and links that are connected together: PrimaryLayout. This defaults to null and must be set to an instance of a Layout, such as a TreeLayout or a ForceDirectedLayout or a custom Layout.

One is used to arrange separate subnetworks of the main graph: ArrangeLayout. This defaults to an instance of GridLayout.

One is used for laying out the additional nodes along one of the sides of the main graph: SideLayout. This also defaults to an instance of GridLayout.

A filter predicate, Filter, splits up the collection of nodes and links into two subsets, one for the main layout and one for the side layout. By default, when there is no filter, it puts all nodes that have no link connections into the subset to be processed by the side layout.

If all pairs of nodes in the main graph can be reached by some path of undirected links, there are no separate subnetworks, so the ArrangeLayout need not be used and the PrimaryLayout would apply to all of those nodes and links.

But if there are disconnected subnetworks, the PrimaryLayout is applied to each subnetwork, and then all of those results are arranged by the ArrangeLayout. If you don't want to use an ArrangeLayout and you want to force the PrimaryLayout to operate on all of the subnetworks, set ArrangeLayout to null.

In either case if there are any nodes in the side graph, those are arranged by the SideLayout to be on the side of the arrangement of the main graph of nodes and links. The Side property controls which side they will be placed -- the default is BottomSide.

Note: if you do not want to have singleton nodes be arranged by SideLayout, set Filter to

(part) => { return true; }
. That will cause all singleton nodes to be arranged by ArrangeLayout as if they were each their own subnetwork.

If you both don't want to use SideLayout and you don't want to use ArrangeLayout to lay out connected subnetworks, don't use this ArrangingLayout at all -- just use whatever Layout you would have assigned to PrimaryLayout.

Constructors

ArrangingLayout()

Constructs a new ArrangingLayout.

Declaration
public ArrangingLayout()

Properties

ArrangeLayout

Gets or sets the Layout used to arrange multiple separate connected subnetworks of the main graph.

Declaration
public Layout ArrangeLayout { get; set; }
Property Value
Type Description
Layout
Remarks

The default value is an instance of GridLayout. Set this property to null in order to get the PrimaryLayout to operate on all connected graphs as a whole.

Filter

Gets or sets the predicate function to call on each non-Link.

Declaration
public Func<Part, bool> Filter { get; set; }
Property Value
Type Description
Func<Part, bool>
Remarks

If the predicate returns true, the part will be laid out by the main layouts, the PrimaryLayouts and the ArrangingLayout, otherwise by the SideLayout. The default value is a function that is true when there are any links connecting with the node. Such default behavior will have the SideLayout position all of the singleton nodes.

PrimaryLayout

Gets or sets the Layout used for the main part of the diagram.

Declaration
public Layout PrimaryLayout { get; set; }
Property Value
Type Description
Layout
Remarks

The default value is an instance of GridLayout. Any new value must not be null.

Side

Gets or sets the side Spot where the side nodes and links should be laid out, relative to the results of the main Layout.

Declaration
public Spot Side { get; set; }
Property Value
Type Description
Spot
Remarks

The default value is Spot.BottomSide.

If the value is Spot.Bottom, Spot.Top, Spot.Right, or Spot.Left, the side nodes will be centered along that side.

Currently only handles a single side.

SideLayout

Gets or sets the Layout used to arrange the "side" nodes and links -- those outside of the main layout.

Declaration
public Layout SideLayout { get; set; }
Property Value
Type Description
Layout
Remarks

The default value is an instance of GridLayout. Any new value must not be null.

Spacing

Gets or sets the space between the main layout and the side layout.

Declaration
public Size Spacing { get; set; }
Property Value
Type Description
Size
Remarks

The default value is Size(20, 20).

Methods

DoLayout(IEnumerable<Part>)

Perform the layout.

Declaration
public override void DoLayout(IEnumerable<Part> coll = null)
Parameters
Type Name Description
IEnumerable<Part> coll

the collection of Parts to layout.

Overrides

MoveSideCollection(IEnumerable<Part>, Rect, Rect)

This method is called just after the SideLayout has been performed in order to move its parts to the desired area relative to the results of the main layouts.

Declaration
public virtual void MoveSideCollection(IEnumerable<Part> sidecoll, Rect mainbounds, Rect sidebounds)
Parameters
Type Name Description
IEnumerable<Part> sidecoll

a collection of Parts that were laid out by the SideLayout

Rect mainbounds

the area occupied by the results of the main layouts

Rect sidebounds

the area occupied by the results of the SideLayout

Remarks

By default this calls MoveParts(IEnumerable<Part>, Point, bool, DraggingOptions) on the sidecoll collection to the Side of the mainbounds. This won't get called if there are no Parts in the sidecoll collection.

MoveSubgraph(IEnumerable<Part>, Rect, Rect)

Move a Set of Nodes and Links to the given area.

Declaration
public virtual void MoveSubgraph(IEnumerable<Part> subColl, Rect subbounds, Rect bounds)
Parameters
Type Name Description
IEnumerable<Part> subColl

the Set of Nodes and Links that form a separate connected subnetwork

Rect subbounds

the area occupied by the subColl

Rect bounds

the area where they should be moved according to the ArrangingLayout

PreparePrimaryLayout(Layout, IEnumerable<Part>)

This method is called just before the PrimaryLayout is performed so that there can be adjustments made to the PrimaryLayout, if desired.

Declaration
public virtual void PreparePrimaryLayout(Layout primaryLayout, IEnumerable<Part> mainColl)
Parameters
Type Name Description
Layout primaryLayout

the sideLayout that may be modified for the results of the PrimaryLayout

IEnumerable<Part> mainColl

the Nodes and Links to be laid out by PrimaryLayout after being separated into subnetworks

Remarks

By default this method makes no adjustments to the PrimaryLayout.

PrepareSideLayout(Layout, IEnumerable<Part>, Rect)

This method is called just after the main layouts (the PrimaryLayouts and ArrangingLayout) have been performed and just before the SideLayout is performed so that there can be adjustments made to the sideLayout, if desired.

Declaration
public virtual void PrepareSideLayout(Layout sideLayout, IEnumerable<Part> sideColl, Rect mainBounds)
Parameters
Type Name Description
Layout sideLayout

the SideLayout that may be modified for the results of the main layouts

IEnumerable<Part> sideColl

the Nodes and Links filtered out to be laid out by SideLayout

Rect mainBounds

the area occupied by the nodes and links of the main layout, after it was performed

Remarks

By default this method makes no adjustments to the sideLayout.

SplitParts(HashSet<Part>, HashSet<Part>, HashSet<Part>)

Assign all of the Parts in the given collection into either the set of Nodes and Links for the main graph or the set of Nodes and Links for the side graph.

Declaration
public virtual void SplitParts(HashSet<Part> coll, HashSet<Part> maincoll, HashSet<Part> sidecoll)
Parameters
Type Name Description
HashSet<Part> coll
HashSet<Part> maincoll
HashSet<Part> sidecoll
Remarks

By default this just calls the Filter on each non-Link to decide, and then looks at each Link's connected Nodes to decide.

A null filter assigns all Nodes that have connected Links to the main graph, and all Links will be assigned to the main graph, and the side graph will only contain Parts with no connected Links.