Link Action

LinkAction handles adding a link between two nodes in the Diagrammer. If a preprocessing step is needed to validate whether to accept the link add or no, it is specified in the Diagrammer.requestManager via a RequestDescriptor:

The link action takes a LinkActionData.as as an input whose properties can be described as follows:

Property Description
source it should be an ISprite, it is used to specify the source of the added link
target it should be an ISprite, it is used to specify the target of the added link
sourceAnchorIndex It is an int, it is used to specify the anchor from which the link starts in case of multiple anchors. The line is linked by default to the source from the first indexed anchor
targetAnchorIndex It is an int, it is used to specify the anchor from which the link ends in case of multiple anchors. The line is linked by default to the target from the first indexed anchor
linkStyle It should be a LinkStyle. The user/developer can set a specific style to the added link by setting the linkStyle property.
linkLine It is an uint that indicated the nature of the used line to draw the added link. The main line types used to draw links are :
  • STRAIGHT_LINE: Straight line drawing;
  • STRAIGHT_POLYLINE: a straight line drawing that uses more than two control points;
  • CURVED_POLYLINE: a curved line drawing that uses more than two control points;
  • ORTHOGONAL_STRAIGHT_POLYLINE: Straight line drawing flag that use only vertical and horizontal lines and uses more than two control points;
  • ORTHOGONAL_CURVED_POLYLINE: Curved line drawing flag that use only vertical and horizontal lines and uses more than two control points.
linkCursor It is a Class used to specify the cursor used when drawing the line using the link action
interactionParam It specifies main use interaction options :
  • enableMouseMove : enables mouse move on the considered action.
  • deactivateActionOnEscape : lets user deactivate (or not) the action when pressing the Escpace key
forceAnchoringComputation It forces anchoring computation of created links for each extremity based on the generated controlPoints. Link anchor indexes for each node extremity (sourceAnchorIndex and targetAnchorIndex) are computed only in case where the extremity in question have anchors.
routingParam It holds parameters controlling routing directives (routing options and links overlapping-avoid directives).
creationModeParam Indicates if the user have to use a custom behavior when clicking on the target. it contains a number of parameters, namely, enablCreationMode , which enables context menu creation mode, menuRendererClass , in which you can specify custom context menu.

This following code shows how can developer can use the LinkActionAction.

runLinkAction():void
{
	var linkActionData:LinkActionData = new LinkActionData();
	var lineLink:uint= 0
	linkActionData.desactivateOnEscapeKey = false;
	switch(lineLinkCombobox.selectedItem)
	{
		case "STRAIGHT_LINE":
			lineLink = 0;
			break;
		case "STRAIGHT_POLYLINE":
			lineLink = 1;
			break;
		case "CURVED_POLYLINE":
			lineLink = 2;
		break;
		case "ORTHOGONAL_STRAIGHT_POLYLINE":
			lineLink = 3;
			break;
		case "ORTHOGONAL_CURVED_POLYLINE":
			 lineLink = 4;
			 break;
	}
	linkActionData.linkLine =lineLink;
	diagrammer.activateAction(LinkAction.ID,linkActionData);
}