y.layout.hierarchic
Class IncrementalHierarchicLayouter

java.lang.Object
  extended by y.layout.CanonicMultiStageLayouter
      extended by y.layout.hierarchic.IncrementalHierarchicLayouter
All Implemented Interfaces:
Layouter

public class IncrementalHierarchicLayouter
extends CanonicMultiStageLayouter

This class is a variant of the classic HierarchicLayouter implementation. It serves as a facade to HierarchicLayouter.

Instances can be used to simply create hierarchic layouts from scratch or add new elements to the existing sketch drawing incrementally.
In order to add elements incrementally to the current sketch or let the algorithm optimize certain elements in the current sketch, set its mode to LAYOUT_MODE_INCREMENTAL and add a DataProvider (e.g. use Maps.createHashedDataMap()) using the INCREMENTAL_HINTS_DPKEY DataProvider key to the graph and associate the marks obtained from the IncrementalHintsFactory with the elements to be added incrementally.

Many settings of the layout can be controlled using the EdgeLayoutDescriptor and NodeLayoutDescriptor instances. The ones that are used during the layout run can be obtained from getEdgeLayoutDescriptor() and getNodeLayoutDescriptor() respectively.
If at the time of the invocation DataProvider instances are bound to the graph using either the HierarchicLayouter.EDGE_LAYOUT_DESCRIPTOR_DPKEY or HierarchicLayouter.NODE_LAYOUT_DESCRIPTOR_DPKEY keys, they will be wrapped and whenever they do not provide values the ones set in this instance will be used as fallback values.

Here is a sample layout output:

The following example shows the result of an incremental layout with lots of port constraints (For clarity colored layers have been added to the diagram):

The last example shows the result of a layout run that considered swim lanes. Nodes with the same label have been placed into the same swim lane. Swim lanes have been ordered in ascending order of the label names. (For clarity lines have been added to the diagram that depict the bounds of the swimlanes):

See Also:
setLayoutMode(byte), INCREMENTAL_HINTS_DPKEY, createIncrementalHintsFactory(), HierarchicLayouter
 

Field Summary
static Object INCREMENTAL_HINTS_DPKEY
          DataProvider key used to store incremental layout hints that can be retrieved from the IncrementalHintsFactory which itself can be obtained from the createIncrementalHintsFactory() method.
static Object LAYER_VALUE_HOLDER_DPKEY
          DataProvider key used to store IntValueHolder for each node in the graph.
static byte LAYERING_STRATEGY_BFS
          Layering strategy specifier.
static byte LAYERING_STRATEGY_FROM_SKETCH
          Layering strategy specifier.
static byte LAYERING_STRATEGY_HIERARCHICAL_DOWNSHIFT
          Layering strategy specifier.
static byte LAYERING_STRATEGY_HIERARCHICAL_OPTIMAL
          Layering strategy specifier.
static byte LAYERING_STRATEGY_HIERARCHICAL_TIGHT_TREE
          Layering strategy specifier.
static byte LAYERING_STRATEGY_HIERARCHICAL_TOPMOST
          Layering strategy constant.
static byte LAYERING_STRATEGY_UNKNOWN
          Dummy layering strategy specifier.
static byte LAYERING_STRATEGY_USER_DEFINED
          Layering strategy specifier.
static byte LAYOUT_MODE_FROM_SCRATCH
          Layout mode constant that can be used in setLayoutMode(byte).
static byte LAYOUT_MODE_INCREMENTAL
          Layout mode constant that can be used in setLayoutMode(byte).
static byte POLICY_ALIGN_GROUPS_BOTTOM
          Group layering alignment strategy specifier.
static byte POLICY_ALIGN_GROUPS_CENTER
          Group layering alignment strategy specifier.
static byte POLICY_ALIGN_GROUPS_TOP
          Group layering alignment strategy specifier.
static Object SWIMLANE_DESCRIPTOR_DPKEY
          DataProvider key used to store SwimLaneDescriptor instances for each node in the graph.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
