Class LinkingBaseToolAbstract

GoJS® Diagramming Components
version 3.0.0
by Northwoods Software®

Hierarchy

This abstract class is the base class for the LinkingTool and RelinkingTool classes.

This class includes properties for defining and accessing any temporary nodes and temporary link that are used during any linking operation, as well as access to the existing diagram's nodes and link (if any) that are involved with the linking operation.

For a general discussion of link routing, see: Introduction to Links, Introduction to Link Labels, and Introduction to Link Connection Points. For customizing the linking tools, see Introduction to the Linking Tools. For customizing the reshaping of Links, see Introduction to the LinkReshapingTool. For a general discussion of validation, see Introduction to Validation.

Index

Constructors

Accessors

  • Gets whether the linking operation is in the forwards direction, connecting from the "From" port to the "To" port.

  • Gets or sets whether it is valid to have partly or completely unconnected links.

    The default value is false -- the user cannot draw or reconnect a link to "nowhere". Setting this property does not raise any events.

  • Gets or sets a predicate that determines whether or not a new link between two ports would be valid. This predicate is called in addition to the normal link checking performed by isValidLink and any Node.linkValidation predicates on the "from" and "to" nodes. When relinking, the Link being considered for reconnection is passed as the fifth argument. The default predicate is null, which is equivalent to simply returning true.

    For a more general discussion of validation, see Introduction to Validation.

    The function, if supplied, must not have any side-effects.

  • Gets or sets the cursor used during the linking or relinking operation. This defaults to 'pointer'. Read more about cursors at Diagram.currentCursor

    since

    2.2

  • Gets or sets the original Node from which the new link is being drawn or from which the originalLink was connected when being relinked. Setting this property does not raise any events.

  • Gets or sets the original Link being reconnected by the RelinkingTool. Setting this property does not raise any events.

  • Gets or sets the original Node to which the new link is being drawn or to which the originalLink was connected when being relinked. Setting this property does not raise any events.

  • Gets or sets the distance at which link snapping occurs. The default value is 100.0. The value must be non-negative. Setting this property does not raise any events.

  • Gets or sets a function that is called as the tool targets the nearest valid port. The first two arguments specify the port by providing the Node that it is in and the GraphObject that is the actual port object. The next two arguments are the temporary port that has been moved and styled to be like the valid port. These values will be either the temporaryToNode and temporaryToPort or the temporaryFromNode and temporaryFromPort, depending on which end of the temporary link is being updated. The fifth argument is true if the target port represents a potential "to" end of a link; it is false if it is for the "from" end of a link.

    When there is no valid port within the portGravity, the first two arguments are null.

    The function, if supplied, must not add or remove any links or nodes or port objects, nor may it change the validity of any potential link connection.

  • Gets or sets a proposed GraphObject port for connecting a link. Whether this is a "to" port or a "from" port depends on the direction (isForwards) in which the link is being drawn or reconnected.

    This is set when the mouse is being dragged and when a mouse-up event occurs with the result of a call to findTargetPort. Setting this property does not raise any events.

  • Gets or sets the temporary Node at the "from" end of the temporaryLink while the user is drawing or reconnecting a link. Setting this property does not raise any events.

  • Gets or sets the GraphObject that is the port at the "from" end of the temporaryLink while the user is drawing or reconnecting a link. Setting this property does not raise any events.

  • Gets or sets the temporary Link that is shown while the user is drawing or reconnecting a link. Setting this property does not raise any events.

  • Gets or sets the temporary Node at the "to" end of the temporaryLink while the user is drawing or reconnecting a link. Setting this property does not raise any events.

  • Gets or sets the GraphObject that is the port at the "to" end of the temporaryLink while the user is drawing or reconnecting a link. Setting this property does not raise any events.

Methods

  • Make a temporary port look and act like a real one.

    This is called by doMouseMove as the tool finds new valid target ports. If findTargetPort returns null, it calls setNoTargetPortProperties instead.

    If the portTargeted property is a function, that function is called. It is easier to customize the behavior by setting that functional property than it is to override this method and the setNoTargetPortProperties method. But you may want to call this method to get the standard behavior for dynamically adapting the temporary node/port to "act like" the target port. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

    Parameters

    Returns void

  • Mouse movement results in a temporary node moving to where a valid target port is located, or to where the mouse is if there is no valid target port nearby.

    This calls findTargetPort to update the targetPort given the new mouse point. If a valid target port is found this moves the temporary node/port and makes them appear like the target node/port by calling copyPortProperties. If no valid target port is found, this moves the temporary node to where the mouse currently is and removes any node/port appearance, by calling setNoTargetPortProperties.

    This method may be overridden, but we recommend that you call this base method.

    Returns void

  • Find a port with which the user could complete a valid link.

    This finds objects near to the current mouse point for which a valid link connection is possible.

    For each port element found, this calls isValidLink to find out if a link between the original node/port and the found node/port would be valid. The result is saved in a cache for faster decisions later during operation of this tool. The closest valid port is returned.

    This method may be overridden, but we recommend that you call this base method. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

    Parameters

    • toend: boolean

      true if looking for a "to" port.

    Returns GraphObject

    a valid port, or null if no such port is near the current mouse point within the portGravity distance.

  • This predicate is true if both argument ports are in the same Node. This is called by isValidLink.

    This method may be overridden, but we recommend that you call this base method. It is rare that you will want to override this method. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

    Parameters

    Returns boolean

  • This predicate is true if there is a link in the diagram going from the given port to the given port. This is called by isValidLink.

    This method may be overridden, but we recommend that you call this base method. It is rare that you will want to override this method. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

    Parameters

    Returns boolean

  • Checks whether a proposed link would be valid according to Diagram.validCycle. This does not distinguish between different ports on a node, so this method does not need to take port arguments. This is called by isValidLink.

    This method may be overridden, but we recommend that you call this base method. It is rare that you will want to override this method. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

    Parameters

    Returns boolean

  • This predicate is true if it is permissible to connect a link from a given node/port. This is called by isValidLink.

    For a more general discussion of validation, see Introduction to Validation.

    This method may be overridden, but we recommend that you call this base method. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

    Parameters

    Returns boolean

    False if the node is in a Layer that does not Layer.allowLink. False if the port's GraphObject.fromLinkable is either false or null. False if the number of links connected to the port would exceed the port's GraphObject.fromMaxLinks. Otherwise true.

  • This predicate is true if it is permissible to connect a link to a given node/port. This is called by isValidLink.

    For a more general discussion of validation, see Introduction to Validation.

    This method may be overridden, but we recommend that you call this base method. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

    Parameters

    Returns boolean

    False if the node is in a Layer that does not Layer.allowLink. False if the port's GraphObject.toLinkable is either false or null. False if the number of links connected from the port would exceed the port's GraphObject.toMaxLinks. Otherwise true.

  • Reset a temporary port's properties to neutral values when there is no target port.

    This is called by doMouseMove when the tool finds no new valid target port. If findTargetPort returns non-null, it calls copyPortProperties instead.

    If the portTargeted property is a function, that function is called with null values as the first two arguments. It is easier to customize the behavior by setting that functional property than it is to override this method and the copyPortProperties method. But you may want to call this method to get the standard behavior for dynamically adapting the temporary node/port to "act like" it is not connecting with any target port. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

    Parameters

    Returns void