- I
Remarks
This class provides a factory callback that the final edge creation will be delegated to. The styling of the newly created edge can be customized via the edgeDefaults. Defaults can be automatically adjusted in response to the various events that will be triggered by this instance during the edge creation.
Use the previewGraph property to modify the appearance of the preview edge. This class uses IPortCandidateProvider instances found in the ILookup of the nodes in the graph to display port candidates and to finally create the edges.
The CreateEdgeInputMode provides a well-defined event lifecycle to track the progression of the edge creation:
- gesture-starting – Occurs when the edge creation gesture is initiated. This happens before the edge becomes visible and marks the beginning of the interaction sequence.
- gesture-started – Occurs immediately after gesture-starting, indicating that the gesture has been fully initialized and is now in progress. This event precedes any visible feedback or edge creation operations.
- edge-creation-started – Occurs when the creation of an edge visibly begins. This happens when the cursor moves outside the source node during the gesture. At this point, the target port candidate becomes relevant.
- gesture-canceling – Occurs when the edge creation gesture is about to be canceled. This event is always followed by gesture-canceled.
- gesture-canceled – Occurs when the gesture has been canceled. No edge will be created, and the gesture sequence ends.
- gesture-finishing – Occurs when the gesture is about to be successfully completed. This event allows the target port candidate to be updated one last time before finalization.
- edge-created – Occurs after an edge has been successfully created as a result of the interaction.
- gesture-finished – Occurs when the edge creation gesture has successfully completed and all operations are finalized.
Additionally, the following auxiliary events provide specific feedback during the gesture:
- moving and moved – These events occur at the start and end of every drag or move action during the gesture.
- edge-direction-reversed – Occurs if the direction of the edge creation is reversed during the gesture.
This event sequence ensures symmetry between the initialization and finalization of gestures, and provides fine-grained control for handling cancellations and completions.
This mode is exclusive by default.
Examples
CreateEdgeInputMode is installed as child mode of a GraphEditorInputMode and can be retrieved from the createEdgeInputMode property.const createEdgeInputMode = mode.createEdgeInputModemode.moveViewportInputMode.allowSinglePointerMovement = true
mode.createBendInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.createEdgeInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.handleInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.lassoSelectionInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.marqueeSelectionInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.moveSelectedItemsInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWNSee Also
- An overview of this input mode is given in the section Creating Edges. Additionally, customization of edge creation is discussed in section Customizing User Interaction: Creating Edges .
Developer's Guide
Members
Constructors
Creates a new instance that will use the IGraph from the parentInputModeContext to create edges in.
Properties
true.Examples
// mode is an instance of GraphEditorInputMode
mode.createBendInputMode.enabled = false
mode.createEdgeInputMode.allowCreateBend = falseSee Also
Developer's Guide
false.Examples
createEdgeInputMode.allowEdgeToEdgeConnections = trueSee Also
Developer's Guide
true, which enables that an edge is connected to a sourcePort and targetPort that have the same owner.Examples
createEdgeInputMode.allowSelfLoops = trueSee Also
Developer's Guide
Gets or sets a IHitTestable that determines whether it is valid to start an edge creation gesture here.
true if the cursor is located over a port owner.Examples
To avoid showing port candidates for selected nodes (e.g. to move them instead of considering them as the start point of an edge creation), developers might set a hit testable which excludes selected items.
class UnselectedNodesHitTestable extends BaseClass<IHitTestable>(
IHitTestable,
) {
isHit(context: IInputModeContext, location: Point): boolean {
const graphComponent = context.canvasComponent as GraphComponent
return graphComponent.graph.nodes.some(
(node) =>
!graphComponent.selection.includes(node) &&
node.style.renderer
.getHitTestable(node, node.style)
.isHit(context, location),
)
}
}Note that the same hit testable should be set to showStartPortCandidatesHitTestable, too.
Gets or sets the event recognizer that recognizes the start gesture that is used to prepare the edge creation on the start node or edge.
Gets or sets the event recognizer that recognizes the touch gesture that is used to prepare the edge creation on the start node.
Gets or sets a value that specifies whether moving the input focus away from the canvasComponent cancels edge creation.
Gets or sets whether after calls to createEdge the current undo edit should be canceled if the method returns null.
null.false if you want to perform some undoable actions in these methods and/or in the edgeCreator callback, but need to return null from any of these methods. Default value is true, meaning that returning null results in canceling the composite undo entry.If bend creation is allowed at the current location (i.e. validBendHitTestable returns true), the gesture will always continue by creating a bend. Otherwise, if this property is true, the gesture will be canceled automatically.
The default is true, meaning that the gesture ends when continuing is not possible.
See Also
Gets or sets the event recognizer that determines whether to cancel edge creation.
Gets or sets the event recognizer that determines whether to cancel edge creation via touch.
Gets the installed controller.
Gets or sets the event recognizer that determines whether to create a bend.
Gets or sets the event recognizer that determines whether to create a bend via touch.
Gets or sets the event recognizer that constrains the current edge segment to be orthogonal or diagonal.
Gets or sets the event recognizer that temporarily disables snapping.
Gets or sets the cursor that is used while a new edge is created when there is no valid location to create a bend.
Gets the dynamically updated dragging point for the edge creation.
Gets or sets the ports-based edge creation callback.
The default creator will delegate to createEdge and obtain the tag from the previewEdge. It will then copy over all bends, labels, and ports from the previewEdge.
When a Promise is returned, this mode will keep the mutex until it is resolved, thereby blocking any user interaction.
Property Value
Throws
- Exception ({ name: 'ArgumentError' })
- If the argument is
null
Examples
// set a custom edge creator which creates a label on the new edge
createEdgeInputMode.edgeCreator = (
context: IInputModeContext,
graph: IGraph,
sourceCandidate: IPortCandidate,
targetCandidate: IPortCandidate | null,
dummyEdge: IEdge,
): IEdge | null | Promise<IEdge | null> => {
if (targetCandidate === null) {
return null
}
// get the source and target ports from the candidates
const sourcePort =
sourceCandidate.port !== null
? sourceCandidate.port
: sourceCandidate.createPort(context)
const targetPort =
targetCandidate.port !== null
? targetCandidate.port
: targetCandidate.createPort(context)
// create the edge between the source and target port
const edge = graph.createEdge(sourcePort, targetPort, dummyEdge.style)
// create a label
graph.addLabel(edge, 'A new edge')
// return the created edge
return edge
}See Also
Developer's Guide
Gets or sets the appearance of newly created edges.
See Also
Developer's Guide
Gets or sets a value that determines how the direction of a newly created edge is determined.
This property is START_AT_SOURCE by default which means that edges are created from the source to the target. Setting the value to DETERMINE_FROM_PORT_CANDIDATES will query both source and target port candidates during getStartPortCandidates. Depending on which candidate is chosen in getStartPortCandidate the edge creation will either be reversed or not.
Setting the property to another value during edge creation will not affect the current edge. Set reversedEdgeCreation to control the direction of a currently active edge creation.
Examples
mode.createEdgeInputMode.enabled = falseSee Also
Developer's Guide
Gets or sets the event recognizer that re-enables temporarily disabled snapping.
Gets or sets a IHitTestable that determines whether it is valid to finish an edge creation gesture here if valid IPortCandidates are available.
This hit testable is only queried if forceSnapToCandidate is disabled.
If this IHitTestable returns true a valid port candidate is searched. If and only if one is found the current location is considered as possible end for an edge creation. If this IHitTestable returns false prematureEndHitTestable is queried.
The default implementation returns true if there is a port owner at the given location.
See Also
Developer's Guide
Gets or sets the event recognizer that recognizes the movement of the end point of the edge.
Gets or sets the current candidate for the end point of the dragged edge to be created.
See Also
Developer's Guide
Gets or sets the event recognizer that will be queried to decide if bend creation is enforced.
The value of this property will be delegated to the exclusive property of the controller.
If this mode is marked as exclusive and has the mutex, all other modes added to the same MultiplexingInputMode will be deactivated. Otherwise, it will always run concurrently with all other modes.
Gets or sets the event recognizer that recognizes the finishing gesture that is used to end the edge creation on the end node.
Gets or sets the event recognizer that recognizes the touch gesture that is used to end the edge creation on the end node.
true.See Also
Developer's Guide
Gets the graph this mode is acting upon.
Throws
- Exception ({ name: 'NotSupportedError' })
- If there is no input mode context available or the context does not contain the graph in the lookup.
2 so if you accidentally start an edge creation, you can cancel edge creation by going back to the start node. This limit is only considered when the edge allows adding bends, at all.See Also
Developer's Guide
Gets or sets the event recognizer that recognizes the initial gesture that is used to initiate the creation after the preparation.
Gets or sets the event recognizer that recognizes the touch gesture that is used to initiate the edge creation after the preparation.
Gets or sets the policy that controls whether edges will be created orthogonally.
See Also
Developer's Guide
API
- orthogonalEdgeEditingContext, isOrthogonallyEditedEdge, enabled
5.Retrieves the IInputModeContext this mode has been installed in.
null if this mode is currently not installed. Use createInputModeContext to obtain a context that has this IInputMode as the inputMode.Gets or sets the IObjectRenderer<PortCandidateRenderTag> that visualizes IPortCandidates while creating edges.
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.
By default, an instance of PortCandidateRenderer is used.
Gets or sets the event recognizer that determines whether dynamic port candidates should be resolved.
Gets or sets a IHitTestable that determines whether it is valid to finish an edge creation gesture here even if no IPortCandidates are available.
This hit testable is only queried if forceSnapToCandidate is disabled and endHitTestable returns false or no valid port candidate is found.
If this IHitTestable returns true, the current location is considered as a possible end for an edge creation, even if no valid IPortCandidate is available as an end port candidate.
The default implementation always returns false.
See Also
Developer's Guide
Gets the preview edge instance that will be used to render a preview of the edge to be created.
See Also
Developer's Guide
The INode which is used as a moving end node for the temporarily created previewEdge during edge creation.
The IPort which is used as the end port for the temporarily created previewEdge during edge creation.
This port's owner is the previewEndNode. This port is used as end port of the previewEdge unless the preview edge snaps to a valid endPortCandidate in which case the edge is connected to the port represented by that candidate.
The appearance of it can be changed via previewGraph.
Gets the preview graph instance that will hold the items that will render a preview of the newly created edge.
The preview graph can be used to change the appearance and other properties of the preview edge, either when starting a gesture or during it in response to certain events. Possible actions are:
- Changing the style of the preview edge.
- Adding bends to the preview edge.
- Adding labels to the preview edge.
- Changing style and other properties of the added labels.
All changes made to the preview edge during the gesture will be persisted to the created edge in the original graph. This behavior can be changed by setting a custom edgeCreator.
The preview graph only allows operations on the preview edge.
Changing style of the preview edge's source or target port has no effect. The style for these is controlled by the IPortCandidates and hence by an IPortCandidateProvider.
See Also
Developer's Guide
API
- previewEdge
Implements
IInputMode.priorityGets or sets the event recognizer that determines whether to remove the last created bend.
Gets or sets the event recognizer that determines whether to remove the last created bend via touch.
Gets or sets a value indicating whether DYNAMIC ports that are part of the end port candidates should be resolved for the current pointer location.
See Also
Gets or sets a value indicating whether DYNAMIC ports that are part of the start port candidates should be resolved for the current mouse location.
By default, this feature is enabled and the portCandidateResolutionRecognizer is configured so that the resolution mechanism is used if the user holds the shift modifier during the gesture.
Note that "start" refers to the port candidate where the edge creation started. In case of reversedEdgeCreation this will actually become the targetPort of the edge in the end.
See Also
Gets or sets a value indicating whether the current edge creation should be created from its targetPort to its sourcePort.
Examples
Setting the reversedEdgeCreation in a listener to the start-port-candidate-changed event allows for fully customizing the edge creation direction. The example shows how to set the direction according to the candidate's tag.
createEdgeInputMode.addEventListener(
'start-port-candidate-changed',
(evt) =>
(createEdgeInputMode.reversedEdgeCreation =
evt.item.owner.tag === 'createFromTarget'),
)Setting this value as shown above will override the edgeDirectionPolicy.
See Also
Gets or sets whether the owner of the current endPortCandidate should be highlighted.
Gets or sets whether and where to display possible port candidates during the creation of the edge.
Setting this property to START or ALL will result in displaying start port candidates for each item the pointer is hovering over. For a CreateEdgeInputMode as child of a default GraphEditorInputMode selected nodes will rather be moved than serve as start of an edge creation. To disable showing port candidates for selected nodes developers might set appropriate showStartPortCandidatesHitTestable and beginHitTestables. An example IHitTestable is shown there.
The default is ALL.
See Also
Developer's Guide
API
- startPortCandidateHitRadius
Gets or sets the amount of time to wait until the start port candidates are displayed, when the user hovers over a start port candidate owner.
See Also
Developer's Guide
API
- showPortCandidates, startOverCandidateOnly
Gets or sets a IHitTestable that determines whether to show start port candidates if the cursor hovers over the provided location.
If showPortCandidates is set to START or ALL, the start port candidates will be shown as soon as this testable returns true.
The default implementation returns true if the cursor is located over a port owner.
Examples
To avoid showing port candidates for selected nodes (e.g. to move them instead of considering them as the start point of an edge creation), developers might set a hit testable which excludes selected items.
class UnselectedNodesHitTestable extends BaseClass<IHitTestable>(
IHitTestable,
) {
isHit(context: IInputModeContext, location: Point): boolean {
const graphComponent = context.canvasComponent as GraphComponent
return graphComponent.graph.nodes.some(
(node) =>
!graphComponent.selection.includes(node) &&
node.style.renderer
.getHitTestable(node, node.style)
.isHit(context, location),
)
}
}Note that the same hit testable should be set to beginHitTestable, too.
Gets or sets the GraphSnapContext which manages snapping model items to certain coordinates (for instance, other items).
null (the default), this input mode tries to obtain the GraphSnapContext from the IInputModeContext. To explicitly disable snapping, a GraphSnapContext implementation that is disabled needs to be set.Gets or sets the distance in the view coordinate system that determines how far the mouse should be snapped to a port candidate if snapToEndCandidate is enabled.
20.If set to false edge creation can start if the pointer is located anywhere over a port owner. In this case, the closest valid port candidate will be chosen as the start port.
If set to true edge creation can only start if the pointer is located over a valid port candidate. This candidate will be chosen as the start port. The radius within which a port is considered as hit can be set using startPortCandidateHitRadius. Showing start port candidates can be enabled using showPortCandidates.
Default is true.
Examples
graphEditorInputMode.moveSelectedItemsInputMode.priority = 45
graphEditorInputMode.createEdgeInputMode.priority = 40
graphEditorInputMode.createEdgeInputMode.showPortCandidates =
ShowPortCandidates.ALL
graphEditorInputMode.createEdgeInputMode.startOverCandidateOnly = trueSee Also
Developer's Guide
API
- startPortCandidateHitRadius, showPortCandidates
Gets a copy of the start point at which the edge creation gesture started.
Gets or sets the candidate for the sourcePort of the edge to be created.
See Also
Developer's Guide
The radius is in view coordinates and gets added to the hitTestRadius when checking for a hit.
This value will be considered if startOverCandidateOnly is set to true.
Default is 5.
See Also
Gets or sets the cursor that is used once edge creation has started but the mouse is still over the new edge's start node.
Gets or sets the event recognizer that starts the actual edge creation while dragging.
See Also
Developer's Guide
API
- edge-creation-started
Property Value
Examples
createEdgeInputMode.toggleDirectionRecognizer =
EventRecognizers.SHIFT_DOWNSee Also
Gets or sets the event recognizer that toggles the orientation of the first orthogonal segment.
Property Value
See Also
Gets or sets whether this mode should use the end port candidates of the node the pointer currently hovers over, only.
Gets or sets the cursor that indicates a valid place to begin an edge creation.
Gets or sets the cursor that indicates a valid place to create a bend.
Gets or sets a IHitTestable that determines whether it is valid to create a bend here.
true.Methods
See Also
API
- onCanceled
Implements
IInputMode.cancelCalled at the end of the edge creation process if both startPortCandidate and endPortCandidate have been set.
Parameters
- graph: IGraph
- The graph to create the edge for.
- sourcePortCandidate: IPortCandidate
- The candidate to use for the source end of the edge. Usually the startPortCandidate. In case reversedEdgeCreation, though, the value of endPortCandidate.
- targetPortCandidate: IPortCandidate
- The candidate to use for the target end of the edge. Usually the endPortCandidate. In case reversedEdgeCreation, though, the value of startPortCandidate.
Return Value
- any
- The edge created,
null, or aPromiseresolving with an edge ornull.
See Also
Developer's Guide
Returns the input mode context that will be passed to implementations that are called by this instance and require a context.
Return Value
- IInputModeContext
- A context to use for the implementations that are called by this instance.
Creates a preview bend at the given location and adds it to the previewEdge that will be displayed by the input mode during the creation.
The bend must be part of the previewGraph.
Depending on reversedEdgeCreation, the bend is added at the start or end of the previewEdge's bend list.
Parameters
- location: Point
- The coordinates to create the bend at.
Return Value
- IBend
- The newly created bend or
null.
getEndPortCandidateProvider
(startPortCandidate: IPortCandidate, location: Point): IPortCandidateProviderprotectedRetrieves the IPortCandidateProvider instance that provides the possible candidates for the end of the edge given the current start candidate.
getEndPortCandidateProvider
(startPortCandidate: IPortCandidate, location: Point): IPortCandidateProviderThis implementation queries all nodes in the graph for their provider and returns a composite unless useHitItemsCandidatesOnly is set to true in which case the getEndPortCandidateProvider is queried using the current end.
Note that "end" refers to the port candidate where the edge creation finishes. In case of reversedEdgeCreation this will actually become the sourcePort of the edge.
Parameters
- startPortCandidate: IPortCandidate
- The candidate at the other end of the edge that has been chosen for the edge creation. In case of reversedEdgeCreation this is actually the candidate for the target end of the edge.
- location: Point
- The location of the mouse.
Return Value
- IPortCandidateProvider
- The provider to get the port candidates from.
Retrieves the port candidate provider instance given a start port candidate and a possible ending item.
endPortOwner's lookup to retrieve an IPortCandidateProvider implementation.Parameters
- startPortCandidate: IPortCandidate
- The current start port candidate at the other end of the edge.
- endPortOwner: IPortOwner
- The IPortOwner to find the candidates for.
- location: Point
- The location of the pointer.
Return Value
- IPortCandidateProvider
- A provider instance or
null.
getEndPortCandidates
(location: Point, resolveCandidates: boolean): IEnumerable<IPortCandidate>protectedRetrieves the end port candidates for a given location in world coordinates.
getEndPortCandidates
(location: Point, resolveCandidates: boolean): IEnumerable<IPortCandidate>The resolveCandidates parameter determines whether DYNAMIC port candidates should be resolved with respect to location or simply be discarded.
This implementation delegates to getEndPortCandidateProvider or returns an empty enumerable if no provider has been found.
Note that "end" refers to the port candidate where the edge creation ends. In case of reversedEdgeCreation this will actually become the sourcePort of the edge.
Parameters
- location: Point
- The location of the pointer in world coordinates.
- resolveCandidates: boolean
- Determines whether DYNAMIC ports should be resolved with respect to the
locationor not.
Return Value
- IEnumerable<IPortCandidate>
- A possibly empty enumeration over all end port candidates.
See Also
Finds the end port owner at the specified location.
This always is a node if allowEdgeToEdgeConnections is set to false.
This default implementation simply delegates to getPortOwner.
Note that "end" refers to the end of the edge where creation finishes. In case of reversedEdgeCreation this will actually become the sourcePort's owner of the created edge.
Parameters
- endLocation: Point
- The location of the pointer at the end of the gesture.
Return Value
- IPortOwner
- The port owner or
nullif no valid owner is found at the given location.
Calculates the direction of the first edge segment of the PreviewNode.
Return Value
- EdgeSegmentDirection
- A EdgeSegmentDirection defining the direction of the first edge segment.
Retrieves the port owner at a given position in world coordinates.
Parameters
- location: Point
- The position in world coordinates.
Return Value
- IPortOwner
- The IPortOwner or
nullif no suitable node or edge was found.
Retrieves the port owners from the graph in the order of their importance.
true, in which case edges are also added to the enumerable.Return Value
- IEnumerable<IPortOwner>
- An enumerable over all IPortOwners in this graph
Gets the snap references that are induced by the current preview edge.
Parameters
- context: GraphSnapContext
- The graph snap context.
Return Value
- IEnumerable<OrthogonalSnapLine>
- The snap lines induced by the current preview edge.
Finds the best matching start port candidate based on the given location.
This implementation will use the candidates returned by getStartPortCandidates and delegates to selectStartPortCandidate to find the most appropriate one.
Note that "start" means the port candidate where the edge creation started. In case of reversedEdgeCreation this will actually become the target port of the edge.
Parameters
- location: Point
- The location where the gesture was initiated.
Return Value
- IPortCandidate
- The candidate to use or
null.
See Also
Finds the start port candidate provider at the specified location.
Parameters
- startLocation: Point
- The location of the mouse at the beginning of the gesture.
Return Value
- IPortCandidateProvider
- The port candidate provider to use for the start of the edge creation or
null.
Retrieves the port candidate provider instance given a port owner for the start of the gesture.
startPortOwner's lookup to retrieve an IPortCandidateProvider implementation.Parameters
- startPortOwner: IPortOwner
- The IPortOwner to find the candidates for.
Return Value
- IPortCandidateProvider
- A provider instance or
null.
Gets the start port candidates for the given location.
location.This implementation first tries to get port candidate provider for the given location. If a provider is found its method getAllSourcePortCandidates or getAllTargetPortCandidates respectively (depending on the edgeDirectionPolicy) is called to get the candidates.
If no owner or provider is found, null is returned.
Note that "start" refers to the port candidate where the edge creation started. In case of reversedEdgeCreation this will actually become the targetPort of the edge, otherwise, it's the sourcePort.
Parameters
- location: Point
- The location to get the port candidates for.
Return Value
- IEnumerable<IPortCandidate>
- The port candidates for the given location or
nullif there are none.
See Also
Finds the start port owner at the specified location.
This always is a node if allowEdgeToEdgeConnections is set to false.
This default implementation simply delegates to getPortOwner.
Parameters
- startingLocation: Point
- The location of the pointer at the beginning of the gesture.
Return Value
- IPortOwner
- The port owner to use for the start of the edge creation or
null.
Installs this mode into the given context that is provided by the canvas.
In general a mode can only be installed into a single canvas at all times.
This method is called to initialize this instance. Subclasses should override this method to register the corresponding event handler delegates for the various input events they need to register with.
Overriding implementations should call the base implementation, first.
Parameters
- context: IInputModeContext
- The context that this instance shall be installed into. The same instance will be passed to this instance during uninstall. A reference to the context may be kept and queried during the time the mode is installed.
- controller: ConcurrencyController
- The controller for this mode.
See Also
API
- uninstall
Implements
IInputMode.installGets or sets a value that specifies whether the current focus owner is valid as an intermediate focus owner and does not count against cancelCreationOnFocusLost.
Return Value
- boolean
- Whether it is OK for the focus to be temporarily moved away from the CanvasComponent to the current focus owner. If
falsethe edge creation will be canceled.
Measures the distance between a port candidate and a given location.
candidate and a given location.Parameters
- candidate: IPortCandidate
- The port candidate.
- location: Point
- The location in world coordinates.
Return Value
- number
- The distance between the
candidateand thelocation(in world coordinates if no projection is set; in view coordinates if it has).
Called after cancel has been called.
Can be overridden in subclasses to perform additional actions after the mode has been canceled.
This implementation does nothing.
Called after the ConcurrencyController property of the installed ConcurrencyController has been set to true.
true.Can be overridden in subclasses to perform additional actions after the mode has been activated.
Overriding implementations should call the base implementation.
Can be overridden in subclasses to perform additional actions after the mode has been deactivated.
Overriding implementations should call the base implementation.
Called after the edge has been finalized.
Parameters
- evt: InputModeItemEventArgs<IEdge>
- The event argument holding the edge.
Raises the edge-creation-started event when the edge is dragged outside the start node.
Parameters
- evt: InputModeItemEventArgs<IEdge>
- The InputModeItemEventArgs<TModelItem> instance containing the preview edge that will be used during edge creation.
Triggers the edge-direction-reversed event.
Triggers the end-port-candidate-changed event.
Parameters
- evt: InputModeItemEventArgs<IPortCandidate>
- The event argument that contains context information.
Triggers the gesture-canceled event.
Triggers the gesture-canceling event.
Called once the drag has been finalized.
Parameters
- evt: InputModeEventArgs
- The event argument that contains context information.
Called before the drag will be finalized.
Parameters
- evt: InputModeEventArgs
- The event argument that contains context information.
Triggers the gesture-started event.
Triggers the gesture-starting event.
Called at the end of each drag.
Parameters
- evt: InputModeEventArgs
- The event argument that contains context information.
Called at the start of each drag.
Parameters
- evt: InputModeEventArgs
- The event argument that contains context information.
Raises the port-added event if the mode has added a port for the source or target node to complete the edge creation.
Parameters
- evt: InputModeItemEventArgs<IPort>
- The InputModeItemEventArgs<TModelItem> instance containing the port that has been added.
See Also
API
- port-added
Called when the reversedEdgeCreation property changes and the edge creation is in progress.
Triggers the start-port-candidate-changed event.
Parameters
- evt: InputModeItemEventArgs<IPortCandidate>
- The event argument that contains context information.
Called after tryStop has been called.
Can be overridden in subclasses to perform additional actions after the mode has been stopped.
This implementation does nothing.
Sets the position of the dragged end of the edge during creation.
resolveCandidates
(candidates: IEnumerable<IPortCandidate>, location: Point): IEnumerable<IPortCandidate>protected
resolveCandidates
(candidates: IEnumerable<IPortCandidate>, location: Point): IEnumerable<IPortCandidate>Parameters
- candidates: IEnumerable<IPortCandidate>
- The candidates to possibly resolve.
- location: Point
- The location to resolve dynamic candidates against or
nullif they should be discarded instead.
Return Value
- IEnumerable<IPortCandidate>
- An enumerable of non-DYNAMIC port candidates.
selectClosestCandidate
(candidates: IEnumerable<IPortCandidate>, location: Point): IPortCandidateprotectedFinds the closest VALID candidate given a number of IPortCandidates and a location in world coordinates.
selectClosestCandidate
(candidates: IEnumerable<IPortCandidate>, location: Point): IPortCandidateParameters
- candidates: IEnumerable<IPortCandidate>
- The candidates to find the closest from.
- location: Point
- The location of the mouse in world coordinates.
Return Value
- IPortCandidate
- The candidate to use or
nullif no candidate satisfies the needs
selectClosestEndCandidate
(candidates: IEnumerable<IPortCandidate>, location: Point): IPortCandidateprotectedFinds the closest end candidate given a number of IPortCandidates and a location in world coordinates.
selectClosestEndCandidate
(candidates: IEnumerable<IPortCandidate>, location: Point): IPortCandidateParameters
- candidates: IEnumerable<IPortCandidate>
- The candidates to find the closest from.
- location: Point
- The location of the mouse in world coordinates.
Return Value
- IPortCandidate
- The candidate to use or
nullif no candidate satisfies the needs or enforceBendCreationRecognizer yieldstrue.
selectClosestStartCandidate
(candidates: IEnumerable<IPortCandidate>, location: Point): IPortCandidateprotectedFinds the closest candidate given a number of IPortCandidates and a location in world coordinates.
selectClosestStartCandidate
(candidates: IEnumerable<IPortCandidate>, location: Point): IPortCandidateParameters
- candidates: IEnumerable<IPortCandidate>
- The candidates to find the closest from.
- location: Point
- The location of the pointer in world coordinates.
Return Value
- IPortCandidate
- The candidate to use or
nullif no candidate satisfies the needs
Finds the best matching start port IPortCandidate for the given candidates at the provided location.
candidates at the provided location.The resolveCandidates parameter determines whether dynamic port candidates should be resolved with respect to location or simply be discarded.
Note that "start" refers to either source or target port candidates depending on the current value of reversedEdgeCreation.
Parameters
- candidates: IEnumerable<IPortCandidate>
- The candidates.
- location: Point
- The location where the gesture was initiated.
- resolveCandidates: boolean
- Determines whether DYNAMIC ports should be resolved with respect to the
locationor not.
Return Value
- IPortCandidate
- The candidate to use or
null.
See Also
Parameters
- node: INode
- The start node to use for the edge creation.
- initialEndLocation?: IPoint
- The initial location that is passed to updateEndLocation.
Return Value
- any
- A task that represents the asynchronous edge creation. The result of the task contains the newly created edge or
nullif the creation was canceled.
Parameters
- port: IPort
- The start port to use for the edge creation.
- initialEndLocation?: IPoint
- The initial location that is passed to updateEndLocation.
Return Value
- any
- A task that represents the asynchronous edge creation. The result of the task contains the newly created edge or
nullif the creation was canceled.
Synthetically starts the interactive edge creation process using the provided IPortCandidate as the start port.
Parameters
- startPortCandidate: IPortCandidate
- The start port candidate to use for the edge creation.
- initialEndLocation?: IPoint
- The initial location that is passed to updateEndLocation.
Return Value
- any
- A task that represents the asynchronous edge creation. The result of the task contains the newly created edge or
nullif the creation was canceled.
See Also
Developer's Guide
falseReturn Value
- boolean
trueif and only if the editing has been stopped or there was no edit in progress
Implements
IInputMode.tryStopUninstalls this mode from the given context.
This code should clean up all changes made to the canvas in the install method. After a mode has been uninstalled it can be installed again into the same or another canvas.
Overriding implementations should call the base implementation after their own code.
Parameters
- context: IInputModeContext
- The context to deregister from. This is the same instance that had been passed to install during installation.
Implements
IInputMode.uninstallDraws the highlight for the owner of the current endPortCandidate.
This implementation retrieves the HighlightIndicatorManager<T> from the parentInputModeContext's ILookup.
Overriders have to take care of removal of the highlight of the oldCandidate's owner, too.
Parameters
- oldCandidate: IPortCandidate
- The port candidate whose owner is currently highlighted.
- newCandidate: IPortCandidate
- The port candidate whose owner should be highlighted.
See Also
Updates the dragged end point of the edge.
Parameters
- location: Point
- The new coordinates.
Updates the previewEdge to reflect the current end port candidate.
This implementation creates a self-loop of the preview edge if the endPortCandidate is the same as the owner of the startPortCandidate.
In case of edge creation in reversed direction, the updated port is the sourcePort of the preview edge.
Parameters
- endPortCandidate: IPortCandidate
- The new end port candidate.
Updates the previewEdge to reflect the current start port candidate.
This implementation creates a self-loop of the preview edge if the startPortCandidate is the same as the owner of the endPortCandidate.
In case of edge creation in reversed direction, the updated port is the targetPort of the created edge.
Parameters
- startPortCandidate: IPortCandidate
- The new start port candidate.
Events
Occurs after an edge has been created by this mode.
Properties of
InputModeItemEventArgs<IEdge>- context: IInputModeContext
- Gets the context for the current event.
- item: TModelItem
- Gets the item which has been created or changed.
Examples
createEdgeInputMode.addEventListener('edge-created', () =>
createEdgeInputMode.graph.applyLayout(new EdgeRouter()),
)See Also
Developer's Guide
API
- onEdgeCreated
Occurs when the edge creation has visibly started, that is when the cursor is dragged outside the start node.
Properties of
InputModeItemEventArgs<IEdge>- context: IInputModeContext
- Gets the context for the current event.
- item: TModelItem
- Gets the item which has been created or changed.
Examples
createEdgeInputMode.addEventListener('edge-creation-started', (evt) => {
const polylineEdgeStyle = evt.item.style
if (polylineEdgeStyle instanceof PolylineEdgeStyle) {
polylineEdgeStyle.stroke = Stroke.RED
}
})See Also
Developer's Guide
Occurs when the direction of the edge creation changed during edge creation.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
See Also
Occurs when the value of the endPortCandidate property changes.
Properties of
InputModeItemEventArgs<IPortCandidate>- context: IInputModeContext
- Gets the context for the current event.
- item: TModelItem
- Gets the item which has been created or changed.
See Also
Developer's Guide
Occurs when the gesture has been canceled.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
Examples
createEdgeInputMode.addEventListener(
'gesture-started',
() => (statusLabel.innerText = 'Edge creation in progress...'),
)
createEdgeInputMode.addEventListener(
'gesture-canceled',
() => (statusLabel.innerText = ''),
)
createEdgeInputMode.addEventListener(
'gesture-finished',
() => (statusLabel.innerText = ''),
)See Also
Developer's Guide
Occurs before the gesture will be canceled.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
See Also
Developer's Guide
Occurs once the gesture has been finished.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
Examples
createEdgeInputMode.addEventListener(
'gesture-started',
() => (statusLabel.innerText = 'Edge creation in progress...'),
)
createEdgeInputMode.addEventListener(
'gesture-canceled',
() => (statusLabel.innerText = ''),
)
createEdgeInputMode.addEventListener(
'gesture-finished',
() => (statusLabel.innerText = ''),
)See Also
Developer's Guide
Occurs before the gesture will be finished.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
See Also
Developer's Guide
Occurs once the actual creation gesture is initialized and has started, that is when the edge is dragged from its start, but before edge-creation-started which fires only when it becomes visible.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
Examples
createEdgeInputMode.addEventListener('gesture-started', () =>
createEdgeInputMode.previewGraph.setStyle(
createEdgeInputMode.previewEndNode,
new ShapeNodeStyle({ fill: Color.ORANGE }),
),
)createEdgeInputMode.addEventListener(
'gesture-started',
() => (statusLabel.innerText = 'Edge creation in progress...'),
)
createEdgeInputMode.addEventListener(
'gesture-canceled',
() => (statusLabel.innerText = ''),
)
createEdgeInputMode.addEventListener(
'gesture-finished',
() => (statusLabel.innerText = ''),
)See Also
Developer's Guide
Occurs once the actual creation gesture starts, that is when starting to drag gesture from the start, but before edge-creation-started, which fires only when it becomes visible.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
See Also
Developer's Guide
Occurs at the end of every drag or move.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
See Also
Developer's Guide
Occurs at the start of every drag or move.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
See Also
Developer's Guide
Occurs when this instance adds a port to the source or target node during completion of the edge creation gesture.
Properties of
InputModeItemEventArgs<IPort>- context: IInputModeContext
- Gets the context for the current event.
- item: TModelItem
- Gets the item which has been created or changed.
See Also
Developer's Guide
Occurs when the value of the startPortCandidate property changes.
Properties of
InputModeItemEventArgs<IPortCandidate>- context: IInputModeContext
- Gets the context for the current event.
- item: TModelItem
- Gets the item which has been created or changed.
See Also
Developer's Guide