Search this API

y.layout.orthogonal
Class OrthogonalLayouter

java.lang.Object
  extended by y.layout.CanonicMultiStageLayouter
      extended by y.layout.orthogonal.OrthogonalLayouter
All Implemented Interfaces:
Layouter

public class OrthogonalLayouter
extends CanonicMultiStageLayouter

This class provides a layout algorithm which produces orthogonal drawings.

OrthogonalLayouter can consider edge label data when laying out a graph. That means that the the layout of edge labels will be part of the resulting layout and the layout of nodes and edges is chosen in such a way that the edge labels do not conflict with the rest of the layout. See classes LabelLayoutData, LabelLayoutConstants LabelLayoutKeys and LabelLayoutTranslator on how to setup the integrated edge label layout feature.

Here is an sample output of the layouter using the layout style NORMAL_STYLE.


Field Summary
static byte BOX_STYLE
          Layout style specifier.
static Object EDGE_LAYOUT_DESCRIPTOR_DPKEY
          DataProvider key used to retrieve EdgeLayoutDescriptor instances for each edge in the graph.
static byte FIXED_BOX_STYLE
          Layout style specifier.
static byte FIXED_MIXED_STYLE
          Layout style specifier.
static byte MIXED_STYLE
          Layout style specifier.
static int NODEMODEL_UNCHANGED
          Deprecated. use NORMAL_STYLE instead.
static int NODEMODEL_UNIFORM
          Deprecated. use UNIFORM_STYLE instead.
static byte NORMAL_STYLE
          Layout style specifier.
static byte NORMAL_TREE_STYLE
          Layout style specifier.
static byte UNIFORM_STYLE
          Layout style specifier.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
OrthogonalLayouter()
          Returns a new instance.
 
Method Summary
 boolean canLayoutCore(LayoutGraph graph)
          Returns always true.
protected  EdgeLayoutDescriptor createEdgeLayoutDescriptor()
          Factory method that creates the default EdgeLayoutDescriptor.
 void doLayoutCore(LayoutGraph graph)
          Assigns an orthogonal graph layout to the given layout graph.
 EdgeLayoutDescriptor getEdgeLayoutDescriptor()
          Returns the EdgeLayoutDescriptor instance used for all those edges, that do not have a specific layout descriptor assigned.
 int getGrid()
          Returns the size of the grid on which the nodes and edges are placed.
 int getLayoutStyle()
          Returns the layout style of this layouter.
 int getNodeModel()
          Deprecated. use setLayoutStyle(int) instead.
 boolean getUseCrossingPostprocessing()
          Returns if post-processing is used to reduce the number of crossings.
 boolean getUseFaceMaximization()
          Returns if the layouter should try to maximize one face of the embedding.
 boolean getUseLengthReduction()
          Returns if the algorithm optimizes over the length of the edges.
 boolean getUseRandomization()
          Returns if a randomization strategy is used.
 boolean getUseSketchDrawing()
          Returns if the existing drawing should be used as sketch.
 boolean getUseSpacePostprocessing()
          Deprecated.  
 boolean isConsiderNodeLabelsEnabled()
          Returns whether or not node labels are taken into account when calculating node positions (thereby preventing possible node/node label or node label/node label overlaps).
 boolean isIntegratedEdgeLabelingEnabled()
          Returns whether integrated edge labeling is enabled.
 boolean isPerceivedBendsOptimizationEnabled()
          Returns whether the algorithm should perform a post processing algorithm to reduce perceived bends in the drawing.
 void setConsiderNodeLabelsEnabled(boolean enabled)
          Specifies whether or not to consider node labels when calculating node positions (thereby preventing possible node/node label or node label/node label overlaps).
 void setEdgeLayoutDescriptor(EdgeLayoutDescriptor edgeLayoutDescriptor)
          Sets the EdgeLayoutDescriptor instance used for all those edges, that do not have a specific layout descriptor assigned.
 void setGrid(int value)
          Sets the size of the grid on which the nodes and edges are placed.
 void setIntegratedEdgeLabelingEnabled(boolean enabled)
          Specifies whether or not to use integrated edge labeling.
 void setLayoutStyle(int value)
          Sets the layout style for this layouter.
 void setNodeModel(int value)
          Deprecated. use setLayoutStyle(int) instead.
 void setPerceivedBendsOptimizationEnabled(boolean perceivedBendsOptimizationEnabled)
          Determines whether the algorithm should perform a post processing algorithm to reduce perceived bends in the drawing.
 void setUseCrossingPostprocessing(boolean value)
          Sets if post-processing is used to reduce the number of crossings.
 void setUseFaceMaximization(boolean value)
          Sets if the layouter should try to maximize one face of the embedding.
 void setUseLengthReduction(boolean value)
          Sets if the algorithm optimizes over the length of the edges.
 void setUseRandomization(boolean value)
          Sets if a randomization strategy is used.
 void setUseSketchDrawing(boolean value)
          Sets if the existing drawing should be used as sketch.
 void setUseSpacePostprocessing(boolean value)
          Deprecated.  
 
