CurveFittingLayoutStage fits a piecewise cubic bezier curve to given arbitrary edge paths.
Remarks
Concept
The path of an edge, i.e., its start and end point as well as the intermediate control points, are interpreted as the set of input points. A cubic bezier curve is then fitted to these points.
After the fitting, the points of the processed edges can be interpreted as cubic bezier control points. Each four consecutive points form a bezier curve, where the first and last of the four points represent the start and end of the curve and the second and third point are the control points defining how the curve looks. The second and third point do not necessarily lie on the actual curve.
There are two exceptions to the stated rules:
- If an input edge only consists of a source and a target point, it will be ignored by this stage.
- Self-loop edges with only one intermediate control point are also ignored. Note that self-loops with more control points are, however, handled by this stage.
Features
The maximum allowed error for the fitting process can be selected to control how high the precision should be. A high allowed error means that the approximation process has a lot of freedom. Curves are only loosely bound to the original edge path. If this is not desired, e.g., because no new intersection with other graph elements should be introduced, then a rather low error value should be specified. The lower the error value, the larger the number of bend points of an approximated edge will be.
It is possible to define the set of edges that should be processed by this layout stage. Therefore, only paths of a sub-set of edges can be changed. Use a IDataProvider registered with the specified selection key to mark edges which should be part of the considered sub-set.
Default Values of Properties
affectedEdgesDpKey | DEFAULT_AFFECTED_EDGES_DP_KEY
| |
maximumError | 4.0 | |
straightControlPointRatio | 0.33 |
Type Details
- yfiles module
- layout-core
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.layout.CurveFittingLayoutStage
Constructors
Creates a new CurveFittingLayoutStage with an optional core layout algorithm.
Parameters
A map of options to pass to the method.
- coreLayout - ILayoutAlgorithm
- The core layout algorithm.
- maximumError - number
The maximum allowed error for the fitting process. This option sets the maximumError property on the created object.
- straightControlPointRatio - number
The ratio that defines the distance between the intermediate control points and the end points of a cubic segment which actually represents a straight line, i.e., in case the four points are collinear. This option sets the straightControlPointRatio property on the created object.
- affectedEdgesDpKey - Object
The IDataProvider key to look up the selection state of the edges that defines whether or not an edge's path should be approximated by a bezier curve. This option sets the affectedEdgesDpKey property on the created object.
Properties
Gets or sets the IDataProvider key to look up the selection state of the edges that defines whether or not an edge's path should be approximated by a bezier curve.
Remarks
Default Value
DEFAULT_AFFECTED_EDGES_DP_KEY.Throws
- Exception({ name: 'ArgumentError' })
- if the specified
key is null
Gets or sets the core layout algorithm that is wrapped by this stage.
Gets or sets the maximum allowed error for the fitting process.
Remarks
The error is defined as the minimum distance between an original input control point (i.e. bend) of and edge and the fitted bezier curve.
The maximum error must be greater than or equal to zero.
Default Value
4.0
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified maximum error is negative
Gets or sets the ratio that defines the distance between the intermediate control points and the end points of a cubic segment which actually represents a straight line, i.e., in case the four points are collinear.
Remarks
0.33
- the second and third control point are equally distributed between te first and fourth point.0.0
- the first and second control point as well as the third and fourth point are equal.0.5
- the second and third control point are equal and exactly the mid-point between the first and fourth point.
[0.0, 0.5]
.Default Value
0.33
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified ratio is outside the interval
[0.0, 0.5]
Methods
Changes the edge paths of selected edges of the given graph such that they represent piecewise cubic bezier curves which approximate the original points of the path.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Implements
Invokes the layout process of the core layout algorithm.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Defined in
Constants
A data provider key for selecting edges for curve fitting.
Domain | Edge | |
Values | boolean | true if a bezier curve should be fitted to the edge's path, false otherwise |