IncrementalHierarchicLayouter()
          Creates a new IncrementalHierarchicLayouter instance which is set to LAYOUT_MODE_FROM_SCRATCH initially
 
Method Summary
 boolean canLayoutCore(LayoutGraph graph)
          Determines whether this layouter can perform the core layout on the given graph.
protected  void configureCoreLayout(LayoutGraph graph, HierarchicLayouter ihl)
          Called before the actual layout is performed.
protected  EdgeLayoutDescriptor createEdgeLayoutDescriptor()
          Factory method that creates the default EdgeLayoutDescriptor.
protected  HierarchicLayouter createHierarchicLayouter()
          Factory method that creates the internally used HierarchicLayouter instance.
 IncrementalHintsFactory createIncrementalHintsFactory()
          Returns a IncrementalHintsFactory instance that must be used to obtain marks that can be associated with elements in the graph that will be laid out incrementally.
protected  NodeLayoutDescriptor createNodeLayoutDescriptor()
          Factory method that creates the default NodeLayoutDescriptor.
 void doLayoutCore(LayoutGraph g)
          Performs the actual layout using the currently set mode.
protected  DefaultDrawingDistanceCalculator getDefaultDrawingDistanceCalculator()
          Helper method that returns the DefaultDrawingDistanceCalculator that is registered with the layout algorithm by default.
 EdgeLayoutDescriptor getEdgeLayoutDescriptor()
          Returns the EdgeLayoutDescriptor instance used for all edges, that don't have a layout descriptor assigned.
 double getEdgeToEdgeDistance()
          Returns the minimum distance between two adjacent edges in one layer.
 Layerer getFixedElementsLayerer()
          Returns the Layerer instance that is used to obtain the layering for the nodes that are not marked as to be laid out incrementally if the layouter is set to LAYOUT_MODE_INCREMENTAL.
 Sequencer getFixedElementsSequencer()
          Returns the Sequencer instance that is used to calculated the sequence of the nodes that are not marked to be laid out incrementally if the layouter is set to LAYOUT_MODE_INCREMENTAL.
 Layerer getFromScratchLayerer()
          Returns the Layerer instance that is used to obtain the layering for the nodes if the layouter is set to LAYOUT_MODE_FROM_SCRATCH.
 byte getFromScratchLayeringStrategy()
          Returns the currently set layering strategy for the from scratch layering.
 Sequencer getFromScratchSequencer()
          Returns the Sequencer instance that is used to calculated the sequence of the nodes if the layouter is set to LAYOUT_MODE_FROM_SCRATCH.
 byte getGroupAlignmentPolicy()
          Get the group layer alignment strategy used for recursive group layering.
 HierarchicLayouter getHierarchicLayouter()
          Convenience method that provides access to the internally used HierarchicLayouter instance.
 byte getLayoutMode()
          Returns the layout mode this layouter is currently in.
 double getMinimumLayerDistance()
          Returns the minimum distance between two adjacent layers.
 NodeLayoutDescriptor getNodeLayoutDescriptor()
          Returns the NodeLayoutDescriptor instance used for all nodes, that don't have a layout descriptor assigned.
 NodePlacer getNodePlacer()
          Returns the NodePlacer instance that will be used to calculated the final node placement of the layout.
 double getNodeToEdgeDistance()
          Returns the minimum distance between two adjacent nodes in one layer.
 double getNodeToNodeDistance()
          Returns the minimum distance between two adjacent nodes in one layer.
 boolean isConsiderNodeLabelsEnabled()
          Checks whether node label consideration is enabled.
 boolean isGroupCompactionEnabled()
          Return whether layer compaction for recursive group layering is active.
 boolean isIntegratedEdgeLabelingEnabled()
          Checks whether the integrated edge labeling is enabled.
 boolean isRecursiveGroupLayeringEnabled()
          Return whether groups are respected during the layering stage.
 void setConsiderNodeLabelsEnabled(boolean enabled)
          Enables node label consideration.
 void setEdgeLayoutDescriptor(EdgeLayoutDescriptor edgeLayoutDescriptor)
          Sets the EdgeLayoutDescriptor instance used for all edges that don't have a layout descriptor assigned.
 void setEdgeToEdgeDistance(double d)
          Sets the minimum distance between two adjacent edges in one layer.
 void setFixedElementsLayerer(Layerer fixedElementsLayerer)
          Sets the Layerer instance that is used to obtain the layering for the nodes that are not marked to be laid out incrementally if the layouter is set to LAYOUT_MODE_INCREMENTAL.
 void setFixedElementsSequencer(Sequencer fixedElementsSequencer)
          Sets the Sequencer instance that is used to calculated the sequence of the nodes that are not marked to be laid out incrementally if the layouter is set to LAYOUT_MODE_INCREMENTAL.
 void setFromScratchLayerer(Layerer layerer)
          Sets the Layerer instance that is used to obtain the layering for the nodes if the layouter is set to LAYOUT_MODE_FROM_SCRATCH.
 void setFromScratchLayeringStrategy(byte strategy)
          Convenience method that sets a predefined layering strategy for the from scratch layerer.
 void setFromScratchSequencer(Sequencer sequencer)
          Sets the Sequencer instance that is used to obtain the sequencing for the nodes if the layouter is set to LAYOUT_MODE_FROM_SCRATCH.
 void setGroupAlignmentPolicy(byte groupAlignmentPolicy)
          Set the group layer alignment strategy used for recursive group layering.
 void setGroupCompactionEnabled(boolean groupCompactionEnabled)
          Set whether layer compaction for recursive group layering should be used.
 void setIntegratedEdgeLabelingEnabled(boolean enabled)
          Enables integrated edge labeling.
 void setLayoutMode(byte layoutMode)
          Sets the layout mode this layouter should use for upcoming layouts.
 void setMinimumLayerDistance(double d)
          Sets the minimum distance between two adjacent layers.
 void setNodeLayoutDescriptor(NodeLayoutDescriptor nodeLayoutDescriptor)
          Sets the NodeLayoutDescriptor instance used for all nodes that don't have a layout descriptor assigned.
 void setNodePlacer(NodePlacer nodePlacer)
          Sets the NodePlacer instance that will be used to calculated the final node placement of the layout.
 void setNodeToEdgeDistance(double d)
          Sets the minimum distance between an edge and an adjacent node in one layer.
 void setNodeToNodeDistance(double d)
          Sets the minimum distance between two adjacent nodes in one layer.
 void setRecursiveGroupLayeringEnabled(boolean recursiveGroupLayeringEnabled)
          Control whether groups are respected during the layering stage.
