Search this API

y.layout
Class CanonicMultiStageLayouter

java.lang.Object
  extended by y.layout.CanonicMultiStageLayouter
All Implemented Interfaces:
Layouter
Direct Known Subclasses:
ARTreeLayouter, BalloonLayouter, CircularLayouter, DirectedOrthogonalLayouter, FamilyTreeLayouter, GenericTreeLayouter, GraphTransformer, GRIP, HierarchicLayouter, HierarchicLayouter, HVTreeLayouter, IncrementalHierarchicLayouter, OrganicLayouter, OrthogonalGroupLayouter, OrthogonalLayouter, RandomLayouter, SingleCycleLayouter, SmartOrganicLayouter, TreeLayouter

public abstract class CanonicMultiStageLayouter
extends Object
implements Layouter

An abstract base class for layout algorithms that provides services to simplify and decompose the input graph before it is passed to the core layout routine itself.

Subclass layout algorithms have to provide implementations for the abstract methods
doLayoutCore(LayoutGraph)
and
canLayoutCore(LayoutGraph) The maximal number of steps involved before and after the core layout will be invoked are summarized below.

  1. Copy the input graph
  2. Hide all but the induced subgraph
  3. Decompose the graph into it's connected components. On each component perform the steps 3-11
  4. Prepare for an orientation change
  5. Hide parallel edges
  6. Hide self-loops
  7. Invoke core layouter on simplified graph
  8. Unhide and route self-loops
  9. Unhide and route parallel edges
  10. Complete orientation change of layout
  11. Arrange connected components of the graph
  12. Unhide non-induced subgraph
  13. Assign label positions
  14. Copy layout information back to original input graph or pass out layout information separately
Each of the phases above can be subdued if necessary.


Field Summary
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
CanonicMultiStageLayouter()
          Constructs a new AbstractLayouter
 
Method Summary
 void appendStage(LayoutStage stage)
          Appends a stage to the layout pipeline.
 GraphLayout calcLayout(GraphInterface graph, GraphLayout layout)
          Returns a layout for the given graph interface and layout.
 GraphLayout calcLayout(LayoutGraph layoutGraph)
          Returns a layout for the given layout graph.
 boolean canLayout(LayoutGraph graph)
          Tests whether or not the given graph can be laid out by this layouter.
protected abstract  boolean canLayoutCore(LayoutGraph graph)
          Subclasses have to provide information whether or not they can layout the given graph.
protected  void checkGroupNodeSize(GraphLayout layout, Object node)
          This method throws an IllegalArgumentException if the width/height of the given group node object is zero.
protected  void checkNodeSize(GraphLayout layout, Object node)
          This method throws an IllegalArgumentException if the width/height of the given node object is zero.
 void doLayout(GraphInterface graph, GraphLayout layout)
          Calculates a layout for the given graph interface and layout.
 void doLayout(LayoutGraph layoutGraph)
          Calculates a layout for the given graph.
protected abstract  void doLayoutCore(LayoutGraph graph)
          Subclasses have to provide core layout code in this method.
 void enableOnlyCore()
          Disables all layout stages and performs only the core layouter.
 LayoutStage getComponentLayouter()
          Returns the LayoutStage responsible for laying out the connected components of the graph.
 LayoutStage getGroupNodeHider()
          Returns the LayoutStage that is responsible for hiding away grouping information for the layout algorithm.
 LayoutStage getLabelLayouter()
          Returns the algorithm used for placing labels.
 byte getLayoutOrientation()
          Returns the main layout orientation.
 LayoutStage getOrientationLayouter()
          Returns the LayoutStage that is responsible for changing the orientation of the computed layout.
 LayoutStage getParallelEdgeLayouter()
          Returns the LayoutStage responsible for routing parallel edges.
 LayoutStage getSelfLoopLayouter()
          Returns the LayoutStage used for routing Self-loops.
 LayoutStage getSubgraphLayouter()
          Returns the LayoutStage that is responsible for constraining the layout process to a subgraph of the target graph.
 boolean isComponentLayouterEnabled()
          Returns whether or not ComponentLayouter is enabled.
 boolean isGroupNodeHidingEnabled()
          Returns whether or not to hide away group nodes before the layout begins.
 boolean isLabelLayouterEnabled()
          Returns whether or not LabelLayouter is enabled.
 boolean isOrientationLayouterEnabled()
          Returns whether or not the OrientationLayouter is enabled.
 boolean isParallelEdgeLayouterEnabled()
          Returns whether or not the ParallelEdgeLayouter is enabled.
 boolean isSelfLoopLayouterEnabled()
          Returns whether or not the SelfLoopLayouter is enabled.
 boolean isSubgraphLayouterEnabled()
          Returns whether or not the SubgraphLayouter is enabled.
 void prependStage(LayoutStage stage)
          Prepends a stage to the layout pipeline.
 void removeStage(LayoutStage stage)
          Removes a LayoutStage that has been previously added by the methods appendStage(LayoutStage) or prependStage(LayoutStage).
 void setComponentLayouter(LayoutStage layouter)
          Sets the LayoutStage responsible for laying out the connected components of the graph.
 void setComponentLayouterEnabled(boolean enabled)
          Specifies whether or not to enable the ComponentLayouter.
 void setGroupNodeHider(LayoutStage layouter)
          Sets the LayoutStage that is responsible for hiding away grouping information for the layout algorithm.
 void setGroupNodeHidingEnabled(boolean groupNodeHidingEnabled)
          Specifies whether or not to hide away group nodes before the layout begins.
 void setLabelLayouter(LayoutStage labeler)
          Sets the algorithm used for placing labels.
 void setLabelLayouterEnabled(boolean enabled)
          Specifies whether or not to enable the labeling algorithm.
 void setLayoutOrientation(byte orientation)
          Sets the main layout orientation.
 void setOrientationLayouter(LayoutStage layouter)
          Sets the LayoutStage that is responsible for changing the orientation of the computed layout.
 void setOrientationLayouterEnabled(boolean enabled)
          Specifies whether or not to enable the OrientationLayouter.
 void setParallelEdgeLayouter(LayoutStage layouter)
          Sets the ParallelEdgeLayouter responsible for routing parallel edges.
 void setParallelEdgeLayouterEnabled(boolean enabled)
          Specifies whether or not to enable the ParallelEdgeLayouter.
 void setSelfLoopLayouter(LayoutStage layouter)
          Sets the LayoutStage responsible for routing Self-loops.
 void setSelfLoopLayouterEnabled(boolean enabled)
          Specifies whether or not to enable the SelfLoopLayouter.
 void setSubgraphLayouter(LayoutStage layouter)
          Sets the LayoutStage that is responsible for constraining the layout process to a subgraph of the target graph.
 void setSubgraphLayouterEnabled(boolean enabled)
          Specifies whether or not to enable the SubgraphLayouter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CanonicMultiStageLayouter

