Provides various edge styles to be used as the values for mxConstants.STYLE_EDGE in a cell style.
var style = stylesheet.getDefaultEdgeStyle(); style[mxConstants.STYLE_EDGE] = mxEdgeStyle.ElbowConnector;
Sets the default edge style to ElbowConnector.
To write a custom edge style, a function must be added to the mxEdgeStyle object as follows:
mxEdgeStyle.MyStyle = function(state, source, target, points, result) { if (source != null && target != null) { var pt = new mxPoint(target.getCenterX(), source.getCenterY()); if (mxUtils.contains(source, pt.x, pt.y)) { pt.y = source.y + source.height; } result.push(pt); } };
In the above example, a right angle is created using a point on the horizontal center of the target vertex and the vertical center of the source vertex. The code checks if that point intersects the source vertex and makes the edge straight if it does. The point is then added into the result array, which acts as the return value of the function.
mxStyleRegistry.putValue('myEdgeStyle', mxEdgeStyle.MyStyle);
model.setStyle(edge, 'edgeStyle=myEdgeStyle');
Note that the key of the mxStyleRegistry entry for the function should be used in string values, unless mxGraphView.allowEval is true, in which case you can also use mxEdgeStyle.MyStyle for the value in the cell style above.
var style = graph.getStylesheet().getDefaultEdgeStyle(); style[mxConstants.STYLE_EDGE] = mxEdgeStyle.MyStyle;
Note that the object can be used directly when programmatically setting the value, but the key in the mxStyleRegistry should be used when setting the value via a key, value pair in a cell style.
mxEdgeStyle | Provides various edge styles to be used as the values for mxConstants.STYLE_EDGE in a cell style. |
Functions | |
EntityRelation | Implements an entity relation style for edges (as used in database schema diagrams). |
Loop | Implements a self-reference, aka. |
ElbowConnector | Uses either SideToSide or TopToBottom depending on the horizontal flag in the cell style. |
SideToSide | Implements a vertical elbow edge. |
TopToBottom | Implements a horizontal elbow edge. |
SegmentConnector | Implements an orthogonal edge style. |
scalePointArray | Scales an array of mxPoint |
scaleCellState | Scales an mxCellState |
OrthConnector | Implements a local orthogonal router between the given cells. |
EntityRelation: function( state, source, target, points, result )
Implements an entity relation style for edges (as used in database schema diagrams). At the time the function is called, the result array contains a placeholder (null) for the first absolute point, that is, the point where the edge and source terminal are connected. The implementation of the style then adds all intermediate waypoints except for the last point, that is, the connection point between the edge and the target terminal. The first ant the last point in the result array are then replaced with mxPoints that take into account the terminal’s perimeter and next point on the edge.
state | mxCellState that represents the edge to be updated. |
source | mxCellState that represents the source terminal. |
target | mxCellState that represents the target terminal. |
points | List of relative control points. |
result | Array of mxPoints that represent the actual points of the edge. |
ElbowConnector: function( state, source, target, points, result )
Uses either SideToSide or TopToBottom depending on the horizontal flag in the cell style. SideToSide is used if horizontal is true or unspecified. See EntityRelation for a description of the parameters.
SideToSide: function( state, source, target, points, result )
Implements a vertical elbow edge. See EntityRelation for a description of the parameters.
TopToBottom: function( state, source, target, points, result )
Implements a horizontal elbow edge. See EntityRelation for a description of the parameters.
SegmentConnector: function( state, sourceScaled, targetScaled, controlHints, result )
Implements an orthogonal edge style. Use <mxEdgeSegmentHandler> as an interactive handler for this style.
state | mxCellState that represents the edge to be updated. |
sourceScaled | mxCellState that represents the source terminal. |
targetScaled | mxCellState that represents the target terminal. |
controlHints | List of relative control points. |
result | Array of mxPoints that represent the actual points of the edge. |
scaleCellState: function( state, scale )
Scales an mxCellState
state | mxCellState to scale |
scale | the scaling to divide by |
OrthConnector: function( state, sourceScaled, targetScaled, controlHints, result )
Implements a local orthogonal router between the given cells.
state | mxCellState that represents the edge to be updated. |
sourceScaled | mxCellState that represents the source terminal. |
targetScaled | mxCellState that represents the target terminal. |
controlHints | List of relative control points. |
result | Array of mxPoints that represent the actual points of the edge. |
Defines the key for the edge style.
STYLE_EDGE: 'edgeStyle'
Implements an entity relation style for edges (as used in database schema diagrams).
EntityRelation: function( state, source, target, points, result )
Implements a self-reference, aka.
Loop: function( state, source, target, points, result )
Uses either SideToSide or TopToBottom depending on the horizontal flag in the cell style.
ElbowConnector: function( state, source, target, points, result )
Implements a vertical elbow edge.
SideToSide: function( state, source, target, points, result )
Implements a horizontal elbow edge.
TopToBottom: function( state, source, target, points, result )
Implements an orthogonal edge style.
SegmentConnector: function( state, sourceScaled, targetScaled, controlHints, result )
Scales an array of mxPoint
scalePointArray: function( points, scale )
Scales an mxCellState
scaleCellState: function( state, scale )
Implements a local orthogonal router between the given cells.
OrthConnector: function( state, sourceScaled, targetScaled, controlHints, result )
Specifies if string values in cell styles should be evaluated using mxUtils.eval.
mxGraphView.prototype.allowEval