protected  void unconfigureCoreLayout(LayoutGraph graph, HierarchicLayouter ihl)
          Called after the actual layout is performed.
 
Methods inherited from class y.layout.CanonicMultiStageLayouter
appendStage, calcLayout, calcLayout, canLayout, doLayout, doLayout, enableOnlyCore, getComponentLayouter, getGroupNodeHider, getLabelLayouter, getLayoutOrientation, getOrientationLayouter, getParallelEdgeLayouter, getSelfLoopLayouter, getSubgraphLayouter, isComponentLayouterEnabled, isGroupNodeHidingEnabled, isLabelLayouterEnabled, isOrientationLayouterEnabled, isParallelEdgeLayouterEnabled, isSelfLoopLayouterEnabled, isSubgraphLayouterEnabled, prependStage, removeStage, setComponentLayouter, setComponentLayouterEnabled, setGroupNodeHider, setGroupNodeHidingEnabled, setLabelLayouter, setLabelLayouterEnabled, setLayoutOrientation, setOrientationLayouter, setOrientationLayouterEnabled, setParallelEdgeLayouter, setParallelEdgeLayouterEnabled, setSelfLoopLayouter, setSelfLoopLayouterEnabled, setSubgraphLayouter, setSubgraphLayouterEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INCREMENTAL_HINTS_DPKEY

