Search this API

y.layout
Class ComponentLayouter

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.ComponentLayouter
All Implemented Interfaces:
Layouter, LayoutStage
Direct Known Subclasses:
IsolatedGroupComponentLayouter

public class ComponentLayouter
extends AbstractLayoutStage

A ComponentLayouter arranges the connected components of a graph.

Layout Style

The components can be arranged using different styles. All styles except STYLE_NONE place the components without overlaps.


Layout with orthogonal components using STYLE_MULTI_ROWS_COMPACT

Concept

ComponentLayouter is a LayoutStage that can wrap another layout algorithm. That way, it allows handling disconnected graphs for the wrapped core layout algorithm.

The following steps outline the concept of ComponentLayouter:

  1. Determine the connected components of the graph
  2. Hide all graph components
  3. Apply the following steps to each component separately
    1. Unhide the component
    2. Apply the core layout algorithm to the component
    3. Hide the component
  4. Unhide all graph components
  5. Optionally arrange the components

Features

To arrange the subgraphs of the components, ComponentLayouter uses the specified core layout algorithm. If there is no core layout algorithm specified, it will keep the locations in the subgraph and arrange the components as they are.

Hierarchically grouped graphs are handled in a special way. The contents of a group node will always belong to the same component as the group node itself. To change that behavior grouping can be disabled.

By default, the components consist of the connected nodes in a graph. To choose custom subgraphs to form components, register a DataProvider with GIVEN_COMPONENT_ID_DPKEY and assign component IDs to the nodes.

When arranging components, node types (see Layouter.NODE_TYPE_DPKEY) can be considered. If all nodes of a component have the same node type, the component is considered to be of that type. Components with same type are preferably put next to each other. Note, however, that only the styles STYLE_ROWS, STYLE_SINGLE_ROW, STYLE_SINGLE_COLUMN and STYLE_MULTI_ROWS_TYPE_SEPARATED handle types such that an ordering by type is realized. Other styles aim at more important optimization criteria (e.g. compactness) such that components of the same type are not guaranteed to be close to each other.

See Also:
CanonicMultiStageLayouter
 

Field Summary
static java.lang.Object GIVEN_COMPONENT_ID_DPKEY
          A DataProvider key for specifying custom graph components
static java.lang.Object LAYOUT_NODE_DPKEY
          A DataProvider key for specifying which nodes should be arranged If no DataProvider is registered with this key, all components will be laid out by the core layout algorithm.
static byte STYLE_MASK
          A constant for masking actual style constants from style modifiers.
static byte STYLE_MODIFIER_AS_IS
          A modifier that can be added to normal style specifiers to indicate that the arrangement strategy should take the initial positions of the components into account.
static byte STYLE_MODIFIER_NO_OVERLAP
          A modifier that can be added to normal style specifiers to indicate that the arrangement strategy should produce a non-overlapping component layout.
static byte STYLE_MULTI_ROWS
          Style specifier describing a component arrangement strategy that places components in multiple rows.
static byte STYLE_MULTI_ROWS_COMPACT
          Style specifier describing a component arrangement strategy that places components in multiple rows.
static byte STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED
          Style specifier describing a component arrangement strategy that places the components in STYLE_MULTI_ROWS with a restricted height.
static byte STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED_COMPACT
          Style specifier describing a component arrangement strategy that places the components in STYLE_MULTI_ROWS with a restricted height and as compact as possible.
static byte STYLE_MULTI_ROWS_TYPE_SEPARATED
          Style specifier describing a component arrangement strategy that places the components in multiple nested rows, like STYLE_MULTI_ROWS, but separates components of different node type.
static byte STYLE_MULTI_ROWS_WIDTH_CONSTRAINED
          Style specifier describing a component arrangement strategy that places the components in STYLE_MULTI_ROWS with a restricted width.
