DiscreteNodeLabelLayoutModel allows placing labels at eight positions around a node and at nine positions inside the node.
Remarks
It's possible to specify an insets value that controls the distance between label and node.
Furthermore, there's the possibility to mask out arbitrary node label candidates. This can either be done by specifying predefined candidate masks or a combination of valid positions of this model using a logical or
-operation.
Default Values of Properties
candidateMask | INTERNAL_MASK
| |
distance | 4 |
Type Details
- yfiles module
- layout-core
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.layout.DiscreteNodeLabelLayoutModel
See Also
Constructors
Creates a new instance of DiscreteNodeLabelLayoutModel with default settings.
Parameters
A map of options to pass to the method.
- distance - number
The distance between the label's bounding box and the node. This option sets the distance property on the created object.
Creates a new instance of DiscreteNodeLabelLayoutModel using the given candidate mask and insets.
Remarks
Parameters
A map of options to pass to the method.
- candidateMask - DiscreteNodeLabelPositions
- the position mask that defines the allowed positions for a node label
- inset - number
- the inset value that defines the internal label distance to the node's border
- distance - number
The distance between the label's bounding box and the node. This option sets the distance property on the created object.
Properties
Gets the candidate mask which specifies the valid positions for node labels.
Default Value
INTERNAL_MASK.Gets a model parameter that encodes the default position of this model's allowed node label positions.
Remarks
Default positions are (in descending order):
Descending order means that whenever two or more of the above default positions are part of the allowed positions, then the model parameter encodes the one that is listed first.
Implements
Methods
Creates a model parameter that represents the given node label position within this model.
Remarks
The created model parameter is the closest parameter representation of the given label location that can be achieved within this model.
This parameter can be passed to getLabelPlacement to retrieve the current label box.
A model parameter can be an arbitrary Object. However it must contain all information to allow restoring of the encoded location with this INodeLabelLayoutModel.
Parameters
A map of options to pass to the method.
- labelBounds - YOrientedRectangle
- the box of the label, encoding the label location for which the parameter should be created
- nodeLayout - INodeLayout
- the layout of the node to which the label belongs
Returns
- ↪Object
- the model parameter representing the given label location
See Also
Implements
Returns all NodeLabelCandidates that describe valid label positions within this model.
Remarks
Parameters
A map of options to pass to the method.
- labelLayout - INodeLabelLayout
- the label for which candidates should be generated
- nodeLayout - INodeLayout
- the layout of the node to which the label belongs
Returns
- ↪YList
- a list of NodeLabelCandidate instances
Implements
getLabelPlacement
(labelSize: YDimension, nodeLayout: INodeLayout, parameter: Object) : YOrientedRectangleReturns the bounds of the label for the position encoded by the given model parameter.
Parameters
A map of options to pass to the method.
- labelSize - YDimension
- the width and height of the label
- nodeLayout - INodeLayout
- the layout of the node to which the label belongs
- parameter - Object
- the model parameter that describes the abstract position of the label within this model
Returns
- ↪YOrientedRectangle
- the oriented box of the label
Implements
getLabelPlacementForPosition
(labelSize: YDimension, nodeLayout: INodeLayout, position: DiscreteNodeLabelPositions) : YOrientedRectangleReturns the oriented box of the label for the given label position.
Remarks
Parameters
A map of options to pass to the method.
- labelSize - YDimension
- the size of the label that should be placed
- nodeLayout - INodeLayout
- the layout of the node to which the label belongs
- position - DiscreteNodeLabelPositions
- the label position that is valid in this model
Returns
- ↪YOrientedRectangle
- the oriented box of the label
Checks whether or not the given model parameter encodes a valid node label position for this model.
Remarks
Parameters
A map of options to pass to the method.
- parameter - Object
- the model parameter
Returns
- ↪boolean
true
if the label position described by the given model parameter is allowed,false
otherwise