Implementation of the ILabelModelParameterFinder interface that uses the ILabelModel's own ILabelModelParameterProvider instance to find the closest match.
Inheritance Hierarchy
DefaultLabelModelParameterFinder
Implemented Interfaces
Remarks
This implementation uses a metric to find the closest of the provided parameter candidates to the layout provided in selectBestParameter.
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.graph.DefaultLabelModelParameterFinder
Methods
calculateMetric
(label: ILabel, layoutParameter: ILabelModelParameter, layout: IOrientedRectangle) : numberCalculates a metric for the given label/parameter pair and the target label layout.
Remarks
This implementation gets the geometry from the parameter's model's getGeometry method and returns the result of a call to distance.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- label - ILabel
- The label to apply the parameter to.
- layoutParameter - ILabelModelParameter
- The parameter candidate.
- layout - IOrientedRectangle
- The targeted layout rectangle.
Returns
- ↪number
- A metric that indicates the distance between the candidate's layout and the target layout.
Returns the distance between two IOrientedRectangle instances.
Remarks
The distance is calculated using the Euclidean distance between the two centers and the angular deviation between the two up vectors.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- rectangle1 - IOrientedRectangle
- The first geometry.
- rectangle2 - IOrientedRectangle
- The geometry to compare the first one with.
Returns
- ↪number
- A value indicating the distance between the two instances.
findBestParameter
(label: ILabel, model: ILabelModel, layout: IOrientedRectangle) : ILabelModelParameterTries to find a parameter that best matches the given layout for the provided label instance.
Remarks
This method may not necessarily find a parameter that matches the provided layout exactly. It will first query the getCandidateParameters parameter for an enumeration of candidates and will then find the best matching candidate using a metric calculated by calculateMetric. If no parameter can be found this method returns the default parameter for the model.
Parameters
options - Object
A map of options to pass to the method.
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
Retrieves an enumerator over all candidates for a given label and model.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- label - ILabel
- The label.
- model - ILabelModel
- The model of the label.
Returns
- ↪IEnumerable<ILabelModelParameter>
- An enumerator over the candidates. The enumerator may be empty.
selectBestParameter
(label: ILabel, layout: IOrientedRectangle, layoutParameters: IEnumerable<ILabelModelParameter>) : ILabelModelParameterTries to find a parameter that best matches the given layout for the provided label instance among the set of given parameters.
Remarks
Null may be returned if an empty enumerable is passed.
Parameters
options - Object
A map of options to pass to the method.
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.
- layoutParameters - IEnumerable<ILabelModelParameter>
- A set of parameters to choose from.
Returns
- ↪ILabelModelParameter
- A parameter that can be used for the label to approximate the provided layout.
Constants
A singleton instance of this class.