static byte STYLE_MULTI_ROWS_WIDTH_CONSTRAINED_COMPACT
          Style specifier describing a component arrangement strategy that places the components in STYLE_MULTI_ROWS with a restricted width and as compact as possible.
static byte STYLE_NONE
          Style specifier describing no special component arrangement at all.
static byte STYLE_PACKED_CIRCLE
          Style specifier describing a component arrangement strategy that places components in a circular cloud around the biggest component.
static byte STYLE_PACKED_COMPACT_CIRCLE
          Style specifier describing a component arrangement strategy that places components in a circular compact cloud around the biggest component.
static byte STYLE_PACKED_COMPACT_RECTANGLE
          Style specifier describing a component arrangement strategy that places components in a rectangular cloud around the biggest component.
static byte STYLE_PACKED_RECTANGLE
          Style specifier describing a component arrangement strategy that places components in a rectangular cloud around the biggest component.
static byte STYLE_ROWS
          Style specifier describing a component arrangement strategy that places components in multiple rows so that the overall aspect ratio of the whole graph gets as close to the aspect ratio of the preferred layout size as possible.
static byte STYLE_SINGLE_COLUMN
          Style specifier describing a component arrangement strategy that places components above each other in a single column.
static byte STYLE_SINGLE_ROW
          Style specifier describing a component arrangement strategy that places all components next to each other in a single row.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
ComponentLayouter()
          Creates a new ComponentLayouter instance with default settings.
ComponentLayouter(Layouter coreLayouter)
          Creates a new ComponentLayouter instance using the given core layout algorithm.
 
Method Summary
protected  void arrangeComponents(LayoutGraph graph, NodeList[] nodes, EdgeList[] edges, YRectangle[] bbox, java.awt.geom.Rectangle2D[] boxes)
          Produces a component graph layout.
protected  void arrangeFields(LayoutGraph graph, NodeList[] nodes, EdgeList[] edges, YRectangle[] bbox, java.awt.geom.Rectangle2D[] boxes, boolean circular, boolean fill, boolean fromSketch)
          Arranges the bounding boxes of the components.
protected  java.awt.geom.Rectangle2D calcBoundingBox(LayoutGraph graph)
          Calculates the bounding box of a graph component including NodeHalos.
 boolean canLayout(LayoutGraph graph)
          Accepts graphs where all components can be arranged by the core layout algorithm.
 void doLayout(LayoutGraph graph)
          Delegates the layout calculation for each component separately to the core layout algorithm and optionally arranges the components.
protected  int findGraphComponents(LayoutGraph graph, NodeMap compNumber)
          Determines which nodes belong to the same graph component.
 double getComponentSpacing()
          Returns the distance between the bounding boxes of the components.
 double getGridSpacing()
          Returns the current grid spacing.
 YDimension getPreferredLayoutSize()
          Returns the preferred size of the layout.
 byte getStyle()
          Returns how the components are arranged.
 boolean isComponentArrangementEnabled()
          Returns whether or not the separately arranged components of the input graph should be arranged relative to each other.
 boolean isGroupingActive()
          Returns whether or not grouping information bound to the graph should be considered when determining the graph components.
 boolean isLabelAwarenessEnabled()
          Returns whether or not to take node and edge labels into account when calculating the bounding box of the graph components.
 void setComponentArrangementEnabled(boolean enabled)
          Specifies whether or not the separately arranged components of the input graph should be arranged relative to each other.
 void setComponentSpacing(double componentSpacing)
          Specifies the distance between the bounding boxes of the components.
 void setGridSpacing(double gridSpacing)
          Specifies the current grid spacing.
 void setGroupingActive(boolean groupingActive)
          Specifies whether or not grouping information bound to the graph should be considered when determining the graph components.
 void setLabelAwarenessEnabled(boolean enabled)
          Specifies whether or not to take node and edge labels into account when calculating the bounding box of the graph components.
