Package | com.yworks.graph.model |
Class | public class DefaultLabelModelParameterFinder |
Inheritance | DefaultLabelModelParameterFinder Object |
Implements | ILabelModelParameterFinder |
ILabelModelParameterFinder
interface that uses the
ILabelModel
's own ILabelModelParameterProvider
instance to find the closest match.
This implementation uses a metric to find the closest of the provided parameter candidates to the layout
provided in findBestParameter
.
See also
Property | Defined By | ||
---|---|---|---|
angularDeviationFactor : Number
This factor is used to weight the angular deviation in the metric calculating of a model parameter. | DefaultLabelModelParameterFinder |
Method | Defined By | ||
---|---|---|---|
findBestParameter(label:ILabel, model:ILabelModel, labelLayout:IOrientedRectangle):ILabelModelParameter
Tries to find a parameter that best matches the given layout for the provided label instance. | DefaultLabelModelParameterFinder | ||
pickBestParameter(label:ILabel, labelLayout:IOrientedRectangle, parameters:Iterator):ILabelModelParameter
Tries to find a parameter that best matches the given layout for the provided label instance
among the set of given parameters. | DefaultLabelModelParameterFinder |
Method | Defined By | ||
---|---|---|---|
Calculates a metric for the given label/parameter pair and the target label layout. | DefaultLabelModelParameterFinder | ||
Returns the distance between two IOrientedRectangle instances. | DefaultLabelModelParameterFinder | ||
Retrieves an enumerator over all candidates for a given label and model. | DefaultLabelModelParameterFinder |
Constant | Defined By | ||
---|---|---|---|
instance : DefaultLabelModelParameterFinder [static]
A singleton instance of this class. | DefaultLabelModelParameterFinder |
angularDeviationFactor | property |
angularDeviationFactor:Number
This factor is used to weight the angular deviation in the metric calculating of a model parameter.
The default value is 0.05
.
public function get angularDeviationFactor():Number
public function set angularDeviationFactor(value:Number):void
See also
calculateMetric | () | method |
protected function calculateMetric(label:ILabel, parameter:ILabelModelParameter, layout:IOrientedRectangle):Number
Calculates a metric for the given label/parameter pair and the target label layout.
This implementation gets the geometry from the parameter's model's ILabelModel.getGeometry
method
and returns the result of a call to distance
.
Parameters
label:ILabel — The label to apply the parameter to.
| |
parameter:ILabelModelParameter — The parameter candidate.
| |
layout:IOrientedRectangle — The targeted layout rectangle.
|
Number — A metric that indicates the distance between the candidate's layout and the target layout.
|
distance | () | method |
protected function distance(geometry:IOrientedRectangle, targetGeometry:IOrientedRectangle):Number
Returns the distance between two IOrientedRectangle
instances.
The distance is calculated using the euclidean distance between the two centers
and the angular deviation between the two up vectors weighted with the angularDeviationFactor
.
Parameters
geometry:IOrientedRectangle | |
targetGeometry:IOrientedRectangle |
Number —
|
See also
findBestParameter | () | method |
public function findBestParameter(label:ILabel, model:ILabelModel, labelLayout:IOrientedRectangle):ILabelModelParameter
Tries to find a parameter that best matches the given layout for the provided label instance.
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 ILabelModel.createDefaultParameter
default parameter for the model.
Parameters
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.
| |
labelLayout:IOrientedRectangle — The anticipated layout for the label.
|
ILabelModelParameter — A non-null parameter that can be used for the label to approximate the provided layout.
|
See also
getCandidateParameters | () | method |
protected function getCandidateParameters(label:ILabel, model:ILabelModel):Iterator
Retrieves an enumerator over all candidates for a given label and model.
Parameters
label:ILabel — The label.
| |
model:ILabelModel — The model of the label.
|
Iterator — An enumerator over the candidates. The enumerator may be empty.
|
pickBestParameter | () | method |
public function pickBestParameter(label:ILabel, labelLayout:IOrientedRectangle, parameters:Iterator):ILabelModelParameter
Tries to find a parameter that best matches the given layout for the provided label instance among the set of given parameters.
null
may be returned if an empty iterator is passed.
Parameters
label:ILabel — The label to find a parameter for.
| |
labelLayout:IOrientedRectangle — The anticipated layout for the label.
| |
parameters:Iterator — A set of parameters to choose from.
|
ILabelModelParameter — A parameter that can be used for the label to approximate the provided layout.
|
instance | Constant |
public static const instance:DefaultLabelModelParameterFinder
A singleton instance of this class.