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 — GraphDataModel | @maxgraph/core

  • GraphDataModel

Class GraphDataModel

Extends EventSource to implement a graph model. The graph model acts as a wrapper around the cells which are in charge of storing the actual graph data structure. The model acts as a transactional wrapper with event notification for all changes, whereas the cells contain the atomic operations for updating the actual data structure.

Layers

The cell hierarchy in the model must have a top-level root cell which contains the layers (typically one default layer), which in turn contain the top-level cells of the layers. This means each cell is contained in a layer. If no layers are required, then all new cells should be added to the default layer.

Layers are useful for hiding and showing groups of cells, or for placing groups of cells on top of other cells in the display. To identify a layer, the isLayer function is used. It returns true if the parent of the given cell is the root of the model.

Events

See events section for more details. There is a new set of events for tracking transactional changes as they happen. The events are called startEdit for the initial beginUpdate, executed for each executed change and endEdit for the terminal endUpdate. The executed event contains a property called change which represents the change after execution.

Encoding the model

To encode a graph model, use the following code:

var enc = new Codec();
var node = enc.encode(graph.getDataModel());

This will create an XML node that contains all the model information.

Encoding and decoding changes:

For the encoding of changes, a graph model listener is required that encodes each change from the given array of changes.

model.addListener(InternalEvent.CHANGE, function(sender, evt) {
const changes = evt.getProperty('edit').changes;
const codec = new Codec();

const nodes = changes.map(change => codec.encode(change));
// do something with the nodes
});

For the decoding and execution of changes, the codec needs a lookup function that allows it to resolve cell IDs as follows:

var codec = new Codec();
codec.lookup(id)
{
return model.getCell(id);
}

For each encoded change (represented by a node), the following code can be used to carry out the decoding and create a change object.

var changes = [];
var change = codec.decode(node);
change.model = model;
change.execute();
changes.push(change);

The changes can then be dispatched using the model as follows.

var edit = new UndoableEdit(model, false);
edit.changes = changes;

edit.notify()
{
edit.source.fireEvent(new EventObject(InternalEvent.CHANGE,
'edit', edit, 'changes', edit.changes));
edit.source.fireEvent(new EventObject(InternalEvent.NOTIFY,
'edit', edit, 'changes', edit.changes));
}

model.fireEvent(new EventObject(InternalEvent.UNDO, 'edit', edit));
model.fireEvent(new EventObject(InternalEvent.CHANGE,
'edit', edit, 'changes', changes));

Event: InternalEvent.CHANGE

Fires when an undoable edit is dispatched. The edit property contains the UndoableEdit. The changes property contains the array of atomic changes inside the undoable edit. The changes property is deprecated, please use edit.changes instead.

Example

For finding newly inserted cells, the following code can be used:

graph.model.addListener(InternalEvent.CHANGE, function(sender, evt) {
const changes = evt.getProperty('edit').changes;

for (const change of changes) {
if (change instanceof ChildChange && !change.change.previous) {
graph.startEditingAtCell(change.child);
break;
}
}
});

Event: InternalEvent.NOTIFY

Same as Event#CHANGE, this event can be used for classes that need to implement a sync mechanism between this model and, say, a remote model. In such a setup, only local changes should trigger a notify event and all changes should trigger a change event.

Event: InternalEvent.EXECUTE

Fires between begin- and endUpdate and after an atomic change was executed in the model. The change property contains the atomic change that was executed.

Event: InternalEvent.EXECUTED

Fires between START_EDIT and END_EDIT after an atomic change was executed. The change property contains the change that was executed.

Event: InternalEvent.BEGIN_UPDATE

Fires after the updateLevel was incremented in beginUpdate. This event contains no properties.

Event: InternalEvent.START_EDIT

Fires after the updateLevel was changed from 0 to 1. This event contains no properties.

Event: InternalEvent.END_UPDATE

Fires after the updateLevel was decreased in endUpdate but before any notification or change dispatching. The edit property contains the currentEdit.

Event: InternalEvent.END_EDIT

