y.layout
Class ComponentLayouter

java.lang.Object
  |
  +--y.layout.AbstractLayoutStage
        |
        +--y.layout.ComponentLayouter
All Implemented Interfaces:
Layouter, LayoutStage
Direct Known Subclasses:
IsolatedGroupComponentLayouter

public class ComponentLayouter
extends AbstractLayoutStage

This layout stage arranges the connected components of a graph.

It is possible to specify a core layout algorithm that will be invoked on all connected components of the graph before this layouter arranges the components themselves.

ComponentLayouter will handle hierrchically grouped graphs in a special way. The contents of a group node will always belong to the same component as the group node itself.


Field Summary
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
ComponentLayouter()
          Instantiates a ComponentLayouter.
ComponentLayouter(Layouter coreLayouter)
          Instantiates a ComponentLayouter.
 
Method Summary
protected  void arrangeComponentGraphs(LayoutGraph graph, NodeList[] nl, EdgeList[] el, YRectangle[] rl, boolean horizontal)
          Produces a non-overlapping component graph layout.
 boolean canLayout(LayoutGraph graph)
          Determines if the preconditions for the graph layout algorithm are fullfilled, by applying them to the connected components.
 void doLayout(LayoutGraph graph)
          Calculate the layout.
protected  int findGraphComponents(LayoutGraph graph, NodeMap compNumber)
          Determines which nodes will belong to the same graph component.
 double getComponentSpacing()
          Getter for property componentSpacing.
 double getGridSpacing()
          Getter for property gridSpacing.
 boolean isGroupingActive()
          Returns whether grouping information bound to the graph will be used to calculate the components.
 void setComponentSpacing(double componentSpacing)
          Setter for property componentSpacing.
 void setGridSpacing(double gridSpacing)
          Setter for property gridSpacing.
 void setGroupingActive(boolean groupingActive)
          Determines whether grouping information bound to the graph should be used to determine the connectedness of the graph structure.
protected  void setOrigin(LayoutGraph graph, NodeList nl, EdgeList el, YPoint org, YRectangle r)
          Sets the origin for a subgraph.
 void setPreferredLayoutSize(double width, double height)
          Sets the preferred layout size for this layouter.
 
Methods inherited from class y.layout.AbstractLayoutStage
canLayoutCore, doLayoutCore, getCoreLayouter, setCoreLayouter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentLayouter

public ComponentLayouter(Layouter coreLayouter)
Instantiates a ComponentLayouter. Sets the layouter which is invoked for the connected components.


ComponentLayouter

public ComponentLayouter()
Instantiates a ComponentLayouter.

Method Detail

setPreferredLayoutSize

public void setPreferredLayoutSize(double width,
                                   double height)
Sets the preferred layout size for this layouter.


canLayout

public boolean canLayout(LayoutGraph graph)
Determines if the preconditions for the graph layout algorithm are fullfilled, by applying them to the connected components.


findGraphComponents

protected int findGraphComponents(LayoutGraph graph,
                                  NodeMap compNumber)
Determines which nodes will belong to the same graph component. Additionally to normal connectedness a group node and all of its children will belong to the same component.

Parameters:
graph - the input graph
compNumber - return value that will hold the zero-based number of the component that it belongs to. The component number of Node v is compNum.getInt().
Returns:
the number of connected components of this graph.

doLayout

public void doLayout(LayoutGraph graph)
Calculate the layout. This is done by decomposing the Graph in its connected components and applying the layout algorithm on them.


arrangeComponentGraphs

protected void arrangeComponentGraphs(LayoutGraph graph,
                                      NodeList[] nl,
                                      EdgeList[] el,
                                      YRectangle[] rl,
                                      boolean horizontal)
Produces a non-overlapping component graph layout. This method moves the given graphs in such a fashion that their bounding boxes do not overlap. The arrangement strategy used is simply from left to right along an upper horizontal line with x-coordinate 0. Thus after merging the components the resulting graph has a bounding box with upper left coordinate (0,0).

Subclasses may want to overwrite this method.


setOrigin

protected void setOrigin(LayoutGraph graph,
                         NodeList nl,
                         EdgeList el,
                         YPoint org,
                         YRectangle r)
Sets the origin for a subgraph.


getGridSpacing

public double getGridSpacing()
Getter for property gridSpacing. If this value is set to a value greater than 0, components will be moved by multiples of this value. This assures, that laid out subcomponents, which adhere to a known grid, will stay on their grid.

Returns:
Value of property gridSpacing.

setGridSpacing

public void setGridSpacing(double gridSpacing)
Setter for property gridSpacing. If this value is set to a value greater than 0, components will be moved by multiples of this value. This assures, that laid out subcomponents, which adhere to a known grid, will stay on their grid.

Parameters:
gridSpacing - New value of property gridSpacing.

getComponentSpacing

public double getComponentSpacing()
Getter for property componentSpacing. This value represents the minimum allowed distance between the boundingboxes of to components.

Returns:
Value of property componentSpacing.

setComponentSpacing

public void setComponentSpacing(double componentSpacing)
Setter for property componentSpacing. This value represents the minimum allowed distance between the boundingboxes of to components.

Parameters:
componentSpacing - New value of property componentSpacing.

isGroupingActive

public boolean isGroupingActive()
Returns whether grouping information bound to the graph will be used to calculate the components. Default is true.


setGroupingActive

public void setGroupingActive(boolean groupingActive)
Determines whether grouping information bound to the graph should be used to determine the connectedness of the graph structure.


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

2003