Packagecom.yworks.graph.model
Classpublic class DefaultLabelModelParameterFinder
ImplementsILabelModelParameterFinder

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 Methods
 MethodDefined by
  
Tries to find a parameter that best matches the given layout for the provided label instance.
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
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 targetted 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.

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.
Constant detail
instanceconstant
public static const instance:DefaultLabelModelParameterFinder

A singleton instance of this class.