Optional
model: GraphDataModelReturns an array with the given cells and all edges that are connected to a cell or one of its descendants.
Adds the cell to the parent and connects it to the given source and target terminals.
This is a shortcut method.
mxCell to be inserted into the given parent.
mxCell that represents the new parent. If no parent is given then the default parent is used.
Optional
index: null | numberOptional index to insert the cells at. Default is 'to append'.
Optional
source: null | CellOptional Cell that represents the source terminal.
Optional
target: null | CellOptional Cell that represents the target terminal.
the cell that was added.
Adds an CellOverlay for the specified cell.
This method fires an InternalEvent.ADD_OVERLAY event and returns the new CellOverlay.
Cell to add the overlay for.
CellOverlay to be added for the 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 Event#ADD_CELLS while the transaction is in progress. Returns the cells that were added.
Array of Cells to be inserted.
Cell that represents the new parent. If no parent is given then the default parent is used.
Optional index to insert the cells at. Default is to append.
Optional source Cell for all inserted cells.
Optional target Cell for all inserted cells.
Optional
absolute: booleanOptional boolean indicating of cells should be kept at their absolute position. Default is false
.
Adds the edge to the parent and connects it to the given source and target terminals. This is a shortcut method.
Cell to be inserted into the given parent.
Cell that represents the new parent. If no parent is given then the default parent is used.
Optional Cell that represents the source terminal.
Optional Cell that represents the target terminal.
Optional
index: null | numberOptional index to insert the cells at. Default is 'to append'.
The edge that was added.
Adds the specified ImageBundle.
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.
Listener to be added to the graph event listeners.
Adds the given cell to the selection.
Adds the given cells to the selection.
Aligns the given cells vertically or horizontally according to the given alignment using the optional parameter as the coordinate.
Specifies if panning via panGraph should be allowed to implement autoscroll if no scrollbars are available in scrollPointToVisible.
To enable panning inside the container, near the edge, set PanningManager.border to a positive value.
Specifies if edges with disconnected terminals are allowed in the graph.
Specifies if loops (aka self-references) are allowed.
Specifies if negative coordinates for vertices are allowed.
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.
Specifies the alternate edge style to be used if the main control point on an edge is being double-clicked.
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.
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.
Resizes the specified cell to just fit around its label and/or children.
mxCell to be resized.
Optional
recurse: booleanOptional boolean which specifies if all descendants should be auto-sized. Default is true
.
Specifies if the graph should automatically update the cell size after an edit. This is used in isAutoSizeCell.
Specifies if autoSize style should be applied when cells are added.
Specifies the Image to be returned by getBackgroundImage.
Border to be added to the bottom and right side when the container is being resized after the graph has been changed.
Returns true if the given cell may be exported to the clipboard.
This implementation returns exportEnabled for all cells.
Returns true if the given cell may be imported from the clipboard.
This implementation returns importEnabled for all cells.
Sets the new terminal for the given edge and resets the edge points if resetEdgesOnConnect is true
.
This method fires InternalEvent.CELL_CONNECTED while the transaction is in progress.
Cell whose terminal should be updated.
Cell that represents the new terminal to be used.
Boolean indicating if the new terminal is the source or target. Default is false
.
Optional
constraint: null | ConnectionConstraintConnectionConstraint to be used for this connection.
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);
};
Cell whose label should be changed.
New label to be assigned.
Boolean that specifies if cellSizeUpdated should be called.
Holds the CellRenderer for rendering the cells in the graph.
Resizes the parents recursively so that they contain the complete area of the resized child cell.
Cell whose bounds should be changed.
Rectangles that represent the new bounds.
Boolean that indicates if relative cells should be ignored. Default is false
.
Optional boolean that specifies if the children should be resized. Default is false
.
Adds the specified cells to the given parent. This method fires Event#CELLS_ADDED while the transaction is in progress.
Specifies the return value for isCellsBendable.
Specifies the return value for isCellCloneable.
Specifies the return value for isCellDeletable.
Specifies the return value for isCellsDisconnectable.
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.
Array of Cell whose collapsed state should be set. Default is null
.
Boolean indicating the collapsed state to be assigned. Default is false
.
Boolean indicating if the collapsed state of all descendants should be set. Default is false
.
Optional
checkFoldable: booleanOptional boolean indicating of isCellFoldable should be checked. Default is false
.
Updates the size of the given cell in the model using getPreferredSizeForCell to get the new size.
Specifies the return value for isCellLocked.
Specifies the return value for isCellMovable.
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.
Moves the given cells to the front or back.
This method fires InternalEvent.CELLS_ORDERED while the transaction is in progress.
Removes the given cells from the model. This method fires InternalEvent.CELLS_REMOVED while the transaction is in progress.
Specifies the return value for isCellsResizable.
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(mxEvent.CELLS_RESIZED, function(sender, evt)
{
var cells = evt.getProperty('cells');
if (cells != null)
{
for (var i = 0; i < cells.length; i++)
{
if (graph.getDataModel().getChildCount(cells[i]) > 0)
{
var geo = cells[i].getGeometry();
if (geo != null)
{
var children = graph.getChildCells(cells[i], true, true);
var 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(cells[i], geo);
}
}
}
}
});
Specifies the return value for isCellsSelectable.
Sets the visible state of the specified cells.
Specifies if the zoom operations should go into the center of the actual diagram rather than going from top, left.
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.
Clears the selection using GraphSelectionModel.clear.
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();
}
});
mxMouseEvent that represents the single click.
Returns the clone for the given cell. Uses cloneCells.
Cell to be cloned.
Optional
allowInvalidEdges: booleanOptional boolean that specifies if invalid edges should be cloned. Default is true
.
Optional
mapping: anyOptional mapping for existing clones.
Optional
keepPosition: booleanOptional boolean indicating if the position of the cells should be updated to reflect the lost parent cell. Default is false
.
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.
Array of Cell to be cloned.
Optional
allowInvalidEdges: booleanOptional boolean that specifies if invalid edges should be cloned. Default is true
.
Optional
mapping: anyOptional mapping for existing clones.
Optional
keepPosition: booleanOptional boolean indicating if the position of the cells should be updated to reflect the lost parent cell. Default is false
.
Specifies if edges that are cloned should be validated and only inserted if they are valid.
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.
Specifies if edges are connectable. This overrides the connectable field in edges.
Connects the specified end of the given edge to the given terminal using cellConnected and fires InternalEvent.CONNECT_CELL while the transaction is in progress.
Cell whose terminal should be updated.
Cell that represents the new terminal to be used.
Boolean indicating if the new terminal is the source or target. Default is false
.
Optional
constraint: null | ConnectionConstraintOptional ConnectionConstraint to be used for this connection.
the updated edge.
Keeps the given cell inside the bounds returned by getCellContainmentArea for its parent, according to the rules defined by getOverlap and isConstrainChild.
This modifies the cell's geometry in-place and does not clone it.
Constrains the children of the given cell using constrainChild.
Specifies if a child should be constrained inside the parent bounds after a move or resize of the child.
Specifies if child cells with relative geometries should be constrained inside the parent bounds, if constrainChildren is true
, and/or the maximumGraphBounds.
Consumes the given InternalMouseEvent if it's a touchStart event.
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.
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.
Cell that specifies the parent of the new edge. If not set, use the default parent.
Optional string that defines the Id of the new edge. If not set, the id is auto-generated when creating the vertex.
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.
Cell that defines the source of the edge.
Cell that defines the target of the edge.
Optional
style: CellStyleOptional object that defines the cell style.
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;
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
});
EdgeStyle to be used for loops. This is a fallback for loops if the
CellStateStyle.loopStyle is undefined
.
Value returned by getOverlap if isAllowOverlapParent returns
true
for the given cell. getOverlap is used in constrainChild if
isConstrainChild returns true
. The value specifies the
portion of the child which is allowed to overlap the parent.
Specifies the default parent to be used to insert new cells. This is used in getDefaultParent.
Dialect to be used for drawing the graph. Possible values are all constants in DIALECT.
Disconnects the given edges from the terminals which are not in the given array.
Specifies if edges should be disconnected from their terminals when they are moved.
Specifies if double taps on touch-based devices should be handled as a double click.
Specifies the timeout in milliseconds for double taps and non-native double clicks.
Specifies the tolerance in pixels for double taps and double-clicks in quirks mode.
Specifies the return value for isDropEnabled.
Specifies the return value for edges in isLabelMovable.
Specifies the return value for isEnabled.
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
.
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: You can always use F2 and escape to stop editing.
Processes an escape keystroke.
Event that represents the keystroke.
Specifies if KeyHandler should invoke escape when the escape key is pressed.
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.
Specifies if events can be fired. Default is true.
Optional source for events. Default is null.
Changes the current root to the next valid root in the displayed cell hierarchy.
Specifies the return value for canExportCell.
Resizes the parents recursively so that they contain the complete area of the resized child cell.
Specifies if a parent should contain the child bounds after a resize of the child. This has precedence over constrainChildren.
Specifies if parents should be extended according to the extendParents switch if cells are added.
Specifies if parents should be extended according to the extendParents switch if cells are added.
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();
}
});
Dispatches the given event in the graph event dispatch loop.
Possible event names are InternalEvent.MOUSE_DOWN, InternalEvent.MOUSE_MOVE and InternalEvent.MOUSE_UP. All listeners are invoked for all events regardless of the consumed state of the event.
String that specifies the type of event to be dispatched.
InternalMouseEvent to be fired.
Optional
sender: EventSourceOptional sender argument. Default is this
.
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 ?? Constants.ELBOW.HORIZONTAL;
const value = (elbow == Constants.ELBOW.HORIZONTAL) ? Constants.ELBOW.VERTICAL : Constants.ELBOW.HORIZONTAL;
this.setCellStyles('elbow', value, [edge]);
}
};
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.
Boolean indicating the collapsed state to be assigned. Default is false
.
Optional
recurse: booleanOptional boolean indicating if the collapsed state of all descendants should be set. Default is false
.
Optional
cells: null | Cell[]Array of Cell whose collapsed state should be set. If null
is specified then the foldable selection cells are used. Default is null
.
Optional
checkFoldable: booleanOptional boolean indicating of isCellFoldable should be checked. Default is false
.
Optional
evt: null | EventOptional native event that triggered the invocation. Default is null
.
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.
Returns an array of all ConnectionConstraints for the given terminal. If the shape of the given terminal is a StencilShape then the constraints of the corresponding StencilShape are returned.
Returns all edges connected to the given cells or its descendants.
Returns the bounding box for the given array of Cell. The bounding box for each cell and its descendants is computed using view.getBoundingBox.
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));
}
Returns the bounds to be used for the given group and children.
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.
X-coordinate of the location to be checked.
Y-coordinate of the location to be checked.
Optional
parent: null | CellmxCell that should be used as the root of the recursion. Default is current root of the view or the root of the model.
Optional
vertices: null | booleanOptional boolean indicating if vertices should be returned. Default is true
.
Optional
edges: null | booleanOptional boolean indicating if edges should be returned. Default is true
.
Optional
ignoreFn: null | FunctionOptional 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 the scaled, translated bounds for the given cell. See GraphView.getBounds for arrays.
Cell whose bounds should be returned.
Optional
includeEdges: booleanOptional boolean that specifies if the bounds of the connected edges should be included. Default is false
.
Optional
includeDescendants: booleanOptional boolean that specifies if the bounds of all descendants should be included. Default is false
.
Returns the Rectangle inside which a cell is to be kept.
Returns an array of CellOverlays for the given cell or null
, if no overlays are defined.
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.
X-coordinate of the rectangle.
Y-coordinate of the rectangle.
Width of the rectangle.
Height of the rectangle.
Optional
parent: null | CellmxCell that should be used as the root of the recursion. Default is current root of the view or the root of the model.
Optional
result: Cell[]Optional array to store the result in. Default is an empty Array.
Optional
intersection: null | RectangleDefault is null
.
Optional
ignoreFn: null | FunctionDefault is null
.
Optional
includeDescendants: booleanDefault is false
.
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.
X-coordinate of the origin.
Y-coordinate of the origin.
Optional Cell whose children should be checked. Default is
Boolean indicating if the cells in the right halfpane from the origin should be returned. Default is false
.
Boolean indicating if the cells in the bottom halfpane from the origin should be returned. Default is false
.
Returns the cells with the same parent as the first cell in the given array.
Returns the selection cells that can be ungrouped.
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.
Checks all multiplicities that cannot be enforced while the graph is being modified, namely, all multiplicities that require a minimum of 1 edge.
Returns the visible child vertices or edges in the given parent.
If vertices and edges is false
, then all children are returned.
Optional
parent: null | CellmxCell whose children should be returned.
Optional
vertices: booleanOptional boolean that specifies if child vertices should be returned. Default is false
.
Optional
edges: booleanOptional boolean that specifies if child edges should be returned. Default is false
.
Returns the visible child edges of the given parent.
Returns the visible child vertices of the given parent.
Returns the cells which may be exported in the given array of cells.
Returns an ConnectionConstraint that describes the given connection point. This result can then be passed to getConnectionPoint.
Returns the nearest point in the list of absolute points or the center of the opposite terminal.
CellState that represents the vertex.
ConnectionConstraint that represents the connection point constraint as returned by getConnectionConstraint.
Optional
round: booleanDefault is true
.
Returns all visible edges connected to the given cell without loops.
Returns the style for the given cell from the cell state, if one exists, or using getCellStyle.
Returns the cursor value to be used for the CSS of the shape for the given cell.
This implementation returns null
.
Returns the cursor value to be used for the CSS of the shape for the given event.
This implementation calls getCursorForCell.
InternalMouseEvent whose cursor should be returned.
Returns the cells which may be exported in the given array of cells.
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.
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.
Cell whose edges should be returned.
Optional
parent: null | CellOptional parent of the opposite end for an edge to be returned.
Optional
incoming: booleanOptional boolean that specifies if incoming edges should be included in the result. Default is true
.
Optional
outgoing: booleanOptional boolean that specifies if outgoing edges should be included in the result. Default is true
.
Optional
includeLoops: booleanOptional boolean that specifies if loops should be included in the result. Default is true
.
Optional
recurse: booleanOptional boolean the specifies if the parent specified only needs to be an ancestral parent, true
, or the direct parent, false
. Default is false
.
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.
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);
}
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.
Returns the CellState to be used when firing the mouse event for the given state.
This implementation returns the given state.
Returns the cells which may be exported in the given array of cells.
Returns the cells which are movable in the given array of cells.
Returns the Image used to display the collapsed state of the specified cell state.
This returns null
for all edges.
Returns gridSize.
Searches all imageBundles for the specified key and returns the value for the first match or null
if the key is not found.
Returns the cells which may be imported in the given array of cells.
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.
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(mxEvent.RESIZE_CELLS, function(sender, evt) {
const cells = evt.getProperty('cells');
for (let i = 0; i < cells.length; i++) {
this.view.removeState(cells[i]);
}
});
mxCell whose label should be returned.
Returns the cells which are movable in the given array of cells.
Returns all distinct visible opposite cells for the specified terminal on the given edges.
Array of Cell that contains the edges whose opposite terminals should be returned.
Terminal that specifies the end whose opposite should be returned. Default is null
.
Optional
includeSources: booleanOptional boolean that specifies if source terminals should be included in the result. Default is true
.
Optional
includeTargets: booleanOptional boolean that specifies if target terminals should be included in the result. Default is true
.
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.
Returns the constraint used to connect to the outline of the given state.
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;
};
Returns the first cell from the array of selected Cell.
Returns the array of selected Cell.
Returns the cells to be selected for the given array of changes.
Returns the number of selected cells.
Returns the GraphSelectionModel that contains the selection.
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.
Returns the state for the given touch event.
Returns the nearest ancestor of the given cell which is a swimlane, or the given cell, if it is itself a swimlane.
Returns the bottom-most swimlane that intersects the given point (x, y) in the cell hierarchy that starts at the given parent.
X-coordinate of the location to be checked.
Y-coordinate of the location to be checked.
Optional
parent: null | CellmxCell that should be used as the root of the recursion. Default is defaultParent.
Returns the direction for the given swimlane style.
Returns the terminal to be used for a given port.
This implementation always returns the parent cell.
Returns the string or DOM node that represents the tooltip for the given state, node and coordinate pair. This implementation checks if the given node is a folding icon or overlay and returns the respective tooltip. If this does not result in a tooltip, the handler for the cell is retrieved from SelectionCellsHandler and the optional getTooltipForNode method is called. If no special tooltip exists here then getTooltipForCell is used with the cell in the given state as the argument to return a tooltip for the given state.
Returns the string or DOM node to be used as the tooltip for the given cell. This implementation uses the Cell.getTooltip function if it exists, or else it returns convertValueToString for the cell.
Specifies if the grid is enabled. This is used in snap.
Specifies the grid size.
Adds the cells into the given group. The change is carried out using cellsAdded, cellsMoved and cellsResized.
This method fires InternalEvent.GROUP_CELLS while the transaction is in progress.
Cell that represents the target group. If null
is specified then a new group is created using createGroupCell.
Optional integer that specifies the border between the child area and the group bounds. Default is 0
.
Optional
cells: null | Cell[]Optional array of Cell to be grouped. If null
is specified then the selection cells are used.
the new group. A group is only created if there is at least one entry in the given array of cells.
Returns true
if the given coordinate pair is inside the content are of the given swimlane.
Specifies the return value for isHtmlLabel.
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
.
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.
Array of Cell to be imported.
Optional
dx: numberInteger that specifies the x-coordinate of the vector. Default is 0
.
Optional
dy: numberInteger that specifies the y-coordinate of the vector. Default is 0
.
Optional
target: null | CellCell that represents the new parent of the cells.
Optional
evt: null | MouseEventMouseEvent that triggered the invocation.
Optional
mapping: anyOptional mapping for existing clones.
the cells that were imported.
Specifies the return value for canImportCell.
Holds the x-coordinate of the initial touch event for tap and hold.
Holds the y-coordinate of the initial touch event for tap and hold.
Returns the bottom-most cell that intersects the given point (x, y) in the cell hierarchy that starts at the given parent.
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.
Returns allowDanglingEdges as a boolean.
Returns allowNegativeCoordinates.
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
.
Returns autoSizeCells.
Returns true if the given cell is bendable.
This returns cellsBendable for all given cells if cellsLocked does not return true
for the given cell
and its style does not specify CellStateStyle.bendable to be false
.
Returns true if the given cell is cloneable.
This implementation returns isCellsCloneable for all cells unless a cell style specifies CellStateStyle.cloneable to be false
.
Returns true
if the given cell is deletable.
cellsDeletable for all given cells if a cells style does not specify CellStateStyle.deletable to be false
.
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.
Returns true
if the given cell is editable.
This returns cellsEditable for all given cells if isCellLocked does not return true
for the given cell
and its style does not specify CellStateStyle.editable to be false
.
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
.
whose foldable state should be returned.
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
.
Returns true
if the given cell is movable.
This returns cellsMovable for all given cells if isCellLocked does not return true
for the given cell,
and its style does not specify CellStateStyle.movable to be false
.
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
.
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
.
Returns cellsBendable.
Returns cellsCloneable, that is, if the graph allows cloning of cells by using control-drag.
Returns cellsDeletable.
Returns cellsDisconnectable.
Returns cellsEditable.
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)
{
var style = this.getCurrentCellStyle(cell);
return this.isCellsSelectable() && !this.isCellLocked(cell) && style.selectable != 0;
};
You can then use the new style as shown in this example.
graph.insertVertex(parent, null, 'Hello,', 20, 20, 80, 30, 'selectable=0');
Returns true
if the given cell is selected.
Returns cellsMovable.
Returns cellsResizable.
Returns cellsSelectable.
Returns true
if the given event is a clone event.
This implementation returns true
if control is pressed.
Returns cloneInvalidEdges as a boolean.
Returns true
if the ConnectionHandler is enabled.
Returns connectableEdges as a boolean.
Returns true
if the given cell should be kept inside the bounds of its parent according to the rules defined by getOverlap and isAllowOverlapParent.
This implementation returns false for
all children of edges and isConstrainChildren otherwise.
Returns constrainChildren.
Returns true
if the given mouse event should be aligned to the grid.
Returns constrainRelativeChildren.
Returns disconnectOnMove as a boolean.
Returns dropEnabled as a boolean.
Returns edgeLabelsMovable.
Checks if the return value of getEdgeValidationError for the given arguments is null.
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.
Returns enterStopsCellEditing.
Returns escapeEnabled.
Returns true
if the event should be ignored in fireMouseEvent.
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.
The name of the event.
InternalMouseEvent that should be ignored.
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.
Returns extendParents.
Returns extendParentsOnAdd.
Returns extendParentsOnMove.
Returns gridEnabled.
Returns true
if the given mouse event should be aligned to the grid.
Returns true if the label must be rendered as HTML markup.
The default implementation returns htmlLabels.
Returns htmlLabels.
Returns true
if the given mouse event should not allow any connections to be made.
This implementation returns false
.
Returns invokesStopCellEditing.
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'.
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.
Holds the state of the mouse button.
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;
};
Returns portsEnabled.
Returns true
if the selection is empty.
Returns true
if any sibling of the given cell is selected.
Returns splitEnabled as a boolean.
Returns true
if the given edge may be split into two edges with the given cell as a new terminal between the two.
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.
Returns swimlaneNesting as a boolean.
Returns swimlaneSelectionEnabled as a boolean.
Hook for ignoring synthetic mouse events after touchend in Firefox.
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
.
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.
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
.
Returns whether the specified parent is a valid ancestor of the specified cell, either direct or indirectly based on whether ancestor recursion is enabled.
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.
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.
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.
mxCell that represents a possible source or null
.
Returns isValidSource for the given cell. This is called by isValidConnection.
mxCell that represents a possible target or null
.
Returns vertexLabelsMovable.
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.
const 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.
Specifies if edges should appear in the background regardless of their order
in the model. If keepEdgesInForeground and keepEdgesInBackground are
both true
then the normal order is applied.
Specifies if edges should appear in the foreground regardless of their order
in the model. If keepEdgesInForeground and keepEdgesInBackground are
both true
then the normal order is applied.
Specifies if the viewport should automatically contain the selection cells after a zoom operation.
Sets the label of the specified cell to the given value using cellLabelChanged and fires InternalEvent.LABEL_CHANGED while the transaction is in progress.
Cell whose label should be changed.
New label to be assigned.
Optional event that triggered the change.
The cell whose label was changed.
Specifies if labels should be visible. This is used in getLabel.
Holds the time of the last touch event for double click detection.
Holds the x-coordinate of the last touch event for double tap detection.
Holds the x-coordinate of the last touch event for double tap detection.
Specifies the maximum scale to be applied in fit. Set this to null
to allow any value.
Rectangle that specifies the maximum size of the container if
resizeContainer is true
.
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.
Specifies the minimum scale to be applied in fit. Set this to null
to allow any value.
Rectangle that specifies the minimum size of the container if
resizeContainer is true
.
Rectangle that specifies the minimum size of the graph. This is ignored if the graph container has no scrollbars.
Specifies the minimum distance in pixels for page breaks to be visible.
Holds the GraphDataModel that contains the cells to be displayed.
Holds the mouse event listeners. See fireMouseEvent.
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);
Array of Cell to be moved, cloned or added to the target.
Optional
dx: numberInteger that specifies the x-coordinate of the vector. Default is 0
.
Optional
dy: numberInteger that specifies the y-coordinate of the vector. Default is 0
.
Optional
clone: booleanBoolean indicating if the cells should be cloned. Default is false
.
Optional
target: null | CellCell that represents the new parent of the cells.
Optional
evt: null | MouseEventMouseEvent that triggered the invocation.
Optional
mapping: anyOptional mapping for existing clones.
the cells that were moved.
Specifies if multiple edges in the same direction between the same pair of vertices are allowed.
An array of Multiplicity describing the allowed connections in a graph.
Specifies if native double click events should be detected.
Folding options.
Moves the given cells to the front or back. The change is carried out using cellsOrdered.
This method fires InternalEvent.ORDER_CELLS while the transaction is in progress.
Specifies the color for page breaks.
Specifies the page breaks should be dashed.
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.
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
.
Specifies the scale of the background page. Not yet implemented.
Specifies if the background page should be visible. Not yet implemented.
Current horizontal panning value.
Current vertical panning value.
Shifts the graph display by the given amount. This is used to preview panning operations, use GraphView.setTranslate to set a persistent translation of the view.
Fires InternalEvent.PAN.
Amount to shift the graph along the x-axis.
Amount to shift the graph along the y-axis.
Specifies if ports are enabled. This is used in cellConnected to update the respective style.
Tries to resolve the value for the image style in the image bundles and turns short data URIs as defined in ImageBundle to data URIs as defined in RFC 2397 of the IETF.
Specifies if the graph size should be rounded to the next page number in sizeDidChange. This is only used if the graph container has scrollbars.
Specifies the return value for isRecursiveResize.
Removes and returns the given CellOverlay from the given cell.
This method fires a InternalEvent.REMOVE_OVERLAY event.
If no overlay is given, then all overlays are removed using removeCellOverlays.
Cell whose overlay should be removed.
Optional CellOverlay to be removed.
Removes all CellOverlays from the given cell.
This method fires a InternalEvent.REMOVE_OVERLAY event for each CellOverlay and returns an array of CellOverlays that was removed from the cell.
Removes the given cells from the graph including all connected edges if includeEdges is true. The change is carried out using cellsRemoved. This method fires InternalEvent.REMOVE_CELLS while the transaction is in progress. The removed cells are returned as an array.
Hook to remove the groups after ungroupCells.
Removes the specified cells from their parents and adds them to the default parent.
Removes the specified ImageBundle.
Removes the specified graph listener.
Listener to be removed from the graph event listeners.
Removes the given cell from the selection.
Removes the given cells from the selection.
Removes all cached information for the given cell and its descendants. This is called when a cell was removed from the model.
RenderHint as it was passed to the constructor.
Resets the control points of the given edge.
Resets the control points of the edges that are connected to the given cells if not both ends of the edge are in the given cells array.
Specifies if edge control points should be reset after the edge has been reconnected.
Specifies if edge control points should be reset after the move of a connected cell.
Specifies if edge control points should be reset after the resize of a connected cell.
Specifies if the scale and translate should be reset if the root changes in the model.
Sets the bounds of the given cell using resizeCells. Returns the cell which was passed to the function.
Sets the bounds of the given cells and fires a InternalEvent.RESIZE_CELLS event while the transaction is in progress. Returns the cells which have been passed to the function.
Resizes the child cells of the given cell for the given new geometry with respect to the current geometry of the cell.
Specifies if the container should be resized to the graph size when the graph size has changed.
Scales the points, position and size of the given cell according to the given vertical and horizontal scaling factors.
Pans the graph so that it shows the given cell. Optionally the cell may be centered in the container.
To center a given graph if the container has no scrollbars, use the following code.
const bounds = graph.getGraphBounds();
graph.view.setTranslate(-bounds.x - (bounds.width - container.clientWidth) / 2,
-bounds.y - (bounds.height - container.clientHeight) / 2);
Pans the graph so that it shows the given rectangle.
Selects all children of the given parent cell or the children of the default parent if no parent is specified.
To select leaf vertices and/or edges use selectCells.
Optional
parent: null | CellOptional Cell whose children should be selected. Default is defaultParent.
Optional
descendants: booleanOptional boolean specifying whether all descendants should be selected. Default is false
.
Selects the next, parent, first child or previous cell, if all arguments are false
.
Optional
isNext: booleanBoolean indicating if the next cell should be selected. Default is false
.
Optional
isParent: booleanBoolean indicating if the parent cell should be selected. Default is false
.
Optional
isChild: booleanBoolean indicating if the first child cell should be selected. Default is false
.
Selects the given cell by either adding it to the selection or replacing the selection depending on whether the given mouse event is a toggle event.
Selects all vertices and/or edges depending on the given boolean arguments recursively, starting at the given parent or the default parent if no parent is specified.
Use selectAll to select all cells.
For vertices, only cells with no children are selected.
Boolean indicating if vertices should be selected.
Boolean indicating if edges should be selected.
Optional
parent: null | CellOptional Cell that acts as the root of the recursion. Default is defaultParent.
Optional
selectGroups: booleanOptional boolean that specifies if groups should be selected. Default is false
.
Selects the given cells by either adding them to the selection or replacing the selection depending on whether the given mouse event is a toggle event.
Selects the first child cell.
Select all edges inside the given parent or the default parent.
Selects the next cell.
Selects the parent cell.
Selects the previous cell.
Selects and returns the cells inside the given rectangle for the specified event.
Select all vertices inside the given parent or the default parent.
Specifies if dangling edges are allowed, that is, if edges are allowed that do not have a source and/or target terminal defined.
Boolean indicating if dangling edges are allowed.
Sets allowNegativeCoordinates.
Specifies if cell sizes should be automatically updated after a label change.
This implementation sets autoSizeCells to the given parameter.
To update the size of cells when the cells are added, set autoSizeCellsOnAdd to true
.
Boolean indicating if cells should be resized automatically.
Specifies if the graph should allow bending of edges.
This implementation updates cellsBendable.
Boolean indicating if the graph should allow bending of edges.
Specifies if the graph should allow cloning of cells by holding down the control key while cells are being moved.
This implementation updates cellsCloneable.
Boolean indicating if the graph should be cloneable.
Sets cellsDeletable.
Boolean indicating if the graph should allow deletion of cells.
Sets cellsDisconnectable.
Specifies if the graph should allow in-place editing for cell labels.
This implementation updates cellsEditable.
Boolean indicating if the graph should allow in-place editing.
Sets if any cell may be moved, sized, bended, disconnected, edited or selected.
Boolean that defines the new value for cellsLocked.
Specifies if the graph should allow moving of cells.
This implementation updates cellsMovable.
Boolean indicating if the graph should allow moving of cells.
Specifies if the graph should allow resizing of cells. This implementation updates cellsResizable.
Boolean indicating if the graph should allow resizing of cells.
Sets cellsSelectable.
Sets the style of the specified cells. If no cells are given, then the selection cells are changed.
IMPORTANT: Do not pass Cell.getStyle as value of the style
parameter. Always get a clone of the style of the cell with Cell.getClonedStyle, then update it and pass the updated style to this method.
For more details, see GraphDataModel.setStyle.
Sets or toggles the given bit for the given key in the styles of the specified cells.
String representing the key to toggle the flag in.
Integer that represents the bit to be toggled.
Optional
value: null | booleanBoolean value to be used or null
if the value should be toggled. Default is null
.
Optional
cells: null | Cell[]Optional array of Cell to change the style for. Default is the selection cells.
Sets the key to value in the styles of the given cells. This will modify the existing cell styles in-place and override any existing assignment for the given key.
If no cells are specified, then the selection cells are changed.
If no value is specified, then the respective key is removed from the styles.
String representing the key to be assigned.
String representing the new value for the key.
Optional
cells: Cell[]Optional array of Cell to change the style for. Default is the selection cells.
Creates an overlay for the given cell using the warning and image or warningImage and returns the new CellOverlay.
The warning is displayed as a tooltip in a red font and may contain HTML markup.
If the warning is null
or a zero length string, then all overlays are removed from the cell.
Cell whose warning should be set.
String that represents the warning to be displayed.
Optional
img: ImageBoxOptional Image to be used for the overlay. Default is warningImage.
Optional
isSelect: booleanOptional boolean indicating if a click on the overlay should select the corresponding cell. Default is false
.
Sets cloneInvalidEdges.
Specifies if the graph should allow new connections.
This implementation updates ConnectionHandler.enabled.
Boolean indicating if new connections should be allowed.
Specifies if edges should be connectable.
Boolean indicating if edges should be connectable.
Sets the ConnectionConstraint that describes the given connection point. If no constraint is given then nothing is changed.
To remove an existing constraint from the given edge, use an empty constraint instead.
Cell that represents the edge.
Cell that represents the terminal.
Boolean indicating if the terminal is the source or target. Default is false
.
Optional ConnectionConstraint to be used for this connection.
Sets constrainChildren.
Specifies if edges should be disconnected when moved.
Note: cloned edges are always disconnected.
Boolean indicating if edges should be disconnected when moved.
Specifies if the graph should allow dropping of cells onto or into other cells.
Boolean indicating if the graph should allow dropping of cells into other cells.
Sets edgeLabelsMovable.
Sets enterStopsCellEditing.
Sets escapeEnabled.
Boolean indicating if escape should be enabled.
Sets extendParents.
New boolean value for extendParents.
Sets extendParentsOnAdd.
New boolean value for extendParentsOnAdd.
Sets extendParentsOnMove.
New boolean value for extendParentsOnAdd.
Specifies if the grid should be enabled.
Boolean indicating if the grid should be enabled.
Sets gridSize.
Sets htmlLabels.
Sets invokesStopCellEditing.
Specifies if panning should be enabled. This implementation updates PanningHandler.panningEnabled.
IMPORTANT*: only has an effect if the PanningHandler plugin is available.
Boolean indicating if panning should be enabled.
Specifies if the ports should be enabled.
Boolean indicating if the ports should be enabled.
Sets the selection cell.
Sets the selection cell.
Sets the GraphSelectionModel that contains the selection.
Specifies if the graph should allow dropping of cells onto or into other cells.
Boolean indicating if the graph should allow dropping of cells into other cells.
Specifies if swimlanes can be nested by drag and drop. This is only taken into account if dropEnabled is true.
Boolean indicating if swimlanes can be nested.
Specifies if swimlanes should be selected if the mouse is released over their content area.
Boolean indicating if swimlanes content areas should be selected when the mouse is released over them.
Specifies if tooltips should be enabled.
This implementation updates TooltipHandler.enabled.
IMPORTANT: only has an effect if the TooltipHandler plugin is available.
Boolean indicating if tooltips should be enabled.
Sets vertexLabelsMovable.
Called when the size of the graph has changed.
This implementation fires a size event after updating the clipping region of the SVG element in SVG-bases browsers.
Snaps the given numeric value to the grid if gridEnabled is true.
Numeric value to be snapped to the grid.
Snaps the given delta with the given scaled bounds.
Splits the given edge by adding the newEdge between the previous source and the given cell and reconnecting the source of the given edge to the given cell.
This method fires InternalEvent.SPLIT_EDGE while the transaction is in progress.
Cell that represents the edge to be split.
Cells that represents the cells to insert into the edge.
Optional
dx: numberOptional integer that specifies the vector to move the cells.
Optional
dy: numberOptional integer that specifies the vector to move the cells.
Optional
x: numberInteger that specifies the x-coordinate of the drop location.
Optional
y: numberInteger that specifies the y-coordinate of the drop location.
Optional
parent: null | CellOptional parent to insert the cell. If null
, the parent of the edge is used.
The new edge that was inserted.
Specifies if dropping onto edges should be enabled.
This is ignored if dropEnabled is false
.
If enabled, it will call splitEdge to carry out the drop operation.
Calls startEditingAtCell using the given cell or the first selection cell.
Optional mouse event that triggered the editing.
Fires a InternalEvent.START_EDITING event and invokes CellEditorHandler.startEditing. After editing was started, a InternalEvent.EDITING_STARTED event is fired.
Stops the current editing and fires a InternalEvent.EDITING_STOPPED event.
Boolean that specifies if the current editing value should be stored.
Holds the Stylesheet that defines the appearance of the cells.
Use the following code to read a stylesheet into an existing graph.
Swaps the alternate and the actual bounds in the geometry of the given cell invoking updateAlternateBounds before carrying out the swap.
The attribute used to find the color for the indicator if the indicator color is set to 'swimlane'.
Specifies if nesting of swimlanes is allowed.
Specifies if swimlanes should be selectable via the content if the mouse is released.
Handles the InternalMouseEvent by highlighting the CellState.
mxMouseEvent that represents the touch event.
Specifies the time in milliseconds for a tap and hold.
Specifies if tap and hold should be used for starting connections on touch-based devices.
true
if the timer for tap and hold events is running.
true
as long as the timer is running and the touch events stay within the given tapAndHoldTolerance.
Specifies if auto scrolling should be carried out via PanningHandler even if the container has scrollbars.
This disables scrollPointToVisible and uses PanningManager instead. If this is true
then autoExtend is disabled.
It should only be used with a scroll buffer or when scrollbars are visible and scrollable in all directions.
Sets the visible state of the specified cells and all connected edges if includeEdges is true. The change is carried out using cellsToggled. This method fires InternalEvent.TOGGLE_CELLS while the transaction is in progress. Returns the cells whose visible state was changed.
Boolean that specifies the visible state to be assigned.
Array of Cell whose visible state should be changed. If null
is specified then the selection cells are used.
Optional boolean indicating if the visible state of all connected edges should be changed as well. Default is true
.
Toggles the boolean value for the given key in the style of the given cell and returns the new value as boolean.
If no cell is specified then the selection cell is used.
String representing the key for the boolean value to be toggled.
Optional
defaultValue: booleanOptional boolean default value if no value is defined. Default is false
.
Optional
cell: CellOptional Cell whose style should be modified. Default is the selection cell.
Toggles the given bit for the given key in the styles of the specified cells.
String representing the key to toggle the flag in.
Integer that represents the bit to be toggled.
Optional
cells: null | Cell[]Optional array of Cell to change the style for. Default is the selection cells.
Toggles the boolean value for the given key in the style of the given cells and returns the new value as boolean.
If no cells are specified, then the selection cells are used.
For example, this can be used to toggle CellStateStyle.rounded or any other style with a boolean value.
String representing the key for the boolean value to be toggled.
Optional
defaultValue: booleanOptional boolean default value if no value is defined. Default is false
.
Optional
cells: Cell[]Optional array of Cell whose styles should be modified. Default is the selection cells.
Tolerance in pixels for a move to be handled as a single click.
Translates the geometry of the given cell and stores the new, translated geometry in the model as an atomic change.
Specifies if the graph should automatically convert the current scroll position to a translate in the graph view when a mouseUp event is received. This can be used to avoid conflicts when using autoScroll and ignoreScrollbars with no scrollbars in the container.
Ungroups the given cells by moving the children to their parents parent and removing the empty groups.
Updates or sets the alternate bounds in the given geometry for the given cell depending on whether the cell is going to be collapsed.
If no alternate bounds are defined in the geometry and collapseToPreferredSize is true
,
then the preferred size is used for the alternate bounds.
The top, left corner is always kept at the same location.
Updates the size of the given cell in the model using cellSizeUpdated. This method fires InternalEvent.UPDATE_CELL_SIZE while the transaction is in progress. Returns the cell whose size was updated.
Updates the bounds of the given groups to include all children and returns the passed-in cells.
Call this with the groups in parent to child order, top-most group first, the cells are processed in reverse order and cells with no children are ignored.
The groups whose bounds should be updated. If this is null
, then the selection cells are used.
Optional
border: numberOptional border to be added in the group. Default is 0
.
Optional
moveGroup: booleanOptional boolean that allows the group to be moved. Default is false
.
Optional
topBorder: numberOptional top border to be added in the group. Default is 0
.
Optional
rightBorder: numberOptional top border to be added in the group. Default is 0
.
Optional
bottomBorder: numberOptional top border to be added in the group. Default is 0
.
Optional
leftBorder: numberOptional top border to be added in the group. Default is 0
.
Sets the graphX and graphY properties if the given InternalMouseEvent if required and returned the event.
InternalMouseEvent to be updated.
Name of the mouse event.
Invokes from sizeDidChange to redraw the page breaks.
Boolean that specifies if page breaks should be shown.
Specifies the width of the container in pixels.
Specifies the height of the container in pixels.
Removes selection cells that are not in the model from the selection.
Specifies if scrollbars should be used for panning in panGraph if any scrollbars are available.
If scrollbars are enabled in CSS, but no scrollbars appear because the graph is smaller than the container size,
then no panning occurs if this is true
.
Hook method for subclasses to return an error message for the given cell and validation context.
Any HTML breaks will be converted to linefeed in the calling method.
This implementation returns null
.
Hook method for subclasses to return an error message for the given edge and terminals.
This implementation returns null
.
Validates the graph by validating each descendant of the given cell or the root of the model. Context is an object that contains the validation state for the complete validation run. The validation errors are attached to their cells using setCellWarning. Returns null in the case of successful validation or an array of strings (warnings) in the case of failed validations.
Displays the given validation error in a dialog.
This implementation uses window.alert
.
Specifies the return value for vertices in isLabelMovable.
Specifies the Image for the image to be used to display a warning overlay. See setCellWarning. Default value is Client.imageBasePath + '/warning'. The extension for the image depends on the platform. It is '.png' on the Mac and '.gif' on all other platforms.
Zooms the graph using the given factor. Center is an optional boolean argument that keeps the graph scrolled to the center. If the center argument is omitted, then centerZoom will be used as its value.
Resets the zoom in the view to the original scale.
Zooms into the graph by zoomFactor.
Zooms out of the graph by zoomFactor.
Zooms the graph to the given scale with an optional boolean center argument, which is passed to zoom.
Zooms the graph to the specified rectangle. If the rectangle does not have same aspect ratio as the display container, it is increased in the smaller relative dimension only until the aspect match. The original rectangle is centralised within this expanded one.
Note that the input rectangular must be un-scaled and un-translated.
The un-scaled and un-translated rectangluar region that should be just visible after the operation
Binds the specified function to the given event name. If no event name is given, then the listener is registered for all events.
The parameters of the listener are the sender and an EventObject.
Centers the graph in the container.
Optional boolean that specifies if the graph should be centered
horizontally. Default is true
.
Optional boolean that specifies if the graph should be centered
vertically. Default is true
.
Optional float that specifies the horizontal center. Default is 0.5
.
Optional float that specifies the vertical center. Default is 0.5
.
Returns the textual representation for the given cell.
This implementation returns the node name or string-representation of the user object.
The following returns the label attribute from the cells user object if it is an XML node.
graph.convertValueToString = function(cell)
{
return cell.getAttribute('label');
}
See also: cellLabelChanged.
Creates a new CellRenderer to be used in this graph.
Hooks to create a new EdgeHandler for the given CellState.
CellState to create the handler for.
the EdgeStyleFunction that let choose the actual edge handler.
Hooks to create a new EdgeHandler for the given CellState.
Hooks to create a new EdgeSegmentHandler for the given CellState.
Hooks to create a new ElbowEdgeHandler for the given CellState.
Creates a new GraphDataModel to be used in this graph.
Creates a new handler for the given cell state. This implementation returns a new EdgeHandler of the corresponding cell is an edge, otherwise it returns an VertexHandler.
Creates a new Stylesheet to be used in this graph.
Hook method that creates the new vertex for insertVertex.
IMPORTANT:
x
and y
parameters), it is advised to use a GraphLayout or a LayoutManager to automatically compute the actual position.width
and the height
parameters), it is advised to later set the size on the geometry of the vertex instance.
Otherwise, the vertex has no size and it is not displayed.the parent of the new vertex. If not set, use the default parent.
Optional string that defines the id of the new vertex. If not set, the id is auto-generated when creating the vertex.
Object to be used as the user object.
Optional
x: numberthe x coordinate of the vertex.
Optional
y: numberthe y coordinate of the vertex.
Optional
width: numberthe width of the vertex.
Optional
height: numberthe height of the vertex.
Optional
style: CellStylethe cell style.
Optional
relative: booleanspecifies if the geometry is relative. Default is false
.
Optional
geometryClass: typeof GeometryHooks to create a new VertexHandler for the given CellState.
Dispatches the given event to the listeners which are registered for the event. The sender argument is optional. The current execution scope ("this") is used for the listener invocation (see Utils#bind).
Example:
fireEvent(new mxEventObject("eventName", key1, val1, .., keyN, valN))
EventObject that represents the event.
Optional sender to be passed to the listener. Default value is
the return value of
Scales the graph such that the complete diagram fits into
graph.fit();
graph.view.rendering = true;
graph.refresh();
To fit and center the graph, the following code can be used.
let margin = 2;
let max = 3;
let bounds = graph.getGraphBounds();
let cw = graph.container.clientWidth - margin;
let ch = graph.container.clientHeight - margin;
let w = bounds.width / graph.view.scale;
let h = bounds.height / graph.view.scale;
let s = Math.min(max, Math.min(cw / w, ch / h));
graph.view.scaleAndTranslate(s,
(margin + cw - w * s) / (2 * s) - bounds.x / graph.view.scale,
(margin + ch - h * s) / (2 * s) - bounds.y / graph.view.scale);
Optional number that specifies the border. Default is
Optional boolean that specifies if the translate should be changed. Default is false.
Optional margin in pixels. Default is 0.
Optional boolean that specifies if the scale should be set or just returned. Default is true.
Optional boolean that specifies if the width should be ignored. Default is false.
Optional boolean that specifies if the height should be ignored. Default is false.
Optional maximum height.
Returns the backgroundImage as an Image.
Returns the value of border.
Returns the offset to be used for the cells inside the given cell. The root and layer cells may be identified using GraphDataModel.isRoot and GraphDataModel.isLayer. For all other current roots, the GraphView.currentRoot field points to the respective cell, so that the following holds: cell == this.view.currentRoot. This implementation returns null.
mxCell whose offset should be returned.
Returns the current root of the displayed cell hierarchy. This is a shortcut to GraphView.currentRoot in GraphView.
Returns the GraphDataModel that contains the cells.
Returns defaultParent or GraphView.currentRoot or the first child child of GraphDataModel.root if both are null. The value returned by this function should be used as the parent for new cells (aka default layer).
Returns the bounds of the visible graph. Shortcut to GraphView.getGraphBounds. See also: getBoundingBoxFromGeometry.
Returns a decimal number representing the amount of the width and height of the given cell that is allowed to overlap its parent. A value of 0 means all children must stay inside the parent, 1 means the child is allowed to be placed outside of the parent such that it touches one of the parents sides. If isAllowOverlapParent returns false for the given cell, then this method returns 0.
mxCell for which the overlap ratio should be returned.
Returns the preferred size of the background page if preferPageSize is true.
Returns the Stylesheet that defines the style.
Returns the translation to be used if the given cell is the root cell as an Point. This implementation returns null.
To keep the children at their absolute position while stepping into groups, this function can be overridden as follows.
mxCell that represents the root.
Called when the graph model changes. Invokes processChange on each item of the given array to update the view accordingly.
Array that contains the individual changes.
Adds a new edge into the given parent Cell using value as the user object and the given source and target as the terminals of the new edge. The id and style are used for the respective properties of the new Cell, which is returned.
Cell that specifies the parent of the new edge. If not set, use the default parent.
Optional string that defines the Id of the new edge. If not set, the id is auto-generated when creating the vertex.
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.
Optional
source: null | CellCell that defines the source of the edge.
Optional
target: null | CellCell that defines the target of the edge.
Optional
style: CellStyleOptional object that defines the cell style.
Adds a new edge into the given parent Cell using value as the user object and the given source and target as the terminals of the new edge. The id and style are used for the respective properties of the new Cell, which is returned.
the parameters used to create the new edge.
Adds a new vertex into the given parent Cell using value as the user
object and the given coordinates as the Geometry of the new vertex.
The id and style are used for the respective properties of the new Cell
, which is returned.
IMPORTANT:
mxGraph
. Use the insertVertex method with a single object parameter instead.x
and y
parameters), it is advised to use a GraphLayout or a LayoutManager to automatically compute the actual position.width
and the height
parameters), it is advised to later set the size on the geometry of the vertex instance.
Otherwise, the vertex has no size and it is not displayed.When adding new vertices from a mouse event, one should take into account the offset of the graph container and the scale and translation of the view in order to find the correct unscaled, untranslated coordinates using Graph#getPointForEvent as follows:
const pt = graph.getPointForEvent(evt);
const parent = graph.getDefaultParent();
graph.insertVertex(parent, null, 'Hello, World!', pt.x, pt.y, 220, 30);
For adding image cells, the style parameter can be assigned as
style: {
image: imageUrl,
}
See Graph for more information on using images.
the parent of the new vertex. If not set, use the default parent.
Optional string that defines the id of the new vertex. If not set, the id is auto-generated when creating the vertex.
Object to be used as the user object.
Optional
x: numberthe x coordinate of the vertex.
Optional
y: numberthe y coordinate of the vertex.
Optional
width: numberthe width of the vertex.
Optional
height: numberthe height of the vertex.
Optional
style: CellStylethe cell style.
Optional
relative: booleanspecifies if the geometry is relative. Default is false
.
Optional
geometryClass: typeof GeometryAdds a new vertex into the given parent Cell using value as the user
object and the given coordinates as the Geometry of the new vertex.
The id and style are used for the respective properties of the new Cell
, which is returned.
When adding new vertices from a mouse event, one should take into account the offset of the graph container and the scale and translation of the view in order to find the correct unscaled, untranslated coordinates using Graph#getPointForEvent as follows:
const pt = graph.getPointForEvent(evt);
const parent = graph.getDefaultParent();
graph.insertVertex({
parent,
position: [pt.x, pt.y],
size: [220, 30],
value: 'Hello, World!',
});
For adding image cells, the style parameter can be assigned as
style: {
image: imageUrl,
}
See Graph for more information on using images.
the parameters used to create the new vertex.
Returns allowLoops as a boolean.
Returns true if the given cell is allowed to be placed outside of the parents area.
mxCell that represents the child to be checked.
Returns true if the graph is enabled.
Returns multigraph as a boolean.
Returns recursiveResize.
Returns resizeContainer.
Returns true if the given cell is a valid root for the cell display hierarchy. This implementation returns true for all non-null values.
mxCell which should be checked as a possible root.
Processes the given change and invalidates the respective cached data in GraphView. This fires a root event if the root has changed in the model.
Object that represents the change on the model.
Protected
registerSets the new backgroundImage.
Sets the value of border.
Positive integer that represents the border to be used.
Sets the defaultParent to the given cell. Set this to null to return the first child of the root in getDefaultParent.
Specifies if the graph should allow any interactions. This implementation updates enabled.
Boolean indicating if the graph should be enabled.
Sets recursiveResize.
New boolean value for recursiveResize.
Sets resizeContainer.
Boolean indicating if the container should be resized.
Sets the Stylesheet that defines the style.
Extends EventSource to implement a graph component for the browser. This is the main 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.