An implementation of a IHandleProvider that can be used for IEdges.
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
Initializes a new instance of the PortRelocationHandleProvider class using the given graph and edge.
Parameters
A map of options to pass to the method.
- graph - IGraph
- The graph or null. If the graph is null, the handles will try to receive the graph from the IInputModeContext it is used in.
- edge - IEdge
- The edge.
Properties
Gets or sets the maximum distance the pointer may be away of a candidate in order to be snapped to the candidate.
Remarks
50.0
.See Also
Gets or sets a value indicating whether to show the candidates of hit IPortOwners only.
Gets or sets a value indicating whether to show port candidates.
Gets or sets whether the owner of the current IPortCandidate should be highlighted.
Methods
Factory method that creates the handle for this provider.
Gets an IHandle implementation for one end of the provided edge
.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context in which the handle will be used.
- edge - IEdge
- The edge for which an handle is needed.
- sourceHandle - boolean
- if set to
true
the handle for the source side/port should be returned.
Returns
- ↪IHandle
- The handle to use for the provided side or
null
.
Implements
Returns a collection of zero or more IHandle implementations that are associated with this instance.