protected  void setOrigin(LayoutGraph graph, NodeList nodes, EdgeList edges, YPoint origin, YRectangle rectangle)
          Moves the subgraph containing the given nodes and edges to the specified origin.
 void setPreferredLayoutSize(double width, double height)
          Specifies the preferred width and height of the layout.
 void setPreferredLayoutSize(YDimension size)
          Specifies the preferred size of the layout.
 void setStyle(byte style)
          Specifies how the components are arranged.
 
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
 

Field Detail

LAYOUT_NODE_DPKEY

public static final java.lang.Object LAYOUT_NODE_DPKEY
A DataProvider key for specifying which nodes should be arranged

If no DataProvider is registered with this key, all components will be laid out by the core layout algorithm.

 
Components will only be arranged if at least one of the nodes that make up the component is marked.

GIVEN_COMPONENT_ID_DPKEY

public static final java.lang.Object GIVEN_COMPONENT_ID_DPKEY
A DataProvider key for specifying custom graph components

 
The component IDs are sorted and the associated components are then handled in the resulting order. This way it is possible to influence the ordering of components, if they, for example, should be placed in a column/row while keeping a specific order.
 
Most layout algorithms cannot handle disconnected components (only the IncrementalHierarchicLayouter, PartitionLayouter and EdgeRouter can handle such components). Hence, you should not assign the same component ID to nodes of different connected components for algorithms that cannot handle the disconnected components.

STYLE_NONE

public static final byte STYLE_NONE
Style specifier describing no special component arrangement at all. Components will be centered at the same position they resided at before the layout started. If combined with the style modifier STYLE_MODIFIER_NO_OVERLAP, components might get moved so that they don't overlap after the layout.

See Also:
setStyle(byte), Constant Field Values
Sample Graph:

No specific arrangement

STYLE_ROWS

public static final byte STYLE_ROWS
Style specifier describing a component arrangement strategy that places components in multiple rows so that the overall aspect ratio of the whole graph gets as close to the aspect ratio of the preferred layout size as possible.

See Also:
setStyle(byte), setPreferredLayoutSize(YDimension), Constant Field Values
Sample Graph:

Multiple rows and aspect ratio 1

STYLE_SINGLE_ROW

public static final byte STYLE_SINGLE_ROW
Style specifier describing a component arrangement strategy that places all components next to each other in a single row. If combined with the style modifier STYLE_MODIFIER_AS_IS, components will be placed in the same order as they were placed before the layout.

See Also:
setStyle(byte), Constant Field Values
Sample Graph:

All components in one row

STYLE_SINGLE_COLUMN

public static final byte STYLE_SINGLE_COLUMN
Style specifier describing a component arrangement strategy that places components above each other in a single column. If combined with the style modifier STYLE_MODIFIER_AS_IS, components will be placed in the same order as they were placed before the layout.

See Also:
setStyle(byte), Constant Field Values
Sample Graph:

All components in one column

STYLE_PACKED_RECTANGLE

public static final byte STYLE_PACKED_RECTANGLE
Style specifier describing a component arrangement strategy that places components in a rectangular cloud around the biggest component. Entities of different components will not overlap, however the bounding boxes of the components may overlap.

The aspect ratio of the rectangle is defined by the preferred size of the graph.

See Also:
setStyle(byte), setPreferredLayoutSize(YDimension), Constant Field Values
Sample Graph:

Rectangular arrangement with aspect ratio 1

STYLE_PACKED_COMPACT_RECTANGLE

public static final byte STYLE_PACKED_COMPACT_RECTANGLE
Style specifier describing a component arrangement strategy that places components in a rectangular cloud around the biggest component. Entities of different components will not overlap, however the bounding boxes of the components may overlap.

In contrast to STYLE_PACKED_RECTANGLE, components might even be placed in empty spaces inside other components.

The aspect ratio of the rectangle is defined by the preferred size of the graph.

See Also:
setStyle(byte), setPreferredLayoutSize(YDimension), Constant Field Values
Sample Graph:

