Packagecom.yworks.graph.model
Classpublic class FreeNodeLabelModel
InheritanceFreeNodeLabelModel Inheritance Object
Implements ILabelModel, ILabelModelParameterFinder

A node label model that can be used to describe any position and orientation of a label.

The position of the label is stored relative to the layout of the node the label belongs to.



Public Properties
 PropertyDefined By
  instance : FreeNodeLabelModel
[static] [read-only]
FreeNodeLabelModel
Public Methods
 MethodDefined By
  
Creates a default parameter that can be used for this model.
FreeNodeLabelModel
  
createNodeCenterAnchored(offsetX:Number, offsetY:Number, angle:Number):ILabelModelParameter
Creates a parameter instance that is anchored to the node's INode.layout's center.
FreeNodeLabelModel
  
createNodeLayoutAnchored(offsetX:Number, offsetY:Number, angle:Number):ILabelModelParameter
Creates a parameter instance that is anchored to the node's INode.layout.
FreeNodeLabelModel
  
createNodeRatioAnchored(layoutXRatio:Number, layoutYRatio:Number, layoutXOffset:Number, layoutYOffset:Number, labelXRatio:Number, labelYRatio:Number, labelXOffset:Number, labelYOffset:Number, angle:Number):ILabelModelParameter
Creates a parameter instance that anchors the label to the node at a given position.
FreeNodeLabelModel
  
Tries to find a parameter that best matches the given layout for the provided label instance.
FreeNodeLabelModel
  
Provides a lookup context for the given combination of label and parameter.
FreeNodeLabelModel
  
Calculates the geometry in form of an IOrientedRectangle for a given label using the given model parameter.
FreeNodeLabelModel
  
lookup(type:Class):Object
Returns an instance that implements the given type or null.
FreeNodeLabelModel
Property Detail
instanceproperty
instance:FreeNodeLabelModel  [read-only]


Implementation
    public static function get instance():FreeNodeLabelModel
Method Detail
createDefaultParameter()method
public function createDefaultParameter():ILabelModelParameter

Creates a default parameter that can be used for this model.

Returns
ILabelModelParameter — A parameter for this model instance.
createNodeCenterAnchored()method 
public function createNodeCenterAnchored(offsetX:Number, offsetY:Number, angle:Number):ILabelModelParameter

Creates a parameter instance that is anchored to the node's INode.layout's center.

Parameters

offsetX:Number — The x offset to the layout's center.
 
offsetY:Number — The y offset to the layout's center.
 
angle:Number — The angle to rotate the label by.

Returns
ILabelModelParameter — A parameter that exactly fits the described location.

See also

INode.layout
createNodeLayoutAnchored()method 
public function createNodeLayoutAnchored(offsetX:Number, offsetY:Number, angle:Number):ILabelModelParameter

Creates a parameter instance that is anchored to the node's INode.layout.

Parameters

offsetX:Number — The x offset to the layout's top left corner
 
offsetY:Number — The y offset to the layout's top left corner.
 
angle:Number — The angle to rotate the label by.

Returns
ILabelModelParameter — A parameter that exactly fits the described location.

See also

INode.layout
createNodeRatioAnchored()method 
public function createNodeRatioAnchored(layoutXRatio:Number, layoutYRatio:Number, layoutXOffset:Number, layoutYOffset:Number, labelXRatio:Number, labelYRatio:Number, labelXOffset:Number, labelYOffset:Number, angle:Number):ILabelModelParameter

Creates a parameter instance that anchors the label to the node at a given position.

The parameter will use the ratio and offset values to determine a point on both the label and the node. It will place the label in such a way that both points coincide.

Parameters

layoutXRatio:Number — The ratio that describes the point on the node's layout relative to its width.
 
layoutYRatio:Number — The ratio that describes the point on the node's layout relative to its height.
 
layoutXOffset:Number — The x offset to apply to the point on the node after the ratio has been determined.
 
layoutYOffset:Number — The y offset to apply to the point on the node after the ratio has been determined.
 
labelXRatio:Number — The ratio that describes the point on the label's layout relative to its width.
 
labelYRatio:Number — The ratio that describes the point on the label's layout relative to its height.
 
labelXOffset:Number — The x offset to apply to the point on the label after the ratio has been determined.
 
labelYOffset:Number — The y offset to apply to the point on the label after the ratio has been determined.
 
angle:Number — The angle by which the label should be rotated around the point described using the ratio and offset.

Returns
ILabelModelParameter — A parameter that exactly fits the described location.
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 implementation will match the provided layout perfectly.

Parameters

label:ILabel — The label to find a parameter for.
 
model:ILabelModel — The model instance to use. This should be this instance.
 
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.
getContext()method 
public function getContext(label:ILabel, parameter:ILabelModelParameter):ILookup

Provides a lookup context for the given combination of label and parameter.

Parameters

label:ILabel — The label to use in the context.
 
parameter: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.
getGeometry()method 
public function getGeometry(modelParameter:ILabelModelParameter, label:ILabel):IOrientedRectangle

Calculates the geometry in form of an IOrientedRectangle for a given label using the given model parameter.

Parameters

modelParameter:ILabelModelParameter — A parameter that has been created by this model. This is typically the parameter that yielded this instance through its ILabelModelParameter.model property.
 
label:ILabel — The label to calculate the geometry for

Returns
IOrientedRectangle — An instance that describes the geometry. This is typically an instance designed as a flyweight, so clients should not cache the instance but store the values if they need a snapshot for later use
lookup()method 
public function lookup(type:Class):Object

Returns an instance that implements the given type or null.

Typically, this method will be called in order to obtain a different view or aspect of the current instance. This is quite similar to casting or using a super type or interface of this instance, but is not limited to inheritance or compile time constraints. An instance implementing this method is not required to return non-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.

Parameters

type:Class — the type for which an instance shall be returned

Returns
Object — an instance that is assignable to type or null