Defines invalid connections along with the error messages that they produce. To add or remove rules on a graph, you must add/remove instances of this class to mxGraph.multiplicities.
graph.multiplicities.push(new mxMultiplicity( true, 'rectangle', null, null, 0, 2, ['circle'], 'Only 2 targets allowed', 'Only circle targets allowed'));
Defines a rule where each rectangle must be connected to no more than 2 circles and no other types of targets are allowed.
mxMultiplicity | Defines invalid connections along with the error messages that they produce. |
Functions | |
mxMultiplicity | Instantiate class mxMultiplicity in order to describe allowed connections in a graph. |
Variables | |
type | Defines the type of the source or target terminal. |
attr | Optional string that specifies the attributename to be passed to mxUtils.isNode to check if the rule applies to a cell. |
value | Optional string that specifies the value of the attribute to be passed to mxUtils.isNode to check if the rule applies to a cell. |
source | Boolean that specifies if the rule is applied to the source or target terminal of an edge. |
min | Defines the minimum number of connections for which this rule applies. |
max | Defines the maximum number of connections for which this rule applies. |
validNeighbors | Holds an array of strings that specify the type of neighbor for which this rule applies. |
validNeighborsAllowed | Boolean indicating if the list of validNeighbors are those that are allowed for this rule or those that are not allowed for this rule. |
countError | Holds the localized error message to be displayed if the number of connections for which the rule applies is smaller than min or greater than max. |
typeError | Holds the localized error message to be displayed if the type of the neighbor for a connection does not match the rule. |
Functions | |
check | Checks the multiplicity for the given arguments and returns the error for the given connection or null if the multiplicity does not apply. |
checkNeighbors | Checks if there are any valid neighbours in validNeighbors. |
checkTerminal | Checks the given terminal cell and returns true if this rule applies. |
checkType | Checks the type of the given value. |
function mxMultiplicity( source, type, attr, value, min, max, validNeighbors, countError, typeError, validNeighborsAllowed )
Instantiate class mxMultiplicity in order to describe allowed connections in a graph. Not all constraints can be enforced while editing, some must be checked at validation time. The countError and typeError are treated as resource keys in mxResources.
source | Boolean indicating if this rule applies to the source or target terminal. |
type | Type of the source or target terminal that this rule applies to. See type for more information. |
attr | Optional attribute name to match the source or target terminal. |
value | Optional attribute value to match the source or target terminal. |
min | Minimum number of edges for this rule. Default is 1. |
max | Maximum number of edges for this rule. n means infinite. Default is n. |
validNeighbors | Array of types of the opposite terminal for which this rule applies. |
countError | Error to be displayed for invalid number of edges. |
typeError | Error to be displayed for invalid opposite terminals. |
validNeighborsAllowed | Optional boolean indicating if the array of opposite types should be valid or invalid. |
mxMultiplicity.prototype.type
Defines the type of the source or target terminal. The type is a string passed to mxUtils.isNode together with the source or target vertex value as the first argument.
mxMultiplicity.prototype.attr
Optional string that specifies the attributename to be passed to mxUtils.isNode to check if the rule applies to a cell.
mxMultiplicity.prototype.value
Optional string that specifies the value of the attribute to be passed to mxUtils.isNode to check if the rule applies to a cell.
mxMultiplicity.prototype.check = function( graph, edge, source, target, sourceOut, targetIn )
Checks the multiplicity for the given arguments and returns the error for the given connection or null if the multiplicity does not apply.
graph | Reference to the enclosing mxGraph instance. |
edge | mxCell that represents the edge to validate. |
source | mxCell that represents the source terminal. |
target | mxCell that represents the target terminal. |
sourceOut | Number of outgoing edges from the source terminal. |
targetIn | Number of incoming edges for the target terminal. |
mxMultiplicity.prototype.checkNeighbors = function( graph, edge, source, target )
Checks if there are any valid neighbours in validNeighbors. This is only called if validNeighbors is a non-empty array.
Instantiate class mxMultiplicity in order to describe allowed connections in a graph.
function mxMultiplicity( source, type, attr, value, min, max, validNeighbors, countError, typeError, validNeighborsAllowed )
Defines the type of the source or target terminal.
mxMultiplicity.prototype.type
Optional string that specifies the attributename to be passed to mxUtils.isNode to check if the rule applies to a cell.
mxMultiplicity.prototype.attr
Returns true if the given value is an XML node with the node name and if the optional attribute has the specified value.
isNode: function( value, nodeName, attributeName, attributeValue )
Optional string that specifies the value of the attribute to be passed to mxUtils.isNode to check if the rule applies to a cell.
mxMultiplicity.prototype.value
Boolean that specifies if the rule is applied to the source or target terminal of an edge.
mxMultiplicity.prototype.source
Defines the minimum number of connections for which this rule applies.
mxMultiplicity.prototype.min
Defines the maximum number of connections for which this rule applies.
mxMultiplicity.prototype.max
Holds an array of strings that specify the type of neighbor for which this rule applies.
mxMultiplicity.prototype.validNeighbors
Boolean indicating if the list of validNeighbors are those that are allowed for this rule or those that are not allowed for this rule.
mxMultiplicity.prototype.validNeighborsAllowed
Holds the localized error message to be displayed if the number of connections for which the rule applies is smaller than min or greater than max.
mxMultiplicity.prototype.countError
Holds the localized error message to be displayed if the type of the neighbor for a connection does not match the rule.
mxMultiplicity.prototype.typeError
Checks the multiplicity for the given arguments and returns the error for the given connection or null if the multiplicity does not apply.
mxMultiplicity.prototype.check = function( graph, edge, source, target, sourceOut, targetIn )
Checks if there are any valid neighbours in validNeighbors.
mxMultiplicity.prototype.checkNeighbors = function( graph, edge, source, target )
Checks the given terminal cell and returns true if this rule applies.
mxMultiplicity.prototype.checkTerminal = function( graph, terminal, edge )
Checks the type of the given value.
mxMultiplicity.prototype.checkType = function( graph, value, type, attr, attrValue )
An array of mxMultiplicities describing the allowed connections in a graph.
mxGraph.prototype.multiplicities