This class is abstract. Define your own subclass if you want to implement a custom panel layout.
Gets or sets the name of this instance of a particular panel layout.
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
.
Panel which called this layout
Array of Panel elements
rectangle, if properly constructed in measure, that contains the expected union bounds of every element in the Panel.
Arranges the GraphObject onto its parent Panel.
The passed-in numbers typically account for GraphObject.margin and other offsets.
The x
and y
coordinates are where GraphObjects will be placed within the Panel's own coordinates
(from the Panel's top-left corner). The width
and height
are the size it will take up within the Panel's coordinates.
This sets the GraphObject.actualBounds of the obj
.
GraphObject to be arranged.
The final x value of actualBounds that the Panel computes for the GraphObject.
The final y value of actualBounds that the Panel computes for the GraphObject.
The final width value of actualBounds that the Panel computes for the GraphObject.
The final height value of actualBounds that the Panel computes for the GraphObject.
an optional area to constrain this actualBounds to when picking and drawing. By default, this is only used with Table Panel elements, which are clipped to their cell sizes.
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.
Panel which called this layout
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.
expected height of the Panel.
Array of Panel elements
rectangle to be modified to contain the expected union bounds of every element in the Panel, to be potentially used in arrange.
expected minimum width of the Panel, informed by any containing Panel. Often zero.
expected minimum height of the Panel.
Given the available size, measure one element of the Panel and determine its expected drawing size. This sets the GraphObject.measuredBounds of the object, which can then be used to determine the arrangement of objects in the PanelLayout.
Panel which called this layout
expected width of the GraphObject
expected height of the GraphObject
minimum width of the GraphObject
minimum height of the GraphObject
Uncommon: Force a given GraphObject to remeasure in the near future. If a PanelLayout is not just measuring elements, but must also modify some of its elements, this must be called on those elements before modifications are made. This prevents the elements from potentially remeasuring the entire visual tree, which would cause an infinite loop.
Normally, panels do not modify the dimensions of their elements. In other words, a Panel would not normally set a property like GraphObject.desiredSize or TextBlock.text or Shape.geometry on any of its elements. Some custom panels may wish to do this, especially if the programmer knows it will not affect the size of any containing Panel.
Calling this method before changing a property preempts the remeasuring of any containing Panels, ensuring only the GraphObject and its own child elements will be remeasured.
This is used in PanelLayout "Viewbox" on its one element. It modifies that element's GraphObject.scale and is certain that will not affect Panels up the visual tree.
GraphObject to be invalidated.
This is the abstract base class for all Panel Layouts, which inform the possible Panel types. It is possible to create your own Panel type by creating a subclass of PanelLayout, though this is not common and not recommended for beginners.
By default, GoJS has 12 Panel types, each corresponding to a PanelLayout subclass:
PanelLayoutPosition
PanelLayoutHorizontal
PanelLayoutVertical
PanelLayoutSpot
PanelLayoutAuto
PanelLayoutTable
PanelLayoutViewbox
PanelLayoutTableRow
PanelLayoutTableColumn
PanelLayoutLink
PanelLayoutGrid
PanelLayoutGraduated
None of these predefined panel layout classes have their own documentation pages.
These panel layouts are included by default in builds of
go.js
andgo-module.js
and their respective debug versions. When building from source, you can optionally exclude all of them exceptPosition
,Vertical
,Auto
,Link
, andGrid
. This is demonstrated inminimalSource
andmaximalSource
, in the/projects
folder.Registering a new PanelLayout is done by calling the static function, Panel.definePanelLayout:
Each PanelLayout must define a measure and arrange method. The measure method must call measureElement with each element of the Panel, which sets each element's GraphObject.measuredBounds. These bounds can be used to determine object layout. The arrange method must call arrangeElement with each element of the Panel to position the objects relative to the Panel. Remember that each Panel defines its own coordinate system, which is used for sizing and positioning of the panel's elements.
An instance of a PanelLayout is shared by all copies of a Panel that uses it.
There is an example PanelLayout in the PanelLayout sample. There is a Flow PanelLayout extension at PanelLayoutFlow, demonstrated at Flow PanelLayout sample.
2.0