Packagecom.yworks.graph.model
Classpublic class DefaultLabelModelParameterFinder
InheritanceDefaultLabelModelParameterFinder Inheritance Object
Implements ILabelModelParameterFinder

A simple default implementation of the 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

ILabelModelParameterFinder
ILabelModelParameterProvider
ILabelModel


Public Properties
 PropertyDefined By
  angularDeviationFactor : Number
This factor is used to weight the angular deviation in the metric calculating of a model parameter.
DefaultLabelModelParameterFinder
Public Methods
 MethodDefined By
  
Tries to find a parameter that best matches the given layout for the provided label instance.
DefaultLabelModelParameterFinder
  
Tries to find a parameter that best matches the given layout for the provided label instance among the set of given parameters.
DefaultLabelModelParameterFinder
Protected Methods
 MethodDefined By
  
Calculates a metric for the given label/parameter pair and the target label layout.
DefaultLabelModelParameterFinder
  
distance(geometry:IOrientedRectangle, targetGeometry:IOrientedRectangle):Number
Returns the distance between two IOrientedRectangle instances.
DefaultLabelModelParameterFinder
  
Retrieves an enumerator over all candidates for a given label and model.
DefaultLabelModelParameterFinder
Public Constants
 ConstantDefined By
  instance : DefaultLabelModelParameterFinder
[static] A singleton instance of this class.
DefaultLabelModelParameterFinder
Property Detail
angularDeviationFactorproperty
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.


Implementation
    public function get angularDeviationFactor():Number
    public function set angularDeviationFactor(value:Number):void

See also

Method Detail
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.

Returns
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

Returns
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.

Returns
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.

Returns
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.

Returns
ILabelModelParameter — A parameter that can be used for the label to approximate the provided layout.
Constant Detail
instanceConstant
public static const instance:DefaultLabelModelParameterFinder

A singleton instance of this class.