public static final Object INCREMENTAL_HINTS_DPKEY
DataProvider key used to store incremental layout hints that can be retrieved from the IncrementalHintsFactory which itself can be obtained from the createIncrementalHintsFactory() method.

See Also:
HierarchicLayouter.INCREMENTAL_HINTS_DPKEY

LAYER_VALUE_HOLDER_DPKEY

public static final Object LAYER_VALUE_HOLDER_DPKEY
DataProvider key used to store IntValueHolder for each node in the graph. If the algorithm finds this key it will write back the integer layer ids of each node using the IntValueHolder instances obtained from the DataProvider that is bound to the graph using this key.

See Also:
HierarchicLayouter.LAYER_VALUE_HOLDER_DPKEY

SWIMLANE_DESCRIPTOR_DPKEY

public static final Object SWIMLANE_DESCRIPTOR_DPKEY
DataProvider key used to store SwimLaneDescriptor instances for each node in the graph. If this key is present during the layout. The layout algorithm will arrange nodes in swim lanes. The information about the swim lanes is finally written back into the descriptor instances. Instances can be shared among multiple nodes in the same lane, but don't have to be shared.

See Also:
HierarchicLayouter.SWIMLANE_DESCRIPTOR_DPKEY

LAYOUT_MODE_INCREMENTAL

public static final byte LAYOUT_MODE_INCREMENTAL
Layout mode constant that can be used in setLayoutMode(byte). This constant sets the layout algorithm to incremental mode, i.e. fixed elements will be handled by the fixedElementsSequencer and fixedElementsLayerer and elements marked for incremental layout will be added to the drawing later.

See Also:
IncrementalHintsFactory.createSequenceIncrementallyHint(y.base.Edge), IncrementalHintsFactory.createLayerIncrementallyHint(y.base.Node), setLayoutMode(byte), getLayoutMode(), setFixedElementsSequencer(Sequencer), setFixedElementsLayerer(Layerer), Constant Field Values

LAYOUT_MODE_FROM_SCRATCH

public static final byte LAYOUT_MODE_FROM_SCRATCH
Layout mode constant that can be used in setLayoutMode(byte). This constant sets the layout algorithm to "from scratch mode", i.e. the algorithm will recompute the layout from scratch.

See Also:
setLayoutMode(byte), getLayoutMode(), setFromScratchSequencer(Sequencer), setFromScratchLayerer(Layerer), Constant Field Values

LAYERING_STRATEGY_HIERARCHICAL_TOPMOST

public static final byte LAYERING_STRATEGY_HIERARCHICAL_TOPMOST
Layering strategy constant. A simple hierarchical layering variant. All nodes with indegree zero will be assigned to the topmost layer of the layout. The number of separate layers will be as small as possible.

See Also:
setFromScratchLayeringStrategy(byte), Constant Field Values

LAYERING_STRATEGY_HIERARCHICAL_OPTIMAL

public static final byte LAYERING_STRATEGY_HIERARCHICAL_OPTIMAL
Layering strategy specifier. An optimal hierarchical layering strategy. The layer distance of an edge is the absolute difference between the layer numbers of its source and target node. Layer assignment will be done in such a way that the overall sum of the layer distances of all edges in the layout is minimal.

See Also:
setFromScratchLayeringStrategy(byte), Constant Field Values

LAYERING_STRATEGY_HIERARCHICAL_TIGHT_TREE

public static final byte LAYERING_STRATEGY_HIERARCHICAL_TIGHT_TREE
Layering strategy specifier. A heuristic that approximates the ranking done by LAYERING_STRATEGY_HIERARCHICAL_OPTIMAL.

See Also:
setFromScratchLayeringStrategy(byte), Constant Field Values

LAYERING_STRATEGY_HIERARCHICAL_DOWNSHIFT

