PanelLayout class
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
None of these predefined panel layout classes have their own documentation pages.
These panel layouts are included by default in builds of go.js
and go-module.js
and their respective debug versions.
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.
Registering a new PanelLayout is done by calling the static function, Panel.definePanelLayout:
Panel.definePanelLayout('Table', new PanelLayoutCustom());
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.
- Available extensions
- Annotations
-
- @JS()
- @staticInterop
Constructors
- PanelLayout()
-
factory
Properties
- classType ↔ Function
-
Available on PanelLayout, provided by the PanelLayout$Typings extension
(undocumented)getter/setter pair - hashCode → int
-
The hash code for this object.
no setterinherited
- name ↔ String
-
Available on PanelLayout, provided by the PanelLayout$Typings extension
Gets or sets the name of this instance of a particular panel layout.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
arrange(
Panel panel, Array< GraphObject> elements, Rect union) → void -
Available on PanelLayout, provided by the PanelLayout$Typings extension
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. -
arrangeElement(
GraphObject obj, num x, num y, num width, num height, [Rect? clipRect]) → void -
Available on PanelLayout, provided by the PanelLayout$Typings extension
Arranges the GraphObject onto its parent Panel. The passed-in numbers typically account for GraphObject#margin and other offsets. Thex
andy
coordinates are where GraphObjects will be placed within the Panel's own coordinates (from the Panel's top-left corner). Thewidth
andheight
are the size it will take up within the Panel's coordinates. -
measure(
Panel panel, num width, num height, Array< GraphObject> elements, Rect union, num minw, num minh) → void -
Available on PanelLayout, provided by the PanelLayout$Typings extension
Given the available size, measure the Panel and determine its expected drawing size. -
measureElement(
GraphObject obj, num width, num height, num minw, num minh) → void -
Available on PanelLayout, provided by the PanelLayout$Typings extension
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. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remeasureObject(
GraphObject obj) → void -
Available on PanelLayout, provided by the PanelLayout$Typings extension
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. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited