GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • @maxgraph/core

This view

  • Original page
  • New address

GeezerVison is showing maxgraph.github.io — Cell | @maxgraph/core

  • Cell

Class Cell

Cells are the elements of the graph model. They represent the state of the groups, vertices and edges in a graph.

Custom attributes

For custom attributes we recommend using an XML node as the value of a cell. The following code can be used to create a cell with an XML node as the value:

const doc = xmlUtils.createXmlDocument();
const node = doc.createElement('MyNode')
node.setAttribute('label', 'MyLabel');
node.setAttribute('attribute1', 'value1');
graph.insertVertex({parent: graph.getDefaultParent(), value: node, position: [40, 40], size: [80, 30]});

For the label to work, AbstractGraph.convertValueToString and AbstractGraph.cellLabelChanged should be overridden as follows:

graph.convertValueToString(cell) {
if (domUtils.isNode(cell.value)) {
return cell.getAttribute('label', '')
}
};

const cellLabelChanged = graph.cellLabelChanged;
graph.cellLabelChanged(cell, newValue, autoSize) {
if (domUtils.isNode(cell.value)) {
// Clones the value for correct undo/redo
const elt = cell.value.cloneNode(true);
elt.setAttribute('label', newValue);
newValue = elt;
}

cellLabelChanged.apply(this, arguments);
};

Hierarchy (View Summary)

  • Cell
    • GraphAbstractHierarchyCell

Implements

  • IdentityObject
  • Defined in view/cell/Cell.ts:66
Index

Constructors

constructor

Properties

children collapsed connectable edge edges geometry id invalidating mxTransient onInit overlays parent source style target value vertex visible

Methods

clone cloneValue filterDescendants getAttribute getChildAt getChildCells getChildCount getChildEdges getChildren getChildVertices getClonedStyle getConnections getDescendants getDirectedEdgeCount getEdgeAt getEdgeCount getEdgeIndex getEdges getGeometry getId getIncomingEdges getIndex getNearestCommonAncestor getOrigin getOutgoingEdges getParent getRoot getStyle getTerminal getValue hasAttribute insert insertEdge isAncestor isCollapsed isConnectable isEdge isVertex isVisible remove removeEdge removeFromParent removeFromTerminal setAttribute setCollapsed setConnectable setEdge setGeometry setId setParent setStyle setTerminal setValue setVertex setVisible valueChanged

Constructors

constructor

  • new Cell(value?: any, geometry?: Geometry | null, style?: CellStyle): Cell

    Parameters

    • value: any = null
    • geometry: Geometry | null = null
    • style: CellStyle = {}

    Returns Cell

    • Defined in view/cell/Cell.ts:67

Properties

children

children: Cell[] = []

Holds the child cells.

Default

[]
  • Defined in view/cell/Cell.ts:170

collapsed

collapsed: boolean = false

Specifies whether the cell is collapsed.

Default

false
  • Defined in view/cell/Cell.ts:146

connectable

connectable: boolean = true

Specifies whether the cell is connectable.

Default

true
  • Defined in view/cell/Cell.ts:134

edge

edge: boolean = false

Specifies whether the cell is an edge.

Default

false
  • Defined in view/cell/Cell.ts:128

edges

edges: Cell[] = []

Holds the edges.

Default

[]
  • Defined in view/cell/Cell.ts:176

geometry

geometry: Geometry | null = null

Holds the Geometry.

Default

null
  • Defined in view/cell/Cell.ts:110

id

id: string | null = null

Holds the identifier of the Cell.

Default

null
  • Defined in view/cell/Cell.ts:98

invalidating

invalidating: boolean = false
  • Defined in view/cell/Cell.ts:87

mxTransient

mxTransient: string[] = ...

List of members that should not be cloned inside clone. This field is passed to utils.clone and is not made persistent in CellCodec. This is not a convention for all classes, it is only used in this class to mark transient fields since transient modifiers are not supported by the language.

  • Defined in view/cell/Cell.ts:185

onInit

onInit: (() => void) | null = null
  • Defined in view/cell/Cell.ts:89

overlays