Fires after the updateLevel was changed from 1 to 0. This event contains no properties.

Event: InternalEvent.BEFORE_UNDO

Fires before the change is dispatched after the update level has reached 0 in endUpdate. The edit property contains the currentEdit.

Event: InternalEvent.UNDO

Fires after the change was dispatched in endUpdate. The edit property contains the currentEdit.

GraphDataModel

Hierarchy (View Summary)

  • EventSource
    • GraphDataModel
  • Defined in view/GraphDataModel.ts:207
Index

Constructors

constructor

Properties

cells createIds currentEdit endingUpdate eventListeners eventsEnabled eventSource ignoreRelativeEdgeParent maintainEdgeParent nextId postfix prefix root updateLevel

Methods

add addListener batchUpdate beginUpdate cellAdded cellRemoved clear collapsedStateForCellChanged contains createId createRoot createUndoableEdit destroy endUpdate execute filterCells fireEvent geometryForCellChanged getCell getEdgesBetween getEventSource getRoot isCreateIds isEventsEnabled isLayer isRoot mergeChildren mergeChildrenImpl parentForCellChanged remove removeListener rootChanged setCollapsed setCreateIds setEventsEnabled setEventSource setGeometry setRoot setStyle setTerminal setTerminals setValue setVisible styleForCellChanged terminalForCellChanged updateEdgeParent updateEdgeParents valueForCellChanged visibleStateForCellChanged

Constructors

constructor

  • new GraphDataModel(root?: Cell | null): GraphDataModel

    Parameters

    • root: Cell | null = null

    Returns GraphDataModel

    Overrides EventSource.constructor

    • Defined in view/GraphDataModel.ts:275

Properties

cells

cells: { [key: string]: Cell } | null = {}

Maps from Ids to cells.

  • Defined in view/GraphDataModel.ts:218

createIds

createIds: boolean = true

Specifies if the model should automatically create Ids for new cells.

Default

true.
  • Defined in view/GraphDataModel.ts:236

currentEdit

currentEdit: any = null

Holds the changes for the current transaction. If the transaction is closed then a new object is created for this variable using createUndoableEdit.

  • Defined in view/GraphDataModel.ts:260

endingUpdate

endingUpdate: boolean = false

True if the program flow is currently inside endUpdate.

  • Defined in view/GraphDataModel.ts:273

eventListeners

eventListeners: EventListenerObject[] = []

Holds the event names and associated listeners in an array. The array contains the event name followed by the respective listener for each registered listener.

Inherited from EventSource.eventListeners

  • Defined in view/event/EventSource.ts:58

eventsEnabled

eventsEnabled: boolean = true

Specifies if events can be fired. Default is true.

Inherited from EventSource.eventsEnabled

  • Defined in view/event/EventSource.ts:63

eventSource

eventSource: EventTarget | null = null

Optional source for events.

Default

null

Inherited from EventSource.eventSource

  • Defined in view/event/EventSource.ts:69

ignoreRelativeEdgeParent

ignoreRelativeEdgeParent: boolean = true

Specifies if relative edge parents should be ignored for finding the nearest common ancestors of an edge's terminals.

Default

true
  • Defined in view/GraphDataModel.ts:230

maintainEdgeParent

maintainEdgeParent: boolean = true

Specifies if edges should automatically be moved into the nearest common ancestor of their terminals.

Default

true
  • Defined in view/GraphDataModel.ts:224

nextId

nextId: number = 0

Specifies the next Id to be created. Initial value is 0.

  • Defined in view/GraphDataModel.ts:253

postfix

postfix: string = ''

Defines the postfix of new Ids.

Default

''
  • Defined in view/GraphDataModel.ts:248

prefix

prefix: string = ''

Defines the prefix of new Ids. Default is an empty string.

Default

''
  • Defined in view/GraphDataModel.ts:242

root

root: Cell | null = null

Holds the root cell, which in turn contains the cells that represent the layers of the diagram as child cells. That is, the actual elements of the diagram are supposed to live in the third generation of cells and below.

  • Defined in view/GraphDataModel.ts:213

