This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. Extensions can be found in the GoJS kit under the `extensions` or `extensionsTS` folders. See the Extensions intro page for more information.

### Hierarchy

- Layout
  - ArrangingLayout

A custom Layout that provides one way to have a layout of layouts. It partitions nodes and links into separate subgraphs, applies a primary layout to each subgraph, 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 subgraphs.

If you want to experiment with this extension, try the Arranging Layout sample.

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: arrangingLayout. 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 arrangingLayout 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 arrangingLayout.

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.

Note: if you do not want to have singleton nodes be arranged by sideLayout, set filter to `function(part) { return true; }`. That will cause all singleton nodes to be arranged by arrangingLayout as if they were each their own subgraph.

If you both don't want to use sideLayout and you don't want to use arrangingLayout to lay out connected subgraphs, don't use this ArrangingLayout at all -- just use whatever Layout you would have assigned to primaryLayout.

## Index

### Constructors

- constructor

### Properties

- arrangingLayout
- filter
- primaryLayout
- side
- sideLayout
- spacing

### Methods

- moveSideCollection
- moveSubgraph
- preparePrimaryLayout
- prepareSideLayout
- splitParts

## Constructors

### constructor

- new ArrangingLayout(): ArrangingLayout

- #### Returns ArrangingLayout

## Properties

### arrangingLayout : Layout

- Gets or sets the Layout used to arrange multiple separate connected subgraphs of the main graph. The default value is an instance of GridLayout. Set this property to null in order to get the default behavior of the @{link #primaryLayout} when dealing with multiple connected graphs as a whole.

### filter : function(part: Part): boolean | null

- Gets or sets the predicate function to call on each non-Link. 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 : Layout

- Gets or sets the Layout used for the main part of the diagram. The default value is an instance of GridLayout. Any new value must not be null.

### side : Spot

- Gets or sets the side Spot where the side nodes and links should be laid out, relative to the results of the main Layout. The default value is Spot.BottomSide. Currently only handles a single side.

### sideLayout : Layout

- Gets or sets the Layout used to arrange the "side" nodes and links -- those outside of the main layout. The default value is an instance of GridLayout. Any new value must not be null.

### spacing : Size

- Gets or sets the space between the main layout and the side layout. The default value is Size(20, 20).

## Methods

### moveSideCollection

- moveSideCollection(sidecoll: Set<Part>, mainbounds: Rect, sidebounds: Rect): void

- 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. By default this calls Diagram.moveParts on the sidecoll collection to the side of the mainbounds. This won't get called if there are no Parts in the sidecoll collection.

  #### Parameters

  - ##### sidecoll: Set<Part>

    a collection of Parts that were laid out by the sideLayout

  - ##### mainbounds: Rect

    the area occupied by the results of the main layouts

  - ##### sidebounds: Rect

    the area occupied by the results of the sideLayout

  #### Returns void

### moveSubgraph

- moveSubgraph(subColl: Set<Part>, subbounds: Rect, bounds: Rect): void

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

  #### Parameters

  - ##### subColl: Set<Part>

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

  - ##### subbounds: Rect

    the area occupied by the subColl

  - ##### bounds: Rect

    the area where they should be moved according to the arrangingLayout

  #### Returns void

### preparePrimaryLayout

- preparePrimaryLayout(primaryLayout: Layout, mainColl: Set<Part>): void

- This method is called just before the primaryLayout is performed so that there can be adjustments made to the primaryLayout, if desired. By default this method makes no adjustments to the primaryLayout.

  #### Parameters

  - ##### primaryLayout: Layout

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

  - ##### mainColl: Set<Part>

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

  #### Returns void

### prepareSideLayout

- prepareSideLayout(sideLayout: Layout, sideColl: Set<Part>, mainBounds: Rect): void

- 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. By default this method makes no adjustments to the sideLayout.

  #### Parameters

  - ##### sideLayout: Layout

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

  - ##### sideColl: Set<Part>

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

  - ##### mainBounds: Rect

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

  #### Returns void

### splitParts

- splitParts(coll: Set<Part>, maincoll: Set<Part>, sidecoll: Set<Part>): void

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

  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.

  #### Parameters

  - ##### coll: Set<Part>

  - ##### maincoll: Set<Part>

  - ##### sidecoll: Set<Part>

  #### Returns void

Copyright © 1998-2021 by Northwoods Software Corporation.