Methods inherited from class y.layout.CanonicMultiStageLayouter
appendStage, calcLayout, calcLayout, canLayout, checkGroupNodeSize, checkNodeSize, doLayout, doLayout, enableOnlyCore, getComponentLayouter, getGroupNodeHider, getLabelLayouter, getLayoutOrientation, getOrientationLayouter, getParallelEdgeLayouter, getSelfLoopLayouter, getSubgraphLayouter, isComponentLayouterEnabled, isGroupNodeHidingEnabled, isLabelLayouterEnabled, isOrientationLayouterEnabled, isParallelEdgeLayouterEnabled, isSelfLoopLayouterEnabled, isSubgraphLayouterEnabled, prependStage, removeStage, setComponentLayouter, setComponentLayouterEnabled, setGroupNodeHider, setGroupNodeHidingEnabled, setLabelLayouter, setLabelLayouterEnabled, setLayoutOrientation, setOrientationLayouter, setOrientationLayouterEnabled, setParallelEdgeLayouter, setParallelEdgeLayouterEnabled, setSelfLoopLayouter, setSelfLoopLayouterEnabled, setSubgraphLayouter, setSubgraphLayouterEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EDGE_LAYOUT_DESCRIPTOR_DPKEY

public static final Object EDGE_LAYOUT_DESCRIPTOR_DPKEY
DataProvider key used to retrieve EdgeLayoutDescriptor instances for each edge in the graph. Different settings will affect the routing of the edges during the layout. Note: minimum edge length constraints are only considered for layout style NORMAL_STYLE, NORMAL_TREE_STYLE and UNIFORM_STYLE (see setLayoutStyle(int)).

See Also:
setLayoutStyle(int)

NORMAL_STYLE

public static final byte NORMAL_STYLE
Layout style specifier. In this layout style the size of the nodes will not be changed by the algorithm. All edges will be routed orthogonally.

See Also:
Constant Field Values

UNIFORM_STYLE

public static final byte UNIFORM_STYLE
Layout style specifier. In this layout style a uniform size will be assigned to all nodes. All edges will be routed orthogonally.

See Also:
Constant Field Values

BOX_STYLE

public static final byte BOX_STYLE
Layout style specifier. In this layout style the size of the original nodes will be enlarged in order to save some bends. All edges will be routed orthogonally.

See Also:
Constant Field Values

MIXED_STYLE

public static final byte MIXED_STYLE
Layout style specifier. In this layout style not all edges will be routed orthogonally. Edge segments that directly connect to a node may be routed non-vertically and non-horizontally. A small uniform size will be assigned to all nodes.

See Also:
Constant Field Values

NORMAL_TREE_STYLE

public static final byte NORMAL_TREE_STYLE
Layout style specifier. Like NORMAL_STYLE but all directed subtree structures of the graph will be laid out in an optimized way. All edges will be routed orthogonally. The tree edges will be routed in a bus-like fashion.

See Also:
Constant Field Values

FIXED_MIXED_STYLE

public static final byte FIXED_MIXED_STYLE
Layout style specifier. In this layout style not all edges will be routed orthogonally. Edge segments that directly connect to a node may be routed non-vertically and non-horizontally. The size of nodes will not be altered.

See Also:
Constant Field Values

FIXED_BOX_STYLE

public static final byte FIXED_BOX_STYLE
Layout style specifier. Nodes will be placed at the same location as with FIXED_MIXED_STYLE but edges will be routed strictly orthogonally. The size of nodes will not be altered.

See Also:
Constant Field Values

NODEMODEL_UNCHANGED

public static final int NODEMODEL_UNCHANGED
Deprecated. use NORMAL_STYLE instead.
See Also:
Constant Field Values