updateLevel

updateLevel: number = 0

Counter for the depth of nested transactions. Each call to beginUpdate will increment this number and each call to endUpdate will decrement it. When the counter reaches 0, the transaction is closed and the respective events are fired. Initial value is 0.

  • Defined in view/GraphDataModel.ts:268

Methods

add

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

    Adds the specified child to the parent at the given index using ChildChange and adds the change to the current transaction. If no index is specified then the child is appended to the parent's array of children. Returns the inserted child.

    Parameters

    • parent: Cell | null

      that specifies the parent to contain the child.

    • child: Cell | null

      that specifies the child to be inserted.

    • index: number | null = null

      Optional integer that specifies the index of the child.

    Returns Cell | null

    • Defined in view/GraphDataModel.ts:412

addListener

  • addListener(name: string, funct: Function): void

    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.

    Parameters

    • name: string
    • funct: Function

    Returns void

    Inherited from EventSource.addListener

    • Defined in view/event/EventSource.ts:105

batchUpdate

  • batchUpdate(fn: () => void): void

    Updates the model in a transaction. This is a shortcut to the usage of beginUpdate and the endUpdate methods.

    const model = graph.getDataModel();
    const parent = graph.getDefaultParent();
    const index = model.getChildCount(parent);
    model.batchUpdate(() => {
    model.add(parent, v1, index);
    model.add(parent, v2, index+1);
    });

    Parameters

    • fn: () => void

      the update to be performed in the transaction.

    Returns void

    • Defined in view/GraphDataModel.ts:969

beginUpdate

  • beginUpdate(): void

    Increments the updateLevel by one. The event notification is queued until updateLevel reaches 0 by use of endUpdate.

    All changes on GraphDataModel are transactional, that is, they are executed in a single undoable change on the model (without transaction isolation). Therefore, if you want to combine any number of changes into a single undoable change, you should group any two or more API calls that modify the graph model between beginUpdate and endUpdate calls as shown here:

    const model = graph.getDataModel();
    const parent = graph.getDefaultParent();
    const index = model.getChildCount(parent);
    model.beginUpdate();
    try
    {
    model.add(parent, v1, index);
    model.add(parent, v2, index+1);
    }
    finally
    {
    model.endUpdate();
    }

    Of course there is a shortcut for appending a sequence of cells into the default parent:

    graph.addCells([v1, v2]).
    

    Returns void

    • Defined in view/GraphDataModel.ts:1015