public CanonicMultiStageLayouter()
Constructs a new AbstractLayouter

Method Detail

doLayoutCore

protected abstract void doLayoutCore(LayoutGraph graph)
Subclasses have to provide core layout code in this method.


canLayoutCore

protected abstract boolean canLayoutCore(LayoutGraph graph)
Subclasses have to provide information whether or not they can layout the given graph.


checkNodeSize

protected void checkNodeSize(GraphLayout layout,
                             Object node)
                      throws IllegalArgumentException
This method throws an IllegalArgumentException if the width/height of the given node object is zero. It is called by the doLayout(LayoutGraph) method for each node object in the input graph.

Throws:
IllegalArgumentException - thrown if the width/height of the node object is zero.
Parameters:
layout - a graph layout object.
node - the node object to test.
See Also:
checkGroupNodeSize(GraphLayout,Object)

checkGroupNodeSize

protected void checkGroupNodeSize(GraphLayout layout,
                                  Object node)
                           throws IllegalArgumentException
This method throws an IllegalArgumentException if the width/height of the given group node object is zero. It is called by the doLayout(LayoutGraph) method for each group node object in the input graph.

Throws:
IllegalArgumentException - thrown if the width/height of the group node object is zero.
Parameters:
layout - a graph layout object.
node - the group node object to test.
See Also:
checkNodeSize(GraphLayout,Object)

prependStage

public void prependStage(LayoutStage stage)
Prepends a stage to the layout pipeline. Stage added with this method will be invoked before any other stages will be invoked.


appendStage

public void appendStage(LayoutStage stage)
Appends a stage to the layout pipeline. Stages added with this method will be invoked just before the core layouter will be invoked.


removeStage

public void removeStage(LayoutStage stage)
Removes a LayoutStage that has been previously added by the methods appendStage(LayoutStage) or prependStage(LayoutStage).


getLabelLayouter

public LayoutStage getLabelLayouter()
Returns the algorithm used for placing labels. By default an instance of class GreedyMISLabeling will be returned.


setLabelLayouter

public void setLabelLayouter(LayoutStage labeler)
Sets the algorithm used for placing labels. Note that assigning a new layout stage will not automatically activate it. To activate this stage use setLabelLayouterEnabled(boolean).


getSelfLoopLayouter

public LayoutStage getSelfLoopLayouter()
Returns the LayoutStage used for routing Self-loops. By default an instance of class SelfLoopLayouter will be returned.


setSelfLoopLayouter

public void setSelfLoopLayouter(LayoutStage layouter)
Sets the LayoutStage responsible for routing Self-loops.


getParallelEdgeLayouter

public LayoutStage getParallelEdgeLayouter()
Returns the LayoutStage responsible for routing parallel edges. By default an instance of class ParallelEdgeLayouter will be returned.


setParallelEdgeLayouter

public void setParallelEdgeLayouter(LayoutStage layouter)
Sets the ParallelEdgeLayouter responsible for routing parallel edges.


getComponentLayouter

public LayoutStage getComponentLayouter()
Returns the LayoutStage responsible for laying out the connected components of the graph.


setComponentLayouter

public void setComponentLayouter(LayoutStage layouter)
Sets the LayoutStage responsible for laying out the connected components of the graph.


getSubgraphLayouter

public LayoutStage getSubgraphLayouter()
Returns the LayoutStage that is responsible for constraining the layout process to a subgraph of the target graph.


