Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PanelLayoutFlow Extension

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,extensionsTS (UMD modules), or extensionsJSM (ES6 modules) folders. See the Extensions intro page for more information.

Hierarchy

A custom 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 GraphObject.visible, GraphObject.stretch, and GraphObject.alignment properties on each element, along with the Panel's Panel.defaultStretch, Panel.defaultAlignment, and Panel.padding properties.

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

Index

Constructors

Properties

Methods

Inherited Members

Constructors

  • Constructs a PanelLayoutFlow that lays out elements in rows with no space between the elements or between the rows.

    Returns PanelLayoutFlow

Properties

  • 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

    Returns void

  • measure(panel: Panel, width: number, height: number, elements: GraphObject[], union: Rect, minw: number, minh: number): 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

    Returns void