An edge label model that allows placement of labels along the edge path at a set of continuous positions at specified sides of the edge path.
Remarks
The set of positions can be influenced by specifying the sideOfEdge value that controls on which side of the edge labels positions should be considered. Furthermore, it's possible to specify distance values that control the distance between label and edge and between label and nodes.
If a label model parameter is created ON_EDGE, the label's center is usually placed on the edge. It can be shifted by specifying a offset value but the distance value is ignored. For all other values of EdgeSides the total distance between the label bounds and the edge path is the sum of offset and distance.
The label placements use a ratio value as fraction of the full edge path length. This is the main difference to the EdgeSegmentLabelModel which uses a specified segment index from the source or target side and a ratio on this segment.
Type Details
- yFiles module
- view
Constructors
EdgePathLabelModel
(distance?: number, offset?: number, angle?: number, autoRotation?: boolean, sideOfEdge?: EdgeSides)Initializes a new instance of the EdgePathLabelModel class.
Parameters
A map of options to pass to the method.
- distance - number
- The distance to the edge.
- offset - number
- The offset to the default placement.
- angle - number
- The angle of the label's rotation in radians.
- autoRotation - boolean
- If set to
true
auto rotation is enabled. - sideOfEdge - EdgeSides
- The side of the edge labels.
Properties
Gets or sets the distance between the label box and the edge path.
Remarks
The interpretation of the values depends on the sideOfEdge of the individual ILabelModelParameter.
Note that for ON_EDGE this property is ignored. For all other values of EdgeSides the offset property is added to this distance.
The default value is 2
.
Property Value
See Also
Gets or sets the offset of the label box and the edge path relative to the default placement.
Remarks
Property Value
See Also
Gets or sets the side placement specifiers for edge labels.
Remarks
See Also
Methods
Creates a parameter at the provided edge path ratio.
Parameters
A map of options to pass to the method.
- edgePathRatio - number
- The ratio at which to place the label at the edge path. A ratio of 0.0 will place the label at the source side of the edge path, a ratio of 1.0 at the target side. The default is 0.5.
- sideOfEdge - EdgeSides
- The side of the edge the label is placed on. Note that only single enum values but no combined ones are allowed. The default is ON_EDGE.
Returns
- ↪EdgePathLabelModelParameter
- A label parameter at the provided edge path ratio for this model instance.
Tries to find a parameter that best matches the given layout for the provided label instance.
Remarks
Parameters
A map of options to pass to the method.
- label - ILabel
- The label to find a parameter for.
- layout - IOrientedRectangle
- The anticipated layout for the label.
Returns
- ↪ILabelModelParameter
- A non-
null
parameter that can be used for the label to approximate the provided layout.
Calculates the geometry of the given label using the given model parameter.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label to calculate the geometry for.
- layoutParameter - ILabelModelParameter
- A parameter that is compatible with this model. Typically, this is a parameter that has been created by this model, and its property model returns this instance.
Returns
- ↪IOrientedRectangle
- An IOrientedRectangle that describes the geometry of the label. This is typically designed as a flyweight, therefore clients should not cache the instance but store the values if they need a snapshot for later use.