public static final byte LAYERING_STRATEGY_HIERARCHICAL_DOWNSHIFT
Layering strategy specifier. A fast heuristic that improves the the ranking done by LAYERING_STRATEGY_HIERARCHICAL_TOPMOST by down shifting some nodes in the layering. The quality is usually worse than the one produced by Tight Tree Heuristic.

See Also:
setFromScratchLayeringStrategy(byte), Constant Field Values

LAYERING_STRATEGY_BFS

public static final byte LAYERING_STRATEGY_BFS
Layering strategy specifier. Layering based on a breadth first search (bfs). All edges will span at most one layer in the resulting drawing. Edges between nodes that belong to the same layer are possible. The nodes that will be placed in the first layer can be provided by a dataprovider bound to the input graph using the key BFSLayerer.CORE_NODES. If this dataprovider is not given, then nodes that have no incoming edges are placed in the first layer.

See Also:
setFromScratchLayeringStrategy(byte), Constant Field Values

LAYERING_STRATEGY_FROM_SKETCH

public static final byte LAYERING_STRATEGY_FROM_SKETCH
Layering strategy specifier. A layer assignment strategy that uses the initial y-coordinates of the nodes (x-coordinates when the layout orientation is horizontal) to determine a node layering. It tries to find a layering that is similar to the one in the input graph. When this layering strategy is used, the layouter may place nodes in the same layer, even though they are connected by an edge. These inner layer edges are always routed in an orthogonal style.

See Also:
setFromScratchLayeringStrategy(byte), Constant Field Values

LAYERING_STRATEGY_USER_DEFINED

public static final byte LAYERING_STRATEGY_USER_DEFINED
Layering strategy specifier. The ranks of the nodes will be given by the user. The node ranks must be provided by a dataprovider bound to the input graph using the key GivenLayersLayerer.LAYER_ID_KEY. Like LAYERING_STRATEGY_FROM_SKETCH this layering allows inner layer edges.

See Also:
setFromScratchLayeringStrategy(byte), Constant Field Values

LAYERING_STRATEGY_UNKNOWN

public static final byte LAYERING_STRATEGY_UNKNOWN
Dummy layering strategy specifier. Returned by getFromScratchLayeringStrategy() if the current strategy is not known.

See Also:
Constant Field Values

POLICY_ALIGN_GROUPS_TOP

public static final byte POLICY_ALIGN_GROUPS_TOP
Group layering alignment strategy specifier. If recursive group layering is enabled, groups and normal nodes that occupy the same layer are top aligned with respect to their inner layers.

See Also:
setGroupAlignmentPolicy(byte), setRecursiveGroupLayeringEnabled(boolean), Constant Field Values

POLICY_ALIGN_GROUPS_CENTER

public static final byte POLICY_ALIGN_GROUPS_CENTER
Group layering alignment strategy specifier. If recursive group layering is enabled, groups and normal nodes that occupy the same layer are center aligned with respect to their inner layers.

See Also:
setGroupAlignmentPolicy(byte), setRecursiveGroupLayeringEnabled(boolean), Constant Field Values

POLICY_ALIGN_GROUPS_BOTTOM

public static final byte POLICY_ALIGN_GROUPS_BOTTOM
Group layering alignment strategy specifier. If recursive group layering is enabled, groups and normal nodes that occupy the same layer are bottom aligned with respect to their inner layers.

See Also:
setGroupAlignmentPolicy(byte), setRecursiveGroupLayeringEnabled(boolean), Constant Field Values
Constructor Detail

IncrementalHierarchicLayouter

public IncrementalHierarchicLayouter()
Creates a new IncrementalHierarchicLayouter instance which is set to LAYOUT_MODE_FROM_SCRATCH initially

See Also:
setLayoutMode(byte)
Method Detail

getGroupAlignmentPolicy

public byte getGroupAlignmentPolicy()
Get the group layer alignment strategy used for recursive group layering.

Default value is POLICY_ALIGN_GROUPS_CENTER.