NODEMODEL_UNIFORM

public static final int NODEMODEL_UNIFORM
Deprecated. use UNIFORM_STYLE instead.
See Also:
Constant Field Values
Constructor Detail

OrthogonalLayouter

public OrthogonalLayouter()
Returns a new instance.

Method Detail

setNodeModel

public void setNodeModel(int value)
Deprecated. use setLayoutStyle(int) instead.


createEdgeLayoutDescriptor

protected EdgeLayoutDescriptor createEdgeLayoutDescriptor()
Factory method that creates the default EdgeLayoutDescriptor. May not return null!

Returns:
a new EdgeLayoutDescriptor (new EdgeLayoutDescriptor())

getEdgeLayoutDescriptor

public EdgeLayoutDescriptor getEdgeLayoutDescriptor()
Returns the EdgeLayoutDescriptor instance used for all those edges, that do not have a specific layout descriptor assigned.

Returns:
the current instance
See Also:
EDGE_LAYOUT_DESCRIPTOR_DPKEY, createEdgeLayoutDescriptor()

setEdgeLayoutDescriptor

public void setEdgeLayoutDescriptor(EdgeLayoutDescriptor edgeLayoutDescriptor)
Sets the EdgeLayoutDescriptor instance used for all those edges, that do not have a specific layout descriptor assigned.

Throws:
NullPointerException - if the argument is null
Parameters:
edgeLayoutDescriptor - the new descriptor
See Also:
EDGE_LAYOUT_DESCRIPTOR_DPKEY

setConsiderNodeLabelsEnabled

public void setConsiderNodeLabelsEnabled(boolean enabled)
Specifies whether or not to consider node labels when calculating node positions (thereby preventing possible node/node label or node label/node label overlaps). This method is a convenience method that assures that the CanonicMultiStageLayouter.getLabelLayouter() label layouter is of type LabelLayoutTranslator and LabelLayoutTranslator.setTranslateNodeLabelsEnabled(boolean) is set to true. Note that setting this option may overwrite the currently set label layouter. Hence, to combine this option with a generic edge labeling algorithm, the generic labeling has to be applied in an additional step after calculating the layout. Furthermore, node labels can only be considered if the layout style is set to NORMAL_STYLE.

Parameters:
enabled - whether to enable this feature

isConsiderNodeLabelsEnabled

public boolean isConsiderNodeLabelsEnabled()
Returns whether or not node labels are taken into account when calculating node positions (thereby preventing possible node/node label or node label/node label overlaps). This method is a convenience method checks whether the label layouter is of type LabelLayoutTranslator and LabelLayoutTranslator.isTranslateNodeLabelsEnabled() returns true.
The default is false.

Throws:
IllegalStateException - if the current label layouter is not of type LabelLayoutTranslator.
Returns:
whether this feature is enabled.

setIntegratedEdgeLabelingEnabled

public void setIntegratedEdgeLabelingEnabled(boolean enabled)
Specifies whether or not to use integrated edge labeling. This method is a convenience method that assures that the label layouter is of type LabelLayoutTranslator and LabelLayoutTranslator.setTranslateEdgeLabelsEnabled(boolean) is set to true
Note: edge labels can only be considered if the layout style is set to NORMAL_STYLE.

Parameters:
enabled - whether to enable this feature

isIntegratedEdgeLabelingEnabled

public boolean isIntegratedEdgeLabelingEnabled()
Returns whether integrated edge labeling is enabled. This method is a convenience method that checks if the label layouter is of type LabelLayoutTranslator and LabelLayoutTranslator.isTranslateEdgeLabelsEnabled() returns true.
The default is false.

Throws:
IllegalStateException - if the current label layouter is not of type LabelLayoutTranslator.
Returns:
whether this feature is enabled.

getNodeModel

public int getNodeModel()
Deprecated. use setLayoutStyle(int) instead.


setUseRandomization

public void setUseRandomization(boolean value)
Sets if a randomization strategy is used. The randomization usually improves the result but it may be disabled to get a deterministic behavior of the algorithm.
Default is true.

Parameters:
value - true if randomization is used, false if randomization is not used.

getUseRandomization

public boolean getUseRandomization()
Returns if a randomization strategy is used. Default is true.

Returns:
true if randomization is used, false if randomization is not used.
See Also:
setUseRandomization(boolean)