overlays: CellOverlay[] = []
  • Defined in view/cell/Cell.ts:92

parent

parent: Cell | null = null

Reference to the parent cell.

Default

null
  • Defined in view/cell/Cell.ts:152

source

source: Cell | null = null

Reference to the source terminal.

Default

null
  • Defined in view/cell/Cell.ts:158

style

style: CellStyle = {}

Holds the style of the Cell.

Default

{}
  • Defined in view/cell/Cell.ts:116

target

target: Cell | null = null

Reference to the target terminal.

Default

null
  • Defined in view/cell/Cell.ts:164

value

value: any = null

Holds the user object.

Default

null
  • Defined in view/cell/Cell.ts:104

vertex

vertex: boolean = false

Specifies whether the cell is a vertex.

Default

false
  • Defined in view/cell/Cell.ts:122

visible

visible: boolean = true

Specifies whether the cell is visible.

Default

true
  • Defined in view/cell/Cell.ts:140

Methods

clone

  • clone(): Cell

    Returns a clone of the cell.

    Uses cloneValue to clone the user object.

    All fields in mxTransient are ignored during the cloning.

    Returns Cell

    • Defined in view/cell/Cell.ts:608

cloneValue

  • cloneValue(): any

    Returns a clone of the cell's user object.

    Returns any

    • Defined in view/cell/Cell.ts:617

filterDescendants

  • filterDescendants(filter: FilterFunction | null): Cell[]

    Visits all cells recursively and applies the specified filter function to each cell. If the function returns true then the cell is added to the resulting array. The parent and result paramters are optional. If parent is not specified then the recursion starts at root.

    Example: The following example extracts all vertices from a given model:

    var filter(cell)
    {
    return model.isVertex(cell);
    }
    var vertices = model.filterDescendants(filter);

    Parameters

    • filter: FilterFunction | null

      JavaScript function that takes an Cell as an argument and returns a boolean.

    Returns Cell[]

    • Defined in view/cell/Cell.ts:863

getAttribute

  • getAttribute(name: string, defaultValue?: any): any

    Returns the specified attribute from the user object if it is an XML node.

    Parameters

    • name: string

      Name of the attribute whose value should be returned.

    • OptionaldefaultValue: any

      Optional default value to use if the attribute has no value.

    Returns any

    • Defined in view/cell/Cell.ts:580

getChildAt

  • getChildAt(index: number): Cell

    Returns the child at the specified index.

    Parameters

    • index: number

      Integer that specifies the child to be returned.

    Returns Cell

    • Defined in view/cell/Cell.ts:420

getChildCells

  • getChildCells(vertices?: boolean, edges?: boolean): Cell[]

    Returns the children of the given cell that are vertices and/or edges depending on the arguments.

    Parameters

    • vertices: boolean = false

      Boolean indicating if child vertices should be returned. Default is false.

    • edges: boolean = false

      Boolean indicating if child edges should be returned. Default is false.

    Returns Cell[]

    • Defined in view/cell/Cell.ts:708

getChildCount

  • getChildCount(): number

    Returns the number of child cells.

    Returns number

    • Defined in view/cell/Cell.ts:401

getChildEdges

  • getChildEdges(): Cell[]

    Returns the child edges of the given parent.

    Returns Cell[]

    • Defined in view/cell/Cell.ts:695

getChildren

  • getChildren(): Cell[]

    Returns Cell[]

    • Defined in view/cell/Cell.ts:81

getChildVertices

  • getChildVertices(): Cell[]

    Returns the child vertices of the given parent.

    Returns Cell[]

    • Defined in view/cell/Cell.ts:688

getClonedStyle

  • getClonedStyle(): CellStyle

    Use this method to get the style object to later update it and propagate changes to the view.

    See GraphDataModel.setStyle for more details.

    Returns CellStyle

    • Defined in view/cell/Cell.ts:263

getConnections

  • getConnections(): Cell[]

    Returns all edges of the given cell without loops.

    Returns Cell[]

    • Defined in view/cell/Cell.ts:758