Compact rectangular arrangement with aspect ratio 1

STYLE_PACKED_CIRCLE

public static final byte STYLE_PACKED_CIRCLE
Style specifier describing a component arrangement strategy that places components in a circular cloud around the biggest component. Entities of different components will not overlap, however the bounding boxes of the components may overlap.

See Also:
setStyle(byte), Constant Field Values
Sample Graph:

Circular arrangement

STYLE_PACKED_COMPACT_CIRCLE

public static final byte STYLE_PACKED_COMPACT_CIRCLE
Style specifier describing a component arrangement strategy that places components in a circular compact cloud around the biggest component. Entities of different components will not overlap, however the bounding boxes of the components may overlap.

In contrast to STYLE_PACKED_CIRCLE, components might even be placed in empty spaces inside other components.

See Also:
setStyle(byte), Constant Field Values
Sample Graph:

STYLE_MULTI_ROWS

public static final byte STYLE_MULTI_ROWS
Style specifier describing a component arrangement strategy that places components in multiple rows.

The strategy tries to arrange the components such that the aspect ratio of the final component placement gets as close as possible to the aspect ratio of the preferred layout size, configurable using setPreferredLayoutSize(YDimension).

In contrast to STYLE_ROWS, each row may also be divided into further sub-rows, which is especially useful if there are few very large components and many significantly smaller ones.

See Also:
setStyle(byte), setPreferredLayoutSize(YDimension), Constant Field Values
Sample Graph:

Multiple rows with aspect ratio 2.5

STYLE_MULTI_ROWS_COMPACT

public static final byte STYLE_MULTI_ROWS_COMPACT
Style specifier describing a component arrangement strategy that places components in multiple rows.

The strategy tries to arrange the components such that the aspect ratio of the final component placement gets close to the aspect ratio of the preferred layout size, configurable using setPreferredLayoutSize(YDimension). But in contrast to STYLE_MULTI_ROWS, this strategy does not always try to come as close to the preferred view ratio, if a ratio close to the preferred ratio only induces a lot of unused view space. This unused space will be minimized.

In contrast to STYLE_ROWS, each row may also be divided into further sub-rows, which is especially useful if there are few very large components and many significantly smaller ones.

See Also:
setStyle(byte), setPreferredLayoutSize(YDimension), Constant Field Values
Sample Graph:

Compact multiple rows with aspect ratio 2.5

STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED

public static final byte STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED
Style specifier describing a component arrangement strategy that places the components in STYLE_MULTI_ROWS with a restricted height. The resulting height does not exceed the preferred height (getPreferredLayoutSize()).

In contrast to STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED_COMPACT, the result will be an arrangement which uses as much height as possible, even if that means that all components will be arranged in one single column.

 
The preferred width and thus the aspect ratio will be ignored.
See Also:
setStyle(byte), setPreferredLayoutSize(YDimension), Constant Field Values
Sample Graph:

Height constrained to 800

STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED_COMPACT

public static final byte STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED_COMPACT
Style specifier describing a component arrangement strategy that places the components in STYLE_MULTI_ROWS with a restricted height and as compact as possible. The resulting height does not exceed the preferred height (getPreferredLayoutSize()).

In comparison with STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED, the result will be compacted, which means that an arrangement with the minimum width such that the height constraint is still fulfilled will be realized.

 
The preferred width and thus the aspect ratio will be ignored.
See Also:
setStyle(byte), setPreferredLayoutSize(YDimension), Constant Field Values
Sample Graph:

Height constrained to 800 with compact arrangement

STYLE_MULTI_ROWS_WIDTH_CONSTRAINED

public static final byte STYLE_MULTI_ROWS_WIDTH_CONSTRAINED
Style specifier describing a component arrangement strategy that places the components in STYLE_MULTI_ROWS with a restricted width. The resulting width does not exceed the preferred width (getPreferredLayoutSize()).

