GeezerVison is showing maxgraph.github.io (truncated) — AbstractGraph | @maxgraph/core
Class AbstractGraphAbstract
Extends EventSource to implement a graph component for the browser. This is the entry point class of the package.
To activate panning and connections use setPanning and setConnectable.
For rubberband selection you must create a new instance of rubberband.
The following listeners are added to mouseListeners by default:
These listeners will be called in the above order if they are enabled.
Constructors
Properties
addAllEdges
Returns an array with the given cells and all edges that are connected to a cell or one of its descendants.
addCell
addCell: ( cell: Cell, parent?: Cell | null, index?: number | null, source?: Cell | null, target?: Cell | null,) => Cell
Adds the cell to the parent and connects it to the given source and target terminals.
This is a shortcut method.
Type Declaration
-
- (
cell: Cell, parent?: Cell | null, index?: number | null, source?: Cell | null, target?: Cell | null, ): Cell
-
Parameters
- cell: Cell
Cell to be inserted into the given parent.
Optionalparent: Cell | null
Cell that represents the new parent. If no parent is given then the default parent is used.
Optionalindex: number | null
Optional index to insert the cells at. Default is 'to append'.
Optionalsource: Cell | null
Optional Cell that represents the source terminal.
Optionaltarget: Cell | null
Optional Cell that represents the target terminal.
the cell that was added.
addCells
addCells: ( cells: Cell[], parent?: Cell | null, index?: number | null, source?: Cell | null, target?: Cell | null, absolute?: boolean,) => Cell[]
Adds the cells to the parent at the given index, connecting each cell to
the optional source and target terminal. The change is carried out using
cellsAdded. This method fires InternalEvent.ADD_CELLS while the
transaction is in progress. Returns the cells that were added.
Type Declaration
-
- (
cells: Cell[], parent?: Cell | null, index?: number | null, source?: Cell | null, target?: Cell | null, absolute?: boolean, ): Cell[]
-
Parameters
- cells: Cell[]
Array of Cells to be inserted.
Optionalparent: Cell | null
Cell that represents the new parent. If no parent is given then the default parent is used. Default is null.
Optionalindex: number | null
Optional index to insert the cells at. Default is null (append).
Optionalsource: Cell | null
Optional source Cell for all inserted cells. Default is null.
Optionaltarget: Cell | null
Optional target Cell for all inserted cells. Default is null.
Optionalabsolute: boolean
Optional boolean indicating of cells should be kept at their absolute position. Default is false.
Returns Cell[]
addEdge
addEdge: ( edge: Cell, parent: Cell | null, source: Cell | null, target: Cell | null, index?: number | null,) => Cell
Adds the edge to the parent and connects it to the given source and target terminals. This is a shortcut method.
Type Declaration
-
- (
edge: Cell, parent: Cell | null, source: Cell | null, target: Cell | null, index?: number | null, ): Cell
-
Parameters
- edge: Cell
Cell to be inserted into the given parent.
- parent: Cell | null
Cell that represents the new parent. If no parent is given then the default parent is used.
- source: Cell | null
Optional Cell that represents the source terminal.
- target: Cell | null
Optional Cell that represents the target terminal.
Optionalindex: number | null
Optional index to insert the cells at. Default is 'to append'.
The edge that was added.
addMouseListener
Adds a listener to the graph event dispatch loop.
The listener must implement the mouseDown, mouseMove and mouseUp methods as shown in the InternalMouseEvent class.
addSelectionCell
addSelectionCell: (cell: Cell) => void
Adds the given cell to the selection.
Type Declaration
-
- (cell: Cell): void
-
Parameters
- cell: Cell
Cell to be add to the selection.
Returns void
addSelectionCells
addSelectionCells: (cells: Cell[]) => void
Adds the given cells to the selection.
Type Declaration
-
- (cells: Cell[]): void
-
Parameters
- cells: Cell[]
Array of Cell to be added to the selection.
Returns void
alignCells
Aligns the given cells vertically or horizontally according to the given alignment using the optional parameter as the coordinate.
allowAutoPanning
allowAutoPanning: boolean
allowDanglingEdges
allowDanglingEdges: boolean
Specifies if edges with disconnected terminals are allowed in the graph.
allowLoops
allowLoops: boolean = false
Specifies if loops (aka self-references) are allowed.
allowNegativeCoordinates
allowNegativeCoordinates: boolean
Specifies if negative coordinates for vertices are allowed.
alreadyConnectedResource
alreadyConnectedResource: string = ...
Specifies the resource key for the error message to be displayed in
non-multigraphs when two vertices are already connected. If the resource
for this key does not exist then the value is used as the error message.
Default'alreadyConnected'
alternateEdgeStyle
Specifies the alternate edge style to be used if the main control point on an edge is being double-clicked.
autoExtend
autoExtend: boolean
Specifies if the size of the graph should be automatically extended if the
mouse goes near the container edge while dragging.
This is only taken into account if the container has scrollbars.
See autoScroll.
autoScroll
autoScroll: boolean
Specifies if the graph should automatically scroll if the mouse goes near
the container edge while dragging.
This is only taken into account if the container has scrollbars.
If you need this to work without scrollbars then set ignoreScrollbars to
true. Please consult the ignoreScrollbars for details. In general, with
no scrollbars, the use of allowAutoPanning is recommended.
autoSizeCell
autoSizeCell: (cell: Cell, recurse?: boolean) => void
Resizes the specified cell to just fit around its label and/or children.
Type Declaration
-
- (cell: Cell, recurse?: boolean): void
-
Parameters
- cell: Cell
Optionalrecurse: boolean
Optional boolean which specifies if all descendants should be auto-sized. Default is true.
Returns void
autoSizeCells
autoSizeCells: boolean
Specifies if the graph should automatically update the cell size after an
edit. This is used in isAutoSizeCell.
autoSizeCellsOnAdd
autoSizeCellsOnAdd: boolean
Specifies if autoSize style should be applied when cells are added.
backgroundImage
Examplevar img = new mxImage('http://www.example.com/maps/examplemap.jpg', 1024, 768); graph.setBackgroundImage(img); graph.view.validate();
border
border: number = 0
Border to be added to the bottom and right side when the container is
being resized after the graph has been changed.
canExportCell
canExportCell: (cell: Cell | null) => boolean
Returns true if the given cell may be exported to the clipboard.
This implementation returns exportEnabled for all cells.
Type Declaration
-
- (cell: Cell | null): boolean
-
Parameters
- cell: Cell | null
Cell that represents the cell to be exported.
Returns boolean
canImportCell
canImportCell: (cell: Cell | null) => boolean
Returns true if the given cell may be imported from the clipboard.
This implementation returns importEnabled for all cells.
Type Declaration
-
- (cell: Cell | null): boolean
-
Parameters
- cell: Cell | null
Cell that represents the cell to be imported.
Returns boolean
cellConnected
Type Declaration
-
- (
edge: Cell, terminal: Cell | null, source: boolean, constraint?: ConnectionConstraint | null, ): void
-
Parameters
- edge: Cell
Cell whose terminal should be updated.
- terminal: Cell | null
Cell that represents the new terminal to be used.
- source: boolean
Boolean indicating if the new terminal is the source or target. Default is false.
Optionalconstraint: ConnectionConstraint | null
Returns void
cellLabelChanged
cellLabelChanged: (cell: Cell, value: any, autoSize: boolean) => void
Sets the new label for a cell. If autoSize is true, then cellSizeUpdated will be called.
In the following example, the function is extended to map changes to attributes in an XML node, as shown in convertValueToString.
Alternatively, the handling of this can be implemented as shown in GraphDataModel.valueForCellChanged without the need to clone the user object.
const graphCellLabelChanged = graph.cellLabelChanged; graph.cellLabelChanged = function(cell, newValue, autoSize) { // Cloned for correct undo/redo const elt = cell.value.cloneNode(true); elt.setAttribute('label', newValue);
newValue = elt; graphCellLabelChanged.apply(this, arguments); };
Type Declaration
-
- (cell: Cell, value: any, autoSize: boolean): void
-
Parameters
- cell: Cell
Cell whose label should be changed.
- value: any
New label to be assigned.
- autoSize: boolean
Returns void
cellRenderer
Holds the CellRenderer for rendering the cells in the graph.
cellResized
cellResized: ( cell: Cell, bounds: Rectangle, ignoreRelative: boolean, recurse: boolean,) => Geometry | null
Resizes the parents recursively so that they contain the complete area of the resized child cell.
Type Declaration
-
- (
cell: Cell, bounds: Rectangle, ignoreRelative: boolean, recurse: boolean, ): Geometry | null
-
Parameters
- cell: Cell
Cell whose bounds should be changed.
- bounds: Rectangle
- ignoreRelative: boolean
Boolean that indicates if relative cells should be ignored. Default is false.
- recurse: boolean
Optional boolean that specifies if the children should be resized. Default is false.
cellsAdded
cellsAdded: ( cells: Cell[], parent: Cell, index: number, source: Cell | null, target: Cell | null, absolute: boolean, constrain?: boolean, extend?: boolean,) => void
Adds the specified cells to the given parent. This method fires
Event#CELLS_ADDED while the transaction is in progress.
Type Declaration
-
- (
cells: Cell[], parent: Cell, index: number, source: Cell | null, target: Cell | null, absolute: boolean, constrain?: boolean, extend?: boolean, ): void
-
Parameters
- cells: Cell[]
Array of Cells to be added.
- parent: Cell
Cell that represents the new parent.
- index: number
Index to insert the cells at.
- source: Cell | null
Source Cell for all added cells, or null to not connect them.
- target: Cell | null
Target Cell for all added cells, or null to not connect them.
- absolute: boolean
Boolean indicating if the cells should be kept at their absolute position.
Optionalconstrain: boolean
Optional boolean indicating if constrainChild should be called for each added cell. Default is true.
Optionalextend: boolean
Returns void
cellsBendable
cellsBendable: boolean
cellsCloneable
cellsCloneable: boolean
cellsDeletable
cellsDeletable: boolean
cellsDisconnectable
cellsDisconnectable: boolean
cellsEditable
cellsEditable: boolean
cellsFolded
cellsFolded: ( cells: Cell[] | null, collapse: boolean, recurse: boolean, checkFoldable?: boolean,) => void
Sets the collapsed state of the specified cells.
This method fires InternalEvent.CELLS_FOLDED while the transaction is in progress.
Returns the cells whose collapsed state was changed.
Type Declaration
-
- (
cells: Cell[] | null, collapse: boolean, recurse: boolean, checkFoldable?: boolean, ): void
-
Parameters
- cells: Cell[] | null
Array of Cell whose collapsed state should be set. Default is null.
- collapse: boolean
Boolean indicating the collapsed state to be assigned. Default is false.
- recurse: boolean
Boolean indicating if the collapsed state of all descendants should be set. Default is false.
OptionalcheckFoldable: boolean
Optional boolean indicating of isCellFoldable should be checked. Default is false.
Returns void
cellSizeUpdated
cellSizeUpdated: (cell: Cell, ignoreChildren: boolean) => void
Type Declaration
-
- (cell: Cell, ignoreChildren: boolean): void
-
Parameters
- cell: Cell
Cell for which the size should be changed.
- ignoreChildren: boolean
if true, ignore the children of the cell when computing the size of the cell. Default is false.
Returns void
cellsLocked
cellsLocked: boolean
cellsMovable
cellsMovable: boolean
cellsMoved
cellsMoved: ( cells: Cell[], dx: number, dy: number, disconnect: boolean, constrain: boolean, extend?: boolean | null,) => void
Moves the specified cells by the given vector, disconnecting the cells using disconnectGraph is disconnect is true.
This method fires InternalEvent.CELLS_MOVED while the transaction is in progress.
cellsOrdered
cellsOrdered: (cells: Cell[], back: boolean) => void
Type Declaration
-
- (cells: Cell[], back: boolean): void
-
Parameters
- cells: Cell[]
Array of Cell whose order should be changed.
- back: boolean
Boolean that specifies if the cells should be moved to back. Default is false.
Returns void
cellsRemoved
cellsRemoved: (cells: Cell[]) => void
Type Declaration
-
- (cells: Cell[]): void
-
Returns void
cellsResizable
cellsResizable: boolean
cellsResized
cellsResized: (cells: Cell[], bounds: Rectangle[], recurse: boolean) => void
Sets the bounds of the given cells and fires a InternalEvent.CELLS_RESIZED
event. If extendParents is true, then the parent is extended if a
child size is changed so that it overlaps with the parent.
The following example shows how to control group resizes to make sure
that all child cells stay within the group.
graph.addListener(InternalEvent.CELLS_RESIZED, function(sender, evt) { const cells = evt.getProperty('cells');
if (cells) { for (const cell of cells) { if (graph.getDataModel().getChildCount(cell) > 0) { let geo = cell.getGeometry();
if (geo) { const children = graph.getChildCells(cell, true, true); const bounds = graph.getBoundingBoxFromGeometry(children, true);
geo = geo.clone(); geo.width = Math.max(geo.width, bounds.width); geo.height = Math.max(geo.height, bounds.height);
graph.getDataModel().setGeometry(cell, geo); } } } } });
Type Declaration
-
- (cells: Cell[], bounds: Rectangle[], recurse: boolean): void
-
Parameters
- cells: Cell[]
Array of Cell whose bounds should be changed.
- bounds: Rectangle[]
Array of Rectangles that represent the new bounds.
- recurse: boolean
Optional boolean that specifies if the children should be resized. Default is false.
Returns void
cellsSelectable
cellsSelectable: boolean
cellsToggled
cellsToggled: (cells: Cell[], show: boolean) => void
Sets the visible state of the specified cells.
Type Declaration
-
- (cells: Cell[], show: boolean): void
-
Parameters
- cells: Cell[]
Array of Cell whose visible state should be changed.
- show: boolean
Boolean that specifies the visible state to be assigned.
Returns void
centerZoom
centerZoom: boolean
Specifies if the zoom operations should go into the center of the actual
diagram rather than going from top, left.
clearCellOverlays
clearCellOverlays: (cell: Cell | null) => void
Removes all CellOverlays in the graph for the given cell and all its descendants.
If no cell is specified then all overlays are removed from the graph.
This implementation uses removeCellOverlays to remove the overlays from the individual cells.
Type Declaration
-
- (cell: Cell | null): void
-
Parameters
- cell: Cell | null
Optional Cell that represents the root of the subtree to remove the overlays from. Default is the root in the model.
Returns void
clearSelection
clearSelection: () => void
click
Processes a single click on an optional cell and fires a click event.
The click event is fired initially. If the graph is enabled and the event has not been consumed,
then the cell is selected using selectCellForEvent or the selection is cleared using clearSelection.
The events consumed state is set to true if the corresponding InternalMouseEvent has been consumed.
To handle a click event, use the following code.
graph.addListener(InternalEvent.CLICK, function(sender, evt) { const e = evt.getProperty('event'); // mouse event const cell = evt.getProperty('cell'); // cell may be null
if (cell) { // Do something useful with cell and consume the event evt.consume(); } });
cloneCell
cloneCell: ( cell: Cell, allowInvalidEdges?: boolean, mapping?: any, keepPosition?: boolean,) => Cell
Returns the clone for the given cell. Uses cloneCells.
Type Declaration
-
- (
cell: Cell, allowInvalidEdges?: boolean, mapping?: any, keepPosition?: boolean, ): Cell
-
Parameters
- cell: Cell
OptionalallowInvalidEdges: boolean
Optional boolean that specifies if invalid edges should be cloned. Default is true.
Optionalmapping: any
Optional mapping for existing clones.
OptionalkeepPosition: boolean
Optional boolean indicating if the position of the cells should be updated to reflect the lost parent cell. Default is false.
cloneCells
cloneCells: ( cells: Cell[], allowInvalidEdges?: boolean, mapping?: any, keepPosition?: boolean,) => Cell[]
Returns the clones for the given cells. The clones are created recursively using cloneCells.
If the terminal of an edge is not in the given array, then the respective end is assigned a terminal point and the terminal is removed.
Type Declaration
-
- (
cells: Cell[], allowInvalidEdges?: boolean, mapping?: any, keepPosition?: boolean, ): Cell[]
-
Parameters
- cells: Cell[]
Array of Cell to be cloned.
OptionalallowInvalidEdges: boolean
Optional boolean that specifies if invalid edges should be cloned. Default is true.
Optionalmapping: any
Optional mapping for existing clones.
OptionalkeepPosition: boolean
Optional boolean indicating if the position of the cells should be updated to reflect the lost parent cell. Default is false.
Returns Cell[]
cloneInvalidEdges
cloneInvalidEdges: boolean
Specifies if edges that are cloned should be validated and only inserted if they are valid.
collapseExpandResource
collapseExpandResource: string
Specifies the resource key for the tooltip on the collapse/expand icon.
If the resource for this key does not exist then the value is used as
the tooltip.
Default'collapse-expand' is Client.language is not 'none'. Else, it is an empty string.
connectableEdges
connectableEdges: boolean
Specifies if edges are connectable. This overrides the connectable field in edges.
connectCell
Type Declaration
-
- (
edge: Cell, terminal: Cell | null, source: boolean, constraint?: ConnectionConstraint | null, ): Cell
-
Parameters
- edge: Cell
Cell whose terminal should be updated.
- terminal: Cell | null
Cell that represents the new terminal to be used.
- source: boolean
Boolean indicating if the new terminal is the source or target. Default is false.
Optionalconstraint: ConnectionConstraint | null
the updated edge.
constrainChild
constrainChild: (cell: Cell, sizeFirst?: boolean) => void
Type Declaration
-
- (cell: Cell, sizeFirst?: boolean): void
-
Parameters
- cell: Cell
Cell which should be constrained.
OptionalsizeFirst: boolean
Specifies if the size should be changed first. Default is true.
Returns void
constrainChildCells
constrainChildCells: (cell: Cell) => void
Type Declaration
-
- (cell: Cell): void
-
Returns void
constrainChildren
constrainChildren: boolean
Specifies if a child should be constrained inside the parent bounds after a move or resize of the child.
constrainRelativeChildren
constrainRelativeChildren: boolean
container
container: HTMLElement
containsValidationErrorsResource
containsValidationErrorsResource: string = ...
Specifies the resource key for the warning message to be displayed when
a collapsed cell contains validation errors. If the resource for this
key does not exist then the value is used as the warning message.
Default'containsValidationErrors'
createEdge
createEdge: ( parent?: Cell | null, id?: string, value?: any, source?: Cell | null, target?: Cell | null, style?: CellStyle,) => Cell
Hook method that creates the new edge for insertEdge.
This implementation does not set the source and target of the edge, these are set when the edge is added to the model.
Type Declaration
-
- (
parent?: Cell | null, id?: string, value?: any, source?: Cell | null, target?: Cell | null, style?: CellStyle, ): Cell
-
Parameters
Optionalparent: Cell | null
Cell that specifies the parent of the new edge. If not set, use the default parent.
Optionalid: string
Optional string that defines the Id of the new edge. If not set, the id is auto-generated when creating the vertex.
Optionalvalue: any
Object to be used as the user object which is generally used to display the label of the edge. The default implementation handles string object.
Optionalsource: Cell | null
Cell that defines the source of the edge.
Optionaltarget: Cell | null
Cell that defines the target of the edge.
Optionalstyle: CellStyle
Optional object that defines the cell style.
createGroupCell
createGroupCell: (cells: Cell[]) => Cell
Hook for creating the group cell to hold the given array of Cell if no group cell was given to the group function.
The following code can be used to set the style of new group cells.
const graphCreateGroupCell = graph.createGroupCell; graph.createGroupCell = function(cells) { const group = graphCreateGroupCell.apply(this, arguments); group.setStyle('group');
return group;
dblClick
dblClick: (evt: MouseEvent, cell?: Cell | null) => void
Processes a double click on an optional cell and fires a dblclick event. The event is fired initially.
If the graph is enabled and the event has not been consumed, then edit is called with the given cell.
The event is ignored if no cell was specified.
Example for overriding this method.
graph.dblClick = function(evt, cell) { const mxe = new EventObject(InternalEvent.DOUBLE_CLICK, 'event', evt, 'cell', cell); this.fireEvent(mxe);
if (this.isEnabled() && !InternalEvent.isConsumed(evt) && !mxe.isConsumed()) { alert('Hello, World!'); mxe.consume(); } }
Example listener for this event.
graph.addListener(InternalEvent.DOUBLE_CLICK, function(sender, evt) { const cell = evt.getProperty('cell'); // do something with the cell and consume the // event to prevent in-place editing from start });
Type Declaration
-
- (evt: MouseEvent, cell?: Cell | null): void
-
Parameters
- evt: MouseEvent
Mouseevent that represents the double click.
Optionalcell: Cell | null
Optional Cell under the mouse pointer.
Returns void
defaultOverlap
defaultOverlap: number = 0.5
defaultParent
defaultParent: Cell | null = null
Specifies the default parent to be used to insert new cells.
This is used in getDefaultParent.
destroyed
destroyed: boolean = false
dialect
Dialect to be used for drawing the graph.
disconnectGraph
disconnectGraph: (cells: Cell[]) => void
Disconnects the given edges from the terminals which are not in the given array.
Type Declaration
-
- (cells: Cell[]): void
-
Parameters
- cells: Cell[]
Array of Cell to be disconnected.
Returns void
disconnectOnMove
disconnectOnMove: boolean
Specifies if edges should be disconnected from their terminals when they are moved.
doneResource
doneResource: string
doubleClickCounter
doubleClickCounter: number
doubleTapEnabled
doubleTapEnabled: boolean
Specifies if double taps on touch-based devices should be handled as a double click.
doubleTapTimeout
doubleTapTimeout: number
Specifies the timeout in milliseconds for double taps and non-native double clicks.
doubleTapTolerance
doubleTapTolerance: number
Specifies the tolerance in pixels for double taps and double-clicks in quirks mode.
dropEnabled
dropEnabled: boolean
edgeLabelsMovable
edgeLabelsMovable: boolean
enabled
enabled: boolean = true
enterGroup
enterGroup: (cell: Cell) => void
Uses the given cell as the root of the displayed cell hierarchy. If no cell is specified then the selection cell is used.
The cell is only used if isValidRoot returns true.
Type Declaration
-
- (cell: Cell): void
-
Parameters
- cell: Cell
Optional Cell to be used as the new root. Default is the selection cell.
Returns void
enterStopsCellEditing
enterStopsCellEditing: boolean
If true, pressing the enter key without pressing control or shift will stop editing and accept the new value.
This is used in CellEditorHandler to stop cell editing.
Note: The F2 (accept change) and escape keys (undo change) can always be used to stop editing.
escape
escape: (evt: Event) => void
Processes an escape keystroke.
Type Declaration
-
- (evt: Event): void
-
Parameters
- evt: Event
Event that represents the keystroke.
Returns void
escapeEnabled
escapeEnabled: boolean
eventListeners
eventListeners: EventListenerObject[] = []
Holds the event names and associated listeners in an array. The array
contains the event name followed by the respective listener for each
registered listener.
eventsEnabled
eventsEnabled: boolean = true
Specifies if events can be fired. Default is true.
eventSource
eventSource: EventTarget | null = null
Optional source for events.
exitGroup
exitGroup: () => void
Changes the current root to the next valid root in the displayed cell hierarchy.
exportEnabled
exportEnabled: boolean = true
extendParent
extendParent: (cell: Cell) => void
Resizes the parents recursively so that they contain the complete area of the resized child cell.
Type Declaration
-
- (cell: Cell): void
-
Returns void
extendParents
extendParents: boolean
Specifies if a parent should contain the child bounds after a resize of
the child. This has precedence over constrainChildren.
extendParentsOnAdd
extendParentsOnAdd: boolean
Specifies if parents should be extended according to the extendParents
switch if cells are added.
extendParentsOnMove
extendParentsOnMove: boolean
Specifies if parents should be extended according to the extendParents
switch if cells are added.
Defaultfalse (for backwards compatibility)
fireDoubleClick
fireDoubleClick: boolean | null
fireGestureEvent
fireGestureEvent: (evt: MouseEvent, cell?: Cell | null) => void
Dispatches a InternalEvent.GESTURE event. The following example will resize the
cell under the mouse based on the scale property of the native touch event.
graph.addListener(mxEvent.GESTURE, function(sender, eo) { const evt = eo.getProperty('event'); const state = graph.view.getState(eo.getProperty('cell'));
if (graph.isEnabled() && graph.isCellResizable(state.cell) && Math.abs(1 - evt.scale) > 0.2) { const scale = graph.view.scale; const tr = graph.view.translate;
const w = state.width * evt.scale; const h = state.height * evt.scale; const x = state.x - (w - state.width) / 2; const y = state.y - (h - state.height) / 2;
const bounds = new Rectangle(graph.snap(x / scale) - tr.x, graph.snap(y / scale) - tr.y, graph.snap(w / scale), graph.snap(h / scale)); graph.resizeCell(state.cell, bounds); eo.consume(); } });
Type Declaration
-
- (evt: MouseEvent, cell?: Cell | null): void
-
Parameters
- evt: MouseEvent
MouseEvent event that represents the gesture.
Optionalcell: Cell | null
Optional Cell associated with the gesture.
Returns void
flipEdge
Toggles the style of the given edge between null (or empty) and alternateEdgeStyle.
This method fires InternalEvent.FLIP_EDGE while the transaction is in progress.
Here is an example that overrides this implementation to invert the value of CellStateStyle.elbow without removing any existing styles.
graph.flipEdge = function(edge) { if (edge) { const style = this.getCurrentCellStyle(edge); const elbow = style.elbow ?? 'horizontal'; const value = (elbow == 'horizontal') ? 'vertical' : 'horizontal'; this.setCellStyles('elbow', value, [edge]); } };
foldCells
foldCells: ( collapse: boolean, recurse?: boolean, cells?: Cell[] | null, checkFoldable?: boolean, evt?: Event | null,) => Cell[] | null
Sets the collapsed state of the specified cells and all descendants if recurse is true.
The change is carried out using cellsFolded.
This method fires InternalEvent.FOLD_CELLS while the transaction is in progress.
Returns the cells whose collapsed state was changed.
Type Declaration
-
- (
collapse: boolean, recurse?: boolean, cells?: Cell[] | null, checkFoldable?: boolean, evt?: Event | null, ): Cell[] | null
-
Parameters
- collapse: boolean
Boolean indicating the collapsed state to be assigned. Default is false.
Optionalrecurse: boolean
Optional boolean indicating if the collapsed state of all descendants should be set. Default is false.
Optionalcells: Cell[] | null
Array of Cell whose collapsed state should be set. If null is specified then the foldable selection cells are used. Default is null.
OptionalcheckFoldable: boolean
Optional boolean indicating of isCellFoldable should be checked. Default is false.
Optionalevt: Event | null
Optional native event that triggered the invocation. Default is null.
Returns Cell[] | null
getActualStartSize
getActualStartSize: (swimlane: Cell, ignoreState: boolean) => Rectangle
Returns the actual start size of the given swimlane taking into account direction and horizontal and vertical flip styles.
The start size is returned as an Rectangle where top, left, bottom, right start sizes are returned as x, y, height and width, respectively.
Type Declaration
-
- (swimlane: Cell, ignoreState: boolean): Rectangle
-
Parameters
- swimlane: Cell
Cell whose start size should be returned.
- ignoreState: boolean
Optional boolean that specifies if cell state should be ignored.
getAllConnectionConstraints
Type Declaration
-
- (terminal: CellState | null, source: boolean): ConnectionConstraint[] | null
-
Parameters
- terminal: CellState | null
- source: boolean
Boolean that specifies if the terminal is the source or target.
getAllEdges
getAllEdges: (cells: Cell[] | null) => Cell[]
Returns all edges connected to the given cells or its descendants.
getBoundingBox
Returns the bounding box for the given array of Cell. The bounding box for
each cell and its descendants is computed using view.getBoundingBox.
Type Declaration
-
- (cells: Cell[]): Rectangle | null
-
Parameters
- cells: Cell[]
Array of Cell whose bounding box should be returned.
getBoundingBoxFromGeometry
getBoundingBoxFromGeometry: ( cells: Cell[], includeEdges?: boolean,) => Rectangle | null
Returns the bounding box for the geometries of the vertices in the
given array of cells. This can be used to find the graph bounds during
a layout operation (ie. before the last endUpdate) as follows:
var cells = graph.getChildCells(graph.getDefaultParent(), true, true); var bounds = graph.getBoundingBoxFromGeometry(cells, true);
This can then be used to move cells to the origin:
if (bounds.x < 0 || bounds.y < 0) { graph.moveCells(cells, -Math.min(bounds.x, 0), -Math.min(bounds.y, 0)) }
Or to translate the graph view:
if (bounds.x < 0 || bounds.y < 0) { getView().setTranslate(-Math.min(bounds.x, 0), -Math.min(bounds.y, 0)); }
Type Declaration
-
- (cells: Cell[], includeEdges?: boolean): Rectangle | null
-
Parameters
- cells: Cell[]
Array of Cell whose bounds should be returned.
OptionalincludeEdges: boolean
Specifies if edge bounds should be included by computing the bounding box for all points in geometry. Default is false.
getBoundsForGroup
getBoundsForGroup: ( group: Cell, children: Cell[], border: number | null,) => Rectangle | null
Returns the bounds to be used for the given group and children.
getCellAt
getCellAt: ( x: number, y: number, parent?: Cell | null, vertices?: boolean | null, edges?: boolean | null, ignoreFn?: Function | null,) => Cell | null
Returns the bottom-most cell that intersects the given point (x, y) in the cell hierarchy starting at the given parent.
This will also return swimlanes if the given location intersects the content area of the swimlane.
If this is not desired, then the hitsSwimlaneContent may be used if the returned cell is a swimlane
to determine if the location is inside the content area or on the actual title of the swimlane.
Type Declaration
-
- (
x: number, y: number, parent?: Cell | null, vertices?: boolean | null, edges?: boolean | null, ignoreFn?: Function | null, ): Cell | null
-
Parameters
- x: number
X-coordinate of the location to be checked.
- y: number
Y-coordinate of the location to be checked.
Optionalparent: Cell | null
Cell that should be used as the root of the recursion. Default is current root of the view or the root of the model.
Optionalvertices: boolean | null
Optional boolean indicating if vertices should be returned. Default is true.
Optionaledges: boolean | null
Optional boolean indicating if edges should be returned. Default is true.
OptionalignoreFn: Function | null
Optional function that returns true if cell should be ignored. The function is passed the cell state and the x and y parameter. Default is null.
Returns Cell | null
getCellBounds
getCellBounds: ( cell: Cell, includeEdges?: boolean, includeDescendants?: boolean,) => Rectangle | null
Type Declaration
-
- (
cell: Cell, includeEdges?: boolean, includeDescendants?: boolean, ): Rectangle | null
-
Parameters
- cell: Cell
Cell whose bounds should be returned.
OptionalincludeEdges: boolean
Optional boolean that specifies if the bounds of the connected edges should be included. Default is false.
OptionalincludeDescendants: boolean
Optional boolean that specifies if the bounds of all descendants should be included. Default is false.
getCellContainmentArea
Returns the Rectangle inside which a cell is to be kept.
getCellOverlays
Returns an array of CellOverlays for the given cell or null, if no overlays are defined.
getCells
getCells: ( x: number, y: number, width: number, height: number, parent?: Cell | null, result?: Cell[], intersection?: Rectangle | null, ignoreFn?: Function | null, includeDescendants?: boolean,) => Cell[]
Returns the child vertices and edges of the given parent that are contained in the given rectangle.
The result is added to the optional result array, which is returned.
If no result array is specified then a new array is created and returned.
Type Declaration
-
- (
x: number, y: number, width: number, height: number, parent?: Cell | null, result?: Cell[], intersection?: Rectangle | null, ignoreFn?: Function | null, includeDescendants?: boolean, ): Cell[]
-
Parameters
- x: number
X-coordinate of the rectangle.
- y: number
Y-coordinate of the rectangle.
- width: number
- height: number
Optionalparent: Cell | null
Cell that should be used as the root of the recursion. Default is current root of the view or the root of the model.
Optionalresult: Cell[]
Optional array to store the result in. Default is an empty Array.
Optionalintersection: Rectangle | null
OptionalignoreFn: Function | null
OptionalincludeDescendants: boolean
Returns Cell[]
getCellsBeyond
getCellsBeyond: ( x0: number, y0: number, parent: Cell | null, rightHalfpane: boolean, bottomHalfpane: boolean,) => Cell[]
Returns the children of the given parent that are contained in the half-pane from the given point (x0, y0) rightwards or downwards
depending on rightHalfpane and bottomHalfpane.
Type Declaration
-
- (
x0: number, y0: number, parent: Cell | null, rightHalfpane: boolean, bottomHalfpane: boolean, ): Cell[]
-
Parameters
- x0: number
X-coordinate of the origin.
- y0: number
Y-coordinate of the origin.
- parent: Cell | null
Optional Cell whose children should be checked. Default is .
- rightHalfpane: boolean
Boolean indicating if the cells in the right halfpane from the origin should be returned. Default is false.
- bottomHalfpane: boolean
Boolean indicating if the cells in the bottom halfpane from the origin should be returned. Default is false.
Returns Cell[]
getCellsForGroup
getCellsForGroup: (cells: Cell[]) => Cell[]
Returns the cells with the same parent as the first cell in the given array.
getCellsForUngroup
getCellsForUngroup: () => Cell[]
Returns the selection cells that can be ungrouped.
getCellStyle
Returns the computed style of the Cell using the edge or vertex default style regarding of the type of the cell.
The actual computation is done by Stylesheet.getCellStyle.
Note: You should try and get the cell state for the given cell and use the cached style in the state before using this method.
getCellValidationError
getCellValidationError: (cell: Cell) => string | null
Checks all multiplicities that cannot be enforced while the graph is
being modified, namely, all multiplicities that require a minimum of
1 edge.
Type Declaration
-
- (cell: Cell): string | null
-
Parameters
- cell: Cell
Cell for which the multiplicities should be checked.
Returns string | null
getChildCells
getChildCells: ( parent?: Cell | null, vertices?: boolean, edges?: boolean,) => Cell[]
Returns the visible child vertices or edges in the given parent.
If vertices and edges is false, then all children are returned.
Type Declaration
-
- (parent?: Cell | null, vertices?: boolean, edges?: boolean): Cell[]
-
Parameters
Optionalparent: Cell | null
Cell whose children should be returned.
Optionalvertices: boolean
Optional boolean that specifies if child vertices should be returned. Default is false.
Optionaledges: boolean
Optional boolean that specifies if child edges should be returned. Default is false.
Returns Cell[]
getChildEdges
Returns the visible child edges of the given parent.
Type Declaration
-
- (parent: Cell): Cell[]
-
Parameters
- parent: Cell
Cell whose child vertices should be returned.
Returns Cell[]
getChildVertices
getChildVertices: (parent?: Cell | null) => Cell[]
Returns the visible child vertices of the given parent.
Type Declaration
-
- (parent?: Cell | null): Cell[]
-
Parameters
Optionalparent: Cell | null
the Cell whose children should be returned.
Returns Cell[]
getCloneableCells
getCloneableCells: (cells: Cell[]) => Cell[]
Returns the cells which may be exported in the given array of cells.
getCollapseExpandResource
getCollapseExpandResource: () => string
getConnectionPoint
Returns the nearest point in the list of absolute points or the center of the opposite terminal.
getConnections
getConnections: (cell: Cell, parent?: Cell | null) => Cell[]
Returns all visible edges connected to the given cell without loops.
Type Declaration
-
- (cell: Cell, parent?: Cell | null): Cell[]
-
Parameters
- cell: Cell
Cell whose connections should be returned.
Optionalparent: Cell | null
Optional parent of the opposite end for a connection to be returned.
Returns Cell[]
getCurrentCellStyle
Returns the style for the given cell from the cell state, if one exists,
or using getCellStyle.
Type Declaration
-
- (cell: Cell, ignoreState?: boolean): CellStateStyle
-
Parameters
- cell: Cell
Cell whose style should be returned as an array.
OptionalignoreState: boolean
Optional boolean that specifies if the cell state should be ignored.
getCursorForCell
getCursorForCell: (cell: Cell) => string | null
Returns the cursor value to be used for the CSS of the shape for the given cell.
This implementation returns null.
Type Declaration
-
- (cell: Cell): string | null
-
Parameters
- cell: Cell
Cell whose cursor should be returned.
Returns string | null
getCursorForMouseEvent
Returns the cursor value to be used for the CSS of the shape for the given event.
This implementation calls getCursorForCell.
getDeletableCells
getDeletableCells: (cells: Cell[]) => Cell[]
Returns the cells which may be exported in the given array of cells.
getDropTarget
getDropTarget: ( cells: Cell[], evt: MouseEvent, cell: Cell | null, clone?: boolean,) => Cell | null
Returns the given cell if it is a drop target for the given cells or the nearest ancestor that may be used as a drop target for the given cells.
If the given array contains a swimlane and swimlaneNesting is false then this always returns null.
If no cell is given, then the bottommost swimlane at the location of the given event is returned.
This function should only be used if isDropEnabled returns true.
Type Declaration
-
- (
cells: Cell[], evt: MouseEvent, cell: Cell | null, clone?: boolean, ): Cell | null
-
Parameters
- cells: Cell[]
Array of Cell which are to be dropped onto the target.
- evt: MouseEvent
Mouse event for the drag and drop.
- cell: Cell | null
Cell that is under the mouse pointer.
Optionalclone: boolean
Optional boolean to indicate of cells will be cloned.
Returns Cell | null
getEdges
getEdges: ( cell: Cell, parent?: Cell | null, incoming?: boolean, outgoing?: boolean, includeLoops?: boolean, recurse?: boolean,) => Cell[]
Returns the incoming and/or outgoing edges for the given cell.
If the optional parent argument is specified, then only edges are returned where the opposite is in the given parent cell.
If at least one of incoming or outgoing is true, then loops are ignored, if both are false, then all edges connected to the given cell are returned including loops.
Type Declaration
-
- (
cell: Cell, parent?: Cell | null, incoming?: boolean, outgoing?: boolean, includeLoops?: boolean, recurse?: boolean, ): Cell[]
-
Parameters
- cell: Cell
Cell whose edges should be returned.
Optionalparent: Cell | null
Optional parent of the opposite end for an edge to be returned.
Optionalincoming: boolean
Optional boolean that specifies if incoming edges should be included in the result. Default is true.
Optionaloutgoing: boolean
Optional boolean that specifies if outgoing edges should be included in the result. Default is true.
OptionalincludeLoops: boolean
Optional boolean that specifies if loops should be included in the result. Default is true.
Optionalrecurse: boolean
Optional boolean the specifies if the parent specified only needs to be an ancestral parent, true, or the direct parent, false. Default is false.
Returns Cell[]
getEdgesBetween
getEdgesBetween: (source: Cell, target: Cell, directed?: boolean) => Cell[]
Returns the edges between the given source and target.
This takes into account collapsed and invisible cells and returns the connected edges as displayed on the screen.
Type Declaration
-
- (source: Cell, target: Cell, directed?: boolean): Cell[]
-
Parameters
- source: Cell
- target: Cell
Optionaldirected: boolean
If set to true, only returns the directed edges i.e. edges whose source is source and target is target. Default is false.
Returns Cell[]
getEdgeValidationError
getEdgeValidationError: ( edge: Cell | null, source: Cell | null, target: Cell | null,) => string | null
Returns the validation error message to be displayed when inserting or
changing an edges' connectivity. A return value of null means the edge
is valid, a return value of '' means it's not valid, but do not display
an error message. Any other (non-empty) string returned from this method
is displayed as an error message when trying to connect an edge to a
source and target. This implementation uses the multiplicities, and
checks multigraph, allowDanglingEdges and allowLoops to generate
validation errors.
For extending this method with specific checks for source/target cells,
the method can be extended as follows. Returning an empty string means
the edge is invalid with no error message, a non-null string specifies
the error message, and null means the edge is valid.
graph.getEdgeValidationError = function(edge, source, target) { if (source != null && target != null && this.model.getValue(source) != null && this.model.getValue(target) != null) { if (target is not valid for source) { return 'Invalid Target'; } }
// "Supercall" return getEdgeValidationError.apply(this, arguments); }
Type Declaration
-
- (edge: Cell | null, source: Cell | null, target: Cell | null): string | null
-
Parameters
- edge: Cell | null
Cell that represents the edge to validate.
- source: Cell | null
Cell that represents the source terminal.
- target: Cell | null
Cell that represents the target terminal.
Returns string | null
getEditingValue
getEditingValue: (cell: Cell, evt: MouseEvent | null) => string
Returns the initial value for in-place editing.
This implementation returns convertValueToString for the given cell.
If this function is overridden, then GraphDataModel.valueForCellChanged should take care
of correctly storing the actual new value inside the user object.
Type Declaration
-
- (cell: Cell, evt: MouseEvent | null): string
-
Parameters
- cell: Cell
Cell for which the initial editing value should be returned.
- evt: MouseEvent | null
Optional mouse event that triggered the editor.
Returns string
getEventState
Returns the CellState to be used when firing the mouse event for the given state.
This implementation returns the given state.
getEventTolerance
getEventTolerance: () => number
getExportableCells
getExportableCells: (cells: Cell[]) => Cell[]
Returns the cells which may be exported in the given array of cells.
getFoldableCells
getFoldableCells: (cells: Cell[], collapse: boolean) => Cell[] | null
Returns the cells which are movable in the given array of cells.
getFoldingImage
Returns the ImageBox used to display the collapsed state of the specified cell state.
This returns null for all edges.
getGridSize
getGridSize: () => number
getImportableCells
getImportableCells: (cells: Cell[]) => Cell[]
Returns the cells which may be imported in the given array of cells.
getIncomingEdges
getIncomingEdges: (cell: Cell, parent: Cell | null) => Cell[]
Returns the visible incoming edges for the given cell.
If the optional parent argument is specified, then only child edges of the given parent are returned.
Type Declaration
-
- (cell: Cell, parent: Cell | null): Cell[]
-
Parameters
- cell: Cell
Cell whose incoming edges should be returned.
- parent: Cell | null
Optional parent of the opposite end for an edge to be returned.
Returns Cell[]
getLabel
getLabel: (cell?: Cell | null) => string | null
Returns a string or DOM node that represents the label for the given cell.
This implementation uses convertValueToString if labelsVisible is true. Otherwise, it returns an empty string.
To truncate a label to match the size of the cell, the following code can be used.
const getLabel = graph.getLabel; graph.getLabel = function(cell) { const label = getLabel.apply(this, arguments);
if (label && this.model.isVertex(cell)) { const geo = cell.getCellGeometry();
if (geo) { const max = parseInt(geo.width / 8);
if (label.length > max) { label = label.substring(0, max) + '...'; } } } return stringUtils.htmlEntities(label); }
A resize listener is needed in the graph to force a repaint of the label after a resize.
graph.addListener(InternalEvent.RESIZE_CELLS, function(sender, evt) { const cells = evt.getProperty('cells');
for (const cell of cells) { this.view.removeState(cell); } });
Type Declaration
-
- (cell?: Cell | null): string | null
-
Parameters
Optionalcell: Cell | null
Cell whose label should be returned.
Returns string | null
getMovableCells
getMovableCells: (cells: Cell[]) => Cell[]
Returns the cells which are movable in the given array of cells.
getOpposites
getOpposites: ( edges: Cell[], terminal: Cell | null, includeSources?: boolean, includeTargets?: boolean,) => Cell[]
Returns all distinct visible opposite cells for the specified terminal on the given edges.
Type Declaration
-
- (
edges: Cell[], terminal: Cell | null, includeSources?: boolean, includeTargets?: boolean, ): Cell[]
-
Parameters
- edges: Cell[]
Array of Cell that contains the edges whose opposite terminals should be returned.
- terminal: Cell | null
Terminal that specifies the end whose opposite should be returned. Default is null.
OptionalincludeSources: boolean
Optional boolean that specifies if source terminals should be included in the result. Default is true.
OptionalincludeTargets: boolean
Optional boolean that specifies if target terminals should be included in the result. Default is true.
Returns Cell[]
getOutgoingEdges
getOutgoingEdges: (cell: Cell, parent: Cell | null) => Cell[]
Returns the visible outgoing edges for the given cell.
If the optional parent argument is specified, then only child edges of the given parent are returned.
Type Declaration
-
- (cell: Cell, parent: Cell | null): Cell[]
-
Parameters
- cell: Cell
Cell whose outgoing edges should be returned.
- parent: Cell | null
Optional parent of the opposite end for an edge to be returned.
Returns Cell[]
getOutlineConstraint
Returns the constraint used to connect to the outline of the given state.
getPanDx
getPanDx: () => number
getPanDy
getPanDy: () => number
getPointForEvent
getPointForEvent: (evt: MouseEvent, addOffset?: boolean) => Point
Returns an Point representing the given event in the unscaled,
non-translated coordinate space of container and applies the grid.
Type Declaration
-
- (evt: MouseEvent, addOffset?: boolean): Point
-
Parameters
- evt: MouseEvent
MouseEvent that contains the mouse pointer location.
OptionaladdOffset: boolean
Optional boolean that specifies if the position should be
offset by half of the gridSize. Default is true.
getPreferredSizeForCell
getPreferredSizeForCell: ( cell: Cell, textWidth?: number | null,) => Rectangle | null
Returns the preferred width and height of the given Cell as an
Rectangle. To implement a minimum width, add a new style e.g.
minWidth in the vertex and override this method as follows.
var graphGetPreferredSizeForCell = graph.getPreferredSizeForCell; graph.getPreferredSizeForCell(cell) { var result = graphGetPreferredSizeForCell.apply(this, arguments); var style = this.getCellStyle(cell);
if (style.minWidth > 0) { result.width = Math.max(style.minWidth, result.width); }
return result; };
Type Declaration
-
- (cell: Cell, textWidth?: number | null): Rectangle | null
-
Parameters
- cell: Cell
Cell for which the preferred size should be returned.
OptionaltextWidth: number | null
Optional maximum text width for word wrapping.
getSelectionCell
getSelectionCell: () => Cell
Returns the first cell from the array of selected Cell.
getSelectionCells
getSelectionCells: () => Cell[]
Returns the array of selected Cell.
getSelectionCellsForChanges
getSelectionCellsForChanges: ( changes: any[], ignoreFn?: Function | null,) => Cell[]
Returns the cells to be selected for the given array of changes.
Type Declaration
-
- (changes: any[], ignoreFn?: Function | null): Cell[]
-
Parameters
- changes: any[]
OptionalignoreFn: Function | null
Optional function that takes a change and returns true if the change should be ignored.
Returns Cell[]
getSelectionCount
getSelectionCount: () => number
Returns the number of selected cells.
getSnapTolerance
getSnapTolerance: () => number
getStartSize
getStartSize: (swimlane: Cell, ignoreState?: boolean) => Rectangle
Returns the start size of the given swimlane, that is, the width or height of the part that contains the title, depending on the horizontal style.
The return value is an Rectangle with either width or height set as appropriate.
Type Declaration
-
- (swimlane: Cell, ignoreState?: boolean): Rectangle
-
Parameters
- swimlane: Cell
Cell whose start size should be returned.
OptionalignoreState: boolean
Optional boolean that specifies if cell state should be ignored.
getStateForTouchEvent
getStateForTouchEvent: (evt: MouseEvent) => CellState | null
Returns the state for the given touch event.
getSwimlane
getSwimlane: (cell: Cell | null) => Cell | null
Returns the nearest ancestor of the given cell which is a swimlane, or the given cell, if it is itself a swimlane.
Type Declaration
-
- (cell: Cell | null): Cell | null
-
Parameters
- cell: Cell | null
Cell for which the ancestor swimlane should be returned.
Returns Cell | null
getSwimlaneAt
getSwimlaneAt: (x: number, y: number, parent?: Cell | null) => Cell | null
Returns the bottom-most swimlane that intersects the given point (x, y) in the cell hierarchy that starts at the given parent.
Type Declaration
-
- (x: number, y: number, parent?: Cell | null): Cell | null
-
Parameters
- x: number
X-coordinate of the location to be checked.
- y: number
Y-coordinate of the location to be checked.
Optionalparent: Cell | null
Returns Cell | null
getSwimlaneDirection
Returns the direction for the given swimlane style.
getTerminalForPort
getTerminalForPort: (cell: Cell, source?: boolean) => Cell | null
Returns the terminal to be used for a given port.
This implementation always returns the parent cell.
Type Declaration
-
- (cell: Cell, source?: boolean): Cell | null
-
Parameters
- cell: Cell
Cell that represents the port.
Optionalsource: boolean
If the cell is the source or target port. Default is false.
Returns Cell | null
graphModelChangeListener
graphModelChangeListener: Function | null = null
gridEnabled
gridEnabled: boolean
Specifies if the grid is enabled. This is used in snap.
gridSize
gridSize: number
groupCells
groupCells: (group: Cell, border: number, cells?: Cell[] | null) => Cell
hitsSwimlaneContent
hitsSwimlaneContent: (swimlane: Cell, x: number, y: number) => boolean
Returns true if the given coordinate pair is inside the content are of the given swimlane.
Type Declaration
-
- (swimlane: Cell, x: number, y: number): boolean
-
Parameters
- swimlane: Cell
Cell that specifies the swimlane.
- x: number
X-coordinate of the mouse event.
- y: number
Y-coordinate of the mouse event.
Returns boolean
horizontalPageBreaks
horizontalPageBreaks: Shape[] | null
htmlLabels
htmlLabels: boolean
ignoreMouseEvents
ignoreMouseEvents: boolean | null
ignoreScrollbars
ignoreScrollbars: boolean = false
Specifies if the graph should automatically scroll regardless of the
scrollbars. This will scroll the container using positive values for
scroll positions (ie usually only rightwards and downwards). To avoid
possible conflicts with panning, set translateToScrollPosition to true.
importCells
importCells: ( cells: Cell[], dx?: number, dy?: number, target?: Cell | null, evt?: MouseEvent | null, mapping?: any,) => Cell[]
Clones and inserts the given cells into the graph using the move method and returns the inserted cells. This shortcut
is used if cells are inserted via data transfer.
importEnabled
importEnabled: boolean = true
initialTouchX
initialTouchX: number
Holds the x-coordinate of the initial touch event for tap and hold.
initialTouchY
initialTouchY: number
Holds the y-coordinate of the initial touch event for tap and hold.
intersects
intersects: (state: CellState, x: number, y: number) => boolean
Returns the bottom-most cell that intersects the given point (x, y) in the cell hierarchy that starts at the given parent.
Type Declaration
-
- (state: CellState, x: number, y: number): boolean
-
Parameters
- state: CellState
- x: number
X-coordinate of the location to be checked.
- y: number
Y-coordinate of the location to be checked.
Returns boolean
invokesStopCellEditing
invokesStopCellEditing: boolean
If true, when editing is to be stopped by way of selection changing,
data in diagram changing or other means stopCellEditing is invoked, and
changes are saved. This is implemented in a focus handler in
CellEditorHandler.
isAllowAutoPanning
isAllowAutoPanning: () => boolean
isAllowDanglingEdges
isAllowDanglingEdges: () => boolean
isAllowNegativeCoordinates
isAllowNegativeCoordinates: () => boolean
isAutoExtend
isAutoExtend: () => boolean
isAutoScroll
isAutoScroll: () => boolean
isAutoSizeCell
isAutoSizeCell: (cell: Cell) => boolean
Returns true if the size of the given cell should automatically be updated after a change of the label.
This implementation returns autoSizeCells or checks if the cell style does specify CellStateStyle.autoSize to be true.
Type Declaration
-
- (cell: Cell): boolean
-
Returns boolean
isAutoSizeCells
isAutoSizeCells: () => boolean
isCellBendable
isCellBendable: (cell: Cell) => boolean
Type Declaration
-
- (cell: Cell): boolean
-
Parameters
- cell: Cell
Cell whose bendable state should be returned.
Returns boolean
isCellCloneable
isCellCloneable: (cell: Cell) => boolean
Type Declaration
-
- (cell: Cell): boolean
-
Parameters
- cell: Cell
Optional Cell whose cloneable state should be returned.
Returns boolean
isCellDeletable
isCellDeletable: (cell: Cell) => boolean
Returns true if the given cell is deletable.
isCellDisconnectable
isCellDisconnectable: ( cell: Cell, terminal: Cell | null, source: boolean,) => boolean
Returns true if the given cell is disconnectable from the source or target terminal.
This returns isCellsDisconnectable for all given cells if isCellLocked does not return true for the given cell.
Type Declaration
-
- (cell: Cell, terminal: Cell | null, source: boolean): boolean
-
Parameters
- cell: Cell
Cell whose disconnectable state should be returned.
- terminal: Cell | null
Cell that represents the source or target terminal.
- source: boolean
Boolean indicating if the source or target terminal is to be disconnected.
Returns boolean
isCellEditable
isCellEditable: (cell: Cell) => boolean
Type Declaration
-
- (cell: Cell): boolean
-
Parameters
- cell: Cell
Cell whose editable state should be returned.
Returns boolean
isCellFoldable
isCellFoldable: (cell: Cell, collapse: boolean) => boolean
Returns true if the given cell is foldable.
The default implementation returns true if the cell has at least one child and its style
does not specify CellStyle.foldable to be false.
Type Declaration
-
- (cell: Cell, collapse: boolean): boolean
-
Parameters
- cell: Cell
whose foldable state should be returned.
- collapse: boolean
Returns boolean
isCellLocked
isCellLocked: (cell: Cell) => boolean
Returns true if the given cell may not be moved, sized, bended, disconnected, edited or selected.
This implementation returns true for all vertices with a relative geometry if locked is false.
Type Declaration
-
- (cell: Cell): boolean
-
Parameters
- cell: Cell
Cell whose locked state should be returned.
Returns boolean
isCellMovable
isCellMovable: (cell: Cell) => boolean
Type Declaration
-
- (cell: Cell): boolean
-
Parameters
- cell: Cell
Cell whose movable state should be returned.
Returns boolean
isCellResizable
isCellResizable: (cell: Cell) => boolean
Returns true if the given cell is resizable.
This returns cellsResizable for all given cells if isCellLocked does not return true for the given cell
and its style does not specify 'resizable' to be false.
Type Declaration
-
- (cell: Cell): boolean
-
Parameters
- cell: Cell
Cell whose resizable state should be returned.
Returns boolean
isCellRotatable
isCellRotatable: (cell: Cell) => boolean
Returns true if the given cell is rotatable.
This returns true for the given cell if its style does not specify CellStateStyle.rotatable to be false.
Type Declaration
-
- (cell: Cell): boolean
-
Parameters
- cell: Cell
Cell whose rotatable state should be returned.
Returns boolean
isCellsBendable
isCellsBendable: () => boolean
isCellsCloneable
isCellsCloneable: () => boolean
Returns cellsCloneable, that is, if the graph allows cloning of cells by using control-drag.
isCellsDeletable
isCellsDeletable: () => boolean
isCellsDisconnectable
isCellsDisconnectable: () => boolean
isCellsEditable
isCellsEditable: () => boolean
isCellSelectable
isCellSelectable: (cell: Cell) => boolean
Returns true if the given cell is selectable.
This implementation returns cellsSelectable.
To add a new style for making cells (un)selectable, use the following code.
isCellSelectable(cell) { const style = this.getCurrentCellStyle(cell); return this.isCellsSelectable() && !this.isCellLocked(cell) && (style.selectable ?? true); };
You can then use the new style as shown in this example.
graph.insertVertex({ parent, value: 'Hello,', position: [20, 20], size: [80, 30], style: { selectable: false, }, });
Type Declaration
-
- (cell: Cell): boolean
-
Parameters
- cell: Cell
Cell whose selectable state should be returned.
Returns boolean
isCellSelected
isCellSelected: (cell: Cell) => boolean
Returns true if the given cell is selected.
Type Declaration
-
- (cell: Cell): boolean
-
Parameters
- cell: Cell
Cell for which the selection state should be returned.
Returns boolean
isCellsLocked
isCellsLocked: () => boolean
isCellsMovable
isCellsMovable: () => boolean
isCellsResizable
isCellsResizable: () => boolean
isCellsSelectable
isCellsSelectable: () => boolean
isCloneEvent
isCloneEvent: (evt: MouseEvent) => boolean
Returns true if the given event is a clone event.
This implementation returns true if control is pressed.
isCloneInvalidEdges
isCloneInvalidEdges: () => boolean
isConnectable
isConnectable: () => boolean
isConnectableEdges
isConnectableEdges: () => boolean
isConstrainChild
isConstrainChild: (cell: Cell) => boolean
Type Declaration
-
- (cell: Cell): boolean
-
Parameters
- cell: Cell
Cell that should be constrained.
Returns boolean
isConstrainChildren
isConstrainChildren: () => boolean
isConstrainedEvent
isConstrainedEvent: (evt: MouseEvent) => boolean
Returns true if the given mouse event should be aligned to the grid.
isConstrainedMoving
isConstrainedMoving: boolean = false
isConstrainRelativeChildren
isConstrainRelativeChildren: () => boolean
isDisconnectOnMove
isDisconnectOnMove: () => boolean
isDropEnabled
isDropEnabled: () => boolean
isEdgeLabelsMovable
isEdgeLabelsMovable: () => boolean
isEdgeValid
isEdgeValid: (edge: Cell | null, source: Cell, target: Cell) => boolean
Type Declaration
-
- (edge: Cell | null, source: Cell, target: Cell): boolean
-
Parameters
- edge: Cell | null
Cell that represents the edge to validate.
- source: Cell
Cell that represents the source terminal.
- target: Cell
Cell that represents the target terminal.
Returns boolean
isEditing
isEditing: (cell?: Cell | null) => boolean
Returns true if the given cell is currently being edited.
If no cell is specified, then this returns true if any cell is currently being edited.
Type Declaration
-
- (cell?: Cell | null): boolean
-
Parameters
Optionalcell: Cell | null
Cell that should be checked.
Returns boolean
isEnterStopsCellEditing
isEnterStopsCellEditing: () => boolean
isEscapeEnabled
isEscapeEnabled: () => boolean
isEventSourceIgnored
Returns true if the event should be ignored in fireMouseEvent.
This implementation returns true for select, option and input (if not of type
checkbox, radio, button, submit or file) event sources if the event is not
a mouse event or a left mouse button press event.
isExtendParent
isExtendParent: (cell: Cell) => boolean
Returns true if the parent of the given cell should be extended if the child has been resized so that it overlaps the parent.
This implementation returns isExtendParents if the cell is not an edge.
Type Declaration
-
- (cell: Cell): boolean
-
Returns boolean
isExtendParents
isExtendParents: () => boolean
isExtendParentsOnAdd
isExtendParentsOnAdd: (cell: Cell) => boolean
isExtendParentsOnMove
isExtendParentsOnMove: () => boolean
isFoldingEnabled
isFoldingEnabled: () => boolean
isGridEnabled
isGridEnabled: () => boolean
isGridEnabledEvent
isGridEnabledEvent: (evt: MouseEvent) => boolean
Returns true if the given mouse event should be aligned to the grid.
isHtmlLabel
isHtmlLabel: (cell: Cell) => boolean
Returns true if the label must be rendered as HTML markup.
The default implementation returns htmlLabels.
isHtmlLabels
isHtmlLabels: () => boolean
isIgnoreTerminalEvent
isIgnoreTerminalEvent: (evt: MouseEvent) => boolean
Returns true if the given mouse event should not allow any connections to be made.
This implementation returns false.
isInvokesStopCellEditing
isInvokesStopCellEditing: () => boolean
isLabelClipped
isLabelClipped: (cell: Cell) => boolean
Returns true if the overflow portion of labels should be hidden.
If this returns true then vertex labels will be clipped to the size of the vertices.
This implementation returns true if overflow in the style of the given cell is 'hidden'.
Type Declaration
-
- (cell: Cell): boolean
-
Parameters
- cell: Cell
Cell whose label should be clipped.
Returns boolean
isLabelMovable
isLabelMovable: (cell: Cell) => boolean
Returns true if the given edges' label is moveable.
This returns movable for all given cells if isCellLocked does not return true for the given cell.
Type Declaration
-
- (cell: Cell): boolean
-
Parameters
- cell: Cell
Cell whose label should be moved.
Returns boolean
isLabelsVisible
isLabelsVisible: () => boolean
isMouseDown
isMouseDown: boolean
Holds the state of the mouse button.
isMouseTrigger
isMouseTrigger: boolean | null
isNativeDblClickEnabled
isNativeDblClickEnabled: () => boolean
isPort
isPort: (cell: Cell | null) => boolean
Returns true if the given cell is a "port", that is, when connecting to it, the cell returned by getTerminalForPort
should be used as the terminal and the port should be referenced by the ID in either the CellStateStyle.sourcePort or the CellStateStyle.sourcePort.
Note that a port should not be movable.
This implementation always returns false.
A typical implementation is the following:
graph.isPort = function(cell) { const geo = cell.getGeometry();
return (geo != null) ? geo.relative : false; };
Type Declaration
-
- (cell: Cell | null): boolean
-
Parameters
- cell: Cell | null
Cell that represents the port.
Returns boolean
isPortsEnabled
isPortsEnabled: () => boolean
isResetEdgesOnConnect
isResetEdgesOnConnect: () => boolean
isResetEdgesOnMove
isResetEdgesOnMove: () => boolean
isResetEdgesOnResize
isResetEdgesOnResize: () => boolean
isSelectionEmpty
isSelectionEmpty: () => boolean
Returns true if the selection is empty.
isSiblingSelected
isSiblingSelected: (cell: Cell) => boolean
Returns true if any sibling of the given cell is selected.
isSplitEnabled
isSplitEnabled: () => boolean
isSplitTarget
isSplitTarget: ( target: Cell, cells?: Cell[], evt?: MouseEvent | null,) => boolean
Returns true if the given edge may be split into two edges with the given cell as a new terminal between the two.
Type Declaration
-
- (target: Cell, cells?: Cell[], evt?: MouseEvent | null): boolean
-
Parameters
- target: Cell
Cell that represents the edge to be split.
Optionalcells: Cell[]
Cell that should split the edge.
Optionalevt: MouseEvent | null
MouseEvent that triggered the invocation.
Returns boolean
isSwimlane
isSwimlane: (cell: Cell, ignoreState?: boolean) => boolean
Returns true if the given cell is a swimlane in the graph.
A swimlane is a container cell with some specific behaviour. This implementation
checks if the shape associated with the given cell is a SwimlaneShape.
Type Declaration
-
- (cell: Cell, ignoreState?: boolean): boolean
-
Parameters
- cell: Cell
OptionalignoreState: boolean
Optional boolean that specifies if the cell state should be ignored.
Returns boolean
isSwimlaneNesting
isSwimlaneNesting: () => boolean
isSwimlaneSelectionEnabled
isSwimlaneSelectionEnabled: () => boolean
isSyntheticEventIgnored
isSyntheticEventIgnored: ( evtName: string, me: InternalMouseEvent, sender: any,) => boolean
Hook for ignoring synthetic mouse events after touchend in Firefox.
isTerminalPointMovable
isTerminalPointMovable: (cell: Cell, source: boolean) => boolean
Returns true if the given terminal point is movable. This is independent
from isCellConnectable and isCellDisconnectable and controls if terminal
points can be moved in the graph if the edge is not connected.
Note that it is required for this to return true to connect unconnected edges.
This implementation returns true.
Type Declaration
-
- (cell: Cell, source: boolean): boolean
-
Parameters
- cell: Cell
Cell whose terminal point should be moved.
- source: boolean
Boolean indicating if the source or target terminal should be moved.
Returns boolean
isTimerAutoScroll
isTimerAutoScroll: () => boolean
isToggleEvent
isToggleEvent: (evt: MouseEvent) => boolean
Returns true if the given event is a toggle event.
This implementation returns true if the meta key (Cmd) is pressed on Macs or if control is pressed on any other platform.
isTransparentClickEvent
isTransparentClickEvent: (evt: MouseEvent) => boolean
Hook for implementing click-through behaviour on selected cells.
If this method returns true the cell behind the selected cell will be selected.
This implementation returns false.
isUseScrollbarsForPanning
isUseScrollbarsForPanning: () => boolean
isValidAncestor
isValidAncestor: (cell: Cell | null, parent: Cell, recurse?: boolean) => boolean
Returns whether the specified parent is a valid ancestor of the specified cell,
either direct or indirectly based on whether ancestor recursion is enabled.
Type Declaration
-
- (cell: Cell | null, parent: Cell, recurse?: boolean): boolean
-
Parameters
- cell: Cell | null
Cell the possible child cell
- parent: Cell
Cell the possible parent cell
Optionalrecurse: boolean
boolean whether to recurse the child ancestors. Default is false.
Returns boolean
isValidConnection
isValidConnection: (source: Cell | null, target: Cell | null) => boolean
Returns true if the given target cell is a valid target for source.
This is a boolean implementation for not allowing connections between certain pairs of vertices and is called by getEdgeValidationError.
This implementation returns true if isValidSource returns true for the source and isValidTarget returns true for the target.
Type Declaration
-
- (source: Cell | null, target: Cell | null): boolean
-
Parameters
- source: Cell | null
Cell that represents the source cell.
- target: Cell | null
Cell that represents the target cell.
Returns boolean
isValidDropTarget
isValidDropTarget: ( cell: Cell, cells?: Cell[], evt?: MouseEvent | null,) => boolean
Returns true if the given cell is a valid drop target for the specified cells.
If splitEnabled is true then this returns isSplitTarget for the given arguments else it returns true if the cell is not collapsed
and its child count is greater than 0.
Type Declaration
-
- (cell: Cell, cells?: Cell[], evt?: MouseEvent | null): boolean
-
Parameters
- cell: Cell
Cell that represents the possible drop target.
Optionalcells: Cell[]
Cell that should be dropped into the target.
Optionalevt: MouseEvent | null
Mouseevent that triggered the invocation.
Returns boolean
isValidSource
isValidSource: (cell: Cell | null) => boolean
Returns true if the given cell is a valid source for new connections.
This implementation returns true for all non-null values and is called by is called by isValidConnection.
Type Declaration
-
- (cell: Cell | null): boolean
-
Parameters
- cell: Cell | null
Cell that represents a possible source or null.
Returns boolean
isValidTarget
isValidTarget: (cell: Cell | null) => boolean
Type Declaration
-
- (cell: Cell | null): boolean
-
Parameters
- cell: Cell | null
Cell that represents a possible target or null.
Returns boolean
isVertexLabelsMovable
isVertexLabelsMovable: () => boolean
isWrapping
isWrapping: (cell: Cell) => boolean
This enables wrapping for HTML labels.
Returns true if no white-space CSS style directive should be used for displaying the given cells label.
This implementation returns true if 'whiteSpace' in the style of the given cell is 'wrap'.
This is used as a workaround for IE ignoring the white-space directive
of child elements if the directive appears in a parent element. It
should be overridden to return true if a white-space directive is used
in the HTML markup that represents the given cells label. In order for
HTML markup to work in labels, isHtmlLabel must also return true
for the given cell.
Type Declaration
-
- (cell: Cell): boolean
-
Parameters
- cell: Cell
Cell whose label should be wrapped.
Returns boolean
Exampleconst getLabel = graph.getLabel; graph.getLabel = function(cell) { const tmp = getLabel.apply(this, arguments); // "supercall"
if (this.model.isEdge(cell)) { tmp = '<div style="width: 150px; white-space:normal;">'+tmp+'</div>'; }
return tmp; }
graph.isWrapping = function(state) { return this.model.isEdge(state.cell); }
Makes sure no edge label is wider than 150 pixels, otherwise the content
is wrapped. Note: No width must be specified for wrapped vertex labels as
the vertex defines the width in its geometry.
keepEdgesInBackground
keepEdgesInBackground: boolean = false
keepEdgesInForeground
keepEdgesInForeground: boolean = false
keepSelectionVisibleOnZoom
keepSelectionVisibleOnZoom: boolean
Specifies if the viewport should automatically contain the selection cells after a zoom operation.
labelsVisible
labelsVisible: boolean
Specifies if labels should be visible. This is used in getLabel.
lastMouseX
lastMouseX: number | null
lastMouseY
lastMouseY: number | null
lastTouchCell
lastTouchCell: Cell | null
lastTouchEvent
lastTouchEvent: MouseEvent | null
lastTouchTime
lastTouchTime: number
Holds the time of the last touch event for double click detection.
lastTouchX
lastTouchX: number
Holds the x-coordinate of the last touch event for double tap detection.
lastTouchY
lastTouchY: number
Holds the x-coordinate of the last touch event for double tap detection.
maximumContainerSize
maximumContainerSize: Rectangle | null = null
maximumGraphBounds
Rectangle that specifies the area in which all cells in the diagram
should be placed. Uses in getMaximumGraphBounds. Use a width or height of
0 if you only want to give a upper, left corner.
minimumContainerSize
minimumContainerSize: Rectangle | null = null
minimumGraphSize
Rectangle that specifies the minimum size of the graph. This is ignored
if the graph container has no scrollbars.
minPageBreakDist
minPageBreakDist: number = 20
Specifies the minimum distance in pixels for page breaks to be visible.
moveCells
moveCells: ( cells: Cell[], dx?: number, dy?: number, clone?: boolean, target?: Cell | null, evt?: MouseEvent | null, mapping?: any,) => Cell[]
Moves or clones the specified cells and moves the cells or clones by the given amount, adding them to the optional
target cell. The evt is the mouse event as the mouse was released. The change is carried out using cellsMoved.
This method fires Event#MOVE_CELLS while the transaction is in progress.
Use the following code to move all cells in the graph.
graph.moveCells(graph.getChildCells(null, true, true), 10, 10);
multigraph
multigraph: boolean = true
Specifies if multiple edges in the same direction between the same pair of
vertices are allowed.
multiplicities
An array of Multiplicity describing the allowed connections in a graph.
nativeDblClickEnabled
nativeDblClickEnabled: boolean
Specifies if native double click events should be detected.
orderCells
orderCells: (back: boolean, cells?: Cell[]) => Cell[]
Type Declaration
-
- (back: boolean, cells?: Cell[]): Cell[]
-
Parameters
- back: boolean
Boolean that specifies if the cells should be moved to back. Default is false.
Optionalcells: Cell[]
Array of Cell to move to the background. If not set, then the selection cells are used.
Returns Cell[]
pageBreakColor
pageBreakColor: string = 'gray'
Specifies the color for page breaks.
pageBreakDashed
pageBreakDashed: boolean = true
Specifies the page breaks should be dashed.
pageBreaksVisible
pageBreaksVisible: boolean = false
Specifies if a dashed line should be drawn between multiple pages.
If you change this value while a graph is being displayed then you
should call sizeDidChange to force an update of the display.
pageFormat
Specifies the page format for the background page.
This is used as the default in PrintPreview and for painting the background page
if pageVisible is true and the page breaks if pageBreaksVisible is true.
pageScale
pageScale: number = 1.5
Specifies the scale of the background page.
Not yet implemented.
pageVisible
pageVisible: boolean = false
Specifies if the background page should be visible.
Not yet implemented.
paintBackground
paintBackground: Function | null = null
panDx
panDx: number
Current horizontal panning value.
panDy
panDy: number
Current vertical panning value.
panGraph
panGraph: (dx: number, dy: number) => void
Type Declaration
-
- (dx: number, dy: number): void
-
Parameters
- dx: number
Amount to shift the graph along the x-axis.
- dy: number
Amount to shift the graph along the y-axis.
Returns void
portsEnabled
portsEnabled: boolean
Specifies if ports are enabled. This is used in cellConnected to update the respective style.
|