getDescendants

  • getDescendants(): Cell[]

    Returns all descendants of the given cell and the cell itself in an array.

    Returns Cell[]

    • Defined in view/cell/Cell.ts:840

getDirectedEdgeCount

  • getDirectedEdgeCount(outgoing: boolean, ignoredEdge?: Cell | null): number

    Returns the number of incoming or outgoing edges, ignoring the given edge.

    Parameters

    • outgoing: boolean

      Boolean that specifies if the number of outgoing or incoming edges should be returned.

    • ignoredEdge: Cell | null = null

      that represents an edge to be ignored.

    Returns number

    • Defined in view/cell/Cell.ts:738

getEdgeAt

  • getEdgeAt(index: number): Cell

    Returns the edge at the specified index in edges.

    Parameters

    • index: number

      Integer that specifies the index of the edge to be returned.

    Returns Cell

    • Defined in view/cell/Cell.ts:500

getEdgeCount

  • getEdgeCount(): number

    Returns the number of edges in the edge array.

    Returns number

    • Defined in view/cell/Cell.ts:482

getEdgeIndex

  • getEdgeIndex(edge: Cell): number

    Returns the index of the specified edge in edges.

    Parameters

    • edge: Cell

      Cell whose index in edges should be returned.

    Returns number

    • Defined in view/cell/Cell.ts:491

getEdges

  • getEdges(incoming?: boolean, outgoing?: boolean, includeLoops?: boolean): Cell[]

    Returns all distinct edges connected to this cell as a new array of Cell. If at least one of incoming or outgoing is true, then loops are ignored, otherwise if both are false, then all edges connected to the given cell are returned including loops.

    Parameters

    • incoming: boolean = true

      Optional boolean that specifies if incoming edges should be returned. Default is true.

    • outgoing: boolean = true

      Optional boolean that specifies if outgoing edges should be returned. Default is true.

    • includeLoops: boolean = true

      Optional boolean that specifies if loops should be returned. Default is true.

    Returns Cell[]

    • Defined in view/cell/Cell.ts:789

getGeometry

  • getGeometry(): Geometry | null

    Returns the Geometry that describes the geometry.

    Returns Geometry | null

    • Defined in view/cell/Cell.ts:238

getId

  • getId(): string | null

    Returns the Id of the cell as a string.

    Returns string | null

    • Defined in view/cell/Cell.ts:198

getIncomingEdges

  • getIncomingEdges(): Cell[]

    Returns the incoming edges of the given cell without loops.

    Returns Cell[]

    • Defined in view/cell/Cell.ts:765

getIndex

  • getIndex(child: Cell | null): number

    Returns the index of the specified child in the child array.

    Parameters

    • child: Cell | null

      Child whose index should be returned.

    Returns number

    • Defined in view/cell/Cell.ts:410

getNearestCommonAncestor

  • getNearestCommonAncestor(cell2: Cell): Cell | null

    Returns the nearest common ancestor for the specified cells to this.

    Parameters

    • cell2: Cell

      that specifies the second cell in the tree.

    Returns Cell | null

    • Defined in view/cell/Cell.ts:637

getOrigin

  • getOrigin(): Point

    Returns the absolute, accumulated origin for the children inside the given parent as an Point.

    Returns Point

    • Defined in view/cell/Cell.ts:817

getOutgoingEdges

  • getOutgoingEdges(): Cell[]

    Returns the outgoing edges of the given cell without loops.

    Returns Cell[]

    • Defined in view/cell/Cell.ts:772

getParent

  • getParent(): Cell | null

    Returns the cell's parent.

    Returns Cell | null

    • Defined in view/cell/Cell.ts:359

getRoot

  • getRoot(): Cell

    Returns the root of the model or the topmost parent of the given cell.

    Returns Cell

    • Defined in view/cell/Cell.ts:889

getStyle

  • getStyle(): CellStyle

    Returns a string that describes the style.

    IMPORTANT: if you want to get the style object to later update it and propagate changes to the view, use getClonedStyle instead.

    Returns CellStyle

    • Defined in view/cell/Cell.ts:254

