DiscreteEdgeLabelLayoutModel describes the placement of rotated labels at some predefined positions along the edge.
Remarks
The predefined positions in this model
It's possible to specify a distance value that controls the distance between label and edge.
Furthermore, there's the possibility to mask out arbitrary edge label candidates. This can either be done by specifying predefined candidate masks or combining several label positions with a logical or
-operation to a user-defined mask.
Default Values of Properties
angle | 0 | |
autoFlipping | false | Edge labels keep their orientation. |
autoRotation | true | Labels are rotated with their edge segment. |
candidateMask | SIX_POS
| |
distance | 2 | |
positionRelativeToSegment | false | Positions are interpreted geometrically. |
Type Details
- yfiles module
- layout-core
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.layout.DiscreteEdgeLabelLayoutModel
See Also
Constructors
Creates a new instance of DiscreteEdgeLabelLayoutModel with default settings.
Parameters
A map of options to pass to the method.
- positionRelativeToSegment - boolean
Whether or not the label position mask should be interpreted relative to the edge segment. This option sets the positionRelativeToSegment property on the created object.
- autoRotation - boolean
Whether or not edge labels are automatically rotated according to the angle of the corresponding reference edge segment. This option sets the autoRotation property on the created object.
- autoFlipping - boolean
Whether or not edge labels get flipped if they would be upside down in their current position. This option sets the autoFlipping property on the created object.
- angle - number
The angle (measured in radians) of the label model. This option sets the angle property on the created object.
- distance - number
The distance between the label's bounding box and the edge path. This option sets the distance property on the created object.
Creates a new instance of DiscreteEdgeLabelLayoutModel using the given candidate mask.
Remarks
Parameters
A map of options to pass to the method.
- candidateMask - DiscreteEdgeLabelPositions
- the position mask that defines the allowed positions for an edge label
- positionRelativeToSegment - boolean
Whether or not the label position mask should be interpreted relative to the edge segment. This option sets the positionRelativeToSegment property on the created object.
- autoRotation - boolean
Whether or not edge labels are automatically rotated according to the angle of the corresponding reference edge segment. This option sets the autoRotation property on the created object.
- autoFlipping - boolean
Whether or not edge labels get flipped if they would be upside down in their current position. This option sets the autoFlipping property on the created object.
- angle - number
The angle (measured in radians) of the label model. This option sets the angle property on the created object.
- distance - number
The distance between the label's bounding box and the edge path. This option sets the distance property on the created object.
Properties
Gets the candidate mask which specifies the valid positions for edge labels.
Default Value
SIX_POS.Gets a model parameter that encodes the default position of this model's allowed edge 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
Gets or sets whether or not the label position mask should be interpreted relative to the edge segment.
Remarks
Default Value
false
.Positions are interpreted geometrically.
Sample Graphs
Methods
createModelParameter
(labelBounds: YOrientedRectangle, edgeLayout: IEdgeLayout, sourceNode: INodeLayout, targetNode: INodeLayout) : ObjectCreates a model parameter that represents the given edge 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 IEdgeLabelLayoutModel.
Parameters
A map of options to pass to the method.
- labelBounds - YOrientedRectangle
- the oriented box of the label, encoding the label location for which the parameter should be created
- edgeLayout - IEdgeLayout
- the layout of the edge to which the label belongs
- sourceNode - INodeLayout
- the layout of the source node of the label-owning edge
- targetNode - INodeLayout
- the layout of the target node of the label-owning edge
Returns
- ↪Object
- the model parameter representing the given label location
See Also
Implements
getLabelCandidates
(label: IEdgeLabelLayout, edgeLayout: IEdgeLayout, sourceNode: INodeLayout, targetNode: INodeLayout) : YListReturns all EdgeLabelCandidates that describe valid label positions within this model.
Remarks
Parameters
A map of options to pass to the method.
- label - IEdgeLabelLayout
- the label for which candidates should be generated
- edgeLayout - IEdgeLayout
- the layout of the edge to which the label belongs
- sourceNode - INodeLayout
- the layout of the source node of the label-owning edge
- targetNode - INodeLayout
- the layout of the target node of the label-owning edge
Returns
- ↪YList
- a list of EdgeLabelCandidate instances
Implements
getLabelPlacement
(labelSize: YDimension, edgeLayout: IEdgeLayout, sourceNode: INodeLayout, targetNode: INodeLayout, param: Object) : YOrientedRectangleReturns the oriented box 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
- edgeLayout - IEdgeLayout
- the layout of the edge to which the label belongs
- sourceNode - INodeLayout
- the layout of the source node of the label-owning edge
- targetNode - INodeLayout
- the layout of the target node of the label-owning edge
- param - Object
- the model parameter that describes the abstract position of the label within this model
Returns
- ↪YOrientedRectangle
- the oriented bounds of the label
Implements
getLabelPlacementForPosition
(labelSize: YDimension, edgeLayout: IEdgeLayout, sourceLayout: INodeLayout, targetLayout: INodeLayout, position: DiscreteEdgeLabelPositions) : 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
- edgeLayout - IEdgeLayout
- the layout of the edge to which the label belongs
- sourceLayout - INodeLayout
- the layout of the source node of the label-owning edge
- targetLayout - INodeLayout
- the layout of the target node of the label-owning edge
- position - DiscreteEdgeLabelPositions
- 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 edge 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
Static Methods
Returns a model parameter that encodes the specified position.
Remarks
Parameters
A map of options to pass to the method.
- position - number
- one of the valid positions
Returns
- ↪any
- a model parameter that encodes the specified position
Throws
- Exception({ name: 'ArgumentError' })
- if the specified position is unknown
Returns the position specifier that is encoded by the given model parameter.