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

  • Multiplicity

Class Multiplicity

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 AbstractGraph.multiplicities.

Example

Defines a rule where each rectangle must be connected to no more than 2 circles and no other types of targets are allowed.

graph.multiplicities.push(new Multiplicity(
true,
'rectangle',
null,
null,
0,
2,
['circle'],
'Only 2 targets allowed',
'Only circle targets allowed'));
  • Defined in view/other/Multiplicity.ts:46
Index

Constructors

constructor

Properties

attr countError max min source type typeError validNeighbors validNeighborsAllowed value

Methods

check checkNeighbors checkTerminal checkType

Constructors

constructor

  • new Multiplicity(
        source: boolean,
        type: string,
        attr: string | null | undefined,
        value: string | null | undefined,
        min: number | null | undefined,
        max: number | null | undefined,
        validNeighbors: string[] | null | undefined,
        countError: string | null | undefined,
        typeError: string | null | undefined,
        validNeighborsAllowed?: boolean,
    ): Multiplicity

    Parameters

    • source: boolean
    • type: string
    • attr: string | null | undefined
    • value: string | null | undefined
    • min: number | null | undefined
    • max: number | null | undefined
    • validNeighbors: string[] | null | undefined
    • countError: string | null | undefined
    • typeError: string | null | undefined
    • validNeighborsAllowed: boolean = true

    Returns Multiplicity

    • Defined in view/other/Multiplicity.ts:47

Properties

attr

attr: string | null | undefined

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

  • Defined in view/other/Multiplicity.ts:81

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.

  • Defined in view/other/Multiplicity.ts:120

max

max: number

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

Default

Number.MAX_VALUE

  • Defined in view/other/Multiplicity.ts:103

min

min: number

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

Default

0
  • Defined in view/other/Multiplicity.ts:97

source

source: boolean

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

  • Defined in view/other/Multiplicity.ts:91

type

type: string

Defines the type of the source or target terminal.

The type is a string passed to isNode together with the source or target vertex value as the first argument.

  • Defined in view/other/Multiplicity.ts:76

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.

  • Defined in view/other/Multiplicity.ts:125

validNeighbors

validNeighbors: string[]

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

  • Defined in view/other/Multiplicity.ts:110

validNeighborsAllowed

validNeighborsAllowed: boolean = true

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

  • Defined in view/other/Multiplicity.ts:115

value

value: string | null | undefined

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

  • Defined in view/other/Multiplicity.ts:86

Methods

check

  • check(
        graph: AbstractGraph,
        edge: Cell,
        source: Cell,
        target: Cell,
        sourceOut: number,
        targetIn: number,
    ): string | null

    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: AbstractGraph

      Reference to the enclosing AbstractGraph instance.

    • edge: Cell

      Cell that represents the edge to validate.

    • source: Cell

      Cell that represents the source terminal.

    • target: Cell

      Cell 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 | null

    • Defined in view/other/Multiplicity.ts:137

checkNeighbors

  • checkNeighbors(
        graph: AbstractGraph,
        _edge: Cell,
        source: Cell,
        target: Cell,
    ): boolean

    Checks if there are any valid neighbours in validNeighbors. This is only called if validNeighbors is a non-empty array.

    Parameters

    • graph: AbstractGraph
    • _edge: Cell
    • source: Cell
    • target: Cell

    Returns boolean

    • Defined in view/other/Multiplicity.ts:179

checkTerminal

  • checkTerminal(graph: AbstractGraph, _edge: Cell, terminal: Cell): boolean

    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

    • graph: AbstractGraph
    • _edge: Cell
    • terminal: Cell

    Returns boolean

    • Defined in view/other/Multiplicity.ts:204

checkType

  • checkType(
        _graph: AbstractGraph,
        value: string | Element | Cell | null,
        type: string,
        attr?: string | null,
        attrValue?: any,
    ): boolean

    Checks the type of the given value.

    Parameters

    • _graph: AbstractGraph
    • value: string | Element | Cell | null
    • type: string
    • Optionalattr: string | null
    • OptionalattrValue: any

    Returns boolean

    • Defined in view/other/Multiplicity.ts:213

Settings

Member Visibility
  • Protected
  • Inherited
Theme

On This Page

Example
Constructors
constructor
Properties
attrcountErrormaxminsourcetypetypeErrorvalidNeighborsvalidNeighborsAllowedvalue
Methods
checkcheckNeighborscheckTerminalcheckType
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.