Returns:
a layering strategy specifier for relative group layer alignment
See Also:
setGroupAlignmentPolicy(byte), POLICY_ALIGN_GROUPS_TOP, POLICY_ALIGN_GROUPS_CENTER, POLICY_ALIGN_GROUPS_BOTTOM, setRecursiveGroupLayeringEnabled(boolean)

setGroupAlignmentPolicy

public void setGroupAlignmentPolicy(byte groupAlignmentPolicy)
Set the group layer alignment strategy used for recursive group layering.

Default value is POLICY_ALIGN_GROUPS_CENTER.

Parameters:
groupAlignmentPolicy - a layering strategy specifier for relative group layer alignment, one of POLICY_ALIGN_GROUPS_TOP, POLICY_ALIGN_GROUPS_CENTER or POLICY_ALIGN_GROUPS_BOTTOM
See Also:
getGroupAlignmentPolicy(), POLICY_ALIGN_GROUPS_TOP, POLICY_ALIGN_GROUPS_CENTER, POLICY_ALIGN_GROUPS_BOTTOM, setRecursiveGroupLayeringEnabled(boolean)

isGroupCompactionEnabled

public boolean isGroupCompactionEnabled()
Return whether layer compaction for recursive group layering is active.

Returns:
true iff group compaction is active.
See Also:
setRecursiveGroupLayeringEnabled(boolean), setGroupCompactionEnabled(boolean)

setGroupCompactionEnabled

public void setGroupCompactionEnabled(boolean groupCompactionEnabled)
Set whether layer compaction for recursive group layering should be used. If set to true, the recursive layering is compacted, i.e. node ranks are decreased if possible without reversing edge directions. This differs from non-recursive layering, where groups are ignored completely. The resulting layering tries to keep the layer span of a group node minimal, while minimizing the overall vertical space.

By default, this feature is disabled.

Note:
This feature works best when a instance of TopologicalLayerer is used for layer assignment. If this feature is enabled, an alignment policy that is set with setGroupAlignmentPolicy(byte) is ignored.

Parameters:
groupCompactionEnabled - true iff group compaction is active.
See Also:
isGroupCompactionEnabled(), setRecursiveGroupLayeringEnabled(boolean)

isRecursiveGroupLayeringEnabled

public boolean isRecursiveGroupLayeringEnabled()
Return whether groups are respected during the layering stage.

Returns:
true iff group information is used
See Also:
setRecursiveGroupLayeringEnabled(boolean)

setRecursiveGroupLayeringEnabled

public void setRecursiveGroupLayeringEnabled(boolean recursiveGroupLayeringEnabled)
Control whether groups are respected during the layering stage.

If set to true (and group compaction is not enabled), groups are layered recursively, i.e.

If this feature is disabled, group information is ignored for the layering step.
If the graph is flat, this setting is ignored.

By default, this feature is enabled.

Parameters:
recursiveGroupLayeringEnabled - true iff group information is used
See Also:
isRecursiveGroupLayeringEnabled()

setIntegratedEdgeLabelingEnabled

public void setIntegratedEdgeLabelingEnabled(boolean enabled)
Enables integrated edge labeling. This method is a convenience method that assures that the label layouter is of type LabelLayoutTranslator and LabelLayoutTranslator.setTranslateEdgeLabelsEnabled(boolean) is set to true

Throws:
IllegalStateException - if the current label layouter is not of type LabelLayoutTranslator.
Parameters:
enabled - whether to enable this feature

isIntegratedEdgeLabelingEnabled

public boolean isIntegratedEdgeLabelingEnabled()
Checks whether the integrated edge labeling is enabled. This method is a convenience method that checks if the label layouter is of type LabelLayoutTranslator and LabelLayoutTranslator.isTranslateEdgeLabelsEnabled() returns true.
The default is false.

Throws:
IllegalStateException - if the current label layouter is not of type LabelLayoutTranslator.
Returns:
whether this feature is enabled

setConsiderNodeLabelsEnabled

public void setConsiderNodeLabelsEnabled(boolean enabled)
Enables node label consideration. This method is a convenience method that assures that the label layouter is of type LabelLayoutTranslator and LabelLayoutTranslator.setTranslateNodeLabelsEnabled(boolean) is set to true

