|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.layout.CanonicMultiStageLayouter
y.layout.hierarchic.IncrementalHierarchicLayouter
public class IncrementalHierarchicLayouter
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 fall-back 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 swim lanes):

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. |
SequenceConstraintFactory |
createSequenceConstraintFactory(LayoutGraph graph)
Returns a SequenceConstraintFactory
instance that can be used to specify sequence constraints for the given
graph. |
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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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.
HierarchicLayouter.INCREMENTAL_HINTS_DPKEYpublic 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.
HierarchicLayouter.LAYER_VALUE_HOLDER_DPKEYpublic 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.
HierarchicLayouter.SWIMLANE_DESCRIPTOR_DPKEYpublic static final byte LAYOUT_MODE_INCREMENTAL
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.
IncrementalHintsFactory.createLayerIncrementallyHint(Object),
setLayoutMode(byte),
getLayoutMode(),
setFixedElementsSequencer(Sequencer),
setFixedElementsLayerer(Layerer),
Constant Field Valuespublic static final byte LAYOUT_MODE_FROM_SCRATCH
setLayoutMode(byte).
This constant sets the layout algorithm to "from scratch mode", i.e.
the algorithm will recompute the layout from scratch.
setLayoutMode(byte),
getLayoutMode(),
setFromScratchSequencer(Sequencer),
setFromScratchLayerer(Layerer),
Constant Field Valuespublic static final byte LAYERING_STRATEGY_HIERARCHICAL_TOPMOST
setFromScratchLayeringStrategy(byte),
Constant Field Valuespublic static final byte LAYERING_STRATEGY_HIERARCHICAL_OPTIMAL
setFromScratchLayeringStrategy(byte),
Constant Field Valuespublic static final byte LAYERING_STRATEGY_HIERARCHICAL_TIGHT_TREE
LAYERING_STRATEGY_HIERARCHICAL_OPTIMAL.
setFromScratchLayeringStrategy(byte),
Constant Field Valuespublic static final byte LAYERING_STRATEGY_HIERARCHICAL_DOWNSHIFT
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.
setFromScratchLayeringStrategy(byte),
Constant Field Valuespublic static final byte LAYERING_STRATEGY_BFS
BFSLayerer.CORE_NODES.
If this data provider is not given, then nodes that have no incoming edges are placed
in the first layer.
setFromScratchLayeringStrategy(byte),
Constant Field Valuespublic static final byte LAYERING_STRATEGY_FROM_SKETCH
setFromScratchLayeringStrategy(byte),
Constant Field Valuespublic static final byte LAYERING_STRATEGY_USER_DEFINED
GivenLayersLayerer.LAYER_ID_KEY. Like
LAYERING_STRATEGY_FROM_SKETCH this layering allows inner layer edges.
setFromScratchLayeringStrategy(byte),
Constant Field Valuespublic static final byte LAYERING_STRATEGY_UNKNOWN
getFromScratchLayeringStrategy() if the current strategy
is not known.
public static final byte POLICY_ALIGN_GROUPS_TOP
setGroupAlignmentPolicy(byte),
setRecursiveGroupLayeringEnabled(boolean),
Constant Field Valuespublic static final byte POLICY_ALIGN_GROUPS_CENTER
setGroupAlignmentPolicy(byte),
setRecursiveGroupLayeringEnabled(boolean),
Constant Field Valuespublic static final byte POLICY_ALIGN_GROUPS_BOTTOM
setGroupAlignmentPolicy(byte),
setRecursiveGroupLayeringEnabled(boolean),
Constant Field Values| Constructor Detail |
|---|
public IncrementalHierarchicLayouter()
LAYOUT_MODE_FROM_SCRATCH initially
setLayoutMode(byte)| Method Detail |
|---|
public byte getGroupAlignmentPolicy()
Default value is POLICY_ALIGN_GROUPS_CENTER.
setGroupAlignmentPolicy(byte),
POLICY_ALIGN_GROUPS_TOP,
POLICY_ALIGN_GROUPS_CENTER,
POLICY_ALIGN_GROUPS_BOTTOM,
setRecursiveGroupLayeringEnabled(boolean)public void setGroupAlignmentPolicy(byte groupAlignmentPolicy)
Default value is POLICY_ALIGN_GROUPS_CENTER.
groupAlignmentPolicy - a layering strategy specifier for relative group layer alignment, one of
POLICY_ALIGN_GROUPS_TOP, POLICY_ALIGN_GROUPS_CENTER or POLICY_ALIGN_GROUPS_BOTTOMgetGroupAlignmentPolicy(),
POLICY_ALIGN_GROUPS_TOP,
POLICY_ALIGN_GROUPS_CENTER,
POLICY_ALIGN_GROUPS_BOTTOM,
setRecursiveGroupLayeringEnabled(boolean)public boolean isGroupCompactionEnabled()
true iff group compaction is active.setRecursiveGroupLayeringEnabled(boolean),
setGroupCompactionEnabled(boolean)public void setGroupCompactionEnabled(boolean groupCompactionEnabled)
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.
groupCompactionEnabled - true iff group compaction is active.isGroupCompactionEnabled(),
setRecursiveGroupLayeringEnabled(boolean)public boolean isRecursiveGroupLayeringEnabled()
true iff group information is usedsetRecursiveGroupLayeringEnabled(boolean)public void setRecursiveGroupLayeringEnabled(boolean recursiveGroupLayeringEnabled)
If set to true (and group compaction is not enabled), groups are layered recursively, i.e.
By default, this feature is enabled.
recursiveGroupLayeringEnabled - true iff group information is usedisRecursiveGroupLayeringEnabled()public void setIntegratedEdgeLabelingEnabled(boolean enabled)
label layouter
is of type LabelLayoutTranslator and
LabelLayoutTranslator.setTranslateEdgeLabelsEnabled(boolean) is set
to true
IllegalStateException - if the current label layouter is not of type
LabelLayoutTranslator.enabled - whether to enable this featurepublic boolean isIntegratedEdgeLabelingEnabled()
label layouter
is of type LabelLayoutTranslator and
LabelLayoutTranslator.isTranslateEdgeLabelsEnabled() returns
true.
false.
IllegalStateException - if the current label layouter is not of type
LabelLayoutTranslator.
public void setConsiderNodeLabelsEnabled(boolean enabled)
label layouter
is of type LabelLayoutTranslator and
LabelLayoutTranslator.setTranslateNodeLabelsEnabled(boolean) is set
to true
IllegalStateException - if the current label layouter is not of type
LabelLayoutTranslator.enabled - whether to enable this featurepublic boolean isConsiderNodeLabelsEnabled()
label layouter
is of type LabelLayoutTranslator and
LabelLayoutTranslator.isTranslateNodeLabelsEnabled() returns
true.
false.
IllegalStateException - if the current label layouter is not of type
LabelLayoutTranslator.
public void setMinimumLayerDistance(double d)
d - the minimum distance to usepublic double getMinimumLayerDistance()
20.0d.
public void setNodeToNodeDistance(double d)
NodeLayoutDescriptor.getMinimumDistance() for related settings.
d - the minimum distance to usepublic double getNodeToNodeDistance()
30.0d.
public void setNodeToEdgeDistance(double d)
NodeLayoutDescriptor.getMinimumDistance() and
EdgeLayoutDescriptor.getMinimumDistance() for related settings.
d - the minimum distance to usepublic double getNodeToEdgeDistance()
15.0d.
public void setEdgeToEdgeDistance(double d)
EdgeLayoutDescriptor.getMinimumDistance() for related settings.
d - the minimum distance to usepublic double getEdgeToEdgeDistance()
EdgeLayoutDescriptor.getMinimumDistance() for related settings.
protected DefaultDrawingDistanceCalculator getDefaultDrawingDistanceCalculator()
DefaultDrawingDistanceCalculator
that is registered with the layout algorithm by default.
IllegalStateException - if the current instance returned
by HierarchicLayouter.getDrawingDistanceCalculator()
is not an instance of DefaultDrawingDistanceCalculator
protected HierarchicLayouter createHierarchicLayouter()
HierarchicLayouter
instance.
new y.layout.hierarchic.incremental.HierarchicLayouter()public HierarchicLayouter getHierarchicLayouter()
HierarchicLayouter instance.
createHierarchicLayouter()public void setFromScratchLayeringStrategy(byte strategy)
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.
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.public byte getFromScratchLayeringStrategy()
from scratch layering.
LAYERING_STRATEGY_UNKNOWN if
the strategy is unknown.setFromScratchLayeringStrategy(byte)public boolean canLayoutCore(LayoutGraph graph)
canLayoutCore in class CanonicMultiStageLayouterpublic void doLayoutCore(LayoutGraph g)
doLayoutCore in class CanonicMultiStageLayoutersetLayoutMode(byte),
getLayoutMode(),
configureCoreLayout(LayoutGraph,y.layout.hierarchic.incremental.HierarchicLayouter),
unconfigureCoreLayout(LayoutGraph,y.layout.hierarchic.incremental.HierarchicLayouter)
protected void configureCoreLayout(LayoutGraph graph,
HierarchicLayouter ihl)
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.
graph - the graph to be laid outihl - the instance used for the core layout.
protected void unconfigureCoreLayout(LayoutGraph graph,
HierarchicLayouter ihl)
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.
graph - the graph to be laid outihl - the instance used for the core layout.public IncrementalHintsFactory createIncrementalHintsFactory()
IncrementalHintsFactory instance that must be used
to obtain marks that can be associated with elements in the graph that
will be laid out incrementally. 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.
HierarchicLayouter.createIncrementalHintsFactory(),