In contrast to STYLE_MULTI_ROWS_WIDTH_CONSTRAINED_COMPACT the result will be an arrangement which uses as much space in width as possible, even if that means that all components will be arranged in a single row.

 
The preferred height and thus the aspect ratio will be ignored.
See Also:
setStyle(byte), setPreferredLayoutSize(YDimension), Constant Field Values
Sample Graph:

Width constrained to 1000

STYLE_MULTI_ROWS_WIDTH_CONSTRAINED_COMPACT

public static final byte STYLE_MULTI_ROWS_WIDTH_CONSTRAINED_COMPACT
Style specifier describing a component arrangement strategy that places the components in STYLE_MULTI_ROWS with a restricted width and as compact as possible. The resulting width does not exceed the preferred width (getPreferredLayoutSize()).

In comparison with STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED the result will be compacted, in order to minimize unused view space induced by components that are large in height.

 
The preferred height and thus the aspect ratio will be ignored.
See Also:
setStyle(byte), setPreferredLayoutSize(YDimension), Constant Field Values
Sample Graph:

Width constrained to 1000 with compact arrangement

STYLE_MULTI_ROWS_TYPE_SEPARATED

public static final byte STYLE_MULTI_ROWS_TYPE_SEPARATED
Style specifier describing a component arrangement strategy that places the components in multiple nested rows, like STYLE_MULTI_ROWS, but separates components of different node type.

The strategy for placing components of same type is equal to the one of STYLE_MULTI_ROWS, but components of different node type are not placed in the same nested row. This means rows are not filled-up anymore (even though there would be space), but the components of different type are placed in a new row. Therefore, this strategy produces more rows and is less compact.

The type of a component is derived from the type of its nodes such that if most of the nodes are of same type, the component is considered to be of this dominant type, too. If there is no dominant type, the component is considered to have no type. Components without type are separated from the components with type.

In contrast to STYLE_MULTI_ROWS without type separation, this strategy may not come as close to the preferred view ratio, because the node types are of higher priority. Furthermore, results may contain more white space and be less compact.

See Also:
setStyle(byte), setPreferredLayoutSize(YDimension), Layouter.NODE_TYPE_DPKEY, Constant Field Values

STYLE_MASK

public static final byte STYLE_MASK
A constant for masking actual style constants from style modifiers.

See Also:
setStyle(byte), Constant Field Values

STYLE_MODIFIER_AS_IS

public static final byte STYLE_MODIFIER_AS_IS
A modifier that can be added to normal style specifiers to indicate that the arrangement strategy should take the initial positions of the components into account.

Combining this modifier is supported with the following styles: STYLE_SINGLE_ROW and STYLE_SINGLE_COLUMN.

See Also:
setStyle(byte), Constant Field Values

STYLE_MODIFIER_NO_OVERLAP

public static final byte STYLE_MODIFIER_NO_OVERLAP
A modifier that can be added to normal style specifiers to indicate that the arrangement strategy should produce a non-overlapping component layout.

Combining this modifier is not supported with STYLE_NONE.

 
Non-overlapping component layout (in the sense that no elements from adjacent components overlap) is inherently supported by all styles except for STYLE_NONE.
See Also:
setStyle(byte), Constant Field Values
Constructor Detail

ComponentLayouter

public ComponentLayouter(Layouter coreLayouter)
Creates a new ComponentLayouter instance using the given core layout algorithm.

Parameters:
coreLayouter - the core layout routine

ComponentLayouter

public ComponentLayouter()
Creates a new ComponentLayouter instance with default settings.

Method Detail

setPreferredLayoutSize

public void setPreferredLayoutSize(double width,
                                   double height)
Specifies the preferred width and height of the layout.

Width and height define the preferred layout size and also the desired aspect ratio (width/height).