Throws:
IllegalStateException - if the current label layouter is not of type LabelLayoutTranslator.
Parameters:
enabled - whether to enable this feature

isConsiderNodeLabelsEnabled

public boolean isConsiderNodeLabelsEnabled()
Checks whether node label consideration is enabled. This method is a convenience method checks whether the label layouter is of type LabelLayoutTranslator and LabelLayoutTranslator.isTranslateNodeLabelsEnabled() returns true.
The default is false.

Throws:
IllegalStateException - if the current label layouter is not of type LabelLayoutTranslator.
Returns:
whether this feature is enabled

setMinimumLayerDistance

public void setMinimumLayerDistance(double d)
Sets the minimum distance between two adjacent layers.

Parameters:
d - the minimum distance to use

getMinimumLayerDistance

public double getMinimumLayerDistance()
Returns the minimum distance between two adjacent layers. The default is 20.0d.

Returns:
the minimum distance to use

setNodeToNodeDistance

public void setNodeToNodeDistance(double d)
Sets the minimum distance between two adjacent nodes in one layer. See NodeLayoutDescriptor.getMinimumDistance() for related settings.

Parameters:
d - the minimum distance to use

getNodeToNodeDistance

public double getNodeToNodeDistance()
Returns the minimum distance between two adjacent nodes in one layer. The default is 30.0d.

Returns:
the minimum distance to use

setNodeToEdgeDistance

public void setNodeToEdgeDistance(double d)
Sets the minimum distance between an edge and an adjacent node in one layer. See NodeLayoutDescriptor.getMinimumDistance() and EdgeLayoutDescriptor.getMinimumDistance() for related settings.

Parameters:
d - the minimum distance to use

getNodeToEdgeDistance

public double getNodeToEdgeDistance()
Returns the minimum distance between two adjacent nodes in one layer. The default is 15.0d.

Returns:
the minimum distance to use

setEdgeToEdgeDistance

public void setEdgeToEdgeDistance(double d)
Sets the minimum distance between two adjacent edges in one layer. See EdgeLayoutDescriptor.getMinimumDistance() for related settings.

Parameters:
d - the minimum distance to use

getEdgeToEdgeDistance

public double getEdgeToEdgeDistance()
Returns the minimum distance between two adjacent edges in one layer. See EdgeLayoutDescriptor.getMinimumDistance() for related settings.

Returns:
the minimum distance to use

getDefaultDrawingDistanceCalculator

protected DefaultDrawingDistanceCalculator getDefaultDrawingDistanceCalculator()
Helper method that returns the DefaultDrawingDistanceCalculator that is registered with the layout algorithm by default.

Throws:
IllegalStateException - if the current instance returned by HierarchicLayouter.getDrawingDistanceCalculator() is not an instance of DefaultDrawingDistanceCalculator
Returns:
the current DefaultDrawingDistanceCalculator

createHierarchicLayouter

protected HierarchicLayouter createHierarchicLayouter()
Factory method that creates the internally used HierarchicLayouter instance.

Returns:
new y.layout.hierarchic.incremental.HierarchicLayouter()

getHierarchicLayouter

public HierarchicLayouter getHierarchicLayouter()
Convenience method that provides access to the internally used HierarchicLayouter instance.

Returns:
the internal layouter instance
See Also:
createHierarchicLayouter()

setFromScratchLayeringStrategy

public void setFromScratchLayeringStrategy(byte strategy)
Convenience method that sets a predefined layering strategy for the from scratch layerer. The layouter assigns the nodes to separate layers. The nodes within each layer will be placed on the same horizontal layer. The layers will be arranged vertically starting with the small-numbered layers. The rank of a node is the number of the layer it belongs to.

An important layering strategy for the hierarchic layout style is called Hierarchical Layering. A hierarchical layering tries to assign nodes to layers in a way that as much as possible edges of the graph will point to the main layout direction, i.e. the start nodes of the edges will have a smaller rank than the corresponding end nodes. Also, a hierarchical layering will never put two connected nodes in the same layer.

