An edge label model that allows placement at any position.
Remarks
Similar to EdgeSegmentLabelModel, a position is specified by an edge segment and a ratio on that segment, amongst others. During changes of the edge path, the label keeps its relative location with respect to the bends of the reference segment in a similar way.
In contrast to EdgeSegmentLabelModel, the distance from the edge path is not a property of the model but of the particular parameter. In addition, this class does not implement ILabelModelParameterProvider and therefore, labels with this model can be moved freely and are not restricted to a fixed set of candidates at a given distance from the edge.
If autoRotation is enabled, labels are automatically rotated according to the angle of the corresponding reference edge segment.
During movements, labels with this model snap to notable positions if the MoveInputMode provides a GraphSnapContext that is enabled and has a suitable configuration.
Type Details
- yFiles module
- view
Constructors
Initializes a new instance of this class.
Parameters
A map of options to pass to the method.
- autoRotation - boolean
- Whether or not edge labels are automatically rotated according to the angle of the corresponding reference edge segment. This option sets the autoRotation property on the created object.
- angle - number
- The rotation angle of all labels with this model. This option sets the angle property on the created object.
Properties
Methods
Creates 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.
- distance - number
- The distance between the label's box and the edge's path. The default is 0.
- 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 of1.0
at the target side. Ratios less than0.0
or greater than1.0
will be interpreted as absolute values in world coordinates. The default is 0.5.
Returns
- ↪SmartEdgeLabelModelParameter
- A label parameter that describes the provided parameters for this model instance.
createParameterFromSource
(segmentIndex: number, distance?: number, segmentRatio?: number) : SmartEdgeLabelModelParameterCreates a parameter that measures the provided segment index 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.
- distance - number
- The distance between the label's box and the edge's path. The default is 0.
- 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 of1.0
at the target side. Ratios less than0.0
or greater than1.0
will be interpreted as absolute values in world coordinates. The default is 0.5.
Returns
- ↪SmartEdgeLabelModelParameter
- A label parameter that describes the provided parameters for this model instance.
createParameterFromTarget
(segmentIndex: number, distance?: number, segmentRatio?: number) : SmartEdgeLabelModelParameterCreates a parameter that measures the provided segment index 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.
- distance - number
- The distance between the label's box and the edge's path. The default is 0.
- 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 of1.0
at the source side. Ratios less than0.0
or greater than1.0
will be interpreted as absolute values in world coordinates. The default is 0.5.
Returns
- ↪SmartEdgeLabelModelParameter
- 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.
Provides a lookup context for the given label.
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.