Width and height need to be greater than zero.

 
STYLE_NONE, STYLE_SINGLE_ROW and STYLE_SINGLE_COLUMN do not consider the preferred layout size.
Parameters:
width - the preferred width of the calculated graph layout
height - the preferred height of the calculated graph layout
Throws:
java.lang.IllegalArgumentException - if the specified width or height is negative or zero.
See Also:
setPreferredLayoutSize(YDimension)

setPreferredLayoutSize

public void setPreferredLayoutSize(YDimension size)
Specifies the preferred size of the layout.

The layout size also defines the desired aspect ratio (width/height).

The width and height need to be greater than zero.

 
STYLE_NONE, STYLE_SINGLE_ROW and STYLE_SINGLE_COLUMN do not consider the preferred layout size.
Default Value:
The default value is YDimension. Both preferred width and height are 400.
Parameters:
size - the preferred size of the calculated graph layout
Throws:
java.lang.IllegalArgumentException - if the specified width or height is negative or zero or the given dimension is null
Sample Graphs:

Size 100x400

Size 400x400

Size 400x100

getPreferredLayoutSize

public YDimension getPreferredLayoutSize()
Returns the preferred size of the layout.

The layout size also defines the desired aspect ratio (width/height).

The width and height need to be greater than zero.

 
STYLE_NONE, STYLE_SINGLE_ROW and STYLE_SINGLE_COLUMN do not consider the preferred layout size.
Returns:
the preferred size of the calculated graph layout
See Also:
setPreferredLayoutSize(YDimension)

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts graphs where all components can be arranged by the core layout algorithm.

Parameters:
graph - the input graph
Returns:
true if all components of the graph can be handled by the core layout algorithm, the graph is empty or there is no core layout algorithm, false otherwise
See Also:
Layouter.doLayout(LayoutGraph)

findGraphComponents

protected int findGraphComponents(LayoutGraph graph,
                                  NodeMap compNumber)
Determines which nodes belong to the same graph component.

This implementation uses the graph connectivity to sort the nodes into different components. Nodes that are not connected by a path will be in separate components.

This method is called by doLayout(LayoutGraph). It may be overridden to choose another approach to find components that will be passed to the core layout algorithm. However, most of the layout algorithms cannot handle disconnected graphs. Also, edges between custom components will be ignored.

 
Additionally to normal connectedness, a group node and all of its children will belong to the same component.
Parameters:
graph - the input graph
compNumber - a map that will be filled with the zero-based index of the component to which the node belongs
Returns:
the number of connected components of this graph
See Also:
GraphConnectivity.connectedComponents(y.base.Graph)

doLayout

public void doLayout(LayoutGraph graph)
Delegates the layout calculation for each component separately to the core layout algorithm and optionally arranges the components.

Parameters:
graph - the input graph
See Also:
Layouter.canLayout(LayoutGraph)

calcBoundingBox

protected java.awt.geom.Rectangle2D calcBoundingBox(LayoutGraph graph)
Calculates the bounding box of a graph component including NodeHalos.

This method will be invoked for each component of the graph. Depending on the state of property isLabelAwarenessEnabled(), the returned bounding box will also include node and edge labels. It may be overridden to extend the bounds to reserve space for other elements.

Parameters:
graph - the subgraph containing the nodes and edges of a component
Returns:
the bounding box of the component
See Also:
setLabelAwarenessEnabled(boolean)

setLabelAwarenessEnabled

public void setLabelAwarenessEnabled(boolean enabled)
Specifies whether or not to take node and edge labels into account when calculating the bounding box of the graph components.

Default Value:
The default value is true. Node and edge labels are included in the bounds of the components.
Parameters:
enabled - true if node and edge labels should be taken into account when calculating the bounding box of the graph components, false otherwise
See Also:
calcBoundingBox(LayoutGraph graph)
Sample Graphs:

false

true

isLabelAwarenessEnabled

public boolean isLabelAwarenessEnabled()
Returns whether or not to take node and edge labels into account when calculating the bounding box of the graph components.

