An implementation of an 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.edges.portHandleProvider.addFactory((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.edges.portHandleProvider.addFactory((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
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 from a candidate in order to be snapped to the candidate.
Remarks
50.0
.See Also
Gets or sets the IObjectRenderer<PortCandidateRenderTag> that visualizes the IPortCandidates.
Remarks
When queried for an IVisualCreator to obtain the visualizations for port candidates, this renderer is passed instances of PortCandidateRenderTag as render tag. The renderer may change the appearance of a port candidate depending on isCurrentCandidate and validity.
This class will assign the value of this property to portCandidateRenderer in createPortRelocationHandle.
The default value is an instance of PortCandidateRenderer.
Property Value
See Also
Gets or sets a value indicating whether to show the candidates of hit IPortOwners only.
Property Value
true
if only candidates of hit nodes and edges are shown; false
otherwise.See Also
Gets or sets a value indicating whether to show port candidates.
Property Value
true
port candidates should be shown; false
otherwise. Default is true
.See Also
Gets or sets whether the owner of the current IPortCandidate should be highlighted.
Gets or sets how the changed edge should be shown during the gesture.
Remarks
If this property is set to LIVE it is crucial that graph is not null
and edge is contained in that graph.
Default is PLACEHOLDER.
See Also
Methods
Factory method that creates the handle for this provider.
Gets an IHandle implementation for one end of the edge.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context in which the handle will be used.
- 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.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The IInputModeContext that provides the invoking mode.
Returns
- ↪IEnumerable<IHandle>
- A collection of handles.