Search this API

y.layout.grouping
Class FixedGroupLayoutStage

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.grouping.FixedGroupLayoutStage
All Implemented Interfaces:
Layouter, LayoutStage

public class FixedGroupLayoutStage
extends AbstractLayoutStage

A layout stage that can handle fixed nodes in hierarchically grouped graphs.

This stage guarantees that a core layout algorithm will maintain the relative positions of nodes within the same group.

Also, this stage is responsible for routing edges that connect nodes belonging to hierarchically unrelated groups. More precisely, the stage temporarily replaces fixed group nodes (see FIXED_GROUP_NODES_DPKEY) with normal nodes of the same size while the content of the groups is removed from the graph during layout.

The nodes are used as placeholders and are responsible for keeping the relations to the remaining graph elements. Edges that originate from the outside of the group node and terminate in its interior (inter-edges) are redirected such that they connect to the node that replaces the group.

After the layout process, the group nodes are restored and the stage inserts the content at the new group position (derived from the position of the associated node). The content itself (including the edges between content nodes) remains unchanged and is only relocated. Furthermore, the inter-edges are connected to their original source/target and the stage reroutes them using the specified inter-edge routing algorithm (see setOrthogonalEdgeRouter(Layouter)).


Initial graph. Nodes inside groups have to remain at their relative positions.

Example after using FixedGroupLayoutStage with OrthogonalGroupLayouter. Nodes inside groups did not change relative positions.

 

Field Summary
static java.lang.Object FIXED_GROUP_NODES_DPKEY
          A DataProvider key for selecting group nodes whose contents should keep their relative positions.
static java.lang.Object INTER_EDGES_DPKEY
          A DataProvider key for marking edges as inter-edges.
static byte ROUTING_STYLE_ADOPT
          An inter-edge routing style based on which the edge layout of inter-edges will be adopted from the core layout algorithm.
static byte ROUTING_STYLE_ORTHOGONAL
          An inter-edge routing style based on which inter-edges are routed in an orthogonal style.
static byte ROUTING_STYLE_STRAIGHTLINE
          An inter-edge routing style based on which inter-edges are routed as straight lines.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
FixedGroupLayoutStage()
          Creates a new instance of FixedGroupLayoutStage.
FixedGroupLayoutStage(Layouter core)
          Creates a new instance of FixedGroupLayoutStage with the given algorithm as core layout algorithm.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Accepts all graphs that are accepted by the specified core layout algorithm.
 void doLayout(LayoutGraph graph)
          Calculates the layout for the given graph, that is, prepares the graph by hiding the content of fixed group nodes for the core layout algorithm, executes it and, finally, restores the graph and routes inter-edges.
 byte getInterEdgeRoutingStyle()
          Returns the inter-edge routing style used by this layout stage.
 Layouter getOrthogonalEdgeRouter()
          Returns the edge routing algorithm that is applied to route the inter-edges.
 void setInterEdgeRoutingStyle(byte routingStyle)
          Specifies the inter-edge routing style used by this layout stage.
 void setOrthogonalEdgeRouter(Layouter edgeRouter)
          Specifies the edge routing algorithm that is applied to route the inter-edges.
 
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

FIXED_GROUP_NODES_DPKEY

public static final java.lang.Object FIXED_GROUP_NODES_DPKEY
A DataProvider key for selecting group nodes whose contents should keep their relative positions.

A group node is considered selected in this context, if the corresponding DataProvider returns true for the group node or any of its ancestor (group) nodes.

 
If there is no DataProvider registered with this key, all group nodes are considered to be selected.

INTER_EDGES_DPKEY

public static final java.lang.Object INTER_EDGES_DPKEY
A DataProvider key for marking edges as inter-edges.

The inter-edges will automatically be marked by this stage during the post-processing step.


ROUTING_STYLE_ADOPT

public static final byte ROUTING_STYLE_ADOPT
An inter-edge routing style based on which the edge layout of inter-edges will be adopted from the core layout algorithm.

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

ROUTING_STYLE_ORTHOGONAL

public static final byte ROUTING_STYLE_ORTHOGONAL
An inter-edge routing style based on which inter-edges are routed in an orthogonal style.

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

ROUTING_STYLE_STRAIGHTLINE

public static final byte ROUTING_STYLE_STRAIGHTLINE
An inter-edge routing style based on which inter-edges are routed as straight lines.

See Also:
setInterEdgeRoutingStyle(byte), getOrthogonalEdgeRouter(), Constant Field Values
Sample Graph:
Constructor Detail

FixedGroupLayoutStage

public FixedGroupLayoutStage()
Creates a new instance of FixedGroupLayoutStage.


FixedGroupLayoutStage

public FixedGroupLayoutStage(Layouter core)
Creates a new instance of FixedGroupLayoutStage with the given algorithm as core layout algorithm.

Parameters:
core - the core layout algorithm used by this stage
Method Detail

setInterEdgeRoutingStyle

public void setInterEdgeRoutingStyle(byte routingStyle)
Specifies the inter-edge routing style used by this layout stage.

Default Value:
The default value is ROUTING_STYLE_ADOPT. Inter-edge routes will be adopted from the core layout algorithm.
Parameters:
routingStyle - one of the predefined routing styles for inter-edges
Throws:
java.lang.IllegalArgumentException - if the given routing style is unknown

getInterEdgeRoutingStyle

public byte getInterEdgeRoutingStyle()
Returns the inter-edge routing style used by this layout stage.

Returns:
one of the predefined routing styles for inter-edges
See Also:
setInterEdgeRoutingStyle(byte)

setOrthogonalEdgeRouter

public void setOrthogonalEdgeRouter(Layouter edgeRouter)
Specifies the edge routing algorithm that is applied to route the inter-edges.

If no routing algorithm is set, a new instance of CompositeLayouter associated with a GroupNodeHider and an EdgeRouter will be used.

Default Value:
The default value is CompositeLayouter. A CompositeLayouter associated with a GroupNodeHider and an EdgeRouter.
Parameters:
edgeRouter - the edge routing algorithm for inter-edges

getOrthogonalEdgeRouter

public Layouter getOrthogonalEdgeRouter()
Returns the edge routing algorithm that is applied to route the inter-edges.

If no routing algorithm is set, a new instance of CompositeLayouter associated with a GroupNodeHider and an EdgeRouter will be used.

Returns:
the edge routing algorithm for inter-edges
See Also:
setOrthogonalEdgeRouter(Layouter)

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all graphs that are accepted by the specified core layout algorithm.

Parameters:
graph - the input graph
Returns:
true if the core layout algorithm accepts this graph or is null, false otherwise
See Also:
Layouter.doLayout(LayoutGraph)

doLayout

public void doLayout(LayoutGraph graph)
Calculates the layout for the given graph, that is, prepares the graph by hiding the content of fixed group nodes for the core layout algorithm, executes it and, finally, restores the graph and routes inter-edges.

 
The given graph will not be copied during the layout process and the layout will be immediately applied to the given graph.
Parameters:
graph - the input graph
See Also:
Layouter.canLayout(LayoutGraph)

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