setSubgraphLayouter

public void setSubgraphLayouter(LayoutStage layouter)
Sets the LayoutStage that is responsible for constraining the layout process to a subgraph of the target graph.


getGroupNodeHider

public LayoutStage getGroupNodeHider()
Returns the LayoutStage that is responsible for hiding away grouping information for the layout algorithm.


setGroupNodeHider

public void setGroupNodeHider(LayoutStage layouter)
Sets the LayoutStage that is responsible for hiding away grouping information for the layout algorithm.


getOrientationLayouter

public LayoutStage getOrientationLayouter()
Returns the LayoutStage that is responsible for changing the orientation of the computed layout.


setOrientationLayouter

public void setOrientationLayouter(LayoutStage layouter)
Sets the LayoutStage that is responsible for changing the orientation of the computed layout.


setOrientationLayouterEnabled

public void setOrientationLayouterEnabled(boolean enabled)
Specifies whether or not to enable the OrientationLayouter. By default it is activated but does not change orientation of the layout.


setLayoutOrientation

public void setLayoutOrientation(byte orientation)
Sets the main layout orientation. The layouter tries to arrange nodes in such a way that all edges point in the main layout direction.

Note, the documentation for the other layout options assumes that the default layout orientation LayoutOrientation.TOP_TO_BOTTOM is being used.

Parameters:
orientation - one of LayoutOrientation.BOTTOM_TO_TOP, LayoutOrientation.LEFT_TO_RIGHT, LayoutOrientation.TOP_TO_BOTTOM or LayoutOrientation.RIGHT_TO_LEFT.
See Also:
getLayoutOrientation()

getLayoutOrientation

public byte getLayoutOrientation()
Returns the main layout orientation.

See Also:
setLayoutOrientation(byte)

isOrientationLayouterEnabled

public boolean isOrientationLayouterEnabled()
Returns whether or not the OrientationLayouter is enabled.


setSelfLoopLayouterEnabled

public void setSelfLoopLayouterEnabled(boolean enabled)
Specifies whether or not to enable the SelfLoopLayouter. By default it is enabled.


isSelfLoopLayouterEnabled

public boolean isSelfLoopLayouterEnabled()
Returns whether or not the SelfLoopLayouter is enabled.


setLabelLayouterEnabled

public void setLabelLayouterEnabled(boolean enabled)
Specifies whether or not to enable the labeling algorithm. By default it is disabled.


isLabelLayouterEnabled

public boolean isLabelLayouterEnabled()
Returns whether or not LabelLayouter is enabled.


isGroupNodeHidingEnabled

public boolean isGroupNodeHidingEnabled()
Returns whether or not to hide away group nodes before the layout begins. By default this is enabled for instances that cannot deal with node groupings.


setGroupNodeHidingEnabled

public void setGroupNodeHidingEnabled(boolean groupNodeHidingEnabled)
Specifies whether or not to hide away group nodes before the layout begins.


setComponentLayouterEnabled

public void setComponentLayouterEnabled(boolean enabled)
Specifies whether or not to enable the ComponentLayouter. By default it is enabled.


isComponentLayouterEnabled

public boolean isComponentLayouterEnabled()
Returns whether or not ComponentLayouter is enabled.


setParallelEdgeLayouterEnabled

public void setParallelEdgeLayouterEnabled(boolean enabled)
Specifies whether or not to enable the ParallelEdgeLayouter. By default it is enabled.


isParallelEdgeLayouterEnabled

public boolean isParallelEdgeLayouterEnabled()
Returns whether or not the ParallelEdgeLayouter is enabled.


setSubgraphLayouterEnabled

public void setSubgraphLayouterEnabled(boolean enabled)
Specifies whether or not to enable the SubgraphLayouter. By default it is disabled.


isSubgraphLayouterEnabled

public boolean isSubgraphLayouterEnabled()
Returns whether or not the SubgraphLayouter is enabled.


enableOnlyCore

public void enableOnlyCore()
Disables all layout stages and performs only the core layouter.


doLayout

public void doLayout(LayoutGraph layoutGraph)
Calculates a layout for the given graph. The given graph will not be copied during the layout process and the layout will be immediately applied to the given graph. This method is not side effect free in the sense that the order of edges or nodes in the input graph may change during the layout process.

Specified by:
doLayout in interface Layouter

doLayout

public void doLayout(GraphInterface graph,
                     GraphLayout layout)
Calculates a layout for the given graph interface and layout. The calculated layout will be written back to the given layout.


calcLayout

public GraphLayout calcLayout(LayoutGraph layoutGraph)
Returns a layout for the given layout graph. The given graph will not be modified by the layout process.


calcLayout

public GraphLayout calcLayout(GraphInterface graph,
                              GraphLayout layout)
Returns a layout for the given graph interface and layout. The given graph and layout will not be modified by the layout process.


canLayout

public boolean canLayout(LayoutGraph graph)
Tests whether or not the given graph can be laid out by this layouter. All stage layouters and the core layouter must be able to calculate the layout to make this test successful.

Specified by:
canLayout in interface Layouter

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