Options
All
  • Public
  • Public/Protected
  • All
Menu
example
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.

Hierarchy

  • mxMultiplicity

Index

Constructors

constructor

  • new mxMultiplicity(source: boolean, type: string, attr: string, value: string, min: number, max: number, validNeighbors: string[], countError: string, typeError: string, validNeighborsAllowed: boolean): mxMultiplicity
  • Parameters

    • source: boolean

      Boolean indicating if this rule applies to the source or target terminal.

    • type: string

      Type of the source or target terminal that this rule applies to. See type for more information.

    • attr: string

      Optional attribute name to match the source or target terminal.

    • value: string

      Optional attribute value to match the source or target terminal.

    • min: number

      Minimum number of edges for this rule. Default is 1.

    • max: number

      Maximum number of edges for this rule. n means infinite. Default is n.

    • validNeighbors: string[]

      Array of types of the opposite terminal for which this rule applies.

    • countError: string

      Error to be displayed for invalid number of edges.

    • typeError: string

      Error to be displayed for invalid opposite terminals.

    • validNeighborsAllowed: boolean

      Optional boolean indicating if the array of opposite types should be valid or invalid.

    Returns mxMultiplicity

Properties

attr

attr: string

Optional string that specifies the attributename to be passed to mxUtils.isNode to check if the rule applies to a cell.

countError

countError: string

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.

max

max: number | "n"

Defines the maximum number of connections for which this rule applies. A value of 'n' means unlimited times.

default

'n'

min

min: number

Defines the minimum number of connections for which this rule applies.

default

0

source

source: boolean

Boolean that specifies if the rule is applied to the source or target terminal of an edge.

type

type: string

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.

typeError

typeError: string

Holds the localized error message to be displayed if the type of the neighbor for a connection does not match the rule.

validNeighbors

validNeighbors: string[]

Holds an array of strings that specify the type of neighbor for which this rule applies. The strings are used in {@link mxCell.is} on the opposite terminal to check if the rule applies to the connection.

validNeighborsAllowed

validNeighborsAllowed: boolean

Boolean indicating if the list of validNeighbors are those that are allowed for this rule or those that are not allowed for this rule.

value

value: string

Optional string that specifies the value of the attribute to be passed to mxUtils.isNode to check if the rule applies to a cell.

Methods

check

  • Checks the multiplicity for the given arguments and returns the error for the given connection or null if the multiplicity does not apply.

    Parameters

    • graph: mxGraph

      Reference to the enclosing mxGraph instance.

    • edge: mxCell

      mxCell that represents the edge to validate.

    • source: mxCell

      mxCell that represents the source terminal.

    • target: mxCell

      mxCell that represents the target terminal.

    • sourceOut: number

      Number of outgoing edges from the source terminal.

    • targetIn: number

      Number of incoming edges for the target terminal.

    Returns string

checkNeighbors

checkTerminal

  • Checks the given terminal cell and returns true if this rule applies. The given cell is the source or target of the given edge, depending on source. This implementation uses checkType on the terminal's value.

    Parameters

    Returns boolean

checkType

  • checkType(graph: mxCell, value: string, type: string, attr: string, attrValue: any): boolean
  • Checks the type of the given value.

    Parameters

    • graph: mxCell
    • value: string
    • type: string
    • attr: string
    • attrValue: any

    Returns boolean

Generated using TypeDoc