By default the layering strategy LAYERING_STRATEGY_HIERARCHICAL_OPTIMAL is set.

This method wraps the internal implementations into a MultiComponentLayerer instance so that it is possible to specify the behavior of the algorithm if the component layouter is disabled.

Parameters:
strategy - one of LAYERING_STRATEGY_HIERARCHICAL_TOPMOST, LAYERING_STRATEGY_HIERARCHICAL_DOWNSHIFT, LAYERING_STRATEGY_HIERARCHICAL_TIGHT_TREE, LAYERING_STRATEGY_HIERARCHICAL_OPTIMAL, LAYERING_STRATEGY_FROM_SKETCH, LAYERING_STRATEGY_USER_DEFINED or LAYERING_STRATEGY_BFS.

getFromScratchLayeringStrategy

public byte getFromScratchLayeringStrategy()
Returns the currently set layering strategy for the from scratch layering.

Returns:
a byte constant as defined in this class or LAYERING_STRATEGY_UNKNOWN if the strategy is unknown.
See Also:
setFromScratchLayeringStrategy(byte)

canLayoutCore

public boolean canLayoutCore(LayoutGraph graph)
Determines whether this layouter can perform the core layout on the given graph.

Specified by:
canLayoutCore in class CanonicMultiStageLayouter

doLayoutCore

public void doLayoutCore(LayoutGraph g)
Performs the actual layout using the currently set mode.

Specified by:
doLayoutCore in class CanonicMultiStageLayouter
See Also:
setLayoutMode(byte), getLayoutMode(), configureCoreLayout(LayoutGraph,y.layout.hierarchic.incremental.HierarchicLayouter), unconfigureCoreLayout(LayoutGraph,y.layout.hierarchic.incremental.HierarchicLayouter)

configureCoreLayout

protected void configureCoreLayout(LayoutGraph graph,
                                   HierarchicLayouter ihl)
Called before the actual layout is performed. Overwrite this to manually reconfigure the instance. If PortCandidateSet.NODE_DP_KEY is registered with the layout graph and there is no HierarchicLayouter.getPortConstraintOptimizer() registered, PCListOptimizer will be temporarily configured with the instance.

Parameters:
graph - the graph to be laid out
ihl - the instance used for the core layout.

unconfigureCoreLayout

protected void unconfigureCoreLayout(LayoutGraph graph,
                                     HierarchicLayouter ihl)
Called after the actual layout is performed. Overwrite this to manually unconfigure the instance. If PortCandidateSet.NODE_DP_KEY is registered with the layout graph and PCListOptimizer was registered with the instance during configureCoreLayout(y.layout.LayoutGraph,y.layout.hierarchic.incremental.HierarchicLayouter) it will be removed by this method.

Parameters:
graph - the graph to be laid out
ihl - the instance used for the core layout.

createIncrementalHintsFactory

public IncrementalHintsFactory createIncrementalHintsFactory()
Returns a IncrementalHintsFactory instance that must be used to obtain marks that can be associated with elements in the graph that will be laid out incrementally.
Use this factory and a DataProvider that is bound to the graph using the INCREMENTAL_HINTS_DPKEY DataProvider key to associate appropriate hints with the elements in the graph that should be laid out incrementally by the algorithm.

Returns:
the factory
See Also:
HierarchicLayouter.createIncrementalHintsFactory(), INCREMENTAL_HINTS_DPKEY, Graph.addDataProvider(Object,DataProvider), setLayoutMode(byte), LAYOUT_MODE_INCREMENTAL

getFromScratchLayerer

public Layerer getFromScratchLayerer()
Returns the Layerer instance that is used to obtain the layering for the nodes if the layouter is set to LAYOUT_MODE_FROM_SCRATCH.

Returns:
the layerer for LAYOUT_MODE_FROM_SCRATCH mode.
See