An edge label model that allows placement of labels relative to an edge segment 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 specified segment index from the source or target side and a ratio on this segment. This is the main difference to the EdgePathLabelModel which only uses a ratio value of the full edge path.
Type Details
- yFiles module
- view
Constructors
EdgeSegmentLabelModel
(distance?: number, offset?: number, angle?: number, autoRotation?: boolean, sideOfEdge?: EdgeSides)Initializes a new instance of the EdgeSegmentLabelModel 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
createParameterFromCenter
(segmentRatio?: number, sideOfEdge?: EdgeSides) : EdgeSegmentLabelModelParameterCreates a parameter where the label is attached to the edge segment that contains the edge's midpoint.
Parameters
A map of options to pass to the method.
- segmentRatio - number
- The ratio at which to place the label at the segment. A ratio of 0.0 will place the label at the source side of the segment, a ratio of 1.0 at the target side. Ratios < 0.0 or > 1.0 will be interpreted as absolute values in world coordinates. 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
- ↪EdgeSegmentLabelModelParameter
- A label parameter that describes the provided parameters for this model instance.
createParameterFromSource
(segmentIndex: number, segmentRatio?: number, sideOfEdge?: EdgeSides) : EdgeSegmentLabelModelParameterCreates a parameter that describes the provided segment index and ratio from the source side of the edge path.
Parameters
A map of options to pass to the method.
- segmentIndex - number
- The zero-based index of the segment beginning from the source side.
- segmentRatio - number
- The ratio at which to place the label at the segment. A ratio of 0.0 will place the label at the source side of the segment, a ratio of 1.0 at the target side. Ratios < 0.0 or > 1.0 will be interpreted as absolute values in world coordinates. 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
- ↪EdgeSegmentLabelModelParameter
- A label parameter that describes the provided parameters for this model instance.
createParameterFromTarget
(segmentIndex: number, segmentRatio?: number, sideOfEdge?: EdgeSides) : EdgeSegmentLabelModelParameterCreates a parameter that describes the provided segment index and ratio from the target side of the edge path.
Parameters
A map of options to pass to the method.
- segmentIndex - number
- The zero-based index of the segment beginning from the target side.
- segmentRatio - number
- The ratio at which to place the label at the segment. A ratio of 0.0 will place the label at the target side of the segment, a ratio of 1.0 at the source side. Ratios < 0.0 or > 1.0 will be interpreted as absolute values in world coordinates. 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
- ↪EdgeSegmentLabelModelParameter
- A label parameter that describes the provided parameters 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.