getTerminal

  • getTerminal(source?: boolean): Cell | null

    Returns the source or target terminal.

    Parameters

    • source: boolean = false

      Boolean that specifies if the source terminal should be returned.

    Returns Cell | null

    • Defined in view/cell/Cell.ts:378

getValue

  • getValue(): any

    Returns the user object of the cell. The user object is stored in value.

    Returns any

    • Defined in view/cell/Cell.ts:212

hasAttribute

  • hasAttribute(name: string): boolean

    Returns true if the user object is an XML node that contains the given attribute.

    Parameters

    • name: string

      Name nameName of the attribute.

    Returns boolean

    • Defined in view/cell/Cell.ts:565

insert

  • insert(child: Cell, index?: number): Cell | null

    Inserts the specified child into the child array at the specified index and updates the parent reference of the child. If not index is specified, then the child is appended to the child array. Returns the inserted child.

    Parameters

    • child: Cell

      Cell to be inserted or appended to the child array.

    • Optionalindex: number

      Optional integer that specifies the index at which the child should be inserted into the child array.

    Returns Cell | null

    • Defined in view/cell/Cell.ts:432

insertEdge

  • insertEdge(edge: Cell, isOutgoing?: boolean): Cell

    Inserts the specified edge into the edge array and returns the edge. Will update the respective terminal reference of the edge.

    Parameters

    • edge: Cell

      Cell to be inserted into the edge array.

    • isOutgoing: boolean = false

      Boolean that specifies if the edge is outgoing.

    Returns Cell

    • Defined in view/cell/Cell.ts:511

isAncestor

  • isAncestor(child: Cell | null): boolean

    Returns true if the given parent is an ancestor of the given child. Note returns true if child == parent.

    Parameters

    • child: Cell | null

      that specifies the child.

    Returns boolean

    • Defined in view/cell/Cell.ts:677

isCollapsed

  • isCollapsed(): boolean

    Returns true if the cell is collapsed.

    Returns boolean

    • Defined in view/cell/Cell.ts:343

isConnectable

  • isConnectable(): boolean

    Returns true if the cell is connectable.

    Returns boolean

    • Defined in view/cell/Cell.ts:311

isEdge

  • isEdge(): boolean

    Returns true if the cell is an edge.

    Returns boolean

    • Defined in view/cell/Cell.ts:294

isVertex

  • isVertex(): boolean

    Returns true if the cell is a vertex.

    Returns boolean

    • Defined in view/cell/Cell.ts:277

isVisible

  • isVisible(): boolean

    Returns true if the cell is visibile.

    Returns boolean

    • Defined in view/cell/Cell.ts:327

remove

  • remove(index: number): Cell | null

    Removes the child at the specified index from the child array and returns the child that was removed. Will remove the parent reference of the child.

    Parameters

    • index: number

      Integer that specifies the index of the child to be removed.

    Returns Cell | null

    • Defined in view/cell/Cell.ts:455

removeEdge

  • removeEdge(edge: Cell | null, isOutgoing?: boolean): Cell | null

    Removes the specified edge from the edge array and returns the edge. Will remove the respective terminal reference from the edge.

    Parameters

    • edge: Cell | null

      Cell to be removed from the edge array.

    • isOutgoing: boolean = false

      Boolean that specifies if the edge is outgoing.

    Returns Cell | null

    • Defined in view/cell/Cell.ts:533

removeFromParent

  • removeFromParent(): void

    Removes the cell from its parent.

    Returns void

    • Defined in view/cell/Cell.ts:472

removeFromTerminal

  • removeFromTerminal(isSource: boolean): void

    Removes the edge from its source or target terminal.

    Parameters

    • isSource: boolean

      Boolean that specifies if the edge should be removed from its source or target terminal.

    Returns void

    • Defined in view/cell/Cell.ts:552

setAttribute

  • setAttribute(name: string, value: any): void

    Sets the specified attribute on the user object if it is an XML node.

    Parameters

    • name: string

      Name of the attribute whose value should be set.

    • value: any

      New value of the attribute.

    Returns void

    • Defined in view/cell/Cell.ts:593

