(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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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:
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.
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
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.
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
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
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.
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.
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.
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.
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.
Rollback the current transaction, undoing any recorded changes.
This just calls UndoManager#rollbackTransaction.
@return {boolean} the value returned by UndoManager#rollbackTransaction.
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
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.
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.
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.
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
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.
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.