Class EdgeHandler

Graph event handler that reconnects edges, modifies control points and the edge label location.

Uses CellMarker for finding and highlighting new source and target vertices.

This handler is automatically created in Graph.createHandler for each selected edge.

Some elements of this handler and its subclasses can be configured using EdgeHandlerConfig.

Hierarchy (view full)

Constructors

Properties

Methods

Constructors

Properties

abspoints: (null | Point)[] = []
active: boolean = true
addEnabled: boolean = false

Specifies if adding bends by shift-click is enabled.

Note: This experimental feature is not recommended for production use.

false
allowHandleBoundsCheck: boolean = true

Specifies if the bounds of handles should be used for hit-detection in IE.

true
bends: Shape[] = []

Holds the Shapes that represent the points.

cloneEnabled: boolean = true

Specifies if cloning by control-drag is enabled.

true
constraintHandler: ConstraintHandler

Holds the ConstraintHandler used for drawing and highlighting constraints.

currentPoint: null | Point = null
customHandles: undefined | CellHandle[]
dblClickRemoveEnabled: boolean = false

Specifies if removing bends by double click is enabled.

false
error: null | string = null

Holds the current validation error while a connection is being changed.

escapeHandler: ((sender: Listenable, evt: Event) => void)
graph: Graph

Reference to the enclosing Graph.

handleImage: null | ImageBox = null

Optional Image to be used as handles.

null
index: null | number = null
isLabel: boolean = false
isSource: boolean = false
isTarget: boolean = false
label: Point
labelHandleImage: null | ImageBox = null
labelShape: Shape

Holds the Shape that represents the label position.

manageLabelHandle: boolean = false

Specifies if the label handle should be moved if it intersects with another handle. Uses checkLabelHandle for checking and moving.

false
marker: CellMarker

Holds the CellMarker which is used for highlighting terminals.

mergeRemoveEnabled: boolean = false

Specifies if removing bends by dropping them on other bends is enabled.

false
outline: boolean = true
outlineConnect: boolean = false

Specifies if connections to the outline of a highlighted target should be enabled. This will allow to place the connection point along the outline of the highlighted target.

false
parentHighlight: null | RectangleShape = null
parentHighlightEnabled: boolean = false

Specifies if the parent should be highlighted if a child cell is selected.

false
points: Point[] = []
preferHtml: boolean = false

Specifies if bends should be added to the graph container. This is updated in init based on whether the edge or one of its terminals has an HTML label in the container.

removeEnabled: boolean = false

Specifies if removing bends by shift-click is enabled.

Note: This experimental feature is not recommended for production use.

false
shape: Shape

Holds the Shape that represents the preview edge.

snapPoint: null | Point = null
snapToTerminals: boolean = false

Specifies if waypoints should snap to the routing centers of terminals.

false
startX: number = 0
startY: number = 0
state: CellState

Reference to the CellState being modified.

straightRemoveEnabled: boolean = false

Specifies if removing bends by creating straight segments should be enabled. If enabled, this can be overridden by holding down the alt key while moving.

false
tolerance: number = 0

Optional tolerance for hit-detection in getHandleForEvent.

0
virtualBendOpacity: number = 20

Opacity to be used for virtual bends (see virtualBendsEnabled).

20
virtualBends: undefined | Shape[]
virtualBendsEnabled: boolean = false

Specifies if virtual bends should be added in the center of each segment. These bends can then be used to add new waypoints.

false

Methods

  • Changes the terminal or terminal point of the given edge in the graph model.

    Parameters

    • edge: Cell

      Cell that represents the edge to be reconnected.

    • terminal: Cell

      Cell that represents the new terminal.

    • isSource: boolean

      Boolean indicating if the new terminal is the source or target terminal.

    • isClone: boolean

      Boolean indicating if the new connection should be a clone of the old edge.

    • me: InternalMouseEvent

      MouseEvent that contains the mouse up event.

    Returns Cell

  • Converts the given point in-place from screen to unscaled, untranslated graph coordinates and applies the grid. Returns the given, modified point instance.

    Parameters

    • point: Point

      Point to be converted.

    • gridEnabled: boolean

      Boolean that specifies if the grid should be applied.

    Returns Point

  • Returns the fillcolor for the handle at the given index.

    Parameters

    • index: number

    Returns string

  • Returns the tolerance for the guides. Default value is gridSize * scale / 2.

    Returns number

  • Helper method to initialize the given bend.

    Parameters

    • bend: Shape

      Shape that represents the bend to be initialized.

    • OptionaldblClick: ((evt: MouseEvent) => void)
        • (evt): void
        • Parameters

          • evt: MouseEvent

          Returns void

    Returns void

  • Returns true if the given event is a trigger to add a new Point. This implementation returns true if shift is pressed.

    Parameters

    • evt: MouseEvent

    Returns boolean

  • Returns true if the given cell allows new connections to be created. This implementation always returns true.

    Parameters

    Returns boolean

  • Returns true if the given cell is connectable. This is a hook to disable floating connections. This implementation returns true.

    Parameters

    Returns boolean

  • Creates the shape used to display the given bend.

    Parameters

    • index: number

    Returns boolean

  • Returns true if the handle at the given index is visible.

    Parameters

    • index: number

    Returns boolean

  • Returns true if the parent highlight should be visible. This implementation always returns true.

    Returns null | boolean

  • Returns true if the given event is a trigger to remove a point. This implementation returns true if shift is pressed.

    Parameters

    • evt: MouseEvent

    Returns boolean

  • Returns true if virtual bends should be added. This returns true if virtualBendsEnabled is true and the current style allows and renders custom waypoints.

    Parameters

    • Optionalevt: Event

    Returns undefined | boolean

  • Changes the coordinates for the label of the given edge.

    Parameters

    • edgeState: CellState
    • x: number

      Integer that specifies the x-coordinate of the new location.

    • y: number

      Integer that specifies the y-coordinate of the new location.

    Returns void

  • Destroys the handler and all its resources and DOM nodes. This does normally not need to be called as handlers are destroyed automatically when the corresponding cell is deselected.

    Returns void

  • Redraws the preview, and the bends- and label control points.

    Parameters

    • OptionalignoreHandles: boolean

    Returns void

  • Hook for rounding the unscaled width or height. This uses Math.round.

    Parameters

    • length: number

    Returns number

  • Starts the handling of the mouse gesture.

    Parameters

    • x: number
    • y: number
    • index: number

    Returns void

  • Returns the error message or an empty string if the connection for the given source, target pair is not valid. Otherwise, it returns null. This implementation uses Graph#getEdgeValidationError.

    Parameters

    • source: null | Cell

      Cell that represents the source terminal.

    • target: null | Cell

      Cell that represents the target terminal.

    Returns null | string