setCollapsed

  • setCollapsed(collapsed: boolean): void

    Sets the collapsed state.

    Parameters

    • collapsed: boolean

      Boolean that specifies the new collapsed state.

    Returns void

    • Defined in view/cell/Cell.ts:352

setConnectable

  • setConnectable(connectable: boolean): void

    Sets the connectable state.

    Parameters

    • connectable: boolean

      Boolean that specifies the new connectable state.

    Returns void

    • Defined in view/cell/Cell.ts:320

setEdge

  • setEdge(edge: boolean): void

    Specifies if the cell is an edge. This should only be assigned at construction of the cell and not be changed during its lifecycle.

    Parameters

    • edge: boolean

      Boolean that specifies if the cell is an edge.

    Returns void

    • Defined in view/cell/Cell.ts:304

setGeometry

  • setGeometry(geometry: Geometry | null): void

    Sets the Geometry to be used as the geometry.

    Parameters

    • geometry: Geometry | null

    Returns void

    • Defined in view/cell/Cell.ts:245

setId

  • setId(id: string): void

    Sets the Id of the cell to the given string.

    Parameters

    • id: string

    Returns void

    • Defined in view/cell/Cell.ts:205

setParent

  • setParent(parent: Cell | null): void

    Sets the parent cell.

    Parameters

    • parent: Cell | null

    Returns void

    • Defined in view/cell/Cell.ts:368

setStyle

  • setStyle(style: CellStyle): void

    Sets the string to be used as the style.

    Parameters

    • style: CellStyle

    Returns void

    • Defined in view/cell/Cell.ts:270

setTerminal

  • setTerminal(terminal: Cell | null, isSource: boolean): Cell | null

    Sets the source or target terminal and returns the new terminal.

    Parameters

    • terminal: Cell | null

      Cell that represents the new source or target terminal.

    • isSource: boolean

      boolean that specifies if the source or target terminal should be set.

    Returns Cell | null

    • Defined in view/cell/Cell.ts:388

setValue

  • setValue(value: any): void

    Sets the user object of the cell. The user object is stored in value.

    Parameters

    • value: any

    Returns void

    • Defined in view/cell/Cell.ts:219

setVertex

  • setVertex(vertex: boolean): void

    Specifies if the cell is a vertex. This should only be assigned at construction of the cell and not be changed during its lifecycle.

    Parameters

    • vertex: boolean

      Boolean that specifies if the cell is a vertex.

    Returns void

    • Defined in view/cell/Cell.ts:287

setVisible

  • setVisible(visible: boolean): void

    Specifies if the cell is visible.

    Parameters

    • visible: boolean

      Boolean that specifies the new visible state.

    Returns void

    • Defined in view/cell/Cell.ts:336

valueChanged

  • valueChanged(newValue: any): any

    Changes the user object after an in-place edit and returns the previous value. This implementation replaces the user object with the given value and returns the old user object.

    Parameters

    • newValue: any

    Returns any

    • Defined in view/cell/Cell.ts:229

Settings

Member Visibility
  • Protected
  • Inherited
Theme

On This Page

Custom attributes
Constructors
constructor
Properties
childrencollapsedconnectableedgeedgesgeometryidinvalidatingmxTransientonInitoverlaysparentsourcestyletargetvaluevertexvisible
Methods
clonecloneValuefilterDescendantsgetAttributegetChildAtgetChildCellsgetChildCountgetChildEdgesgetChildrengetChildVerticesgetClonedStylegetConnectionsgetDescendantsgetDirectedEdgeCountgetEdgeAtgetEdgeCountgetEdgeIndexgetEdgesgetGeometrygetIdgetIncomingEdgesgetIndexgetNearestCommonAncestorgetOrigingetOutgoingEdgesgetParentgetRootgetStylegetTerminalgetValuehasAttributeinsertinsertEdgeisAncestorisCollapsedisConnectableisEdgeisVertexisVisibleremoveremoveEdgeremoveFromParentremoveFromTerminalsetAttributesetCollapsedsetConnectablesetEdgesetGeometrysetIdsetParentsetStylesetTerminalsetValuesetVertexsetVisiblevalueChanged
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.