Returns:
true if node and edge labels are taken into account when calculating the bounding box of the graph components, false otherwise
See Also:
setLabelAwarenessEnabled(boolean), calcBoundingBox(LayoutGraph graph)

arrangeComponents

protected void arrangeComponents(LayoutGraph graph,
                                 NodeList[] nodes,
                                 EdgeList[] edges,
                                 YRectangle[] bbox,
                                 java.awt.geom.Rectangle2D[] boxes)
Produces a component graph layout.

This method is called by doLayout(LayoutGraph) in case component arrangement is enabled. It moves the graph's components such that their bounding boxes do not overlap. Subclasses may want to override this method to introduce custom component arrangement styles.

 
Depending on the chosen arrangement strategy, this layout algorithm takes the ratio of the overall layout area into account. STYLE_NONE, STYLE_SINGLE_ROW and STYLE_SINGLE_COLUMN are excluded.
Parameters:
graph - the input graph
nodes - the nodes of the components; the i-th list contains the nodes of the i-th component
edges - the edges of the components; the i-th list contains the edges of the i-th component
bbox - the bounds of the components; the i-th rectangle describes the bounding box of the i-th component
boxes - the extended bounds of the components; the i-th rectangle describes the bounding box of the i-th component extended by the spacing between components. The method arranges these boxes in such a way that they do not overlap. Then, the i-th graph component must be placed inside the i-th box
See Also:
arrangeFields(LayoutGraph, NodeList[], EdgeList[], YRectangle[], Rectangle2D[], boolean, boolean, boolean), LayoutTool.arrangeRectangleRows(Rectangle2D[], Rectangle2D, double), LayoutTool.arrangeRectangleMultiRows(Rectangle2D[], Rectangle2D, double, double, boolean, byte)

setComponentArrangementEnabled

public void setComponentArrangementEnabled(boolean enabled)
Specifies whether or not the separately arranged components of the input graph should be arranged relative to each other. If enabled, the components are arranged using a specific style without producing overlaps between components (except for STYLE_NONE). Otherwise, the layout algorithm will keep the components at their location. Then, the components may overlap.

Default Value:
The default value is true. The components are arranged relative to each other.
Parameters:
enabled - true if the components of the graph should be arranged, false otherwise
Sample Graphs:

false

true

isComponentArrangementEnabled

public boolean isComponentArrangementEnabled()
Returns whether or not the separately arranged components of the input graph should be arranged relative to each other. If enabled, the components are arranged using a specific style without producing overlaps between components (except for STYLE_NONE). Otherwise, the layout algorithm will keep the components at their location. Then, the components may overlap.

Returns:
true if the components of the graph are arranged, false otherwise
See Also:
setComponentArrangementEnabled(boolean)

setOrigin

protected void setOrigin(LayoutGraph graph,
                         NodeList nodes,
                         EdgeList edges,
                         YPoint origin,
                         YRectangle rectangle)
Moves the subgraph containing the given nodes and edges to the specified origin.

This method is called by arrangeComponents(LayoutGraph, NodeList[], EdgeList[], YRectangle[], Rectangle2D[]) and arrangeFields(LayoutGraph, NodeList[], EdgeList[], YRectangle[], Rectangle2D[], boolean, boolean, boolean) to move the components to overlap-free positions.

Parameters:
graph - the input graph
nodes - the nodes in the moving subgraph
edges - the edges in the moving subgraph
origin - the new origin of the graph
rectangle - the current bounds of the subgraph

getGridSpacing

public double getGridSpacing()
Returns the current grid spacing. Components will be moved by multiples of this value, thus keeping their offset to the grid. That way, components or parts of them that were placed on a grid before, will stay on their original grid. The grid spacing also influences the distance between the components.

