Search this API

y.layout.hierarchic.incremental
Class DefaultLayeredComponentsMerger

java.lang.Object
  extended by y.layout.hierarchic.incremental.DefaultLayeredComponentsMerger
All Implemented Interfaces:
LayeredComponentsMerger

public class DefaultLayeredComponentsMerger
extends java.lang.Object
implements LayeredComponentsMerger

A default implementation of a LayeredComponentsMerger that provides simple default behaviors. Instances of this class are used internally by HierarchicLayouter and MultiComponentLayerer when e.g. the graph is grouped or it consists of more than one connected component.

 

Field Summary
static byte POLICY_ADD_ABOVE
          A constant that adds the new layers of the source layering above the layers of the target layering.
static byte POLICY_ADD_BELOW
          A constant that adds the new layers of the source layering below the layers of the target layering.
static byte POLICY_ADD_LEFT_BOTTOM_ALIGNED
          A constant that adds the new layers of the source layering to the left of the layers of the target layering.
static byte POLICY_ADD_LEFT_CENTER_ALIGNED
          A constant that adds the new layers of the source layering to the left of the layers of the target layering.
static byte POLICY_ADD_LEFT_TOP_ALIGNED
          A constant that adds the new layers of the source layering to the left of the layers of the target layering.
static byte POLICY_ADD_RIGHT_BOTTOM_ALIGNED
          A constant that adds the new layers of the source layering to the right of the layers of the target layering.
static byte POLICY_ADD_RIGHT_CENTER_ALIGNED
          A constant that adds the new layers of the source layering to the right of the layers of the target layering.
static byte POLICY_ADD_RIGHT_TOP_ALIGNED
          A constant that adds the new layers of the source layering to the right of the layers of the target layering.
 
Constructor Summary
DefaultLayeredComponentsMerger()
          Creates a new instance of DefaultLayeredComponentsMerger with default settings.
DefaultLayeredComponentsMerger(byte policy)
          Creates a new instance of DefaultLayeredComponentsMerger using the given merging policy.
 
Method Summary
 byte getPolicy()
          Returns the merging policy constant as defined in DefaultLayeredComponentsMerger.
 void merge(LayoutGraph graph, LayoutDataProvider ldp, Layers srcLayers, Layers targetLayers)
          Merges two Layers instances.
 void setPolicy(byte policy)
          Specifies the merging policy constant as defined in DefaultLayeredComponentsMerger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POLICY_ADD_BELOW

public static final byte POLICY_ADD_BELOW
A constant that adds the new layers of the source layering below the layers of the target layering.

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

Blue-colored nodes belong to the source layering, while yellow-colored node to the target layering.

POLICY_ADD_ABOVE

public static final byte POLICY_ADD_ABOVE
A constant that adds the new layers of the source layering above the layers of the target layering.

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

Blue-colored nodes belong to the source layering, while yellow-colored node to the target layering.

POLICY_ADD_RIGHT_TOP_ALIGNED

public static final byte POLICY_ADD_RIGHT_TOP_ALIGNED
A constant that adds the new layers of the source layering to the right of the layers of the target layering.

Both layerings will become top-aligned before the merge.

 
The source layering is the one with the larger number of layers.
See Also:
setPolicy(byte), Constant Field Values
Sample Graph:

Blue-colored nodes belong to the source layering, while yellow-colored node to the target layering; the source layering is the one with the larger number of layers

POLICY_ADD_RIGHT_BOTTOM_ALIGNED

public static final byte POLICY_ADD_RIGHT_BOTTOM_ALIGNED
A constant that adds the new layers of the source layering to the right of the layers of the target layering.

Both layerings will become bottom-aligned before the merge.

 
The source layering is the one with the larger number of layers.
See Also:
setPolicy(byte), Constant Field Values
Sample Graph:

Blue-colored nodes belong to the source layering, while yellow-colored node to the target layering; the source layering is the one with the larger number of layers

