An edge label model that allows the 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 MoveLabelInputMode provides a LabelSnapContext that is enabled and has a suitable configuration.
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.graph.SmartEdgeLabelModel
See Also
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 default parameter that can be used for this model.
createParameterFromSource
(segmentIndex: number, distance?: number, segmentRatio?: number) : ILabelModelParameterCreates 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
- ↪ILabelModelParameter
- A label parameter that describes the provided parameters for this model instance.
createParameterFromTarget
(segmentIndex: number, distance?: number, segmentRatio?: number) : ILabelModelParameterCreates 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
- ↪ILabelModelParameter
- A label parameter that describes the provided parameters for this model instance.
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
Provides a lookup context for the given combination of label and parameter.
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 implementation of the ILookup interface that can be used to query additional aspects of the label/parameter combination.
See Also
Implements
Gets the distance from the edge path described by the specified parameter.
Parameters
A map of options to pass to the method.
- layoutParameter - ILabelModelParameter
- The parameter to get the edge path distance for.
Returns
- ↪number
- The distance from the edge path
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