documentationfor yFiles for HTML 2.6

PortRelocationHandleProvider

An implementation of a IHandleProvider that can be used for IEdges.

Inheritance Hierarchy
PortRelocationHandleProvider
Implemented Interfaces

Remarks

It will return the IHandles for the source and target ports using PortRelocationHandles.

The properties showHitPortOwnerCandidatesOnly, maximumSnapDistance and visualization will only be used in createPortRelocationHandle to configure the created PortRelocationHandles.

Note that this implementation also explicitly implements the IEdgePortHandleProvider and that it is recommended to decorate the IEdgePortHandleProvider interface with edges in order to influence the handles of the source and target port of the edge instead of directly decorating and implementing the IHandleProvider interface. The default implementation of the IHandleProvider interface in the lookup of the IEdges (see DEFAULT_EDGE_LOOKUP) will use the IEdgeReconnectionPortCandidateProvider interface to collect the source and target port handles.

Examples

This implementation provides instances of PortRelocationHandle. The most commonly used settings for PortRelocationHandle are available here, too:

graph.decorator.edgeDecorator.edgePortHandleProviderDecorator.setFactory(
  (edge) => {
    const portRelocationHandleProvider = new PortRelocationHandleProvider(
      graph,
      edge
    )
    portRelocationHandleProvider.visualization = Visualization.LIVE
    portRelocationHandleProvider.showPortCandidates = false
    return portRelocationHandleProvider
  }
)

For less frequently used settings a custom PortRelocationHandleProvider has to be provided and its createPortRelocationHandle method has to be overridden to provide the configured PortRelocationHandle:

graph.decorator.edgeDecorator.edgePortHandleProviderDecorator.setFactory(
  (edge) => {
    const portRelocationHandleProvider = new MyHandleProvider(graph, edge)
    portRelocationHandleProvider.visualization = Visualization.LIVE
    portRelocationHandleProvider.showPortCandidates = false
    return portRelocationHandleProvider
  }
)

class MyHandleProvider extends PortRelocationHandleProvider {
  /**
   * @param {!IGraph} graph
   * @param {!IEdge} edge
   */
  constructor(graph, edge) {
    super(graph, edge)
  }

  /**
   * @param {!IGraph} graph
   * @param {!IEdge} edge
   * @param {boolean} sourceEnd
   * @returns {!IHandle}
   */
  createPortRelocationHandle(graph, edge, sourceEnd) {
    const portRelocationHandle = new PortRelocationHandle(
      graph,
      edge,
      sourceEnd
    )
    portRelocationHandle.addExistingPort = true
    return portRelocationHandle
  }
}graph.decorator.edgeDecorator.edgePortHandleProviderDecorator.setFactory(
  (edge) => {
    const portRelocationHandleProvider = new MyHandleProvider(graph, edge)
    portRelocationHandleProvider.visualization = Visualization.LIVE
    portRelocationHandleProvider.showPortCandidates = false
    return portRelocationHandleProvider
  }
)

class MyHandleProvider extends PortRelocationHandleProvider {
  constructor(graph: IGraph, edge: IEdge) {
    super(graph, edge)
  }

  createPortRelocationHandle(
    graph: IGraph,
    edge: IEdge,
    sourceEnd: boolean
  ): IHandle {
    const portRelocationHandle = new PortRelocationHandle(
      graph,
      edge,
      sourceEnd
    )
    portRelocationHandle.addExistingPort = true
    return portRelocationHandle
  }
}

Type Details

yfiles module
view-editor
yfiles-umd modules
view-editor, view-table, view
Legacy UMD name
yfiles.input.PortRelocationHandleProvider

See Also

Constructors

Properties

Methods

Fields