根据面板及其元素列表,排列每个元素
这必须为每个Panel元素调用 arrangeElement ,这将设置该元素的 GraphObject.actualBounds
对于某些元素的排列,知道每个元素的统一面积是很有用的,此Rect可用于在区域内将元素右对齐或居中对齐
Panel叫做布局
Panel元素数组
矩形, 如果 measure 正确的构造, 其中包含面板中每个元素的预期联合边界。
Arranges the GraphObject onto its parent Panel. The passed-in numbers typically account for GraphObject.margin and other offsets. This sets GraphObject.actualBounds.
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 Fixed/Table panels element, provided as a Rect.
Given the available size, measure the Panel and determine its expected drawing size. Sets the measuredBounds of the object.
This must call measureElement with each Panel element.
This must also construct the union.width and union.height of the passed in union Rect argument. This union must reflect the measured size of the panel.
Panel which called this layout
expected width of the panel
expected height of the panel
Array of Panel elements
rectangle to contain the expected union bounds of every element in the Panel. Useful for arrange.
minimum width of the panel
minimum height of the panel
Given the available size, measure one element of the Panel and determine its expected drawing size. Sets the measuredBounds of the object.
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
这是所有面板布局的抽象基类,它告知可能的面板类型。可以通过创建PanelLayout的子类来创建自己的Panel类型,尽管这并不常见,不建议初学者使用
默认情况下, GoJS具有12种面板类型,每种类型对应于PanelLayout子类:
'Position', PanelLayoutPosition
'Horizontal', PanelLayoutHorizontal
'Vertical', PanelLayoutVertical
'Spot', PanelLayoutSpot
'Auto', PanelLayoutAuto
'Table', PanelLayoutTable
'Viewbox', PanelLayoutViewbox
'TableRow', PanelLayoutTableRow
'TableColumn', PanelLayoutTableColumn
'Link', PanelLayoutLink
'Grid', PanelLayoutGrid
'Graduated', PanelLayoutGraduated
这些默认包含在
go.js
和go-debug.js
的构建中。 从源构建时,可以选择排除所有其他对象,但Position
,Vertical
,Auto
,Link
, 和Grid
除外。 在/projects
文件夹中的minimalSource
和maximalSource
对此进行了演示。通过调用静态函数 Panel.definePanelLayout 来添加新的Layout:
Panel.definePanelLayout('Table', new PanelLayoutTable());
每个PanelLayout定义一个 measure 和 arrange 例程。 measure例程必须使用Panel的每个元素调用 measureElement , 而 arrange 例程必须类似的使用Panel的每个元素调用 arrangeElement
PanelLayout示例中有一个 PanelLayout 示例
2.0