cellAdded

  • cellAdded(cell: Cell | null): void

    Inner callback to update cells when a cell has been added. This implementation resolves collisions by creating new Ids. To change the ID of a cell after it was inserted into the model, use the following code:

    (code delete model.cells[cell.getId()]; cell.setId(newId); model.cells[cell.getId()] = cell;


    If the change of the ID should be part of the command history, then the
    cell should be removed from the model and a clone with the new ID should
    be reinserted into the model instead.

    @param {Cell} cell that specifies the cell that has been added

    Parameters

    • cell: Cell | null

    Returns void

    • Defined in view/GraphDataModel.ts:449

cellRemoved

  • cellRemoved(cell: Cell): void

    Inner callback to update cells when a cell has been removed.

    Parameters

    • cell: Cell

      that specifies the cell that has been removed.

    Returns void

    • Defined in view/GraphDataModel.ts:625

clear

  • clear(): void

    Sets a new root using createRoot.

    Returns void

    • Defined in view/GraphDataModel.ts:290

collapsedStateForCellChanged

  • collapsedStateForCellChanged(cell: Cell, collapsed: boolean): boolean

    Inner callback to update the collapsed state of the given Cell using Cell#setCollapsed and return the previous collapsed state.

    Parameters

    • cell: Cell

      that specifies the cell to be updated.

    • collapsed: boolean

      Boolean that specifies the new collapsed state.

    Returns boolean

    • Defined in view/GraphDataModel.ts:898

contains

  • contains(cell: Cell): boolean

    Returns true if the model contains the given Cell.

    Parameters

    • cell: Cell

      that specifies the cell.

    Returns boolean

    • Defined in view/GraphDataModel.ts:398

createId

  • createId(cell: Cell): string

    Hook method to create an Id for the specified cell. This implementation concatenates prefix, id and postfix to create the Id and increments nextId. The cell is ignored by this implementation, but can be used in overridden methods to prefix the Ids with eg. the cell type.

    Parameters

    • cell: Cell

      to create the Id for.

    Returns string

    • Defined in view/GraphDataModel.ts:496

createRoot

  • createRoot(): Cell

    Creates a new root cell with a default layer (child 0).

    Returns Cell

    • Defined in view/GraphDataModel.ts:311

createUndoableEdit

  • createUndoableEdit(significant?: boolean): UndoableEdit

    Creates a new UndoableEdit that implements the notify function to fire a change and notify event through the UndoableEdit's source.

    Parameters

    • significant: boolean = true

      Optional boolean that specifies if the edit to be created is significant. Default is true.

    Returns UndoableEdit

    • Defined in view/GraphDataModel.ts:1073

destroy

  • destroy(): void

    Clears all registered event listeners.

    Subclasses with a destroy method should call super.destroy() at the end of their own cleanup to ensure no stale listeners remain.

    Returns void

    Inherited from EventSource.destroy

    • Defined in view/event/EventSource.ts:166

endUpdate

  • endUpdate(): void

    Decrements the updateLevel by one and fires an undo event if the updateLevel reaches 0. This function indirectly fires a change event by invoking the notify function on the currentEdit und then creates a new currentEdit using createUndoableEdit.

    The undo event is fired only once per edit, whereas the change event is fired whenever the notify function is invoked, that is, on undo and redo of the edit.

    Returns void

    • Defined in view/GraphDataModel.ts:1036

execute

  • execute(change: any): void

    Executes the given edit and fires events if required. The edit object requires an execute function which is invoked. The edit is added to the currentEdit between beginUpdate and endUpdate calls, so that events will be fired if this execute is an individual transaction, that is, if no previous beginUpdate calls have been made without calling endUpdate. This implementation fires an execute event before executing the given change.

    Parameters

    • change: any

      Object that described the change.

    Returns void

    • Defined in view/GraphDataModel.ts:943

filterCells

  • filterCells(cells: Cell[], filter: FilterFunction): Cell[]

    Parameters

    • cells: Cell[]
    • filter: FilterFunction

    Returns Cell[]

    • Defined in view/GraphDataModel.ts:327

fireEvent

  • fireEvent(evt: EventObject, sender?: EventTarget | null): void

    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.

    Example:

    fireEvent(new EventObject("eventName", key1, val1, .., keyN, valN))
    

    Parameters

    • evt: EventObject

      EventObject that represents the event.

    • sender: EventTarget | null = null

      Optional sender to be passed to the listener. Default value is the return value of getEventSource.

    Returns void

    Inherited from EventSource.fireEvent

    • Defined in view/event/EventSource.ts:139

geometryForCellChanged

  • geometryForCellChanged(cell: Cell, geometry: Geometry | null): Geometry | null

    Inner callback to update the Geometry of the given Cell using Cell#setGeometry and return the previous Geometry.

    Parameters

    • cell: Cell
    • geometry: Geometry | null

    Returns Geometry | null

    • Defined in view/GraphDataModel.ts:838

getCell

  • getCell(id: string): Cell | null

    Returns the Cell for the specified Id or null if no cell can be found for the given Id.

    Parameters

    • id: string

      A string representing the Id of the cell.

    Returns Cell | null

    • Defined in view/GraphDataModel.ts:323

getEdgesBetween

  • getEdgesBetween(source: Cell, target: Cell, directed?: boolean): Cell[]

    Returns all edges between the given source and target pair. If directed is true, then only edges from the source to the target are returned, otherwise, all edges between the two cells are returned.

    Parameters

    • source: Cell

      that defines the source terminal of the edge to be returned.

    • target: Cell

      that defines the target terminal of the edge to be returned.

    • directed: boolean = false

      Optional boolean that specifies if the direction of the edge should be taken into account. Default is false.

    Returns Cell[]

    • Defined in view/GraphDataModel.ts:752

getEventSource

  • getEventSource(): EventTarget | null

    Returns eventSource.

    Returns EventTarget | null

    Inherited from EventSource.getEventSource

    • Defined in view/event/EventSource.ts:88

getRoot

  • getRoot(cell?: Cell | null): Cell | null

    Parameters

    • cell: Cell | null = null

    Returns Cell | null

    • Defined in view/GraphDataModel.ts:331

isCreateIds

  • isCreateIds(): boolean

    Returns createIds.

    Returns boolean

    • Defined in view/GraphDataModel.ts:297

isEventsEnabled

  • isEventsEnabled(): boolean

    Returns eventsEnabled.

    Returns boolean

    Inherited from EventSource.isEventsEnabled

    • Defined in view/event/EventSource.ts:74

isLayer

  • isLayer(cell: Cell | null): boolean

    Returns true if isRoot returns true for the parent of the given cell.

    Parameters

    • cell: Cell | null

      that represents the possible layer.

    Returns boolean

    • Defined in view/GraphDataModel.ts:389

isRoot

  • isRoot(cell?: Cell | null): boolean

    Returns true if the given cell is the root of the model and a non-null value.

    Parameters

    • cell: Cell | null = null

      that represents the possible root.

    Returns boolean

    • Defined in view/GraphDataModel.ts:380

mergeChildren

  • mergeChildren(from: Cell, to: Cell, cloneAllEdges?: boolean): void

    Merges the children of the given cell into the given target cell inside this model. All cells are cloned unless there is a corresponding cell in the model with the same id, in which case the source cell is ignored and all edges are connected to the corresponding cell in this model. Edges are considered to have no identity and are always cloned unless the cloneAllEdges flag is set to false, in which case edges with the same id in the target model are reconnected to reflect the terminals of the source edges.

    Parameters

    • from: Cell
    • to: Cell
    • cloneAllEdges: boolean = true

    Returns void

    • Defined in view/GraphDataModel.ts:1099

mergeChildrenImpl

  • mergeChildrenImpl(
        from: Cell,
        to: Cell,
        cloneAllEdges: boolean,
        mapping?: any,
    ): void

    Clones the children of the source cell into the given target cell in this model and adds an entry to the mapping that maps from the source cell to the target cell with the same id or the clone of the source cell that was inserted into this model.

    Parameters

    • from: Cell
    • to: Cell
    • cloneAllEdges: boolean
    • mapping: any = {}

    Returns void

    • Defined in view/GraphDataModel.ts:1135

parentForCellChanged

  • parentForCellChanged(cell: Cell, parent: Cell | null, index: number): Cell

    Inner callback to update the parent of a cell using Cell#insert on the parent and return the previous parent.

    Parameters

    • cell: Cell

      to update the parent for.

    • parent: Cell | null

      that specifies the new parent of the cell.

    • index: number

      Optional integer that defines the index of the child in the parent's child array.

    Returns Cell

    • Defined in view/GraphDataModel.ts:654

remove

  • remove(cell: Cell): Cell

    Removes the specified cell from the model using ChildChange and adds the change to the current transaction. This operation will remove the cell and all of its children from the model. Returns the removed cell.

    Parameters

    • cell: Cell

      that should be removed.

    Returns Cell

    • Defined in view/GraphDataModel.ts:611

removeListener

  • removeListener(funct: Function): void

    Removes all occurrences of the given listener from eventListeners.

    Parameters

    • funct: Function

    Returns void

    Inherited from EventSource.removeListener

    • Defined in view/event/EventSource.ts:112

rootChanged

  • rootChanged(root: Cell | null): Cell | null

    Inner callback to change the root of the model and update the internal datastructures, such as cells and nextId. Returns the previous root.

    Parameters

    • root: Cell | null

      that specifies the new root.

    Returns Cell | null

    • Defined in view/GraphDataModel.ts:362

setCollapsed

  • setCollapsed(cell: Cell, collapsed: boolean): boolean

    Sets the collapsed state of the given Cell using CollapseChange and adds the change to the current transaction.

    Parameters

    • cell: Cell

      whose collapsed state should be changed.

    • collapsed: boolean

      Boolean that specifies the new collpased state.

    Returns boolean

    • Defined in view/GraphDataModel.ts:883

setCreateIds

  • setCreateIds(value: boolean): void

    Sets createIds.

    Parameters

    • value: boolean

    Returns void

    • Defined in view/GraphDataModel.ts:304

setEventsEnabled

  • setEventsEnabled(value: boolean): void

    Sets eventsEnabled.

    Parameters

    • value: boolean

    Returns void

    Inherited from EventSource.setEventsEnabled

    • Defined in view/event/EventSource.ts:81

setEventSource

  • setEventSource(value: EventTarget | null): void

    Sets eventSource.

    Parameters

    • value: EventTarget | null

    Returns void

    Inherited from EventSource.setEventSource

    • Defined in view/event/EventSource.ts:95

setGeometry

  • setGeometry(cell: Cell, geometry: Geometry): Geometry

    Sets the Geometry of the given Cell. The actual update of the cell is carried out in geometryForCellChanged. The GeometryChange action is used to encapsulate the change.

    Parameters

    • cell: Cell

      whose geometry should be changed.

    • geometry: Geometry

      that defines the new geometry.

    Returns Geometry

    • Defined in view/GraphDataModel.ts:827

setRoot

  • setRoot(root: Cell | null): Cell | null

    Sets the root of the model using RootChange and adds the change to the current transaction. This resets all datastructures in the model and is the preferred way of clearing an existing model. Returns the new root.

    Example:

    const root = new Cell();
    root.insert(new Cell());
    model.setRoot(root);

    Parameters

    • root: Cell | null

      that specifies the new root.

    Returns Cell | null

    • Defined in view/GraphDataModel.ts:351

setStyle

  • setStyle(cell: Cell, style: CellStyle): void

    Sets the style of the given Cell using StyleChange and adds the change to the current transaction.

    IMPORTANT: Do not pass Cell.getStyle as value of the style parameter. Otherwise, no style change is performed, so the view won't be updated. Always get a clone of the style of the cell with Cell.getClonedStyle, then update it and pass the updated style to this method.

    Parameters

    • cell: Cell

      whose style should be changed.

    • style: CellStyle

      the new cell style to set.

    Returns void

    • Defined in view/GraphDataModel.ts:853

setTerminal

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

    Sets the source or target terminal of the given Cell using TerminalChange and adds the change to the current transaction. This implementation updates the parent of the edge using updateEdgeParent if required.

    Parameters

    • edge: Cell

      that specifies the edge.

    • terminal: Cell | null

      that specifies the new terminal.

    • isSource: boolean

      Boolean indicating if the terminal is the new source or target terminal of the edge.

    Returns Cell | null

    • Defined in view/GraphDataModel.ts:689

setTerminals

  • setTerminals(edge: Cell, source: Cell | null, target: Cell | null): void

    Sets the source and target Cell of the given Cell in a single transaction using setTerminal for each end of the edge.

    Parameters

    • edge: Cell

      that specifies the edge.

    • source: Cell | null

      that specifies the new source terminal.

    • target: Cell | null

      that specifies the new target terminal.

    Returns void

    • Defined in view/GraphDataModel.ts:707

setValue

  • setValue(cell: Cell, value: any): any

    Sets the user object of then given Cell using ValueChange and adds the change to the current transaction.

    Parameters

    • cell: Cell

      whose user object should be changed.

    • value: any

      Object that defines the new user object.

    Returns any

    • Defined in view/GraphDataModel.ts:792

setVisible

  • setVisible(cell: Cell, visible: boolean): boolean

    Sets the visible state of the given Cell using VisibleChange and adds the change to the current transaction.

    Parameters

    • cell: Cell

      whose visible state should be changed.

    • visible: boolean

      Boolean that specifies the new visible state.

    Returns boolean

    • Defined in view/GraphDataModel.ts:911

styleForCellChanged

  • styleForCellChanged(cell: Cell, style: CellStyle): CellStyle

    Inner callback to update the style of the given Cell using Cell#setStyle and return the previous style.

    IMPORTANT: to fully work, this method should not receive cell.getStyle as value of the style parameter. See setStyle for more information.

    Parameters

    • cell: Cell

      whose style should be changed.

    • style: CellStyle

      the new cell style to set.

    Returns CellStyle

    • Defined in view/GraphDataModel.ts:870

terminalForCellChanged

  • terminalForCellChanged(
        edge: Cell,
        terminal: Cell | null,
        isSource?: boolean,
    ): Cell | null

    Inner helper function to update the terminal of the edge using Cell#insertEdge and return the previous terminal.

    Parameters

    • edge: Cell

      that specifies the edge to be updated.

    • terminal: Cell | null

      that specifies the new terminal.

    • isSource: boolean = false

      Boolean indicating if the terminal is the new source or target terminal of the edge.

    Returns Cell | null

    • Defined in view/GraphDataModel.ts:726

updateEdgeParent

  • updateEdgeParent(edge: Cell, root: Cell): void

    Inner callback to update the parent of the specified Cell to the nearest-common-ancestor of its two terminals.

    Parameters

    • edge: Cell

      that specifies the edge.

    • root: Cell

      that represents the current root of the model.

    Returns void

    • Defined in view/GraphDataModel.ts:546

updateEdgeParents

  • updateEdgeParents(cell: Cell, root?: Cell): void

    Updates the parent for all edges that are connected to cell or one of its descendants using updateEdgeParent.

    Parameters

    • cell: Cell
    • root: Cell = ...

    Returns void

    • Defined in view/GraphDataModel.ts:506

valueForCellChanged

  • valueForCellChanged(cell: Cell, value: any): any

    Inner callback to update the user object of the given Cell using Cell#valueChanged and return the previous value, that is, the return value of Cell#valueChanged.

    To change a specific attribute in an XML node, the following code can be used.

    graph.getDataModel().valueForCellChanged(cell, value)
    {
    var previous = cell.value.getAttribute('label');
    cell.value.setAttribute('label', value);

    return previous;
    };

    Parameters

    • cell: Cell
    • value: any

    Returns any

    • Defined in view/GraphDataModel.ts:815

visibleStateForCellChanged

  • visibleStateForCellChanged(cell: Cell, visible: boolean): boolean

    Inner callback to update the visible state of the given Cell using Cell#setCollapsed and return the previous visible state.

    Parameters

    • cell: Cell

      that specifies the cell to be updated.

    • visible: boolean

      Boolean that specifies the new visible state.

    Returns boolean

    • Defined in view/GraphDataModel.ts:926

Settings

Member Visibility
  • Protected
  • Inherited
Theme

On This Page

LayersEventsEncoding the model
  • To encode a graph model, use the following code:
  • Encoding and decoding changes:
Example
Constructors
constructor
Properties
cellscreateIdscurrentEditendingUpdateeventListenerseventsEnabledeventSourceignoreRelativeEdgeParentmaintainEdgeParentnextIdpostfixprefixrootupdateLevel
Methods
addaddListenerbatchUpdatebeginUpdatecellAddedcellRemovedclearcollapsedStateForCellChangedcontainscreateIdcreateRootcreateUndoableEditdestroyendUpdateexecutefilterCellsfireEventgeometryForCellChangedgetCellgetEdgesBetweengetEventSourcegetRootisCreateIdsisEventsEnabledisLayerisRootmergeChildrenmergeChildrenImplparentForCellChangedremoveremoveListenerrootChangedsetCollapsedsetCreateIdssetEventsEnabledsetEventSourcesetGeometrysetRootsetStylesetTerminalsetTerminalssetValuesetVisiblestyleForCellChangedterminalForCellChangedupdateEdgeParentupdateEdgeParentsvalueForCellChangedvisibleStateForCellChanged
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.