setUseFaceMaximization

public void setUseFaceMaximization(boolean value)
Sets if the layouter should try to maximize one face of the embedding. Default is false.

Parameters:
value - true if a face of the embedding should be maximized, false if no face of the embedding should be maximized.
See Also:
getUseFaceMaximization()

getUseFaceMaximization

public boolean getUseFaceMaximization()
Returns if the layouter should try to maximize one face of the embedding. Default is false.

Returns:
true if a face of the embedding should be maximized, false if no face of the embedding should be maximized.
See Also:
setUseFaceMaximization(boolean)

setUseCrossingPostprocessing

public void setUseCrossingPostprocessing(boolean value)
Sets if post-processing is used to reduce the number of crossings. This post-processing may decrease the number of crossings significantly but it may slows down the algorithm, too.
Default is true.

Parameters:
value - true if post-processing is used, false if post-processing is not used.

getUseCrossingPostprocessing

public boolean getUseCrossingPostprocessing()
Returns if post-processing is used to reduce the number of crossings. Default is true.

See Also:
setUseCrossingPostprocessing(boolean)

isPerceivedBendsOptimizationEnabled

public boolean isPerceivedBendsOptimizationEnabled()
Returns whether the algorithm should perform a post processing algorithm to reduce perceived bends in the drawing. The default is true.

Returns:
whether the post processing step is activated

setPerceivedBendsOptimizationEnabled

public void setPerceivedBendsOptimizationEnabled(boolean perceivedBendsOptimizationEnabled)
Determines whether the algorithm should perform a post processing algorithm to reduce perceived bends in the drawing. The default is true.


setGrid

public void setGrid(int value)
Sets the size of the grid on which the nodes and edges are placed.
Default is 20.

Parameters:
value - a positive integer

getGrid

public int getGrid()
Returns the size of the grid on which the nodes and edges are placed.
Default is 20.

Returns:
a positive integer
See Also:
setGrid(int)

setLayoutStyle

public void setLayoutStyle(int value)
Sets the layout style for this layouter. By default the layout style NORMAL_STYLE is set.

Parameters:
value - one of NORMAL_STYLE, UNIFORM_STYLE, BOX_STYLE, MIXED_STYLE, FIXED_BOX_STYLE, FIXED_MIXED_STYLE or NORMAL_TREE_STYLE.

getLayoutStyle

public int getLayoutStyle()
Returns the layout style of this layouter.

See Also:
setLayoutStyle(int)

setUseSpacePostprocessing

public void setUseSpacePostprocessing(boolean value)
Deprecated. 

Sets if post-processing is used to reduce the space used by the drawing. This post-processing may decrease space significantly but it slows the algorithm down.
Default is true.

Parameters:
value - true if post-processing is used, false if post-processing is not used.

getUseSpacePostprocessing

public boolean getUseSpacePostprocessing()
Deprecated. 

Returns if post-processing is used to reduce the space used by the drawing. Default is true.

Returns:
value true if post-processing is used, false if post-processing is not used.
See Also:
setUseSpacePostprocessing(boolean)

setUseLengthReduction

public void setUseLengthReduction(boolean value)
Sets if the algorithm optimizes over the length of the edges. This may decrease the length of some edges significantly but it slows the algorithm down.
Default is true.

Parameters:
value - true if length reduction is used, false if length reduction is not used.

getUseLengthReduction

public boolean getUseLengthReduction()
Returns if the algorithm optimizes over the length of the edges.

Returns:
true if length reduction is used, false if length reduction is not used.
See Also:
setUseLengthReduction(boolean)

getUseSketchDrawing

public boolean getUseSketchDrawing()
Returns if the existing drawing should be used as sketch.

Returns:
true if the existing drawing is used as sketch false otherwise.

setUseSketchDrawing

public void setUseSketchDrawing(boolean value)
Sets if the existing drawing should be used as sketch.

Parameters:
value - true if the existing drawing should be used as sketch false otherwise.

canLayoutCore

public boolean canLayoutCore(LayoutGraph graph)
Returns always true.

Specified by:
canLayoutCore in class CanonicMultiStageLayouter

doLayoutCore

public void doLayoutCore(LayoutGraph graph)
Assigns an orthogonal graph layout to the given layout graph.

Specified by:
doLayoutCore in class CanonicMultiStageLayouter

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