Model$Typings extension

on

Properties

afterCopyFunction ↔ void Function(Map<Object, Object>, Model, Model)?
(undocumented) This function (if not null) is called towards the end of Diagram#copyParts in order to support custom data copying operations that depend on references between the parts.
getter/setter pair
copiesArrayObjects bool
Gets or sets whether the default behavior for #copyNodeData or GraphLinksModel#copyLinkData when copying Arrays also copies array items that are Objects. This only covers copying Objects that are items in Arrays that are copied when #copiesArrays is true. Copying an Object when this property is true also recursively copies any Arrays that are property values. It also assumes that the object's constructor can be called with no arguments.
getter/setter pair
copiesArrays bool
Gets or sets whether the default behavior for #copyNodeData or GraphLinksModel#copyLinkData makes copies of property values that are Arrays. This only copies Arrays that are top-level property values in data objects, not for Arrays that are in nested objects. Copying Arrays will also copy any array items that are Objects when #copiesArrayObjects is true.
getter/setter pair
copiesKey bool
Gets or sets whether the default behavior for #copyNodeData or GraphLinksModel#copyLinkData when copying properties of a data object also copies the key property value. Set this to false in order to force a unique key generation for data copied from another Diagram, such as a Palette.
getter/setter pair
copyNodeDataFunction Object Function(Object, Model)?
Gets or sets a function that makes a copy of a node data object.
getter/setter pair
dataFormat String
Gets or sets the name of the format of the diagram data. The default value is the empty string. The value must not be null. Use different values to prevent parts from one model to be copy/pasted or drag-and-dropped into another diagram/model.
getter/setter pair
isReadOnly bool
Gets or sets whether this model may be modified, such as adding nodes. By default this value is false. Setting the #nodeDataArray to something that is not a true Array of Objects will cause this to be set to true.
getter/setter pair
makeUniqueKeyFunction ↔ dynamic Function(Model, Object)?
Gets or sets a function that returns a unique id number or string for a node data object. This function is called by #makeNodeDataKeyUnique when a node data object is added to the model, either as part of a new #nodeDataArray or by a call to #addNodeData, to make sure the value of #getKeyForNodeData is unique within the model.
getter/setter pair
modelData Object
Gets a JavaScript Object that can hold programmer-defined property values for the model as a whole, rather than just for one node or one link.
getter/setter pair
name String
Gets or sets the name of this model. The initial name is an empty string. The value must not be null.
getter/setter pair
nodeCategoryProperty Object
Gets or sets the name of the node data property that returns a string naming that data's category. The value may also be a function taking two arguments, where the first argument will be a node data object. If the second argument is not supplied, the function should return the category name; if the second argument is supplied, the function should modify the node data object so that it has that new category name. The default value is the string 'category', meaning that it expects the data to have a property named 'category' if it cares to name a category. This is used by the diagram to distinguish between different kinds of nodes. The name must not be null. If the value is an empty string, #getCategoryForNodeData will return an empty string for all node data objects.
getter/setter pair
nodeDataArray Array<Object>
Gets or sets the array of node data objects that correspond to Nodes, Groups, or non-Link Parts in the Diagram. The initial value is an empty Array.
getter/setter pair
nodeKeyProperty Object
Gets or sets the name of the data property that returns a unique id number or string for each node data object. The value may also be a function taking two arguments, where the first argument will be a node data object. If the second argument is not supplied, the function should return the unique key value; if the second argument is supplied, the function should modify the node data object so that it has that new value as its unique key value. The default value is the name 'key', meaning that it expects the data to have a property named 'key' if it has a key value. The name must not be null or the empty string. You must set this property before assigning the #nodeDataArray.
getter/setter pair
skipsUndoManager bool
Gets or sets whether ChangedEvents are not recorded by the UndoManager. The initial and normal value is false. WARNING: while this property is true do not perform any changes that cause any previous transactions to become impossible to undo.
getter/setter pair
undoManager UndoManager
Gets or sets the UndoManager for this Model.
getter/setter pair

Methods

