LabelLayoutTranslator automatically translates label layout information provided by the standard label layout classes IEdgeLabelLayout and INodeLabelLayout to layout data of type LabelLayoutData that is accessible by the keys defined in class LabelLayoutKeys.
Remarks
One can use this ILayoutStage as label layout algorithm of a label-aware layout algorithm like HierarchicLayout. This can be done by assigning the stage by an appropriate call to setLabelLayouter.
When writing the LabelLayoutData, the boxes are set relative. In case of a node label, the box's anchor is relative to the center of the owning node. In case of an edge label the box's anchor is relative to the center of the source node of the owning edge.
If writing back node labels and/or writing back edge labels is enabled, the LabelLayoutData is transferred back to the INodeLabelLayouts and/or IEdgeLabelLayouts.
By default, the boxes are now interpreted absolute but by activating writeBackRelativeNodeLabelLocation and/or writeBackRelativeEdgeLabelLocation this can be changed to interpret them relative as explained above.
Note that care must be taken on the choice of the label model that is used by the classes IEdgeLabelLayout and INodeLabelLayout. The calculated label positions must be consistent with the label positions allowed by the label model. The best label layout results are achieved by choosing FreeEdgeLabelLayoutModel for edge layouts and FreeNodeLabelLayoutModel for node layouts.
Default Values of Properties
autoFlipping | true | Labels are automatically flipped if they are upside down. |
coreLayout | null | |
resettingEdgeLabelOrientation | true | The orientation of edge labels is reset. |
resettingNodeLabelOrientation | false | The orientation of node labels is kept. |
translateEdgeLabels | false | The label information is not translated for edge labels. |
translateNodeLabels | false | The label information is not translated for node labels. |
writeBackEdgeLabels | true | Edge label information is transferred back to the label model. |
writeBackNodeLabels | true | Node label information is transferred back to the label model. |
Type Details
- yfiles module
- layout-core
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.layout.LabelLayoutTranslator
Constructors
Creates a new LabelLayoutTranslator instance with default settings.
Parameters
A map of options to pass to the method.
- coreLayout - ILayoutAlgorithm
The core layout algorithm that is wrapped by this ILayoutStage. This option sets the coreLayout property on the created object.
- autoFlipping - boolean
Whether or not this stage should automatically flip edge label content depending on the label's rotation angle. This option sets the autoFlipping property on the created object.
- resettingNodeLabelOrientation - boolean
Whether or not to reset the orientation of node labels. This option sets the resettingNodeLabelOrientation property on the created object.
- resettingEdgeLabelOrientation - boolean
Whether or not to reset the orientation of edge labels. This option sets the resettingEdgeLabelOrientation property on the created object.
- writeBackEdgeLabels - boolean
Whether or not edge label information is written back to the model after core layout. This option sets the writeBackEdgeLabels property on the created object.
- writeBackRelativeEdgeLabelLocation - boolean
Whether or not edge label boxes are interpreted relative to the edge when writing them back to the model. This option sets the writeBackRelativeEdgeLabelLocation property on the created object.
- writeBackNodeLabels - boolean
Whether or not node label information is written back to the model after the core layout. This option sets the writeBackNodeLabels property on the created object.
- writeBackRelativeNodeLabelLocation - boolean
Whether or not node label bounds are interpreted relative to the node when writing them back to the model. This option sets the writeBackRelativeNodeLabelLocation property on the created object.
- translateNodeLabels - boolean
Whether or not node label information is translated. This option sets the translateNodeLabels property on the created object.
- translateEdgeLabels - boolean
Whether or not edge label information is translated. This option sets the translateEdgeLabels property on the created object.
Properties
Gets or sets whether or not this stage should automatically flip edge label content depending on the label's rotation angle.
Remarks
180
degrees without changing the label's center.Default Value
true
.Labels are automatically flipped if they are upside down.
See Also
Sample Graphs
Gets or sets the core layout algorithm that is wrapped by this ILayoutStage.
Gets or sets whether or not to reset the orientation of edge labels.
Remarks
(0,-1)
before adding it to the IDataProvider.Default Value
true
.The orientation of edge labels is reset.
Gets or sets whether or not to reset the orientation of node labels.
Remarks
(0,-1)
before adding it to the IDataProvider.Default Value
false
.The orientation of node labels is kept.
Gets or sets whether or not edge label information is written back to the model after core layout.
Default Value
true
.Edge label information is transferred back to the label model.
Gets or sets whether or not node label information is written back to the model after the core layout.
Default Value
true
.Node label information is transferred back to the label model.
Gets or sets whether or not edge label boxes are interpreted relative to the edge when writing them back to the model.
Default Value
false
.Edge label boxes are interpreted absolute.
Gets or sets whether or not node label bounds are interpreted relative to the node when writing them back to the model.
Default Value
false
.Node label boxes are interpreted absolute.
Methods
Translates traditional ILabelLayout information to IDataProvider-based LabelLayoutData.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph