Search this API

y.layout
Class LabelLayoutTranslator

java.lang.Object
  extended by y.layout.LabelLayoutTranslator
All Implemented Interfaces:
Layouter, LayoutStage

public class LabelLayoutTranslator
extends Object
implements LayoutStage

Layout stage that automatically translates label layout information provided by the standard label layout classes EdgeLabelLayout and NodeLabelLayout to layout data of type LabelLayoutData that is accessible by the keys defined in class LabelLayoutKeys.

One can use this layout stage as label layouter of a label aware layouter like HierarchicLayouter. This can be done by assigning the stage by an appropriate call to setLabelLayouter.

Note that care must be taken on the choice of label model that is used by the classes EdgeLabelLayout and NodeLabelLayout. 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 FreeEdgeLabelModel for edge layouts and FreeNodeLabelModel for node layouts.


Field Summary
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
LabelLayoutTranslator()
          Creates a new instance of LabelLayoutTranslator.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          The returned result gets calculated by the core layouter.
 void doLayout(LayoutGraph graph)
          Before invoking the core layouter this stage translates traditional label layout information to data provider based label layout data.
 Layouter getCoreLayouter()
          Returns the core layouter.
 boolean isAutoFlippingEnabled()
          Determines whether or not this stage should automatically flip edge label content depending on the label's rotation angle.
 boolean isResettingEdgeLabelOrientation()
          Returns whether or not to reset the orientation of edge labels.
 boolean isResettingNodeLabelOrientation()
          Returns whether or not to reset the orientation of node labels.
 boolean isTranslateEdgeLabelsEnabled()
          Returns whether edge label translation is enabled.
 boolean isTranslateNodeLabelsEnabled()
          Returns whether node label translation is enabled.
 boolean isWriteBackEdgeLabelsEnabled()
          Returns whether edge labels are written back to their model.
 boolean isWriteBackNodeLabelsEnabled()
          Returns whether node labels are written back to their model.
 void setAutoFlippingEnabled(boolean enabled)
          Specifies whether or not this stage should automatically flip edge label content depending on the label's rotation angle.
 void setCoreLayouter(Layouter core)
          Sets the core layouter.
 void setResettingEdgeLabelOrientation(boolean resettingEdgeLabelOrientation)
          Whether or not to reset the orientation of edge labels.
 void setResettingNodeLabelOrientation(boolean resettingNodeLabelOrientation)
          Whether or not to reset the orientation of node labels.
 void setTranslateEdgeLabelsEnabled(boolean translateEdgeLabelsEnabled)
          Determines whether edge label translation should be enabled.
 void setTranslateNodeLabelsEnabled(boolean translateNodeLabelsEnabled)
          Determines whether node label translation should be enabled.
 void setWriteBackEdgeLabelsEnabled(boolean writeBack)
          Determines whether edge label information is written back to the model.
 void setWriteBackNodeLabelsEnabled(boolean writeBack)
          Determines whether node label information is written back to the model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelLayoutTranslator

public LabelLayoutTranslator()
Creates a new instance of LabelLayoutTranslator. Initially no core layouter will be bound to this layout stage.

Method Detail

setCoreLayouter

public void setCoreLayouter(Layouter core)
Description copied from interface: LayoutStage
Sets the core layouter.

Specified by:
setCoreLayouter in interface LayoutStage

getCoreLayouter

public Layouter getCoreLayouter()
Description copied from interface: LayoutStage
Returns the core layouter.

Specified by:
getCoreLayouter in interface LayoutStage

doLayout

public void doLayout(LayoutGraph graph)
Before invoking the core layouter this stage translates traditional label layout information to data provider based label layout data. Afterwards the calculated layout data will be written back to the original label layout.

Specified by:
doLayout in interface Layouter

isAutoFlippingEnabled

public boolean isAutoFlippingEnabled()
Determines whether or not this stage should automatically flip edge label content depending on the label's rotation angle.

More precisely, if this option is enabled and the up vector of the OrientedRectangle associated with an EdgeLabelLayout (see method LabelLayout.getOrientedBox()) points downward ({OrientedRectangle#getUpY} > 0), this stage automatically flips the label, i.e., it rotates the label by 180 degree without changing the label's center.

By default, this property is set to true.

Returns:
true if this stage automatically flips edge label content depending on the label's rotation angle and false otherwise.
See Also:
LayoutTool.autoFlipBox(y.geom.OrientedRectangle)

setAutoFlippingEnabled

public void setAutoFlippingEnabled(boolean enabled)
Specifies whether or not this stage should automatically flip edge label content depending on the label's rotation angle.

More precisely, if this option is enabled and the up vector of the OrientedRectangle associated with an EdgeLabelLayout (see method LabelLayout.getOrientedBox()) points downward ({OrientedRectangle#getUpY} > 0), this stage automatically flips the label, i.e., it rotates the label by 180 degree without changing the label's center.

By default, this property is set to true.

Parameters:
enabled - if true, this stage will automatically flip edge label content depending on the label's rotation angle.
See Also:
LayoutTool.autoFlipBox(y.geom.OrientedRectangle)

isResettingNodeLabelOrientation

public boolean isResettingNodeLabelOrientation()
Returns whether or not to reset the orientation of node labels. If this option is enabled, the up vector of the corresponding oriented box is set to (0,-1).


setResettingNodeLabelOrientation

public void setResettingNodeLabelOrientation(boolean resettingNodeLabelOrientation)
Whether or not to reset the orientation of node labels. If this option is enabled, the up vector of the corresponding oriented box is set to (0,-1). Default value is false.

Parameters:
resettingNodeLabelOrientation - whether to reset the orientation

isResettingEdgeLabelOrientation

public boolean isResettingEdgeLabelOrientation()
Returns whether or not to reset the orientation of edge labels. If this option is enabled, the up vector of the corresponding oriented box is set to (0,-1).


setResettingEdgeLabelOrientation

public void setResettingEdgeLabelOrientation(boolean resettingEdgeLabelOrientation)
Whether or not to reset the orientation of edge labels. If this option is enabled, the up vector of the corresponding oriented box is set to (0,-1). Default value is true.

Parameters:
resettingEdgeLabelOrientation - whether to reset the orientation

canLayout

public boolean canLayout(LayoutGraph graph)
The returned result gets calculated by the core layouter.

Specified by:
canLayout in interface Layouter

isWriteBackEdgeLabelsEnabled

public boolean isWriteBackEdgeLabelsEnabled()
Returns whether edge labels are written back to their model. Defaults to true.

Returns:
whether this is enabled

setWriteBackEdgeLabelsEnabled

public void setWriteBackEdgeLabelsEnabled(boolean writeBack)
Determines whether edge label information is written back to the model.

Parameters:
writeBack - whether to write back the information

isWriteBackNodeLabelsEnabled

public boolean isWriteBackNodeLabelsEnabled()
Returns whether node labels are written back to their model. Defaults to false.

Returns:
whether this is enabled

setWriteBackNodeLabelsEnabled

public void setWriteBackNodeLabelsEnabled(boolean writeBack)
Determines whether node label information is written back to the model.

Parameters:
writeBack - whether to write back the information

isTranslateNodeLabelsEnabled

public boolean isTranslateNodeLabelsEnabled()
Returns whether node label translation is enabled. Defaults to false.

Returns:
whether this is enabled

setTranslateNodeLabelsEnabled

public void setTranslateNodeLabelsEnabled(boolean translateNodeLabelsEnabled)
Determines whether node label translation should be enabled.

Parameters:
translateNodeLabelsEnabled - whether to enable the translation for node labels

isTranslateEdgeLabelsEnabled

public boolean isTranslateEdgeLabelsEnabled()
Returns whether edge label translation is enabled. Defaults to true.

Returns:
whether this is enabled

setTranslateEdgeLabelsEnabled

public void setTranslateEdgeLabelsEnabled(boolean translateEdgeLabelsEnabled)
Determines whether edge label translation should be enabled.

Parameters:
translateEdgeLabelsEnabled - whether to enable the translation for edge labels

© Copyright 2000-2013,
yWorks GmbH.
All rights reserved.