public class LabelLayoutTranslator extends Object implements ILayoutStage
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.
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 WritingBackRelativeNodeLabelLocationEnabled
and/or WritingBackRelativeEdgeLabelLocationEnabled 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.
| Constructor and Description |
|---|
LabelLayoutTranslator()
Creates a new
LabelLayoutTranslator instance with default settings. |
| Modifier and Type | Method and Description |
|---|---|
void |
applyLayout(LayoutGraph graph)
|
ILayoutAlgorithm |
getCoreLayout()
Gets the core layout algorithm that is wrapped by this
ILayoutStage. |
boolean |
isAutoFlippingEnabled()
Gets whether or not this stage should automatically flip edge label content depending on the label's rotation angle.
|
boolean |
isEdgeLabelOrientationResetEnabled()
Gets whether or not to reset the orientation of edge labels.
|
boolean |
isEdgeLabelTranslationEnabled()
Gets whether or not edge label information is translated.
|
boolean |
isNodeLabelOrientationResetEnabled()
Gets whether or not to reset the orientation of node labels.
|
boolean |
isNodeLabelTranslationEnabled()
Gets whether or not node label information is translated.
|
boolean |
isWritingBackEdgeLabelsEnabled()
Gets whether or not edge label information is written back to the model after core layout.
|
boolean |
isWritingBackNodeLabelsEnabled()
Gets whether or not node label information is written back to the model after the core layout.
|
boolean |
isWritingBackRelativeEdgeLabelLocationEnabled()
Gets whether or not edge label
boxes are interpreted relative to the edge when
writing them back to the model. |
boolean |
isWritingBackRelativeNodeLabelLocationEnabled()
Gets whether or not node label
bounds are interpreted relative to the node when
writing them back to the model. |
void |
setAutoFlippingEnabled(boolean value)
Sets whether or not this stage should automatically flip edge label content depending on the label's rotation angle.
|
void |
setCoreLayout(ILayoutAlgorithm value)
Sets the core layout algorithm that is wrapped by this
ILayoutStage. |
void |
setEdgeLabelOrientationResetEnabled(boolean value)
Sets whether or not to reset the orientation of edge labels.
|
void |
setEdgeLabelTranslationEnabled(boolean value)
Sets whether or not edge label information is translated.
|
void |
setNodeLabelOrientationResetEnabled(boolean value)
Sets whether or not to reset the orientation of node labels.
|
void |
setNodeLabelTranslationEnabled(boolean value)
Sets whether or not node label information is translated.
|
void |
setWritingBackEdgeLabelsEnabled(boolean value)
Sets whether or not edge label information is written back to the model after core layout.
|
void |
setWritingBackNodeLabelsEnabled(boolean value)
Sets whether or not node label information is written back to the model after the core layout.
|
void |
setWritingBackRelativeEdgeLabelLocationEnabled(boolean value)
Sets whether or not edge label
boxes are interpreted relative to the edge when
writing them back to the model. |
void |
setWritingBackRelativeNodeLabelLocationEnabled(boolean value)
Sets whether or not node label
bounds are interpreted relative to the node when
writing them back to the model. |
public LabelLayoutTranslator()
LabelLayoutTranslator instance with default settings.public void applyLayout(LayoutGraph graph)
ILabelLayout information to IDataProvider-based
LabelLayoutData.
Afterwards, the calculated layout data will be written back to the original label layout.
applyLayout in interface ILayoutAlgorithmgraph - the input graphpublic ILayoutAlgorithm getCoreLayout()
ILayoutStage.getCoreLayout in interface ILayoutStagenull. setCoreLayout(ILayoutAlgorithm)public boolean isAutoFlippingEnabled()
More precisely, if this option is enabled and the up vector of the YOrientedRectangle associated with an IEdgeLabelLayout
points downwards (upY > 0), this ILayoutStage automatically flips the label.
It rotates the label by 180 degrees without changing the label's center.
true. Labels are automatically flipped if they are upside down.true if this ILayoutStage automatically flips edge label content depending on the label's rotation
angle, false otherwiseLayoutGraphUtilities.autoFlipBox(YOrientedRectangle),
ILabelLayout.getOrientedBox(),
setAutoFlippingEnabled(boolean)public boolean isEdgeLabelOrientationResetEnabled()
If this option is enabled, the up vector of the corresponding oriented box is set to (0,-1) before adding it to
the IDataProvider.
LabelLayoutTranslator should not reset their orientation. When
it performs integrated edge labeling, this option should be enabled.true. The orientation of edge labels is reset.true if the orientation of edge labels is reset, false otherwisesetEdgeLabelOrientationResetEnabled(boolean)public boolean isEdgeLabelTranslationEnabled()
false. The label information is not translated for edge labels.true if edge label information is translated, false otherwisesetEdgeLabelTranslationEnabled(boolean)public boolean isNodeLabelOrientationResetEnabled()
If this option is enabled, the up vector of the corresponding oriented box is set to (0,-1) before adding it to
the IDataProvider.
LabelLayoutTranslator should not reset their orientation. When
it performs integrated node labeling, this option should be enabled.false. The orientation of node labels is kept.true if the orientation of node labels is reset, false otherwisesetNodeLabelOrientationResetEnabled(boolean)public boolean isNodeLabelTranslationEnabled()
false. The label information is not translated for node labels.true if node label information is translated, false otherwisesetNodeLabelTranslationEnabled(boolean)public boolean isWritingBackEdgeLabelsEnabled()
core layout algorithm performs integrated edge
labeling.true. Edge label information is transferred back to the label model.true if edge label information is written back, false otherwisesetWritingBackEdgeLabelsEnabled(boolean)public boolean isWritingBackNodeLabelsEnabled()
core layout algorithm performs integrated node
labeling.true. Node label information is transferred back to the label model.true if node label information is written back, false otherwisesetWritingBackNodeLabelsEnabled(boolean)public boolean isWritingBackRelativeEdgeLabelLocationEnabled()
boxes are interpreted relative to the edge when
writing them back to the model.WritingBackEdgeLabelsEnabled is
enabled.false. Edge label boxes are interpreted absolute.true if the bounds are interpreted relative, false for absolute interpretationsetWritingBackRelativeEdgeLabelLocationEnabled(boolean)public boolean isWritingBackRelativeNodeLabelLocationEnabled()
bounds are interpreted relative to the node when
writing them back to the model.WritingBackNodeLabelsEnabled is
enabled.false. Node label boxes are interpreted absolute.true if the bounds are interpreted relative, false for absolute interpretationsetWritingBackRelativeNodeLabelLocationEnabled(boolean)public void setAutoFlippingEnabled(boolean value)
More precisely, if this option is enabled and the up vector of the YOrientedRectangle associated with an IEdgeLabelLayout
points downwards (upY > 0), this ILayoutStage automatically flips the label.
It rotates the label by 180 degrees without changing the label's center.
true. Labels are automatically flipped if they are upside down.value - true if this ILayoutStage automatically flips edge label content depending on the label's rotation
angle, false otherwiseLayoutGraphUtilities.autoFlipBox(YOrientedRectangle),
ILabelLayout.getOrientedBox(),
isAutoFlippingEnabled()public void setCoreLayout(ILayoutAlgorithm value)
ILayoutStage.setCoreLayout in interface ILayoutStagenull. value - the core layout routinegetCoreLayout()public void setEdgeLabelOrientationResetEnabled(boolean value)
If this option is enabled, the up vector of the corresponding oriented box is set to (0,-1) before adding it to
the IDataProvider.
LabelLayoutTranslator should not reset their orientation. When
it performs integrated edge labeling, this option should be enabled.true. The orientation of edge labels is reset.value - true if the orientation of edge labels is reset, false otherwiseisEdgeLabelOrientationResetEnabled()public void setEdgeLabelTranslationEnabled(boolean value)
false. The label information is not translated for edge labels.value - true if edge label information is translated, false otherwiseisEdgeLabelTranslationEnabled()public void setNodeLabelOrientationResetEnabled(boolean value)
If this option is enabled, the up vector of the corresponding oriented box is set to (0,-1) before adding it to
the IDataProvider.
LabelLayoutTranslator should not reset their orientation. When
it performs integrated node labeling, this option should be enabled.false. The orientation of node labels is kept.value - true if the orientation of node labels is reset, false otherwiseisNodeLabelOrientationResetEnabled()public void setNodeLabelTranslationEnabled(boolean value)
false. The label information is not translated for node labels.value - true if node label information is translated, false otherwiseisNodeLabelTranslationEnabled()public void setWritingBackEdgeLabelsEnabled(boolean value)
core layout algorithm performs integrated edge
labeling.true. Edge label information is transferred back to the label model.value - true if edge label information is written back, false otherwiseisWritingBackEdgeLabelsEnabled()public void setWritingBackNodeLabelsEnabled(boolean value)
core layout algorithm performs integrated node
labeling.true. Node label information is transferred back to the label model.value - true if node label information is written back, false otherwiseisWritingBackNodeLabelsEnabled()public void setWritingBackRelativeEdgeLabelLocationEnabled(boolean value)
boxes are interpreted relative to the edge when
writing them back to the model.WritingBackEdgeLabelsEnabled is
enabled.false. Edge label boxes are interpreted absolute.value - true if the bounds are interpreted relative, false for absolute interpretationisWritingBackRelativeEdgeLabelLocationEnabled()public void setWritingBackRelativeNodeLabelLocationEnabled(boolean value)
bounds are interpreted relative to the node when
writing them back to the model.WritingBackNodeLabelsEnabled is
enabled.false. Node label boxes are interpreted absolute.value - true if the bounds are interpreted relative, false for absolute interpretationisWritingBackRelativeNodeLabelLocationEnabled()