The spacing needs to be a non-negative value. If the grid spacing is set to 0, the grid won't be considered at all.

 
This option keeps existing grid locations intact and won't correct the location of a component with respect to the grid specified here.
Returns:
the grid spacing
See Also:
setGridSpacing(double)

setGridSpacing

public void setGridSpacing(double gridSpacing)
Specifies the current grid spacing. Components will be moved by multiples of this value, thus keeping their offset to the grid. That way, components or parts of them that were placed on a grid before, will stay on their original grid. The grid spacing also influences the distance between the components.

The spacing needs to be a non-negative value. If the grid spacing is set to 0, the grid won't be considered at all.

 
This option keeps existing grid locations intact and won't correct the location of a component with respect to the grid specified here.
Default Value:
The default value is 0. No grid is considered.
Parameters:
gridSpacing - the grid spacing
Throws:
java.lang.IllegalArgumentException - if the given spacing is negative
Sample Graphs:

The initial graph

Grid spacing 30

No grid (spacing 0)

getComponentSpacing

public double getComponentSpacing()
Returns the distance between the bounding boxes of the components.

The spacing needs to be non-negative.

Returns:
the component spacing
See Also:
setComponentSpacing(double)

setComponentSpacing

public void setComponentSpacing(double componentSpacing)
Specifies the distance between the bounding boxes of the components.

The spacing needs to be non-negative.

Default Value:
The default value is 45.
Parameters:
componentSpacing - the component spacing
Throws:
java.lang.IllegalArgumentException - if the spacing is negative
Sample Graphs:

45

90

isGroupingActive

public boolean isGroupingActive()
Returns whether or not grouping information bound to the graph should be considered when determining the graph components.

Returns:
true if the nesting structure of the graph is considered when determining the components, false otherwise
See Also:
setGroupingActive(boolean)

setGroupingActive

public void setGroupingActive(boolean groupingActive)
Specifies whether or not grouping information bound to the graph should be considered when determining the graph components.

Default Value:
The default value is true. Grouping information is considered for determining the components.
Parameters:
groupingActive - true if the nesting structure of the graph should be considered when determining the components, false otherwise
Sample Graphs:

false

true

getStyle

public byte getStyle()
Returns how the components are arranged.

 
The style will have no effect if component arrangement is disabled.
Returns:
one of the valid style specifiers
See Also:
setStyle(byte)

setStyle

public void setStyle(byte style)
Specifies how the components are arranged.

 
The style will have no effect if component arrangement is disabled.
Default Value:
The default value is STYLE_ROWS
Parameters:
style - one of the valid style specifiers
Throws:
java.lang.IllegalArgumentException - if the specified style is unknown

arrangeFields

protected void arrangeFields(LayoutGraph graph,
                             NodeList[] nodes,
                             EdgeList[] edges,
                             YRectangle[] bbox,
                             java.awt.geom.Rectangle2D[] boxes,
                             boolean circular,
                             boolean fill,
                             boolean fromSketch)
Arranges the bounding boxes of the components.

This method is called by arrangeComponents(LayoutGraph, NodeList[], EdgeList[], YRectangle[], Rectangle2D[]) if the style is set to STYLE_PACKED_RECTANGLE, STYLE_PACKED_COMPACT_RECTANGLE, STYLE_PACKED_CIRCLE or STYLE_PACKED_COMPACT_CIRCLE. It may be overridden to adjust the component arrangement strategy of the mentioned styles.

Parameters:
graph - the input graph
nodes - the nodes of the components; the i-th list contains the nodes of the i-th component
edges - the edges of the components; the i-th list contains the edges of the i-th component
bbox - the bounds of the components; the i-th rectangle describes the bounding box of the i-th component
boxes - the extended bounds of the components; the i-th rectangle describes the bounding box of the i-th component
circular - true if the arrangement should be circular, false if it should be rectangular
fill - true if it is allowed to place components in empty spaces inside other components, false otherwise
fromSketch - true if the initial coordinates should be considered, false otherwise

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