This interface is used to provide IPortCandidates for a specific IPortOwner.
Remarks
It is used in the context of the items that will later become the owner (IPortOwner) of the ports obtained from the candidates. They are mainly used during edge creation where there is no real edge yet (only the helper edge) and thus they need to use the opposite IPortCandidate to understand the context.
Implementations of this interface may be queried using the lookup method of IPortOwner implementations like INode.
Note that this interface is similar to the interface IEdgeReconnectionPortCandidateProvider in the sense that they will both provide IPortCandidate instances in a certain query context. They are used in different query contexts, though. The two interfaces can come together in concrete implementations of IEdgeReconnectionPortCandidateProvider: an edge could potentially be connected to ports at any given IPortOwner and thus the IPortCandidateProvider interface can be queried from the respective IPortOwner that the edge will be reconnected to.
Related Programming Samples
- Port Candidate Provider
- Shows how edge creation can be customized.
Type Details
- yFiles module
- view
See Also
Methods
Returns all source port candidates that belong to the context of this provider.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context for which the candidates should be provided.
Returns
- ↪IEnumerable<IPortCandidate>
- An enumerable over all source port candidates that are associated with the current context.
See Also
Returns all target port candidates that belong to the context of this provider.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context for which the candidates should be provided.
Returns
- ↪IEnumerable<IPortCandidate>
- An enumerable over all target port candidates that are associated with the current context.
See Also
getSourcePortCandidates
(context: IInputModeContext, target: IPortCandidate) : IEnumerable<IPortCandidate>Returns all port candidates that apply for the provided opposite port candidate.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context for which the candidates should be provided.
- target - IPortCandidate
- The opposite port candidate.
Returns
- ↪IEnumerable<IPortCandidate>
- An enumerable over all port candidates that are associated with the given opposite port.
See Also
getTargetPortCandidates
(context: IInputModeContext, source: IPortCandidate) : IEnumerable<IPortCandidate>Returns all port candidates that apply for the provided opposite port candidate.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context for which the candidates should be provided.
- source - IPortCandidate
- The opposite port candidate.
Returns
- ↪IEnumerable<IPortCandidate>
- An enumerable over all port candidates that are associated with the given opposite port.
See Also
Constants
A generic implementation of the IPortCandidateProvider interface that provides no candidates.
Examples
graph.decorator.nodes.portCandidateProvider.addConstant(
IPortCandidateProvider.NO_CANDIDATES,
)
See Also
Static Methods
Creates a generic composite implementation for the IPortCandidateProvider interface.
Parameters
A map of options to pass to the method.
- providers - IEnumerable<IPortCandidateProvider>
- The providers to create the composite from.
Returns
- ↪IPortCandidateProvider
- An instance of IPortCandidateProvider that combines the given providers.
Examples
graph.decorator.nodes.portCandidateProvider.addFactory((node) =>
IPortCandidateProvider.combine(
IPortCandidateProvider.fromNodeCenter(node),
IPortCandidateProvider.fromShapeGeometry(node, 0.25, 0.75),
),
)
See Also
Creates a generic composite implementation for the IPortCandidateProvider interface.
Parameters
A map of options to pass to the method.
- providers - IPortCandidateProvider
- The providers to create the composite from.
Returns
- ↪IPortCandidateProvider
- An instance of IPortCandidateProvider that combines the given providers.
Examples
graph.decorator.nodes.portCandidateProvider.addFactory((node) =>
IPortCandidateProvider.combine(
IPortCandidateProvider.fromNodeCenter(node),
IPortCandidateProvider.fromShapeGeometry(node, 0.25, 0.75),
),
)
Parameters
A map of options to pass to the method.
- getSourcePortCandidates - function(IInputModeContext, IPortCandidate):IEnumerable<IPortCandidate>
Returns all port candidates that apply for the provided opposite port candidate.
This property holds the implementation for getSourcePortCandidates.
- getTargetPortCandidates - function(IInputModeContext, IPortCandidate):IEnumerable<IPortCandidate>
Returns all port candidates that apply for the provided opposite port candidate.
This property holds the implementation for getTargetPortCandidates.
- getAllSourcePortCandidates - function(IInputModeContext):IEnumerable<IPortCandidate>
Returns all source port candidates that belong to the context of this provider.
This property holds the implementation for getAllSourcePortCandidates.
- getAllTargetPortCandidates - function(IInputModeContext):IEnumerable<IPortCandidate>
Returns all target port candidates that belong to the context of this provider.
This property holds the implementation for getAllTargetPortCandidates.
Creates an implementation of an IPortCandidateProvider that provides only the given port candidates.
Parameters
A map of options to pass to the method.
- candidates - IPortCandidate
- The port candidates the provider should provide.
Returns
- ↪PortCandidateProviderBase
- An instance of PortCandidateProviderBase that returns the given port candidates.
Creates an implementation of an IPortCandidateProvider that provides only the given port candidates.
Parameters
A map of options to pass to the method.
- candidates - IEnumerable<IPortCandidate>
- The port candidates the provider should provide.
Returns
- ↪PortCandidateProviderBase
- An instance of PortCandidateProviderBase that returns the given port candidates.
See Also
Creates an implementation of the IPortCandidateProvider interface that returns the ports that exist in the given ports's IPortOwner collection.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The owner of the port collection.
Returns
- ↪IPortCandidateProvider
- An instance of IPortCandidateProvider that provides the ports from the owner's collection.
Examples
graph.decorator.nodes.portCandidateProvider.addFactory((node) =>
IPortCandidateProvider.fromExistingPorts(node),
)
See Also
Creates a trivial implementation of an IPortCandidateProvider that always returns exactly one candidate that is centered at the node's layout.
Parameters
A map of options to pass to the method.
- node - INode
- The node to get the layout's center from.
Returns
- ↪PortCandidateProviderBase
- An instance of PortCandidateProviderBase that returns the candidate centered at the node's layout.
Examples
graph.decorator.nodes.portCandidateProvider.addFactory((node) =>
IPortCandidateProvider.fromNodeCenter(node),
)
See Also
Creates an implementation of an IPortCandidateProvider that always returns a candidate that uses the default locationParameter for the corresponding IPortDefaults.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The owner of the port.
Returns
- ↪IPortCandidateProvider
- An instance of IPortCandidateProvider that always returns a candidate that uses the default locationParameter for the corresponding IPortDefaults.
Examples
graph.decorator.nodes.portCandidateProvider.addFactory((node) =>
IPortCandidateProvider.fromPortDefaults(node),
)
See Also
Creates an implementation of IPortCandidateProvider that works for IPortOwner implementations that have IShapeGeometry instances in their lookup.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The owner to receive the shape geometry from
- ratios - number
- A number of double values that are interpreted as ratio values between 0.0 and 1.0. If none are given, the provider inserts a port candidate at the center of each straight line segment.
Returns
- ↪PortCandidateProviderBase
- An instance of PortCandidateProviderBase that provides the ports from the shape geometry.
Examples
graph.decorator.nodes.portCandidateProvider.addFactory((node) =>
IPortCandidateProvider.fromShapeGeometry(node, 0.25, 0.75),
)
See Also
fromShapeGeometry
(owner: IPortOwner, addExistingPortsEnabled: boolean, minimumSegmentLength: number, ratios: number…) : PortCandidateProviderBaseCreates an implementation of IPortCandidateProvider that works for IPortOwner implementations that have IShapeGeometry instances in their lookup.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The owner to receive the shape geometry from
- addExistingPortsEnabled - boolean
- Determines whether existing ports should be added to the list of ports.
- minimumSegmentLength - number
- The minimum length a segment needs to have in order to be used to add port candidates.
- ratios - number
- A number of double values that are interpreted as ratio values between 0.0 and 1.0. If none are given, the provider inserts a port candidate at the center of each straight line segment.
Returns
- ↪PortCandidateProviderBase
- An instance of PortCandidateProviderBase that provides the ports from the shape geometry.
Examples
graph.decorator.nodes.portCandidateProvider.addFactory((node) =>
IPortCandidateProvider.fromShapeGeometry(node, 0.25, 0.75),
)
Creates an implementation of an IPortCandidateProvider that returns unoccupied ports at a given entity.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The owner to query the ports from.
Returns
- ↪IPortCandidateProvider
- An instance of IPortCandidateProvider that returns unoccupied ports.
Examples
graph.decorator.nodes.portCandidateProvider.addFactory((node) =>
IPortCandidateProvider.fromUnoccupiedPorts(node),
)