An IInputMode for interactively creating edges between nodes and edges in an IGraph displayed in a CanvasComponent or GraphComponent.
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 dummyEdgeGraph property to modify the appearance of the dummy 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.
This mode is exclusive by default.
Examples
CreateEdgeInputMode
is installed as child mode of a GraphEditorInputMode and can be retrieved from the createEdgeInputMode property.Related Reading in the Developer's Guide
Type Details
- yfiles module
- view-editor
- yfiles-umd modules
- view-editor, view-table, view
- Legacy UMD name
- yfiles.input.CreateEdgeInputMode
See Also
Constructors
Creates a new instance that will use the IGraph from the inputModeContext to create edges in.
Remarks
Parameters
A map of options to pass to the method.
- priority - number
- exclusive - boolean
A value indicating whether this mode will be the only one running when it has the mutex. This option sets the exclusive property on the created object.
- enabled - boolean
The enabled state of this input mode. This option sets the enabled property on the created object.
- validBeginCursor - Cursor
The cursor that indicates a valid place to begin an edge creation. This option sets the validBeginCursor property on the created object.
- validBendCursor - Cursor
The cursor that indicates a valid place to create a bend. This option sets the validBendCursor property on the created object.
- dragCursor - Cursor
The cursor that is used while a new edge is created when there is no valid location to create a bend. This option sets the dragCursor property on the created object.
- sourceNodeDraggingCursor - Cursor
The cursor that is used once edge creation has started but the mouse is still over the new edge's source node. This option sets the sourceNodeDraggingCursor property on the created object.
- validEndCursor - Cursor
The cursor that indicates a valid place to finish creation. This option sets the validEndCursor property on the created object.
- disableSnappingRecognizer - function(Object, EventArgs):boolean
Event recognizer that temporarily disables snapping. This option sets the disableSnappingRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- enableSnappingRecognizer - function(Object, EventArgs):boolean
Event recognizer that reenables temporarily disabled snapping. This option sets the enableSnappingRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- toggleSegmentOrientationRecognizer - function(Object, EventArgs):boolean
The event recognizer that toggles the orientation of the first orthogonally created segment. This option sets the toggleSegmentOrientationRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- toggleDirectionRecognizer - function(Object, EventArgs):boolean
The event recognizer that recognizes gesture which toggles the direction of the created edge. This option sets the toggleDirectionRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- finishRecognizer - function(Object, EventArgs):boolean
The event recognizer that recognizes the finishing gesture that is used to end the edge creation on the target node. This option sets the finishRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- prepareRecognizer - function(Object, EventArgs):boolean
The event recognizer that recognizes the starting gesture that is used to prepare the edge creation on the source node. This option sets the prepareRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- draggedRecognizer - function(Object, EventArgs):boolean
The event recognizer that recognizes the initial dragging gesture that is used to initiate the creation after the preparation. This option sets the draggedRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- endPointMovedRecognizer - function(Object, EventArgs):boolean
The event recognizer that recognizes the movement of the end point of the edge. This option sets the endPointMovedRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- createBendRecognizer - function(Object, EventArgs):boolean
The event recognizer that determines whether to create a bend. This option sets the createBendRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- cancelRecognizer - function(Object, EventArgs):boolean
The event recognizer that determines whether to cancel edge creation. This option sets the cancelRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- removeBendRecognizer - function(Object, EventArgs):boolean
The event recognizer that determines whether to remove bends. This option sets the removeBendRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- portCandidateResolutionRecognizer - function(Object, EventArgs):boolean
The event recognizer that determines whether dynamic port candidates should be resolved. This option sets the portCandidateResolutionRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- finishRecognizerTouch - function(Object, EventArgs):boolean
The event recognizer that recognizes the finishing gesture that is used to end the edge creation on the target node by a touch gesture. This option sets the finishRecognizerTouch property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- prepareRecognizerTouch - function(Object, EventArgs):boolean
The event recognizer that recognizes the starting gesture that is used to prepare the edge creation on the source node via touch. This option sets the prepareRecognizerTouch property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- draggedRecognizerTouch - function(Object, EventArgs):boolean
The event recognizer that recognizes the initial dragging gesture that is used to initiate the creation after the preparation via touch. This option sets the draggedRecognizerTouch property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- createBendRecognizerTouch - function(Object, EventArgs):boolean
The event recognizer that determines whether to create a bend via touch. This option sets the createBendRecognizerTouch property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- cancelRecognizerTouch - function(Object, EventArgs):boolean
The event recognizer that determines whether to cancel edge creation via touch. This option sets the cancelRecognizerTouch property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- removeBendRecognizerTouch - function(Object, EventArgs):boolean
The event recognizer determines whether to remove bends via touch. This option sets the removeBendRecognizerTouch property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- showPortCandidates - ShowPortCandidates
Whether and where to display possible port candidates during the creation of the edge. This option sets the showPortCandidates property on the created object.
- allowEdgeToEdgeConnections - boolean
Whether or not edges are allowed to connect to other edges. This option sets the allowEdgeToEdgeConnections property on the created object.
- snapDistance - number
The distance in the view coordinate system that determines how far the mouse should be snapped to a port candidate if snapToTargetCandidate is enabled. This option sets the snapDistance property on the created object.
- snapContext - SnapContext
The snapContext which manages snapping model items to certain coordinates (for instance, other items). This option sets the snapContext property on the created object.
- candidateDescriptor - ICanvasObjectDescriptor
The ICanvasObjectDescriptor that is used for visualizing the IPortCandidates in the canvas during the edit. This option sets the candidateDescriptor property on the created object.
- closestCandidateDescriptor - ICanvasObjectDescriptor
The ICanvasObjectDescriptor that is used for visualizing the closest IPortCandidate in the canvas during the edit. This option sets the closestCandidateDescriptor property on the created object.
- orthogonalSnapDistance - number
The distance in the view coordinate system that determines how far the mouse should be snapped to a horizontal or vertical line. This option sets the orthogonalSnapDistance property on the created object.
- forceSnapToCandidate - boolean
A property that determines whether the mouse should be forced to snap to the nearest valid port candidate if the mouse hovers over a target node. This option sets the forceSnapToCandidate property on the created object.
- useHitItemsCandidatesOnly - boolean
A property that determines whether this mode should use only the target port candidates of the node the mouse currently hovers over. This option sets the useHitItemsCandidatesOnly property on the created object.
- orthogonalEdgeCreation - OrthogonalEdgeEditingPolicy
The policy that controls whether edges will be create orthogonally. This option sets the orthogonalEdgeCreation property on the created object.
- preferredMinimalEdgeDistance - number
The preferred minimal distance of orthogonal edges. This option sets the preferredMinimalEdgeDistance property on the created object.
- resolveSourcePortCandidates - boolean
A value indicating whether DYNAMIC ports that are part of the source port candidates should be resolved for the current mouse location. This option sets the resolveSourcePortCandidates property on the created object.
- resolveTargetPortCandidates - boolean
A value indicating whether DYNAMIC ports that are part of the target port candidates should be resolved for the current mouse location. This option sets the resolveTargetPortCandidates property on the created object.
- edgeDirectionPolicy - EdgeDirectionPolicy
A value that determines how the direction of a newly created edge is determined. This option sets the edgeDirectionPolicy property on the created object.
- reversedEdgeCreation - boolean
A value indicating whether the current edge creation should be created from its target port to its source port. This option sets the reversedEdgeCreation property on the created object.
- nodeBorderWidthRatio - number
The width of a node's border which is taken into account when deciding which way to route the first segment of an orthogonal edge. This option sets the nodeBorderWidthRatio property on the created object.
- edgeCreator - function(IInputModeContext, IGraph, IPortCandidate, IPortCandidate, IEdge):Promise<IEdge|null>
The ports based edge creation callback. This option sets the edgeCreator property on the created object.
Signature Details
function(context: IInputModeContext, graph: IGraph, sourcePortCandidate: IPortCandidate, targetPortCandidate: IPortCandidate, templateEdge: IEdge) : Promise<IEdge | null> | IEdge
The delegate method that is used by CreateEdgeInputMode to create edges between instances of IPort.The edgeCreator uses this type of callback to actually create edges between nodes.Parameters
- context - IInputModeContext
- The context of the input mode this action is used in.
- graph - IGraph
- The graph to create the edge in.
- sourcePortCandidate - IPortCandidate
- The source port candidate.
- targetPortCandidate - IPortCandidate
- The target port candidate. If
null
the callback either has to create the target port itself or cancel the edge creation by returningnull
. - templateEdge - IEdge
- The dummy edge instance that serves as template for the actual edge creation. This edge is not part of the
graph
Returns
- allowSelfloops - boolean
Whether or not to allow the creation of self loops. This option sets the allowSelfloops property on the created object.
- cancelGestureOnInvalidTarget - boolean
Whether an edge creation gesture will be canceled when the gesture is ended on an invalid target and no bend may be created there. This option sets the cancelGestureOnInvalidTarget property on the created object.
- allowCreateBend - boolean
Whether or not to allow the creation of bends. This option sets the allowCreateBend property on the created object.
- sourcePortCandidate - IPortCandidate
The candidate for the sourcePort of the edge to be created. This option sets the sourcePortCandidate property on the created object.
- targetPortCandidate - IPortCandidate
The current candidate for the targetPort of the edge to be created. This option sets the targetPortCandidate property on the created object.
- showTargetHighlight - boolean
Whether the owner of the current targetPortCandidate should be highlighted. This option sets the showTargetHighlight property on the created object.
- cancelEditImplicitly - boolean
Whether after calls to createEdge the current undo edit should be canceled if the method returns
null
. This option sets the cancelEditImplicitly property on the created object.- edgeDefaults - IEdgeDefaults
The appearance of newly created edges. This option sets the edgeDefaults property on the created object.
- snapToTargetCandidate - boolean
Whether or not the edge's end point should snap to the current target port candidate during the creation of the edge. This option sets the snapToTargetCandidate property on the created object.
- showSourcePortCandidatesHitTestable - IHitTestable
A IHitTestable that determines whether to show source port candidates if the cursor hovers over the provided location. This option sets the showSourcePortCandidatesHitTestable property on the created object.
- beginHitTestable - IHitTestable
A IHitTestable that determines whether it is valid to start an edge creation gesture here. This option sets the beginHitTestable property on the created object.
- endHitTestable - IHitTestable
A IHitTestable that determines whether it is valid to finish an edge creation gesture here if valid IPortCandidates are available. This option sets the endHitTestable property on the created object.
- prematureEndHitTestable - IHitTestable
A IHitTestable that determines, whether it is valid to finish an edge creation gesture here even if no IPortCandidates are available. This option sets the prematureEndHitTestable property on the created object.
- validBendHitTestable - IHitTestable
A IHitTestable that determines whether it is valid to create a bend here. This option sets the validBendHitTestable property on the created object.
- startOverCandidateOnly - boolean
Whether edge creation should only start if the pointer is located directly over a valid port candidate. This option sets the startOverCandidateOnly property on the created object.
- sourcePortCandidateHitRadius - number
The radius from within a valid port candidate will be considered as hit. This option sets the sourcePortCandidateHitRadius property on the created object.
- sourceNodeDraggingFinishedRecognizer - function(Object, EventArgs):boolean
The event recognizer that starts the actual edge creation while dragging. This option sets the sourceNodeDraggingFinishedRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
- enforceBendCreationRecognizer - function(Object, EventArgs):boolean
The event recognizer that will be queried to decide if bend creation is enforced. This option sets the enforceBendCreationRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.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.
See Also
Properties
Gets or sets whether or not to allow the creation of bends.
Remarks
true
.Examples
See Also
Gets or sets whether or not to allow the creation of self loops.
Remarks
true
, which enables that an edge is connected to a sourcePort and targetPort that have the same owner.Examples
createEdgeInputMode.allowSelfloops = true
See Also
Gets or sets a IHitTestable that determines whether it is valid to start an edge creation gesture here.
Remarks
true
if the cursor is located over a port owner.Examples
To avoid showing port candidates for selected nodes (which will by default be moved instead of being considered as source of an edge) developers might set a hit testable which excludes selected nodes.
class UnselectedNodesHitTestable extends BaseClass(IHitTestable) {
/**
* @param {!IInputModeContext} context
* @param {!Point} location
* @returns {boolean}
*/
isHit(context, location) {
const graphComponent = context.canvasComponent
return graphComponent.graph.nodes.some(
(node) =>
!graphComponent.selection.isSelected(node) &&
node.style.renderer
.getHitTestable(node, node.style)
.isHit(context, location)
)
}
}
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.isSelected(node) &&
node.style.renderer
.getHitTestable(node, node.style)
.isHit(context, location)
)
}
}
Note that the same hit testable should be set to showSourcePortCandidatesHitTestable, too.
See Also
Gets or sets whether after calls to createEdge the current undo edit should be canceled if the method returns null
.
Remarks
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.Gets or sets whether an edge creation gesture will be canceled when the gesture is ended on an invalid target and no bend may be created there.
Remarks
If bend creation is allowed at the target 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 false
, meaning that the gesture must always be canceled explicitly.
See Also
Gets or sets the event recognizer that determines whether to cancel edge creation.
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 the event recognizer that determines whether to cancel edge creation via touch.
Remarks
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 the ICanvasObjectDescriptor that is used for visualizing the IPortCandidates in the canvas during the edit.
Remarks
See Also
Gets or sets the ICanvasObjectDescriptor that is used for visualizing the closest IPortCandidate in the canvas during the edit.
Remarks
See Also
Gets the installed controller.
Gets or sets the event recognizer that determines whether to create a bend.
Remarks
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 the event recognizer that determines whether to create a bend via touch.
Remarks
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 event recognizer that temporarily disables snapping.
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 the cursor that is used while a new edge is created when there is no valid location to create a bend.
Remarks
Gets or sets the event recognizer that recognizes the initial dragging gesture that is used to initiate the creation after the preparation.
Remarks
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 the event recognizer that recognizes the initial dragging gesture that is used to initiate the creation after the preparation via touch.
Remarks
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 the dynamically updated dragging point for the edge creation.
Gets the dummy edge instance that will be used to render a preview of the edge to be created.
Remarks
See Also
Gets the dummy graph instance that will hold the items that will render a preview of the newly created edge.
Remarks
The dummy edge graph can be used to change the appearance and other properties of the dummy edge, either when starting a gesture or during it in response to certain events. Possible actions are:
- Changing the style of the dummy edge.
- Adding bends to the dummy edge.
- Adding labels to the dummy edge.
- Changing style and other properties of the added labels.
All changes made to the dummy 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 dummy edge graph only allows operations on the dummy edge.
Changing style of the dummy edge's source or target port has no effect. The style for these is controlled by the IPortCandidates and hence by an IPortCandidateProvider.
If the property is not set initially, method createDummyEdgeGraph will be used as the factory method.
See Also
The IPort which is used as source port for the temporarily created dummyEdge during edge creation.
Remarks
This port's owner is a dummy node. The dummyEdge is either connected to this port, a dummy port at the real source node, or a real port in graph.
The port is created upon first access of property dummyEdgeGraph.
The INode which is used as target node for the temporarily created dummyEdge during edge creation.
Remarks
By default, this node is invisible.
The node is created upon first access by method createDummyTargetNode.
The IPort which is used as target port for the temporarily created dummyEdge during edge creation.
Remarks
This port's owner is the dummyTargetNode. This port is used as target port of the dummyEdge unless the dummy edge snaps to a valid targetPortCandidate in which case the edge is connected to the port represented by that candidate.
The port is created upon first access by method createDummyTargetNodePort.
edgeCreator
: function(IInputModeContext, IGraph, IPortCandidate, IPortCandidate, IEdge):Promise<IEdge|null>Gets or sets the ports based edge creation callback.
Remarks
The default creator will delegate to createEdge and obtain the tag from the dummyEdge. It will then copy over all bends, labels, and ports from the dummyEdge.
When a Promise
is returned, this mode will keep the mutex until it is resolved, thereby blocking any user interaction.
Signature Details
function(context: IInputModeContext, graph: IGraph, sourcePortCandidate: IPortCandidate, targetPortCandidate: IPortCandidate, templateEdge: IEdge) : Promise<IEdge | null> | IEdge
Parameters
- context - IInputModeContext
- The context of the input mode this action is used in.
- graph - IGraph
- The graph to create the edge in.
- sourcePortCandidate - IPortCandidate
- The source port candidate.
- targetPortCandidate - IPortCandidate
- The target port candidate. If
null
the callback either has to create the target port itself or cancel the edge creation by returningnull
. - templateEdge - IEdge
- The dummy edge instance that serves as template for the actual edge creation. This edge is not part of the
graph
Returns
Throws
- Exception({ name: 'ArgumentError' })
- If the argument is
null
Examples
See Also
Gets or sets the appearance of newly created edges.
Gets or sets a value that determines how the direction of a newly created edge is determined.
Remarks
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 getSourcePortCandidates. Depending on which candidate is chosen in getSourcePortCandidates 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.
Gets or sets the enabled state of this input mode.
Remarks
Examples
See Also
Gets or sets event recognizer that reenables temporarily disabled snapping.
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.
See Also
Gets or sets a IHitTestable that determines whether it is valid to finish an edge creation gesture here if valid IPortCandidates are available.
Remarks
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
Gets or sets the event recognizer that recognizes the movement of the end point of the edge.
Remarks
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 the event recognizer that will be queried to decide if bend creation is enforced.
Remarks
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 this mode will be the only one running when it has the mutex.
Remarks
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 target node.
Remarks
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 the event recognizer that recognizes the finishing gesture that is used to end the edge creation on the target node by a touch gesture.
Remarks
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 property that determines whether the mouse should be forced to snap to the nearest valid port candidate if the mouse hovers over a target node.
Remarks
true
.Gets the context instance this mode is currently installed in or null
if this instance is not installed.
Remarks
Implements
Gets or sets the policy that controls whether edges will be create orthogonally.
Remarks
See Also
Gets or sets the event recognizer that determines whether dynamic port candidates should be resolved.
Remarks
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 IHitTestable that determines, whether it is valid to finish an edge creation gesture here even if no IPortCandidates are available.
Remarks
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 possible end for an edge creation, even if no valid IPortCandidate is available as target port candidate.
The default implementation always returns false
.
See Also
Gets or sets the event recognizer that recognizes the starting gesture that is used to prepare the edge creation on the source node.
Remarks
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.
See Also
Gets or sets the event recognizer that recognizes the starting gesture that is used to prepare the edge creation on the source node via touch.
Remarks
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 the priority of this input mode.
Remarks
See Also
Implements
Gets or sets the event recognizer that determines whether to remove bends.
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 the event recognizer determines whether to remove bends via touch.
Remarks
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 DYNAMIC ports that are part of the source port candidates should be resolved for the current mouse location.
Remarks
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 "source" refers to the port candidate where the edge creation started. In case of reversed edge creation this will actually become the target port of the edge.
See Also
Gets or sets a value indicating whether DYNAMIC ports that are part of the target port candidates should be resolved for the current mouse location.
Remarks
See Also
Gets or sets a value indicating whether the current edge creation should be created from its target port to its source port.
Remarks
Examples
Setting the reversedEdgeCreation in a listener to the SourcePortCandidateChanged event allows for fully customizing the edge creation direction. The example shows how to set the direction according to the candidate's tag.
createEdgeInputMode.addSourcePortCandidateChangedListener(
(sender, args) =>
(createEdgeInputMode.reversedEdgeCreation =
args.item.owner.tag === 'createFromTarget')
)
Setting this value as shown above will override the edgeDirectionPolicy.
See Also
Gets or sets whether and where to display possible port candidates during the creation of the edge.
Remarks
Setting this property to SOURCE or ALL will result in displaying source port candidates for each node the mouse is located over. For a CreateEdgeInputMode as child of a default GraphEditorInputMode selected nodes will rather be moved than serve as source of an edge creation. To disable showing port candidates for selected nodes developers might set appropriate showSourcePortCandidatesHitTestable and beginHitTestables. An example IHitTestable is shown there.
The default is TARGET.
Gets or sets a IHitTestable that determines whether to show source port candidates if the cursor hovers over the provided location.
Remarks
If showPortCandidates is set to SOURCE or ALL the source 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 (which will by default be moved instead of being considered as source of an edge) developers might set a hit testable which excludes selected nodes.
class UnselectedNodesHitTestable extends BaseClass(IHitTestable) {
/**
* @param {!IInputModeContext} context
* @param {!Point} location
* @returns {boolean}
*/
isHit(context, location) {
const graphComponent = context.canvasComponent
return graphComponent.graph.nodes.some(
(node) =>
!graphComponent.selection.isSelected(node) &&
node.style.renderer
.getHitTestable(node, node.style)
.isHit(context, location)
)
}
}
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.isSelected(node) &&
node.style.renderer
.getHitTestable(node, node.style)
.isHit(context, location)
)
}
}
Note that the same hit testable should be set to beginHitTestable, too.
See Also
Gets or sets whether the owner of the current targetPortCandidate should be highlighted.
Gets or sets the snapContext which manages snapping model items to certain coordinates (for instance, other items).
Remarks
null
(the default) this input mode tries to obtain the snapContext from the IInputModeContext. To explicitly disable snapping, a snapContext implementation that does nothing has to be set to this instance.Gets or sets the distance in the view coordinate system that determines how far the mouse should be snapped to a port candidate if snapToTargetCandidate is enabled.
Remarks
20
.Gets or sets whether or not the edge's end point should snap to the current target port candidate during the creation of the edge.
Remarks
Gets or sets the event recognizer that starts the actual edge creation while dragging.
Remarks
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.
See Also
Gets or sets the candidate for the sourcePort of the edge to be created.
Remarks
See Also
Gets or sets the radius from within a valid port candidate will be considered as hit.
Remarks
The radius is in world coordinates.
This value will be considered if startOverCandidateOnly is set to true
.
Default is 5.
See Also
Gets or sets whether edge creation should only start if the pointer is located directly over a valid port candidate.
Remarks
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 source 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 source port. The radius within which a port is considered as hit can be set using sourcePortCandidateHitRadius. Showing source port candidates can be enabled using showPortCandidates.
Default is false
.
Examples
graphEditorInputMode.moveInputMode.priority = 45
graphEditorInputMode.createEdgeInputMode.priority = 40
graphEditorInputMode.createEdgeInputMode.showPortCandidates =
ShowPortCandidates.ALL
graphEditorInputMode.createEdgeInputMode.startOverCandidateOnly = true
See Also
Gets a copy of the starting point at which the edge creation gesture started.
Gets or sets the current candidate for the targetPort of the edge to be created.
See Also
Gets or sets the event recognizer that recognizes gesture which toggles the direction of the created edge.
Remarks
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.
Examples
createEdgeInputMode.toggleDirectionRecognizer = KeyEventRecognizers.SHIFT_DOWN
See Also
Gets or sets the event recognizer that toggles the orientation of the first orthogonally created segment.
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.
See Also
Gets or sets a property that determines whether this mode should use only the target port candidates of the node the mouse currently hovers over.
Remarks
true
.See Also
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.
Remarks
true
.Gets or sets the cursor that indicates a valid place to finish creation.
Methods
Cancels the editing of this mode.
Remarks
See Also
Implements
Creates a dummy bend at the given location and adds it to the dummyEdge that will be displayed by the input mode during the creation.
Remarks
The bend must be part of the dummyEdgeGraph.
Depending on reversedEdgeCreation, the bend is added at the start or end of the dummyEdge's bend list.
Parameters
A map of options to pass to the method.
- location - Point
- The coordinates to create the bend at.
Returns
- ↪IBend
- The newly created bend or
null
.
Creates the dummy edge that will be displayed by the input mode during the creation.
Remarks
Returns
Factory method that will create the dummy graph to hold the preview of the dummyEdge.
Remarks
Returns
- ↪IGraph
- A graph instance that will be rendered as a preview.
Creates the dummy node which is used as target for the dummyEdge during the creation.
Remarks
The node must be part of the dummyEdgeGraph and therefore be created by one of its factory methods createNode.
This implementation creates a node at origin using the nodeDefaults of the dummyEdgeGraph (zero size and invisible).
Returns
Creates the dummy port which is used as target for the dummyEdge during the creation.
Remarks
The port must be part of the dummyEdgeGraph and therefore be created by its factory method addPort with the dummyTargetNode as owner.
This port will only be used if the edge is not connected to a valid target.
The default implementation creates an invisible port at the center of the dummyTargetNode with the FreeNodePortLocationModel.
Returns
createEdge
(graph: IGraph, sourcePortCandidate: IPortCandidate, targetPortCandidate: IPortCandidate) : Promise<IEdge | null> | IEdgeCalled at the end of the edge creation process if both sourcePortCandidate and targetPortCandidate have been set.
Remarks
Parameters
A map of options to pass to the method.
- graph - IGraph
- The graph to create the edge for.
- sourcePortCandidate - IPortCandidate
- The candidate to use for the source end of the edge. Usually the sourcePortCandidate. In case reverse edge creation, though, the value of targetPortCandidate.
- targetPortCandidate - IPortCandidate
- The candidate to use for the target end of the edge. Usually the targetPortCandidate. In case reverse edge creation, though, the value of sourcePortCandidate.
Returns
See Also
Creates an IInputModeContext for use with the port candidates queries for the upcoming edge creation operation and the actual edge creation
Returns
- ↪IInputModeContext
- An instance of IInputModeContext that is configured for this mode.
doStartEdgeCreation
(sourcePortCandidate: IPortCandidate, initialTargetLocation?: IPoint) : Promise<IEdge>Synthetically starts the interactive edge creation process using the provided IPortCandidate as the source port.
Remarks
Parameters
A map of options to pass to the method.
- sourcePortCandidate - IPortCandidate
- The source port candidate to use for the edge creation.
- initialTargetLocation - IPoint
- The initial location that is passed to updateTargetLocation.
Returns
- ↪Promise<IEdge>
- A task that represents the asynchronous edge creation. The result of the task contains the newly created edge or
null
if the creation was canceled.
See Also
Finds the closest VALID candidate given a number of IPortCandidates and a location in world coordinates.
Parameters
A map of options to pass to the method.
- candidates - IEnumerable<IPortCandidate>
- The candidates to find the closest from.
- location - Point
- The location of the mouse in world coordinates.
Returns
- ↪IPortCandidate
- The candidate to use or
null
if no candidate satisfies the needs
getClosestSourceCandidate
(candidates: IEnumerable<IPortCandidate>, location: Point) : IPortCandidateFinds the closest candidate given a number of IPortCandidates and a location in world coordinates.
Parameters
A map of options to pass to the method.
- candidates - IEnumerable<IPortCandidate>
- The candidates to find the closest from.
- location - Point
- The location of the pointer in world coordinates.
Returns
- ↪IPortCandidate
- The candidate to use or
null
if no candidate satisfies the needs
getClosestTargetCandidate
(candidates: IEnumerable<IPortCandidate>, location: Point) : IPortCandidateFinds the closest target candidate given a number of IPortCandidates and a location in world coordinates.
Parameters
A map of options to pass to the method.
- candidates - IEnumerable<IPortCandidate>
- The candidates to find the closest from.
- location - Point
- The location of the mouse in world coordinates.
Returns
- ↪IPortCandidate
- The candidate to use or
null
if no candidate satisfies the needs or enforceBendCreationRecognizer yieldstrue
.
getDummyEdgeSnapLines
(context: GraphSnapContext, provider: ISnapLineProvider) : IEnumerable<OrthogonalSnapLine>Gets the snap lines lines that are induced by the current dummy edge.
Parameters
A map of options to pass to the method.
- context - GraphSnapContext
- The graph snap context.
- provider - ISnapLineProvider
- The dummy edge segment snap line provider.
Returns
- ↪IEnumerable<OrthogonalSnapLine>
- The snap lines induced by the current dummy edge.
Calculates direction of first edge segment of the DummyNode.
Remarks
Returns
- ↪EdgeSegmentDirection
- A EdgeSegmentDirection defining the direction of the first edge segment.
Retrieves the port owner at a given position in world coordinates.
Remarks
If there is a IHitTester<T> for type INode in the lookup of this mode's inputModeContext then this instance will be used for the query.
Otherwise this implementation calls the getHitTestable method of the nodes to find hit nodes and uses an IComparer<T> to determine the first hit node.
Parameters
A map of options to pass to the method.
- location - Point
- The position in world coordinates.
Returns
- ↪IPortOwner
- The node or
null
if no suitable node was found.
Retrieves the port owners from the graph in the order of their importance.
Remarks
true
, in which case edges are also added to the enumerable.Returns
- ↪IEnumerable<IPortOwner>
- An enumerable over all IPortOwners in this graph
Finds the source port owner at the specified location.
Remarks
This always is the source node if allowEdgeToEdgeConnections is set to false
.
This default implementation simply delegates to getPortOwner.
Parameters
A map of options to pass to the method.
- sourceLocation - Point
- The location of the mouse at the beginning of the gesture.
Returns
- ↪IPortOwner
- The port owner to use for the source of the edge creation or
null
.
getSourcePortCandidate
(candidates: IEnumerable<IPortCandidate>, location: Point, resolveCandidates: boolean) : IPortCandidateFinds the best matching source port IPortCandidate for the given candidates
at the provided location
.
Remarks
The resolveCandidates
parameter determines whether dynamic port candidates should be resolved with respect to location
or simply be discarded.
Note that "source" refers to the port candidate where the edge creation started. In case of reversed edge creation this will actually become the target port of the edge.
Parameters
A map of options to pass to the method.
- 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
location
or not.
Returns
- ↪IPortCandidate
- The candidate to use or
null
.
See Also
Finds the source port candidate provider at the specified location.
Remarks
Parameters
A map of options to pass to the method.
- sourceLocation - Point
- The location of the mouse at the beginning of the gesture.
Returns
- ↪IPortCandidateProvider
- The port candidate provider to use for the source of the edge creation or
null
.
Gets the source port candidates for the given location
.
Remarks
This implementation first tries to get port candidate provider for the given location
. If a provider is found its method getAllSourcePortCandidates is called to get the candidates.
If no owner or provider is found, null
is returned.
Note that "source" refers to the port candidate where the edge creation started. In case of reversed edge creation this will actually become the target port of the edge.
Parameters
A map of options to pass to the method.
- location - Point
- The location to get the port candidates for.
Returns
- ↪IEnumerable<IPortCandidate>
- The port candidates for the given location or
null
if there are none.
See Also
Finds the target port owner at the specified location.
Remarks
This always is a target node if allowEdgeToEdgeConnections is set to false
.
This default implementation simply delegates to getPortOwner.
Note that "target" refers to the end of the edge where creation finishes. In case of reversed edge creation this will actually become the source end of the created edge.
Parameters
A map of options to pass to the method.
- targetLocation - Point
- The location of the pointer at the beginning of the gesture.
Returns
- ↪IPortOwner
- The port owner or
null
.
getTargetPortCandidateProvider
(sourcePortCandidate: IPortCandidate, location: Point) : IPortCandidateProviderRetrieves the IPortCandidateProvider instance that provides the possible candidates for the target of the edge given the current source candidate.
Remarks
This implementation queries all nodes in the graph for their provider and returns a composite unless useHitItemsCandidatesOnly is set to true
in which case the lookupTargetPortCandidateProvider is queried using the current target.
Note that "target" refers to the port candidate where the edge creation finishes. In case of reversed edge creation this will actually become the source port of the edge.
Parameters
A map of options to pass to the method.
- sourcePortCandidate - IPortCandidate
- The candidate at the other end of the edge that has been chosen for the edge creation. In case of reversed edge creation this is actually the candidate for the target endof the edge.
- location - Point
- The location of the mouse.
Returns
- ↪IPortCandidateProvider
- The provider to get the port candidates from.
Retrieves the target port candidates for a given location in world coordinates.
Remarks
The resolveCandidates
parameter determines whether dynamic port candidates should be resolved with respect to location
or simply be discarded.
This implementation delegates to getTargetPortCandidateProvider or returns an empty enumerable if no provider has been found.
Note that "target" refers to the port candidate where the edge creation finishes. In case of reversed edge creation this will actually become the source port of the edge.
Parameters
A map of options to pass to the method.
- location - Point
- The location of the mouse in world coordinates.
- resolveCandidates - boolean
- Determines whether DYNAMIC ports should be resolved with respect to the
location
or not.
Returns
- ↪IEnumerable<IPortCandidate>
- A possibly empty enumeration over all target port candidates.
See Also
Installs this mode into the given context that is provided by the canvas.
Remarks
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
A map of options to pass to the method.
- 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
Implements
Retrieves the port candidate provider instance given a source port owner.
Remarks
sourceOwner
's lookup to retrieve an IPortCandidateProvider implementation.Parameters
A map of options to pass to the method.
- sourceOwner - IPortOwner
- The IPortOwner to find the candidates for.
Returns
- ↪IPortCandidateProvider
- A provider instance or
null
.
lookupTargetPortCandidateProvider
(sourcePortCandidate: IPortCandidate, targetOwner: IPortOwner, location: Point) : IPortCandidateProviderRetrieves the port candidate provider instance given a source port candidate and a possible target item.
Remarks
targetOwner
's lookup to retrieve an IPortCandidateProvider implementation.Parameters
A map of options to pass to the method.
- sourcePortCandidate - IPortCandidate
- The current source port candidate.
- targetOwner - IPortOwner
- The IPortOwner to find the candidates for.
- location - Point
- The location of the mouse.
Returns
- ↪IPortCandidateProvider
- A provider instance or
null
.
Measures the distance between a port candidate
and a given location
.
Remarks
Parameters
A map of options to pass to the method.
- candidate - IPortCandidate
- The port candidate.
- location - Point
- The location in world coordinates.
Returns
- ↪number
- The distance between the
candidate
and thelocation
(in world coordinates if no projection is set; in view coordinates if it has.
Called after cancel has been called.
Remarks
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
.
Remarks
Can be overridden in subclasses to perform additional actions after the mode has been activated.
Overriding implementations should call the base implementation.
Called after the active property of the installed ConcurrencyController has been set to false
.
Remarks
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.
Remarks
Parameters
A map of options to pass to the method.
- evt - EdgeEventArgs
- The event argument holding the edge.
Raises the EdgeCreationStarted event when the gesture for creating an edge has been initialized.
Parameters
A map of options to pass to the method.
- evt - EdgeEventArgs
- The EdgeEventArgs instance containing the dummy edge that will be used during edge creation.
Triggers the GestureCanceled event.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Triggers the GestureCanceling event.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Called once the drag has been finalized.
Remarks
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Called before the drag will be finalized.
Remarks
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Triggers the GestureStarted event.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Triggers the GestureStarting event.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Called at the end of each drag.
Remarks
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Called at the start of each drag.
Remarks
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Raises the PortAdded event if the mode has added a port for the source or target node to complete the edge creation.
Parameters
A map of options to pass to the method.
- evt - ItemEventArgs<IPort>
- The ItemEventArgs<T> instance containing the port that has been added.
See Also
Called when the reversedEdgeCreation property changes and the edge creation is in progress.
Remarks
Triggers the SourcePortCandidateChanged event.
Parameters
A map of options to pass to the method.
- evt - ItemEventArgs<IPortCandidate>
- The event argument that contains context information.
Called after tryStop has been called.
Remarks
Can be overridden in subclasses to perform additional actions after the mode has been stopped.
This implementation does nothing.
Triggers the TargetPortCandidateChanged event.
Parameters
A map of options to pass to the method.
- evt - ItemEventArgs<IPortCandidate>
- The event argument that contains context information.
Sets the position of the tip of the edge during creation.
Remarks
Parameters
A map of options to pass to the method.
- newLocation - Point
- The location of the tip of the edge.
resolveCandidates
(candidates: IEnumerable<IPortCandidate>, location: Point) : IEnumerable<IPortCandidate>Returns an enumerable over the given candidates where no instance has DYNAMIC validity.
Remarks
Parameters
A map of options to pass to the method.
- candidates - IEnumerable<IPortCandidate>
- The candidates to possibly resolve.
- location - Point
- The location to resolve dynamic candidates against or
null
if they should be discarded instead.
Returns
- ↪IEnumerable<IPortCandidate>
- An enumerable of non-DYNAMIC port candidates.
Called by the client in order to stop a current editing progress.
Remarks
false
Returns
- ↪boolean
true
if and only if the editing has been stopped or there was no edit in progress
See Also
Implements
Uninstalls this mode from the given context.
Remarks
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
A map of options to pass to the method.
- context - IInputModeContext
- The context to deregister from. This is the same instance that had been passed to install during installation.
Implements
Updates the dummyEdge to reflect the current source port candidate.
Remarks
This implementation creates a self loop of the dummy edge if the sourcePortCandidate
is the same as the owner of the targetPortCandidate.
In case of edge creation in reversed direction the updated port is the targetPort of the created edge.
Parameters
A map of options to pass to the method.
- sourcePortCandidate - IPortCandidate
- The new owner target port candidate.
Updates the dummyEdge to reflect the current target port candidate.
Remarks
This implementation creates a self loop of the dummy edge if the targetPortCandidate
is the same as the owner of the sourcePortCandidate.
In case of edge creation in reversed direction the updated port is the sourcePort of the created edge.
Parameters
A map of options to pass to the method.
- targetPortCandidate - IPortCandidate
- The new owner target port candidate.
Draws the highlight for the owner of the current targetPortCandidate.
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
Events
Occurs after an edge has been created by this mode.
Examples
createEdgeInputMode.addEdgeCreatedListener((sender, args) =>
createEdgeInputMode.graph.applyLayout(new EdgeRouter())
)
See Also
Event Registration
addEdgeCreatedListener(function(this, EdgeEventArgs):void)
Event Deregistration
removeEdgeCreatedListener(function(this, EdgeEventArgs):void)
Signature Details
function(sender: this, evt: EdgeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - EdgeEventArgs
- An object that contains the event data.
Occurs when the edge creation has started, that is when the cursor is dragged over the source node.
Remarks
Examples
createEdgeInputMode.addGestureStartedListener((sender, args) => {
const polylineEdgeStyle = createEdgeInputMode.dummyEdge.style
if (polylineEdgeStyle instanceof PolylineEdgeStyle) {
polylineEdgeStyle.stroke = Stroke.RED
}
})
See Also
Event Registration
addEdgeCreationStartedListener(function(this, EdgeEventArgs):void)
Event Deregistration
removeEdgeCreationStartedListener(function(this, EdgeEventArgs):void)
Signature Details
function(sender: this, evt: EdgeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - EdgeEventArgs
- An object that contains the event data.
Occurs when the gesture has been canceled.
Examples
createEdgeInputMode.addGestureStartedListener(
(sender, args) => (statusLabel.innerText = 'Edge creation in progress...')
)
createEdgeInputMode.addGestureCanceledListener(
(sender, args) => (statusLabel.innerText = '')
)
createEdgeInputMode.addGestureFinishedListener(
(sender, args) => (statusLabel.innerText = '')
)
See Also
Event Registration
addGestureCanceledListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeGestureCanceledListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs before the gesture will be canceled.
See Also
Event Registration
addGestureCancelingListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeGestureCancelingListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs once the gesture has been finished.
Examples
createEdgeInputMode.addGestureStartedListener(
(sender, args) => (statusLabel.innerText = 'Edge creation in progress...')
)
createEdgeInputMode.addGestureCanceledListener(
(sender, args) => (statusLabel.innerText = '')
)
createEdgeInputMode.addGestureFinishedListener(
(sender, args) => (statusLabel.innerText = '')
)
See Also
Event Registration
addGestureFinishedListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeGestureFinishedListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs before the gesture will be finished.
See Also
Event Registration
addGestureFinishingListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeGestureFinishingListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs once the actual creation gesture is initialized and has started, that is when the edge is dragged from its source node.
Examples
createEdgeInputMode.addGestureStartedListener((sender, args) =>
createEdgeInputMode.dummyEdgeGraph.setStyle(
createEdgeInputMode.dummyTargetNode,
new ShapeNodeStyle({ fill: Fill.ORANGE })
)
)
createEdgeInputMode.addGestureStartedListener(
(sender, args) => (statusLabel.innerText = 'Edge creation in progress...')
)
createEdgeInputMode.addGestureCanceledListener(
(sender, args) => (statusLabel.innerText = '')
)
createEdgeInputMode.addGestureFinishedListener(
(sender, args) => (statusLabel.innerText = '')
)
See Also
Event Registration
addGestureStartedListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeGestureStartedListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs once the actual creation gesture is starting, that is when starting to drag the edge from its source node.
See Also
Event Registration
addGestureStartingListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeGestureStartingListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs at the end of every drag or move.
See Also
Event Registration
addMovedListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeMovedListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs at the start of every drag or move.
See Also
Event Registration
addMovingListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeMovingListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs when this instance adds a port to the source or target node during completion of the edge creation gesture.
See Also
Event Registration
addPortAddedListener(function(this, ItemEventArgs<IPort>):void)
Event Deregistration
removePortAddedListener(function(this, ItemEventArgs<IPort>):void)
Signature Details
function(sender: this, evt: ItemEventArgs<IPort>)
Parameters
- sender - this
- The source of the event.
- evt - ItemEventArgs<IPort>
- An object that contains the event data.
Occurs when the value of the sourcePortCandidate property changes.
See Also
Event Registration
addSourcePortCandidateChangedListener(function(this, ItemEventArgs<IPortCandidate>):void)
Event Deregistration
removeSourcePortCandidateChangedListener(function(this, ItemEventArgs<IPortCandidate>):void)
Signature Details
function(sender: this, evt: ItemEventArgs<IPortCandidate>)
Parameters
- sender - this
- The source of the event.
- evt - ItemEventArgs<IPortCandidate>
- An object that contains the event data.
Occurs when the value of the targetPortCandidate property changes.
See Also
Event Registration
addTargetPortCandidateChangedListener(function(this, ItemEventArgs<IPortCandidate>):void)
Event Deregistration
removeTargetPortCandidateChangedListener(function(this, ItemEventArgs<IPortCandidate>):void)
Signature Details
function(sender: this, evt: ItemEventArgs<IPortCandidate>)
Parameters
- sender - this
- The source of the event.
- evt - ItemEventArgs<IPortCandidate>
- An object that contains the event data.