Options
Public/Protected
  • Public
  • Public/Protected
  • All
Menu

GoJS API 文档

Hierarchy

  • PanelLayout

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:

  • 'Position', PanelLayoutPosition
  • 'Horizontal', PanelLayoutHorizontal
  • 'Vertical', PanelLayoutVertical
  • 'Spot', PanelLayoutSpot
  • 'Auto', PanelLayoutAuto
  • 'Table', PanelLayoutTable
  • 'Viewbox', PanelLayoutViewbox
  • 'TableRow', PanelLayoutTableRow
  • 'TableColumn', PanelLayoutTableColumn
  • 'Link', PanelLayoutLink
  • 'Grid', PanelLayoutGrid
  • 'Graduated', PanelLayoutGraduated

These are included by default in builds of go.js and go-debug.js. When building from source, you can optionally exclude all of them except Position, Vertical, Auto, Link, and Grid. This is demonstrated in minimalSource and maximalSource, in the /projects folder.

Adding a new Layout is done by calling the static function, Panel.definePanelLayout:

Panel.definePanelLayout('Table', new PanelLayoutTable());

Each PanelLayout defines a measure and arrange routine. The measure routine must call measureElement with each element of the Panel, and the arrange routine must similarly call arrangeElement with each element of the Panel.

There is an example PanelLayout in the PanelLayout sample.

since

2.0

Index

Constructors

constructor

Properties

name : string

Methods

Virtual arrange

  • Given the panel and its list of elements, arrange each element.

    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. This Rect can be used to right-align or center-align, etc, elements within an area.

    Parameters

    • panel: Panel

      Panel which called this layout

    • elements: Array<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

Protected arrangeElement

  • arrangeElement(obj: GraphObject, fx: number, fy: number, fw: number, fh: number, clipRect?: Rect): void
  • Arranges the GraphObject onto its parent Panel. The passed-in numbers typically account for GraphObject.margin and other offsets. This sets GraphObject.actualBounds.

    Parameters

    • obj: GraphObject

      GraphObject to be arranged.

    • fx: number

      The final x value of actualBounds that the Panel computes for the GraphObject.

    • fy: number

      The final y value of actualBounds that the Panel computes for the GraphObject.

    • fw: number

      The final width value of actualBounds that the Panel computes for the GraphObject.

    • fh: number

      The final height value of actualBounds that the Panel computes for the GraphObject.

    • Optional clipRect: Rect

      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.

    Returns void

Virtual measure

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

    Parameters

    • panel: Panel

      Panel which called this layout

    • width: number

      expected width of the panel

    • height: number

      expected width of the panel

    • elements: Array<GraphObject>

      Array of Panel elements

    • union: Rect

      rectangle to contain the expected union bounds of every element in the Panel. Useful for arrange.

    • minw: number

      minimum width of the panel

    • minh: number

      minimum height of the panel

    Returns void

Protected measureElement

  • measureElement(obj: GraphObject, width: number, height: number, minw: number, minh: number): void
  • Given the available size, measure one element of the Panel and determine its expected drawing size. Sets the measuredBounds of the object.

    Parameters

    • obj: GraphObject

      Panel which called this layout

    • width: number

      expected width of the GraphObject

    • height: number

      expected width of the GraphObject

    • minw: number

      minimum width of the GraphObject

    • minh: number

      minimum height of the GraphObject

    Returns void

加入 GoJS 交流群
GoJS 交流群 (769862113)