A sophisticated implementation of the IHandle interface that lets the user change an edge's source and target port.
Remarks
Examples
Instances of this IHandle are provided by the PortRelocationHandleProvider. The most commonly used settings are available on the PortRelocationHandleProvider, 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.PortRelocationHandle
See Also
Constructors
Creates a new instance of the PortRelocationHandle class.
Parameters
A map of options to pass to the method.
- graph - IGraph
- The graph or
null
. If the graph instance is not specified, the handle will try to receive the graph from the IInputModeContext it is passed in during initializeDrag. - edge - IEdge
- The edge.
- sourceEnd - boolean
- if set to
true
the source end will be subject to relocation, otherwise it will be the target port.
Properties
Gets or sets a property that determines whether the existing port should be available as a possible port candidate, too.
Remarks
true
. If this property is set to false
, getPortCandidates will return only the ports provided by the IPortCandidateProvider in the node's lookup.Gets or sets whether or not cyclic port dependencies are allowed.
Remarks
false
.Gets the dummy edge this instance uses during the edit.
Gets the edge this instance acts upon.
Gets or sets the context to operate on.
Gets a view of the location of the item.
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 the event recognizer that determines whether to resolve a dynamic port candidate.
Remarks
Note that this property has no effect if resolvePortCandidates is set to false
.
By default this is set to SHIFT_IS_DOWN.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
Parameters
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets or sets a value indicating whether a dynamic port candidate should be resolved for the current mouse location.
Remarks
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.
Remarks
true
.See Also
Gets or sets how the changed edge should be shown during the gesture.
Remarks
This property must not be changed during the gesture.
If this property is set to LIVE it is crucial that constructor's graph
parameter is not null
and its edge
parameter is an edge which is contained in that graph.
Default is DUMMY.
See Also
Methods
Called by clients to indicate that the dragging has been canceled by the user.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context to retrieve information about the drag from.
- originalLocation - Point
- The value of the coordinate of the location property at the time of initializeDrag.
See Also
Implements
Factory method that creates the ICanvasObjectDescriptor that will be used to paint the "current" IPortCandidate.
Returns
- ↪ICanvasObjectDescriptor
- The descriptor to use for the rendering in the CanvasComponent.
Factory method that creates the dummy edge that will be shown during the drag operation.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge to be represented by the dummy edge.
Returns
- ↪SimpleEdge
- The dummy edge instance to use.
See Also
Factory method that creates a dummy IVisualCreator for the dummy edge during the drag operation.
Remarks
Parameters
A map of options to pass to the method.
- dummy - SimpleEdge
- The dummy to create an IVisualCreator for.
Returns
- ↪IVisualCreator
- An IVisualCreator that shows the dummy.
See Also
Factory method that creates the candidate for the existing port.
Parameters
A map of options to pass to the method.
- port - IPort
- The port to create a candidate for.
Returns
- ↪IPortCandidate
- The candidate or
null
.
See Also
Factory method that creates the ICanvasObjectDescriptor that will be used to paint the IPortCandidates.
Returns
- ↪ICanvasObjectDescriptor
- The descriptor to use for the rendering in the CanvasComponent.
Called by clients to indicate that the repositioning has just been finished.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context to retrieve information about the drag from.
- originalLocation - Point
- The value of the location property at the time of initializeDrag.
- newLocation - Point
- The coordinates in the world coordinate system that the client wants the handle to be at. Depending on the implementation the location may or may not be modified to reflect the new value. This is the same value as delivered in the last invocation of handleMove
See Also
Implements
filterCandidates
(context: IInputModeContext, location: Point, allCandidates: IEnumerable<IPortCandidate>) : IEnumerable<IPortCandidate>Filters the given allCandidates
to return the subset of candidates which are relevant at the given location
.
Remarks
If showHitPortOwnerCandidatesOnly is set to true
this implementation returns only the candidates of the port owner at the given location. Otherwise it returns the entire allCandidates
.
Developers can override this method to apply a different filter, e.g. all port candidates in a defined radius around the location
.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context that is used to retrieve the candidates for.
- location - Point
- The current location.
- allCandidates - IEnumerable<IPortCandidate>
- All possible port candidates.
Returns
- ↪IEnumerable<IPortCandidate>
- The filtered list of port candidates.
getClosestCandidate
(context: IInputModeContext, location: Point, candidates: IEnumerable<IPortCandidate>) : IPortCandidateFinds the closest candidate from the given set of candidates.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context in for which the closest handle candidate is sought.
- location - Point
- The location for which to find a candidate.
- candidates - IEnumerable<IPortCandidate>
- The list of possible candidates.
Returns
- ↪IPortCandidate
- The closes candidate or
null
.
Gets the IPortOwner at the given location
.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- location - Point
- The location to find a port owner at.
Returns
- ↪IPortOwner
- The IPortOwner at the given location or
null
.
Gets the graph to use from the context.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
Returns
- ↪IGraph
- A graph instance or
null
.
getPort
(context: IInputModeContext, portCandidate: IPortCandidate, suggestedLocation: Point) : IPortCalled during dragFinished to actually get the new port from the chosen candidate.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- portCandidate - IPortCandidate
- The candidate to get a port instance from.
- suggestedLocation - Point
- The suggested location for the port.
Returns
- ↪IPort
- A non-
null
port instance.
See Also
getPortCandidates
(context: IInputModeContext, edge: IEdge, sourcePort: boolean) : IEnumerable<IPortCandidate>Gets the possible candidates for the given edge.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context that is used to retrieve the candidates for.
- edge - IEdge
- The edge.
- sourcePort - boolean
- Whether to look for source port candidates.
Returns
- ↪IEnumerable<IPortCandidate>
- A non-
null
enumerable over the candidates.
getPortCandidatesDuringMove
(context: IInputModeContext, edge: IEdge, sourcePort: boolean) : IEnumerable<IPortCandidate>Retrieves the port candidates during handleMove.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context that is used to retrieve the candidates for.
- edge - IEdge
- The edge.
- sourcePort - boolean
- Whether to look for source port candidates.
Returns
- ↪IEnumerable<IPortCandidate>
- A non-
null
enumerable over the candidates.
Called to indicate that the handle has been clicked by the user.
Remarks
This method is called by HandleInputMode when clickedRecognizer or clickedRecognizerTouch is triggered.
Changing the cursor or type of the clicked handle will instantly be considered by the HandleInputMode but handles won't be requeried automatically. If for example different handles should be used as a result of the click, requeryHandles has to be called.
Parameters
A map of options to pass to the method.
- evt - ClickEventArgs
- Arguments describing the click.
See Also
Implements
Called by clients to indicate that the element has been dragged and its position should be updated.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context to retrieve information about the drag from.
- originalLocation - Point
- The value of the location property at the time of initializeDrag.
- newLocation - Point
- The coordinates in the world coordinate system that the client wants the handle to be at. Depending on the implementation the location may or may not be modified to reflect the new value.
See Also
Implements
Hides the original edge that during the drag operation.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context to get the canvas the edge should be hidden from.
- edge - IEdge
- The edge to hide.
See Also
Called by clients to indicate that the element is going to be dragged.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context to retrieve information about the drag from.
See Also
Implements
Determines whether port candidate resolution is enabled for the current gesture.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context to inspect.
Returns
- ↪boolean
true
if port candidates may be resolved;false
otherwise.
resolveCandidate
(context: IInputModeContext, portCandidate: IPortCandidate, location: Point) : IPortCandidateTries to resolve a dynamic port candidate for the given location.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context in which the candidate is resolved.
- portCandidate - IPortCandidate
- The candidate.
- location - Point
- The current location.
Returns
- ↪IPortCandidate
- A candidate.
Updates the closest candidate for visual feedback.
setPort
(context: IInputModeContext, edge: IEdge, setSourcePort: boolean, portCandidate: IPortCandidate, suggestedLocation: Point)Triggered by dragFinished to actually change the port.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context.
- edge - IEdge
- The edge to change ports.
- setSourcePort - boolean
- Whether to set the source port.
false
for target ports. - portCandidate - IPortCandidate
- The candidate that has been chosen.
- suggestedLocation - Point
- The suggested location for the port.
Finally sets the ports for the edge to the new values.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context in which the ports are set.
- edge - IEdge
- The edge to set the ports for.
- sourcePort - IPort
- The (possibly) new source port.
- targetPort - IPort
- The (possibly) new target port.
Updates the dummy edge's visual appearance to reflect the new port candidate.
Parameters
A map of options to pass to the method.
- dummy - SimpleEdge
- The dummy edge.
- source - boolean
- Whether to update the source or target port.
- portCandidate - IPortCandidate
- The new candidate to indicate.
Unhides the original edge that was hidden during the drag operation.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge to unhide.
- canvas - CanvasComponent
- The canvas the edge was hidden from.
See Also
Draws the highlight for the owner of the current port candidate.
Remarks
This implementation retrieves the HighlightIndicatorManager<T> from the inputModeContext's ILookup.
Overriders have to take care of removal of the highlight of the oldCandidate
's owner, too.
Parameters
A map of options to pass to the method.
- oldCandidate - IPortCandidate
- The port candidate whose owner is currently highlighted.
- newCandidate - IPortCandidate
- The port candidate whose owner should be highlighted.
See Also
Constants
A string to define the pen for the visualization if visualization is set to GHOST.