Class PanelLayoutFlow

GoJS® Diagramming Components
version 3.0.16
by Northwoods Software®

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. See the Extensions intro page for more information.

Hierarchy (view full)

A custom go.PanelLayout that arranges panel elements in rows or columns. A typical use might be:

$(go.Node,
...
$(go.Panel, "Flow",
... the elements to be laid out in rows with no space between them ...
)
...
)

A customized use might be:

$(go.Node,
...
$(go.Panel,
$(PanelLayoutFlow, { spacing: new go.Size(5, 5), direction: 90 }),
... the elements to be laid out in columns ...
)
...
)

The direction property determines whether the elements are arranged in rows (if 0 or 180) or in columns (if 90 or 270).

Use the spacing property to control how much space there is between elements in a row or column as well as between rows or columns.

This layout respects the go.GraphObject.visible, go.GraphObject.stretch, and go.GraphObject.alignment properties on each element, along with the Panel's go.Panel.defaultStretch, go.Panel.defaultAlignment, and go.Panel.padding properties.

If you want to experiment with this extension, try the Flow PanelLayout sample.

Index

Constructors

Accessors

Methods

Constructors

Accessors

  • Gets or sets the initial direction in which elements are laid out. The value must be 0 or 180, which results in rows, or 90 or 270, which results in columns.

    The default value is 0, resulting in rows that go rightward. A value of 90 results in columns that go downward.

    Setting this property does not notify about any changed event, nor does a change in value automatically cause the panel layout to be performed again.

  • Gets or sets the space between adjacent elements in the panel and the space between adjacent rows or columns.

    The default value is (0, 0). The size is in the panel's coordinate system.

    Setting this property does not notify about any changed event, nor does a change in value automatically cause the panel layout to be performed again.

Methods

  • After measuring, a Panel must arrange each element, giving the elements a position and size in the Panel's coordinate system. This must call arrangeElement with each Panel element, which will set that element's GraphObject.actualBounds.

    For arranging some elements, it is useful to know the total unioned area of every element, which is given as the union argument. This Rect can be used to right-align or center-align, etc, elements within an area.

    For example, PanelLayoutHorizontal arranges each element sequentially, starting with an x value of 0, and increasing it by each previous element's GraphObject.measuredBounds width. The horizontal Panel arranges each element with a y value determined by the union argument's height considering the GraphObject.alignment of the element, and the GraphObject's own measuredBounds.height.

    Parameters

    • panel: Panel

      Panel which called this layout

    • elements: GraphObject[]

      Array of Panel elements

    • union: Rect

      rectangle, if properly constructed in measure, that contains the expected union bounds of every element in the Panel.

    Returns void

  • Given the available size, measure the Panel and determine its expected drawing size.

    This must call measureElement with each Panel element, which will set the GraphObject.measuredBounds of those elements. Depending on how the Panel intends to lay out its elements, the programmer must construction the union by setting union.width and union.height of the supplied argument. For example PanelLayoutHorizontal measures its elements and sums their widths to set its union.width, and takes the maximum of their heights to set its union.height.

    This union must reflect the measured size of the Panel. After measure is called, the Panel class will modify this union Rect, constraining its size by the Panel's GraphObject.desiredSize, GraphObject.minSize, and GraphObject.maxSize, before passing it to arrange.

    Parameters

    • panel: Panel

      Panel which called this layout

    • width: number

      expected width of the Panel, informed by any containing Panel and by the Panel's own GraphObject.desiredSize, GraphObject.minSize, and GraphObject.maxSize. Often Infinity.

    • height: number

      expected height of the Panel.

    • elements: GraphObject[]

      Array of Panel elements

    • union: Rect

      rectangle to be modified to contain the expected union bounds of every element in the Panel, to be potentially used in arrange.

    • minw: number

      expected minimum width of the Panel, informed by any containing Panel. Often zero.

    • minh: number

      expected minimum height of the Panel.

    Returns void