This node label model can be used to specify any position and orientation of a label.
Remarks
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.graph.FreeNodeLabelModel
See Also
Methods
createCanonicalParameter
(nodeLayout: Rect, labelLayout: IOrientedRectangle, referenceLocation?: Point) : ILabelModelParameterCreates a parameter instance that anchors the labelLayout
relative to the nodeLayout
.
Remarks
This method ultimately delegates to createParameter so its main purpose is to calculate the according node and label layout ratio and offset parameters.
These parameters are calculated in the following way: Each coordinate axis is considered independently. If the reference point coordinate is within the node layout interval, its relative location specifies the layout ratio for this coordinate. Otherwise, the absolute distance of the reference point and the node layout interval specifies the layout offset and the layout ratio is either either 0.0
or 1.0
. The parameters for the label ratio and label offset are calculated analogously. If no reference point is provided, the reference point is determined automatically in the following way: For each coordinate, if the node layout and label layout do not overlap, the reference is the label corner that is closest to the node. If they overlap and if in addition the start or end coordinate of the label matches the start, center or end coordinate of the node, that coordinate is the reference. Otherwise, the center of the label specifies the reference.
Parameters
A map of options to pass to the method.
- nodeLayout - Rect
- The node layout.
- labelLayout - IOrientedRectangle
- The label layout.
- referenceLocation - Point
- A reference location that influences the ratio and offset calculation for the createParameter call.
Returns
- ↪ILabelModelParameter
- The canonical parameter for the specified node and label layout.
Throws
- Exception({ name: 'ArgumentError' })
nodeLayout
orreferenceLocation
contains one or more NaN values.
Creates a parameter that is anchored at the node center and has no rotation.
Returns
- ↪ILabelModelParameter
- A parameter that is anchored at the node center and has no rotation.
Implements
createParameter
(layoutRatio: Point, layoutOffset: Point, labelRatio: Point, labelOffset?: Point, angle?: number) : ILabelModelParameterCreates a parameter instance that anchors the label to the node at a given position.
Remarks
Parameters
A map of options to pass to the method.
- layoutRatio - Point
- The ratio that describes the point on the node's layout relative to its upper-left corner. A value of (0,0) describes the upper-left corner, while (1,1) is the lower-right corner.
- layoutOffset - Point
- The absolute offset to apply to the point on the node after the ratio has been determined.
- labelRatio - Point
- The ratio that describes the point on the label's layout relative to its upper-left corner. A value of (0,0) describes the upper-left corner, while (1,1) is the lower-right corner.
- labelOffset - Point
- The absolute offset to apply to the point on the label after the ratio has been determined. This defaults to (0,0), representing no further offset.
- angle - number
- The angle by which the label should be rotated around the point described using the ratio and offset, measured in radians. The default is 0.
Returns
- ↪ILabelModelParameter
- A parameter that exactly fits the described location.
Throws
- Exception({ name: 'ArgumentError' })
layoutRatio
,layoutOffset
,labelRatio
orlabelOffset
contains one or more NaN values.
Sample Graphs
findBestParameter
(label: ILabel, model: ILabelModel, layout: IOrientedRectangle) : ILabelModelParameterTries to find a parameter that best matches the given layout for the provided label instance.
Remarks
Parameters
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 this instance.
- 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
Returns an empty context.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label to use in the context.
- layoutParameter - ILabelModelParameter
- The parameter to use for the label in the context.
Returns
- ↪ILookup
- An empty context.
See Also
Implements
Calculates the geometry of the given label using the given model parameter.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label to calculate the geometry for.
- layoutParameter - ILabelModelParameter
- A parameter that is compatible with this model. Typically, this is a parameter that has been created by this model, and its property model returns this instance.
Returns
- ↪IOrientedRectangle
- An IOrientedRectangle that describes the geometry of the label. This is typically designed as a flyweight, therefore clients should not cache the instance but store the values if they need a snapshot for later use.
Implements
Returns this instance if an instance of ILabelModelParameterFinder is requested and null
otherwise.
Type Parameters
- T: any
Parameters
A map of options to pass to the method.
- type - Class<T>
- The type for which an instance is requested.
Returns
- ↪T
- An instance that is assignable to the given type or
null
.
See Also
Implements
Constants
A shared public instance that can be used to obtain parameters.