An edge label model that allows placement of labels relative to an edge segment for bezier edges.
Remarks
This model is intended to work with a BezierEdgeStyle and assumes an edge path consisting of cubic segments.
It places the label at a fixed segment with given ratio (a cubic curve parameter value) and distance from the path, which are parameter specific. Additionally, the label can be automatically rotated to be parallel to the tangent vector at the given ratio (autoRotation) and can have an additional rotation angle (independently of the automatic rotation (angle)
If the segment index is less than 0, a placement outside of the path is assumed by taking the connection between source and target as base line and applying the ratio to this line segment. In this case, if auto rotation is enabled, the label will be rotated to match the path slope at the beginning resp. end of the edge path in order to ensure a smooth movement.
Labels are freely movable and movement can optionally be snapped so that the center of the label lies on the edge path, if the label intersects the edge path.
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.graph.BezierEdgeSegmentLabelModel
Constructors
Creates a default instance of the label model with no angle, auto ratio enabled and snapping disabled.
Parameters
A map of options to pass to the method.
- autoRotation - boolean
Whether or not edge labels are automatically rotated according to the tangent 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 in radians. This option sets the angle property on the created object.
- autoSnapping - boolean
Whether the model should snap automatically the layout center to the edge path. This option sets the autoSnapping property on the created object.
Properties
Gets or sets whether the model should snap automatically the layout center to the edge path.
Remarks
true
: - The distance of the parameter will be adjusted so that the whole box has a minimum distance to the edge path - Interactive movements will snap to the edge path as soon as the label layout would come too near to the edge path. Default value is false
Methods
Creates a parameter at middle of the first segment directly on the path.
Returns
- ↪ILabelModelParameter
- A parameter at middle of the first segment directly on the path.
Implements
createParameterFromSource
(segmentIndex: number, segmentRatio?: number, distance?: number) : ILabelModelParameterCreates a parameter at the given segment measured from the source side of the edge path, segment ratio and distance from the segment.
Parameters
A map of options to pass to the method.
- segmentIndex - number
- The segment index. If this value is negative, placement outside of the edge path is assumed.
- 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 are interpreted as parameter values of a cubic spline, i.e. not as percentages of the segment length. If the index is-1
, ratios are interpreted as absolute values instead. The default is0.5
. - distance - number
- The distance from the segment. This may be interpreted differently, depending on whether autoSnapping is enabled or not.
Returns
- ↪ILabelModelParameter
- A new parameter with the given specification.
createParameterFromTarget
(segmentIndex: number, segmentRatio?: number, distance?: number) : ILabelModelParameterCreates a parameter at the given segment measured from the target side of the edge path, segment ratio and distance from the segment.
Parameters
A map of options to pass to the method.
- segmentIndex - number
- The segment index. If this value is negative, placement outside of the edge path is assumed.
- 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 are interpreted as parameter values of a cubic spline, i.e. not as percentages of the segment length. If the index is-1
, ratios are interpreted as absolute values instead. The default is0.5.
- distance - number
- The distance from the segment. This may be interpreted differently, depending on whether autoSnapping is enabled or not.
Returns
- ↪ILabelModelParameter
- A new parameter with the given specification.
findBestParameter
(label: ILabel, model: ILabelModel, layout: IOrientedRectangle) : ILabelModelParameterTries to find a parameter that best matches the given layout for the provided label instance.
Remarks
null
.Parameters
A map of options to pass to the method.
- label - ILabel
- The label to find a parameter for.
- model - ILabelModel
- The model instance to use. This should be the instance this instance has been obtained from.
- 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.
Implements
Returns an empty context.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label to use in the context.
- layoutParameter - ILabelModelParameter
- The parameter to use for the label in the context.
Returns
- ↪ILookup
- An empty context.
See Also
Implements
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.
Implements
Returns an instance that implements the given type or null
.
Remarks
null
implementations for the types, nor does it have to return the same instance any time. Also it depends on the type and context whether the instance returned stays up to date or needs to be reobtained for subsequent use.Type Parameters
- T: any
Parameters
A map of options to pass to the method.
- type - Class<T>
- The type for which an instance shall be returned.
Returns
- ↪T
- an instance that is assignable to type or
null