|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.CanonicMultiStageLayouter y.layout.hierarchic.incremental.HierarchicLayouter
public class HierarchicLayouter
This class can be used to create hierarchical layouts of graphs. It has built-in support for incrementally adding elements to a previously calculated layout or optimizing existing elements of a previously calculated layout.
In order to customize this layout algorithm, modify theLayerer
, Sequencer
,
PortAllocator
,
DrawingDistanceCalculator
, and
NodePlacer
instances.
Use the INCREMENTAL_HINTS_DPKEY
DataProvider
key to
associate incremental hints with the elements in the graph.
IncrementalHintsFactory
.
They are used by the algorithm to determine which elements in the graph
have to be inserted/updated incrementally.
This layout algorithm respects PortConstraint
s, that are bound to
the graph using the PortConstraintKeys.SOURCE_PORT_CONSTRAINT_KEY
and
PortConstraintKeys.TARGET_PORT_CONSTRAINT_KEY
as well as
PortConstraintKeys.SOURCE_GROUPID_KEY
and
PortConstraintKeys.TARGET_GROUPID_KEY
DataProviders that can be used
to create bus-like edge routings.
Fine-grained configuration of the layout style
is supported via DataProviders that are bound to the graph using the
EDGE_LAYOUT_DESCRIPTOR_DPKEY
and NODE_LAYOUT_DESCRIPTOR_DPKEY
DataProvider keys.
NodeLayoutDescriptor
and
EdgeLayoutDescriptor
instances with each element in the graph. These
may be shared.
This algorithm sets a LabelLayoutTranslator
instance as the current
CanonicMultiStageLayouter.getLabelLayouter()
and configures it so that
the node labels are passed to by setting LabelLayoutTranslator.setTranslateNodeLabelsEnabled(boolean)
to true
.
LabelLayoutTranslator
is registered and edge labels are being translated
and written back after the layout.
This algorithm also support swimlane style drawings. This can be enabled by
associating SwimLaneDescriptor
instances with the nodes in the graph
using the SWIMLANE_DESCRIPTOR_DPKEY
DataProvider key.
Moreover, this algorithm supports sequence constraints. These constraints
can be specified using a SequenceConstraintFactory
.
IncrementalHierarchicLayouter
,
Layerer
,
Sequencer
,
PortAllocator
,
DrawingDistanceCalculator
,
NodePlacer
Nested Class Summary | |
---|---|
static class |
HierarchicLayouter.IncrementalHint
Hint objects used internally by this layout algorithm implementation. |
Field Summary | |
---|---|
static Object |
EDGE_LAYOUT_DESCRIPTOR_DPKEY
DataProvider key used to retrieve EdgeLayoutDescriptor
instances for each edge in the graph. |
static Object |
INCREMENTAL_HINTS_DPKEY
DataProvider key used to retrieve incremental layout hint
objects for nodes and edges that have been set using the IncrementalHintsFactory
which itself can be obtained from the
createIncrementalHintsFactory() method. |
static Object |
INCREMENTAL_NODES_DPKEY
DataProvider key used to hold boolean values for each node in the graph that indicate whether the node has to be added incrementally. |
static Object |
LAYER_VALUE_HOLDER_DPKEY
Used for publishing the final layering information. |
static Object |
NODE_LAYOUT_DESCRIPTOR_DPKEY
DataProvider key used to retrieve NodeLayoutDescriptor
instances for each node in the graph. |
static Object |
SEQUENCE_VALUE_HOLDER_DPKEY
Used for publishing the final sequencing information. |
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 | |
---|---|
HierarchicLayouter()
Creates a new instance of HierarchicLayouter with default settings. |
Method Summary | |
---|---|
boolean |
canLayoutCore(LayoutGraph graph)
Always returns true. |
protected DrawingDistanceCalculator |
createDrawingDistanceCalculator()
Factory method that is called lazily upon first usage. |
protected EdgeReverser |
createEdgeReverser()
Factory method that is called during doLayoutCore(LayoutGraph) . |
protected Grouping |
createGrouping(LayoutGraph graph)
Factory method that is called during doLayoutCore(LayoutGraph) . |
IncrementalHintsFactory |
createIncrementalHintsFactory()
Returns an IncrementalHintsFactory implementation that can be used to obtain hint objects that can be
associated with nodes and edges in the graph prior to the invocation of the layout algorithm using an appropriate
DataProvider implementation and the INCREMENTAL_HINTS_DPKEY DataProvider key. |
protected Layerer |
createIncrementalLayerer()
Factory method that is called during doLayoutCore(LayoutGraph) . |
protected void |
createItemData(LayoutGraph g,
ItemFactory itemFactory)
Callback method that is called during doLayoutCore(LayoutGraph) . |
protected LayoutStage |
createLabelLayouter()
Factory method for the label layouter
used by this layouter. |
LayerConstraintFactory |
createLayerConstraintFactory(Graph graph)
|
protected Layerer |
createLayerer()
Factory method that is called lazily upon first usage. |
protected Layers |
createLayers(LayoutDataProvider ldp)
Factory method that is called during doLayoutCore(LayoutGraph) . |
protected NodePlacer |
createNodePlacer()
Factory method that is called lazily upon first usage. |
protected PortAllocator |
createPortAllocator()
Factory method that is called lazily upon first usage. |
protected PortConstraintOptimizer |
createPortConstraintOptimizer()
Factory method that is called lazily upon first usage. |
SequenceConstraintFactory |
createSequenceConstraintFactory(Graph graph)
|
protected Sequencer |
createSequencer()
Factory method that is called lazily upon first usage. |
protected Sequencer |
createSubgraphLayerSequencer()
Factory method that is called during doLayoutCore(LayoutGraph) . |
void |
doLayoutCore(LayoutGraph graph)
Layouts the given graph. |
Object |
getAlgorithmProperty(Object key)
Provides access to implementation specific properties of the algorithms used. |
DrawingDistanceCalculator |
getDrawingDistanceCalculator()
Returns the current DrawingDistanceCalculator instance. |
protected DataProvider |
getEdgeLayoutDescriptors(LayoutGraph graph)
Callback method that is called during doLayoutCore(LayoutGraph) . |
protected DataProvider |
getIncrementalHints(LayoutGraph graph)
Callback method that is called during doLayoutCore(LayoutGraph) . |
Layerer |
getLayerer()
Returns the current Layerer instance. |
long |
getMaximalDuration()
Returns the time limit (in milliseconds) set for the layout algorithm. |
protected DataProvider |
getNodeLayoutDescriptors(LayoutGraph graph)
Callback method that is called during doLayoutCore(LayoutGraph) . |
NodePlacer |
getNodePlacer()
Returns the current NodePlacer instance. |
PortAllocator |
getPortAllocator()
Returns the current PortAllocator instance. |
PortConstraintOptimizer |
getPortConstraintOptimizer()
Returns the current PortConstraintOptimizer instance. |
Sequencer |
getSequencer()
Returns the current Sequencer instance. |
protected DataProvider |
getSwimLaneDescriptors(LayoutGraph graph)
Callback method that is called during doLayoutCore(LayoutGraph) . |
protected void |
publishLayers(LayoutGraph graph,
Layers layers)
Callback method that publishes the layering information |
protected void |
publishSequences(LayoutGraph graph,
Layers layers,
LayoutDataProvider ldp)
Callback method that publishes the sequencing information |
protected void |
reduceBendCount(LayoutGraph graph)
Removes bends from the edges which are obviously not necessary. |
void |
setAlgorithmProperty(Object key,
Object value)
Provides access to implementation specific properties of the algorithms used internally. |
void |
setDrawingDistanceCalculator(DrawingDistanceCalculator drawingDistanceCalculator)
Sets the DrawingDistanceCalculator implementation that is used in the next run. |
void |
setLayerer(Layerer layerer)
Sets the Layerer implementation that is used in the next run. |
void |
setMaximalDuration(long maximalDuration)
Sets a preferred time limit (in milliseconds) for the layout algorithm. |
void |
setNodePlacer(NodePlacer placer)
Sets the NodePlacer implementation that is used in the next run. |
void |
setPortAllocator(PortAllocator allocator)
Sets the PortAllocator implementation that is used in the next run. |
void |
setPortConstraintOptimizer(PortConstraintOptimizer optimizer)
Sets the PortConstraintOptimizer implementation that is used in the next run. |
void |
setSequencer(Sequencer sequencer)
Sets the Sequencer implementation that is used in the next run. |
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 retrieve incremental layout hint
objects for nodes and edges that have been set using the IncrementalHintsFactory
which itself can be obtained from the
createIncrementalHintsFactory()
method.
Note that HierarchicLayouter uses the registered DataProvider
to get layout hint objects as well for
nodes as for edges so neither Graph.createNodeMap()
nor Graph.createEdgeMap()
may be used to create this provider.
public static final Object EDGE_LAYOUT_DESCRIPTOR_DPKEY
DataProvider
key used to retrieve EdgeLayoutDescriptor
instances for each edge in the graph. Different settings will affect the
routing of the edges during the layout.
EdgeData.getEdgeLayoutDescriptor()
public static final Object NODE_LAYOUT_DESCRIPTOR_DPKEY
DataProvider
key used to retrieve NodeLayoutDescriptor
instances for each node in the graph. Different settings will affect node
placement and port assignment during the layout.
NodeData.getNodeLayoutDescriptor()
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.
SwimLaneDescriptor
,
NodeData.getSwimLaneDescriptor()
public static final Object LAYER_VALUE_HOLDER_DPKEY
DataProvider
associated to this key is also a
DataAcceptor
, the integer layer id of each node is stored using
the acceptor's setInt
method.
Otherwise, the provider's values should be of type
IntValueHolder
and the value holder's
setValue
method is used to store the
integer layer ids of each node.
public static final Object SEQUENCE_VALUE_HOLDER_DPKEY
DataProvider
associated to this key is also a
DataAcceptor
, the sequence order number of each node is stored
using the acceptor's setInt
method.
Otherwise, the provider's values should be of type
IntValueHolder
and the value holder's
setValue
method is used to store the
sequence order number of each node.
public static final Object INCREMENTAL_NODES_DPKEY
Layerer
, such as
TopologicalIncrementalLayerer
to determine which nodes need to be
inserted incrementally, as well as the Sequencer
implementation
that determines incrementally sequenced nodes.
Constructor Detail |
---|
public HierarchicLayouter()
createLayerer()
,
createIncrementalLayerer()
,
createSequencer()
,
createDrawingDistanceCalculator()
,
createNodePlacer()
Method Detail |
---|
protected LayoutStage createLabelLayouter()
label layouter
used by this layouter.
In order to use the the integrated node label awareness feature one has to
use an LabelLayoutTranslator
instance with
LabelLayoutTranslator.setTranslateNodeLabelsEnabled(boolean)
set to true
. LabelLayoutTranslator.setTranslateEdgeLabelsEnabled(boolean)
must
be set to true
and
LabelLayoutTranslator.setWriteBackEdgeLabelsEnabled(boolean)
must
be set to true
also (which is the default).
LabelLayoutTranslator
with node translation enabled
and "node label write back" disabled.protected Layerer createLayerer()
new MultiComponentLayerer(new OldLayererWrapper(new WeightedLayerer()))
)getLayerer()
,
MultiComponentLayerer
,
OldLayererWrapper
,
WeightedLayerer
public long getMaximalDuration()
setMaximalDuration(long)
public void setMaximalDuration(long maximalDuration)
maximalDuration
- the time limit.getMaximalDuration()
protected Sequencer createSequencer()
new DefaultLayerSequencer()
)getSequencer()
,
DefaultLayerSequencer
protected DrawingDistanceCalculator createDrawingDistanceCalculator()
new DefaultDrawingDistanceCalculator()
)getDrawingDistanceCalculator()
protected PortAllocator createPortAllocator()
new DefaultPortAllocator()
)getPortAllocator()
protected PortConstraintOptimizer createPortConstraintOptimizer()
null
getPortConstraintOptimizer()
protected NodePlacer createNodePlacer()
new SimplexNodePlacer
)getNodePlacer()
,
SimplexNodePlacer
public void setLayerer(Layerer layerer)
createLayerer()
.
NullPointerException
- if the argument is null
layerer
- the new implementation to use.public Layerer getLayerer()
createLayerer()
public void setSequencer(Sequencer sequencer)
createSequencer()
.
NullPointerException
- if the argument is null
sequencer
- the new implementation to use.public Sequencer getSequencer()
createSequencer()
public void setNodePlacer(NodePlacer placer)
createNodePlacer()
.
NullPointerException
- if the argument is null
placer
- the new implementation to use.public NodePlacer getNodePlacer()
createNodePlacer()
public void setPortAllocator(PortAllocator allocator)
createPortAllocator()
.
NullPointerException
- if the argument is null
allocator
- the new implementation to use.public PortAllocator getPortAllocator()
createPortAllocator()
public void setPortConstraintOptimizer(PortConstraintOptimizer optimizer)
createPortConstraintOptimizer()
.
optimizer
- the new implementation to use.public PortConstraintOptimizer getPortConstraintOptimizer()
createPortConstraintOptimizer()
public void setDrawingDistanceCalculator(DrawingDistanceCalculator drawingDistanceCalculator)
createDrawingDistanceCalculator()
.
NullPointerException
- if the argument is null
drawingDistanceCalculator
- the new implementation to use.public DrawingDistanceCalculator getDrawingDistanceCalculator()
createDrawingDistanceCalculator()
public boolean canLayoutCore(LayoutGraph graph)
canLayoutCore
in class CanonicMultiStageLayouter
graph
- the graph to check
true
public Object getAlgorithmProperty(Object key)
key
- the key to a property
null
setAlgorithmProperty(Object,Object)
public void setAlgorithmProperty(Object key, Object value)
key
- the key to a propertyvalue
- the value to associate with the keypublic void doLayoutCore(LayoutGraph graph)
doLayoutCore
in class CanonicMultiStageLayouter
graph
- the graph to layoutprotected Grouping createGrouping(LayoutGraph graph)
doLayoutCore(LayoutGraph)
.
graph
- the graph to obtain the grouping information from.
null
if there is no grouping information associated with the graph.protected DataProvider getIncrementalHints(LayoutGraph graph)
doLayoutCore(LayoutGraph)
.
This method returns a DataProvider that holds the incremental hint information.
graph
- the graph to obtain the information from.
null
INCREMENTAL_HINTS_DPKEY
protected DataProvider getEdgeLayoutDescriptors(LayoutGraph graph)
doLayoutCore(LayoutGraph)
.
This method returns a DataProvider that holds the EdgeLayoutDescriptor information.
graph
- the graph to obtain the information from.
null
EdgeLayoutDescriptor
,
EDGE_LAYOUT_DESCRIPTOR_DPKEY
protected DataProvider getNodeLayoutDescriptors(LayoutGraph graph)
doLayoutCore(LayoutGraph)
.
This method returns a DataProvider that holds the NodeLayoutDescriptor information.
graph
- the graph to obtain the information from.
null
NodeLayoutDescriptor
,
NODE_LAYOUT_DESCRIPTOR_DPKEY
protected DataProvider getSwimLaneDescriptors(LayoutGraph graph)
doLayoutCore(LayoutGraph)
.
This method returns a DataProvider that holds the SwimLaneDescriptor information.
graph
- the graph to obtain the information from.
null
SwimLaneDescriptor
,
SWIMLANE_DESCRIPTOR_DPKEY
protected void createItemData(LayoutGraph g, ItemFactory itemFactory)
doLayoutCore(LayoutGraph)
. This method creates the NodeData
and EdgeData
instances and binds them to the elements using the itemFactory.
g
- the graph to obtain the grouping information from.itemFactory
- the ItemFactory to useprotected Sequencer createSubgraphLayerSequencer()
doLayoutCore(LayoutGraph)
.
protected Layers createLayers(LayoutDataProvider ldp)
doLayoutCore(LayoutGraph)
.
Creates an appropriate Layers implementation using the LayoutDataProvider
ldp
- provides the layout data
protected Layerer createIncrementalLayerer()
doLayoutCore(LayoutGraph)
.
Creates an appropriate IncrementalLayerer implementation
protected EdgeReverser createEdgeReverser()
doLayoutCore(LayoutGraph)
.
Creates an appropriate EdgeReverser implementation
protected void publishLayers(LayoutGraph graph, Layers layers)
graph
- the graph that contains the elementslayers
- the Layers implementation to get the layering information fromLAYER_VALUE_HOLDER_DPKEY
protected void publishSequences(LayoutGraph graph, Layers layers, LayoutDataProvider ldp)
graph
- the graph that contains the elementslayers
- the Layers implementation to get the layering information fromldp
- the LayoutDataProvider
to get the node information fromSEQUENCE_VALUE_HOLDER_DPKEY
protected void reduceBendCount(LayoutGraph graph)
graph
- the graph to obtain the edges frompublic IncrementalHintsFactory createIncrementalHintsFactory()
IncrementalHintsFactory
implementation that can be used to obtain hint objects that can be
associated with nodes and edges in the graph prior to the invocation of the layout algorithm using an appropriate
DataProvider
implementation and the INCREMENTAL_HINTS_DPKEY
DataProvider key.
INCREMENTAL_HINTS_DPKEY
public SequenceConstraintFactory createSequenceConstraintFactory(Graph graph)
public LayerConstraintFactory createLayerConstraintFactory(Graph graph)
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |