ibm_ilog.diagram.Link
The link is a templatable object that connects two nodes. A link is created by calling graph.createLink(template), where 'graph' is an ibmilog.diagram.Graph instance, and 'template' is a GFX definition of the shapes that make up the link. The template must contain at least a GFX shape that will represent the polyline shape of the link. This shape must have a "dojoAttachPoint: 'path'" property. The template can contain one or two shapes representing the start and/or end arrows of the link, with "dojoAttachPoint: 'startArrow'" and "dojoAttachPoint: 'endArrow'" properties. The template can also contain decorations, that is, shapes that will placed placed automatically along the link's path. Decorations are identified by a isDecoration property which must be set to true. Additional properties can be specified to define how a decoration is placed and aligned on the path. See the getDecorations() method for more details.
Property Summary
- TID Graph element Type ID, used to distinguish basic graph element types: N = Node S = Subgraph L = Link Usually used as a very fast index into maps based on ibm_diagram graph element types.
- defaultTemplate
- nodeType
Method Summary
- addConnection(connection) this method should be called on every dojo.connect done to the graph element that should be disconnected on dispose.
- afterDisposing(graphElement) This function is called after disposing the GraphElement
- applyLayout()
- applyPath(path, points, curveTension)
- applyPathToArrows(target)
- beforeDisposing(graphElement) This function is called before disposing the GraphElement
- byShape(shape) Returns the GraphElement that contains the specified shape, or null.
- connect() override gfx.connect to add the handle to the internal list
- constructor() Constructor.
- disconnectAll() This function is disconnect every dojo.connect attached to this element
- dispose(options) Dispose this GraphElement.
- getBounds(parent) Returns the bounds of this node in the coordinate space of the specified parent.
- getCurveTension() Gets the curve tension.
- getDecorations() Gets an array containing the decorations of the link.
- getEndNode() Gets the end node of the link.
- getEndPort() Gets the end port of the link.
- getFallbackEndPoint() Gets the end point of the link.
- getFallbackStartPoint() Gets the start point of the link.
- getHitTolerance()
- getId()
- getIntermediatePoints() Gets the intermediate points of the link.
- getNodeDistance() Gets the minimum distance between this link and its start or end nodes when the link is orthogonal.
- getPoints() Gets the actual points of the link.
- getShapeType() Gets the shape type of this link.
- getStartNode() Gets the start node of the link.
- getStartPort() Gets the start port of the link.
- hitTest(p, graph, tolerance)
- invalidate()
- invalidateLinkShape() Invalidates the shape of this link.
- isEndArrowVisible() Gets the visibility of the end arrow.
- isStartArrowVisible() Gets the visibility of the start arrow.
- layoutShape(target)
- revalidateLinkShape() Recomputes the shape of this link.
- setCurveTension(t) Sets the curve tension to draw the link as a spline.
- setEndArrowVisible(v) Makes the end arrow visible or invisible.
- setEndNode(node) Sets the end node of the link.
- setEndPort(port) Sets the end port of the link.
- setFallbackEndPoint(point) Sets the end point of the link.
- setFallbackStartPoint(point) Sets the start point of the link.
- setHitTolerance(tolerance)
- setIntermediatePoints(points) Sets the intermediate points of the link.
- setNodeDistance(distance) Sets the minimum distance between this link and its start or end nodes when the link is orthogonal.
- setShapeType(shapeType) Sets the shape type of this link.
- setStartArrowVisible(v) Makes the start arrow visible or invisible.
- setStartNode(node) Sets the start node of the link.
- setStartPort(port) Sets the start port of the link.
- toString()
- validateLinkShape() Recomputes the shape of this link.
Attached Objects
Properties
Methods
Parameter | Type | Description |
---|---|---|
connection |
This function free all possible listeners
Parameter | Type | Description |
---|---|---|
graphElement |
Parameter | Type | Description |
---|---|---|
graphElement |
Parameter | Type | Description |
---|---|---|
shape |
This function should be called when the GraphElement is completely deleted, that is, when it is removed from its parent graph and it will never be used again.
Parameter | Type | Description |
---|---|---|
options | options.noRecurse: | Do not recurse children |
Parameter | Type | Description |
---|---|---|
parent | dojox.gfx.Group | The parent object that determines the coordinate space the bounds are relative to. If null or undefined, the bounds of the node relative to its parent are returned. |
The link can contain shapes called "decorations". Decorations are automatically placed along the link path. To be considered as a decoration, a child shape must have the "isDecoration" set to true. The decoration can have the following properties that define their placement on the link: - position: A number that defines the position of the decoration along the link. The meaning of the position depends on the positionType property. The default position is 0.5, and The default positionType is ibmilog.diagram.LinkDecorationPositionType.Relative, so by default a decoration is placed at the middle of the link. - positionType: Defines the way the position is interpreted. Possible values are: ibmilog.diagram.LinkDecorationPositionType.Relative: The position property is a ratio between 0 and 1 that defines a relative position on the link (0 = start of the link, 1 = of the link, 0.5 = middle of the link, etc). ibmilog.diagram.LinkDecorationPositionType.AnsoluteFromStart: The position is a fixed length that defines an offset from the start of the link (going forward from the start to the end of the link). ibmilog.diagram.LinkDecorationPositionType.AnsoluteFromMiddle: The position is a fixed length that defines an offset from the middle of the link (going forward from the start to the end of the link). ibmilog.diagram.LinkDecorationPositionType.AnsoluteFromEnd: The position is a fixed length that defines an offset from the end of the link (going backward from the end to the start of the link). The default positionType is ibmilog.diagram.LinkDecorationPositionType.Relative, and the default position is 0.5, so by default a decoration is placed at the middle of the link. - orthogonalAlignment: Defines the alignment of the decoration orthogonally to the link path. Possible values are: ibmilog.diagram.LinkDecorationOrthogonalAlignment.Left: The decoration is placed on the "left" of the link, looking towards the end of the link (for example, if the link is horizontal and pointing to the right, the decoration will be above the link). The spacing between the decoration and the link is defined by the distance property. ibmilog.diagram.LinkDecorationOrthogonalAlignment.Center: The decoration is centered on the link. ibmilog.diagram.LinkDecorationOrthogonalAlignment.Start: The decoration is placed on the "right" of the link, looking towards the end of the link (for example, if the link is horizontal and pointing to the right, the decoration will be below the link). The spacing between the decoration and the link is defined by the distance property. The default orthogonalAlignment is ibmilog.diagram.LinkDecorationOrthogonalAlignment.Center. - parallelAlignment: Defines the alignment of the decoration along the link. Possible values are: ibmilog.diagram.LinkDecorationParallelAlignment.Start: The side of the decoration that is closest to the start of the link is aligned on the point defined by the position and positionType. ibmilog.diagram.LinkDecorationParallelAlignment.Middle: The middle of the decoration is aligned on the point defined by the position and positionType. ibmilog.diagram.LinkDecorationParallelAlignment.Start: The side of the decoration that is closest to the end of the link is aligned on the point defined by the position and positionType. The default parallelAlignment is ibmilog.diagram.LinkDecorationParellelAlignment.Middle. - distance: Defines the distance between the decoration and the link when orthogonalAlignment is ibmilog.diagram.LinkDecorationOrthogonalAlignment.Left or ibmilog.diagram.LinkDecorationOrthogonalAlignment.Right. The default distance is 0. - autoRotate: If autoRotate is true, the decoration is rotated according to the orientation of the link segment that contains the decoration position. By default, autoRotate is false.
If a end port has been specified, this function returns the owner of the end port, otherwise it returns null.
The end point is used only when no end port is specified.
The start point is used only when no start port is specified.
The intermediate points define the additional points of the link (i.e., the points between the start and end points, which are always determined by the setStartPort()/setEndPort() or setFallbackStartPoint/setFallbackEndPoint() functions) when the link shape type is ibmilog.diagram.LinkShapeType.Free or ibmilog.diagram.LinkShapeType.OrthogonalEditable. For other shape types, the intermediate points are ignored since the link path is computed automatically.
This property is used when the link shape type is Orthogonal, OrthogonalEditable or Oblique, and determines the minimum distance kept between the link and its start or end nodes. The default distance is 20.
The shape type determines if and how the link automatically computes its shape based on its start and end port or points, and possibly its intermediate points.
If a start port has been specified, this function returns the owner of the start port, otherwise it returns null.
This function ensures that the shape of the link will be recomputed before the next redisplay of the link. This function is called automatically when the start or end port change, or their owner nodes change, or when a property of the link that determines the shape (such as the intermediate points) is changed. In most cases you do not need to call this function explicitly.
This properties allows to draw curved links. By default, the curve tension is 0, which draws a plain polyline (not curved). If the curve tension is set to a value greater than 0, the link is drawn as a smooth spline that goes through the start point, then through the middle of each link segment (as computed according to the link shape type), and then to the end point. The curve tension determines the shape of the curve: small values will produce sharper bends, larger values will produce a smoother curve. The curve tension must be greater than 0 and less than 1 (0.5 usually provides nicest results). NOTE: If the _path part of the link template was a GFX Polyline shape, setting the curve tension to a value greater than 0 automatically replaces it by a GFX Path shape.
Parameter | Type | Description |
---|---|---|
t | number | number: The curve tension, between 0 and 1. |
Parameter | Type | Description |
---|---|---|
v | Boolean: | If no end arrow is defined in the link template (that is, if the template contains no shape with "dojoAttachPoint: '_endArrow'"), this method does nothing. Otherwise, if 'v' is true, the end arrow is shown (i.e., added to the link), and if 'v' is false, the end arrow is hidden (i.e. removed from the link). |
If a end port has been specified, this function returns the owner of the end port, otherwise it returns null.
Parameter | Type | Description |
---|---|---|
node | ibm_ilog.diagram.Node | A ibm_ilog.diagram.Node object. |
Parameter | Type | Description |
---|---|---|
port | ibm_ilog.diagram.PortBase: | The PortBase object that defines the end point of the link. |
The end point is used only when no end port is specified.
Parameter | Type | Description |
---|---|---|
point | An | object with 'x' and 'y' properties. |
The start point is used only when no start port is specified.
Parameter | Type | Description |
---|---|---|
point | An | object with 'x' and 'y' properties. |
The intermediate points define the additional points of the link (i.e., the points between the start and end points, which are always determined by the setStartPort()/setEndPort() or setFallbackStartPoint/setFallbackEndPoint() functions) when the link shape type is ibmilog.diagram.LinkShapeType.Free or ibmilog.diagram.LinkShapeType.OrthogonalEditable. For other shape types, the intermediate points are ignored since the link path is computed automatically.
Parameter | Type | Description |
---|---|---|
points | An | array of objects with 'x' and 'y' properties (can be null to remove all intermediate points). |
This property is used when the link shape type is Orthogonal, OrthogonalEditable or Oblique, and determines the minimum distance kept between the link and its start or end nodes.
Parameter | Type | Description |
---|---|---|
distance | number | number: A distance in pixels. |
The shape type determines if and how the link automatically computes its shape based on its start and end port or points, and possibly its intermediate points.
Parameter | Type | Description |
---|---|---|
shapeType | int | int: One of the values defined in the ibm_ilog.diagram.LinkShapeType enumeration. |
Parameter | Type | Description |
---|---|---|
v | Boolean: | If no start arrow is defined in the link template (that is, if the template contains no shape with "dojoAttachPoint: '_startArrow'"), this method does nothing. Otherwise, if 'v' is true, the start arrow is shown (i.e., added to the link), and if 'v' is false, the start arrow is hidden (i.e. removed from the link). |
If a start port has been specified, this function returns the owner of the start port, otherwise it returns null.
Parameter | Type | Description |
---|---|---|
node | ibm_ilog.diagram.Node | A ibm_ilog.diagram.Node object. |
Parameter | Type | Description |
---|---|---|
port | ibm_ilog.diagram.PortBase: | The PortBase object that defines the start point of the link. |