An edge label model that allows placement of labels along the edge path 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 given ratio of the whole path length 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 parameter is specified as an absolute parameter, 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.BezierEdgePathLabelModel
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 edge path directly on the path.
Creates a parameter at the provided edge path ratio.
Parameters
A map of options to pass to the method.
- ratio - number
- The cubic ratio on the segment
- distance - number
- The distance from the segment. This may be interpreted differently, depending on whether autoSnapping is enabled or not.
- absolute - boolean
- Whether the ratio should be interpreted as the ratio between the source and target ports of the edge. Default is false.
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