POLICY_ADD_RIGHT_CENTER_ALIGNED

public static final byte POLICY_ADD_RIGHT_CENTER_ALIGNED
A constant that adds the new layers of the source layering to the right of the layers of the target layering.

Both layerings will become center-aligned before the merge.

 
The source layering is the one with the larger number of layers.
See Also:
setPolicy(byte), Constant Field Values
Sample Graph:

Blue-colored nodes belong to the source layering, while yellow-colored node to the target layering; the source layering is the one with the larger number of layers

POLICY_ADD_LEFT_TOP_ALIGNED

public static final byte POLICY_ADD_LEFT_TOP_ALIGNED
A constant that adds the new layers of the source layering to the left of the layers of the target layering.

Both layerings will become top-aligned before the merge.

 
The source layering is the one with the larger number of layers.
See Also:
setPolicy(byte), Constant Field Values
Sample Graph:

Blue-colored nodes belong to the target layering, while yellow-colored node to the source layering; the source layering is the one with the larger number of layers

POLICY_ADD_LEFT_BOTTOM_ALIGNED

public static final byte POLICY_ADD_LEFT_BOTTOM_ALIGNED
A constant that adds the new layers of the source layering to the left of the layers of the target layering.

Both layerings will become bottom-aligned before the merge.

 
The source layering is the one with the larger number of layers.
See Also:
setPolicy(byte), Constant Field Values
Sample Graph:

Blue-colored nodes belong to the target layering, while yellow-colored node to the source layering; the source layering is the one with the larger number of layers

POLICY_ADD_LEFT_CENTER_ALIGNED

public static final byte POLICY_ADD_LEFT_CENTER_ALIGNED
A constant that adds the new layers of the source layering to the left of the layers of the target layering.

Both layerings will become center-aligned before the merge.

 
The source layering is the one with the larger number of layers.
See Also:
setPolicy(byte), Constant Field Values
Sample Graph:

Blue-colored nodes belong to the target layering, while yellow-colored node to the source layering; the source layering is the one with the larger number of layers
Constructor Detail

DefaultLayeredComponentsMerger

public DefaultLayeredComponentsMerger()
Creates a new instance of DefaultLayeredComponentsMerger with default settings.


DefaultLayeredComponentsMerger

public DefaultLayeredComponentsMerger(byte policy)
Creates a new instance of DefaultLayeredComponentsMerger using the given merging policy.

Parameters:
policy - one of the predefined merging constants
Throws:
java.lang.IllegalArgumentException - if an unknown policy is given
Method Detail

getPolicy

public byte getPolicy()
Returns the merging policy constant as defined in DefaultLayeredComponentsMerger.

Returns:
one of the predefined merging policy constants
See Also:
setPolicy(byte)

setPolicy

public void setPolicy(byte policy)
Specifies the merging policy constant as defined in DefaultLayeredComponentsMerger.

Default Value:
The default value is POLICY_ADD_RIGHT_TOP_ALIGNED. Nodes of the source layering are to the right of the target layering and all nodes are top-aligned.
Parameters:
policy - one of the predefined merging policy constants
Throws:
java.lang.IllegalArgumentException - if an unknown policy is given

merge

public void merge(LayoutGraph graph,
                  LayoutDataProvider ldp,
                  Layers srcLayers,
                  Layers targetLayers)
Description copied from interface: LayeredComponentsMerger
Merges two Layers instances.

All nodes that belong to the source and target Layers are part of the graph at the moment of invocation.

The state of the source Layers instance is discarded after this call and does not need to be updated to reflect the changes. The target Layers instance must be updated accordingly.

Specified by:
merge in interface LayeredComponentsMerger
Parameters:
graph - the graph containing the nodes of source and target Layers instances
ldp - the LayoutDataProvider used for querying the layer indices
srcLayers - the source Layers instance that will be merged into the target Layers instance
targetLayers - the Layers instance that will be modified to contain the resulting layering

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