addArrayItem(Array arr, [dynamic val]) → void
Add an item at the end of a data array that may be data bound by a Panel as its Panel#itemArray, in a manner that can be undone/redone and that automatically updates any bindings.
addChangedListener(void listener(ChangedEvent)) Model
Register an event handler that is called when there is a ChangedEvent.
addNodeData(Object nodedata) → void
When you want to add a node or group to the diagram, call this method with a new data object. This will add that data to the #nodeDataArray and notify all listeners that a new node data object has been inserted into the collection.
addNodeDataCollection(Object coll) → void
Add to this model all of the node data held in an Array or in an Iterable of node data objects. @param {Iterable.
applyIncrementalJson(Object s) → void
Modify this model by applying the changes given in an "incremental" model change in JSON format generated by #toIncrementalJson. The expected properties of the argument are described at #toIncrementalJson. Incremental changes must be applied in the same order that the changes occurred in the original model.
assignAllDataProperties(Object data, Object props) → void
This is similar to Object.assign, but safely calls #setDataProperty for each property other than a key property. This does not delete any properties on the DATA object, although properties may be set to undefined if they are set that way on the PROPS object. @param data a data object @param props an Object holding various properties whose values are to be assigned to the DATA object
changeState(ChangedEvent e, bool undo) → void
(undocumented) This is called during an undo or redo to modify the model or its objects.
clear() → void
Clear out all references to any model data. This also clears out the UndoManager, so this operation is not undoable. This method is called by Diagram#clear; it does not notify any Diagrams or other listeners. This method does not unregister any Changed event listeners.
clearUnresolvedReferences([dynamic key]) → void
(undocumented) @param {string|number=} key
cloneDeep<T>(T obj) → T
Deeply copy an object or array and return the new object. This is typically called on a #nodeDataArray or GraphLinksModel#linkDataArray or data objects within them.
cloneProtected(Model copy) → void
Copies properties from this model to the given model, which must be of the same class. This is called by #copy. This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method.
commit(void func(Model), [String? tname]) → void
Starts a new transaction, calls the provided function, and commits the transaction. Code is called within a try-finally loop. If the function does not return normally, this rolls back the transaction rather than committing it. Example usage:
commitTransaction([String? tname]) bool
Commit the changes of the current transaction. This just calls UndoManager#commitTransaction. @param {string=} tname a descriptive name for the transaction. @return {boolean} the value returned by UndoManager#commitTransaction.
containsNodeData(Object nodedata) bool
Decide if a given node data object is in this model, using reference equality.
copy() Model
Creates a shallow copy of this Model and returns it. The data are not copied: #nodeDataArray, #modelData, GraphLinksModel#linkDataArray, GraphLinksModel#archetypeNodeData are left empty. Nor are any Changed listeners or the UndoManager copied. @expose @return {Model} an empty copy of the model with the same properties, other than data @since 1.6
copyNodeData(Object nodedata) Object?
Make a copy of a node data object. This uses the value of #copyNodeDataFunction to actually perform the copy, unless that property is null. When it is null the default behavior is to just make a shallow copy of the JavaScript Object.
findNodeDataForKey(dynamic key) Object?
Given a number or string, find the node data object in this model that uses the given value as its unique key. @param {(string|number|undefined)} key a string or a number. @return {Object} null if the key is not present in the model, or if the key is null or undefined or not a string or number. @see #containsNodeData @see #getKeyForNodeData
getCategoryForNodeData(Object nodedata) String
Find the category of a given node data, a string naming the node template or group template or part template that the Diagram should use to represent the node data. @param {Object} nodedata a JavaScript object represented by a node, group, or non-link. @return {string} @see #nodeCategoryProperty @see #setCategoryForNodeData
getKeyForNodeData(Object nodedata) → dynamic
Given a node data object return its unique key: a number or a string. This returns undefined if there is no key value.
insertArrayItem(Array arr, num idx, [dynamic val]) → void
Add an item to a data array that may be data bound by a Panel as its Panel#itemArray, given a new data value and the index at which to insert the new value, in a manner that can be undone/redone and that automatically updates any bindings.
makeNodeDataKeyUnique(Object nodedata) → void
This method is called when a node data object is added to the model to make sure that #getKeyForNodeData returns a unique key value.
mergeNodeDataArray(Array<Object> arr) → void
Take an Array of node data objects and update #nodeDataArray without replacing the Array and without replacing any existing node data objects that are identified by key.
raiseChangedEvent(EnumValue change, Object propertyname, Object obj, [dynamic oldval, dynamic newval, dynamic oldparam, dynamic newparam]) → void
Call this method to notify that the model or its objects have changed. This constructs a ChangedEvent and calls all Changed listeners. @param {EnumValue} change specifies the general nature of the change; typically the value is ChangedEvent.Property. @param {string|function(ObjectData,?=):?} propertyname names the property that was modified, or a function that takes an Object and returns the property value. @param {Object} obj the object that was modified, typically a GraphObject, Diagram, or a Model. @param {} oldval the previous or older value. @param {} newval the next or newer value. @param {=} oldparam an optional value that helps describe the older value. @param {=} newparam an optional value that helps describe the newer value.
raiseDataChanged(Object data, Object propertyname, [dynamic oldval, dynamic newval, dynamic oldparam, dynamic newparam]) → void
Call this method to notify about a data property having changed value. This constructs a ChangedEvent and calls all Changed listeners.
removeArrayItem(Array arr, [num? idx]) → void
Remove an item from a data array that may be data bound by a Panel as its Panel#itemArray, given the index at which to remove a data value, in a manner that can be undone/redone and that automatically updates any bindings.
removeChangedListener(void listener(ChangedEvent)) → void
Unregister an event handler listener.
removeNodeData(Object nodedata) → void
When you want to remove a node or group from the diagram, call this method with an existing data object. This will remove that data from the #nodeDataArray and notify all listeners that a node data object has been removed from the collection.
removeNodeDataCollection(Object coll) → void
Remove from this model all of the node data held in an Array or in an Iterable of node data objects. @param {Iterable.
rollbackTransaction() bool
Rollback the current transaction, undoing any recorded changes. This just calls UndoManager#rollbackTransaction. @return {boolean} the value returned by UndoManager#rollbackTransaction.
set(Object data, String propname, [dynamic val]) → void
A synonym for #setDataProperty @param {Object} data a JavaScript object typically the value of a Panel#data and represented by a Node, Link, Group, simple Part, or item in a Panel#itemArray; or this model's #modelData. @param {string} propname a string that is not null or the empty string. @param {*} val the new value for the property. @see #setDataProperty @since 1.8
setCategoryForNodeData(Object nodedata, String cat) → void
Change the category of a given node data, a string naming the node template or group template or part template that the Diagram should use to represent the node data.
setDataProperty(Object data, String propname, [dynamic val]) → void
Change the value of some property of a node data, a link data, an item data, or the Model#modelData, given a string naming the property and the new value, in a manner that can be undone/redone and that automatically updates any bindings.
setKeyForNodeData(Object nodedata, dynamic key) → void
Change the unique key of a given node data that is already in this model. The new key value must be unique -- i.e. not in use by another node data object. You can call #findNodeDataForKey to check if a proposed new key is already in use.
startTransaction([String? tname]) bool
Begin a transaction, where the changes are held by a Transaction object in the UndoManager. This just calls UndoManager#startTransaction. @param {string=} tname a descriptive name for the transaction. @return {boolean} the value returned by UndoManager#startTransaction. @see #commit
toIncrementalData(ChangedEvent e) IncrementalData
Produce an object representing the changes in the most recent Transaction. The structure of the object follows the same format as the JSON output from #toIncrementalJson.
toIncrementalJson(ChangedEvent e, [String? classname]) String
Produce a JSON-format string representing the changes in the most recent Transaction. This writes out JSON for a model, but recording only changes in the given Transaction, with the addition of the "incremental" property to mark it as different from a complete model. Instead of the "nodeDataArray" property (and "linkDataArray" property for GraphLinksModels), this will have "inserted...", "modified...", and "removed..." properties that are non-empty Arrays.
toJson([String? classname]) String
Generate a string representation of the persistent data in this model, in JSON format, that can be read in later with a call to Model.fromJson.
updateTargetBindings(Object data, [String? srcpropname]) → void
Find a Part corresponding to the given data and call its Panel#updateTargetBindings method, in each Diagram that uses this Model.