|
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.HierarchicLayouter
public class HierarchicLayouter
This layout algorithm arranges graphs in a hierarchic/layered fashion.
Note that class IncrementalHierarchicLayouter
offers a newer, improved implementation and should be used
instead.
The nodes are distributed into layers such that most of the edges point to the main layout direction. The order of the nodes within the layers ensures that the number of edge crossings is as small as possible. There are different edge routing styles available. Edges can be orthogonal or polyline.
Hierarchical diagrams are commonly used for the visualization of hierarchical data, since they facilitate the identification of dependencies and relationships among the nodes of the graph. Possible application domains are the following: workflow visualization, call graph visualization, entity-relationship diagrams, biochemical pathways and network management.
Hierarchic layout obtained with default settings
The layout algorithm runs in three main phases:
getLayerer()
. If the layout orientation is
top-to-bottom, the nodes in each layer are arranged horizontally while the layers are ordered vertically
top-to-bottom.
setLayerSequencer(LayerSequencer)
.
In order to customize this layout algorithm, modify the Layerer
, getLayerSequencer()
,
getDrawer()
instances.
HierarchicLayouter
supports two approaches to connect edges on a specific side or even an exact location
to a node. PortConstraint
s define a single constraint for the ports of an edge. To realize more
complex port restrictions, several PortCandidate
s or PortCandidateSet
s can be
assigned to edges or nodes. If an edge with registered PortCandidate
s connects to nodes with PortCandidateSet
s,
the layouter will try to match both collections to find an appropriate port. In case there is no matching port
candidate, a PortCandidate
specified for the edge is preferred.
Since their simultaneous existence at the same node may be ambiguous, it is not recommended to use a combination of
PortConstraint
s and PortCandidate
s in the same layout.
HierarchicLayouter
can consider edge label data when laying out a graph. This means that the layout of
edge labels will be part of the resulting layout and the layout of nodes and edges is chosen in such a way that the
edge labels do not conflict with the rest of the layout. In order to enable integrated edge labeling of this
algorithm, make sure LabelLayoutTranslator
is registered and edge labels are being translated and written
back after the layout.
Moreover, this algorithm supports layer constraints using a ConstraintLayerer
instance.
Field Summary | |
---|---|
static byte |
LAYERING_BFS
A layering strategy based on a breadth first search (BFS). |
static byte |
LAYERING_FROM_SKETCH
A layering strategy which derives the layers from the initial coordinates of the nodes. |
static byte |
LAYERING_HIERARCHICAL_DOWNSHIFT
A layering strategy which applies a fast heuristic that improves the layering done by LAYERING_HIERARCHICAL_TOPMOST by shifting
some nodes down. |
static byte |
LAYERING_HIERARCHICAL_OPTIMAL
A layering strategy which places each node in the optimal layer to minimize the layer distances. |
static byte |
LAYERING_HIERARCHICAL_TIGHT_TREE
A layering strategy which applies a heuristic to approximate the optimal layering . |
static byte |
LAYERING_HIERARCHICAL_TOPMOST
A layering strategy which places each node in the highest possible layer without passing its predecessor in the topological order of nodes. |
static byte |
LAYERING_STRATEGY_UNKNOWN
A dummy layering strategy which describes a strategy that is not part of the default strategies. |
static byte |
LAYERING_USER_DEFINED
A layering strategy which uses a layer assignment specified by the user. |
static byte |
LINEAR_SEGMENTS
A layout style that draws the edges with at most two bends per edge unless two edges cross. |
static byte |
MEDIAN_SIMPLEX
A layout style that produces layouts similar to SIMPLEX , but more symmetric for the cost
of a few more bends. |
static byte |
PENDULUM
A layout style that draws the edges such that nodes are balanced nicely and the number of bends on an edge is maintained small. |
static byte |
POLYLINE
A layout style that draws the edges in a polyline fashion. |
static byte |
ROUTE_ORTHOGONAL
An edge routing style that draws the edges in an orthogonal fashion, i.e. |
static byte |
ROUTE_POLYLINE
An edge routing style that draws the edges in a polyline fashion. |
static byte |
SIMPLEX
A layout style that produces tight layouts with rather few bends. |
static byte |
TREE
A layout style that produces nice layouts if the graph is a tree. |
Fields inherited from interface y.layout.PortConstraintKeys |
---|
SOURCE_GROUPID_KEY, SOURCE_PORT_CONSTRAINT_KEY, SOURCE_PORT_GROUP_ID_DPKEY, TARGET_GROUPID_KEY, TARGET_PORT_CONSTRAINT_KEY, TARGET_PORT_GROUP_ID_DPKEY |
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
HierarchicLayouter()
Creates a new HierarchicLayouter instance with the default settings. |
Method Summary | |
---|---|
boolean |
canLayoutCore(LayoutGraph graph)
Accepts general graphs without exceptions. |
void |
disposeMementoSupport()
Disposes of the memento support if there exists one, i.e., if it has been queried before by getMementoSupport() . |
void |
doLayoutCore(LayoutGraph graph)
Calculates a hierarchic layout of the given graph. |
int |
getBendReductionThreshold()
Returns the limit when bends are removed and a straight-line is drawn instead. |
Drawer |
getDrawer()
Returns the Drawer instance responsible for assigning the coordinates to the nodes (third
phase of the layout algorithm). |
Layerer |
getLayerer()
Returns the Layerer instance responsible for generating the layer assignment (first phase of
the layout algorithm). |
byte |
getLayeringStrategy()
Returns the layering strategy of this layout algorithm. |
protected NodeList[] |
getLayerSequence(LayoutGraph graph,
NodeMap layerID,
int maxLayer)
Determines the order of the nodes within their layers. |
LayerSequencer |
getLayerSequencer()
Returns the LayerSequencer instance responsible for calculating the sequence of nodes within
each layer (second phase of the layout algorithm). |
byte |
getLayoutStyle()
Returns the layout style of this layout algorithm. |
long |
getMaximalDuration()
Returns the time limit (in milliseconds) set for the layout algorithm. |
MementoSupport |
getMementoSupport()
Returns the cookie for the memento support of the hierarchic layout algorithm. |
double |
getMinimalEdgeDistance()
Returns the minimum distance between two edges in the same layer. |
double |
getMinimalFirstSegmentLength()
Returns the minimum length of the first segment of the edge path (at the source node). |
double |
getMinimalLayerDistance()
Returns the minimum distance between two layers. |
double |
getMinimalNodeDistance()
Specifies the minimum distance between two nodes in the same layer. |
boolean |
getRemoveFalseCrossings()
Returns whether or not to remove so-called false crossings in an additional phase. |
byte |
getRoutingStyle()
Returns the edge routing style. |
boolean |
isPortConstraintOptimizationEnabled()
Returns whether or not the algorithm should try to optimize PortConstraint s that are either
PortConstraint.ANY_SIDE or null . |
boolean |
isSameLayerEdgeRoutingOptimizationEnabled()
Returns whether or not the algorithm should try to optimize the routing of same-layer edges whose PortConstraint s don't impose the routing. |
void |
setBendReductionThreshold(int t)
Specifies the limit when bends are removed and a straight-line is drawn instead. |
void |
setDrawer(Drawer drawer)
Specifies the Drawer instance responsible for assigning the coordinates to the nodes (third
phase of the layout algorithm). |
void |
setLayerer(Layerer layerer)
Specifies the Layerer instance responsible for generating the layer assignment (first phase of
the layout algorithm). |
void |
setLayeringStrategy(byte strategy)
Specifies the layering strategy of this layout algorithm. |
void |
setLayerSequencer(LayerSequencer sequencer)
Specifies the LayerSequencer instance responsible for calculating the sequence of nodes within
each layer (second phase of the layout algorithm). |
void |
setLayoutStyle(byte style)
Specifies the layout style of this layout algorithm. |
void |
setMaximalDuration(long msec)
Specifies the time limit (in milliseconds) set for the layout algorithm. |
void |
setMinimalEdgeDistance(double d)
Specifies the minimum distance between two edges of the same layer. |
void |
setMinimalFirstSegmentLength(double minimalFirstSegmentLength)
Specifies the minimum length of the first segment of the edge path (at the source node). |
void |
setMinimalLayerDistance(double d)
Specifies the minimum distance between two layers. |
void |
setMinimalNodeDistance(double d)
Specifies the minimum distance between two nodes in the same layer. |
void |
setPortConstraintOptimizationEnabled(boolean enabled)
Specifies whether or not the algorithm should try to optimize PortConstraint s, that are either
PortConstraint.ANY_SIDE or null . |
void |
setRemoveFalseCrossings(boolean b)
Specifies whether or not to remove so-called false crossings in an additional phase. |
void |
setRoutingStyle(byte style)
Specifies the edge routing style. |
void |
setSameLayerEdgeRoutingOptimizationEnabled(boolean enabled)
Determines whether or not the algorithm should try to optimize the routing of same-layer edges whose PortConstraint s don't impose the routing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte PENDULUM
public static final byte LINEAR_SEGMENTS
public static final byte POLYLINE
The resulting layout tends to be compact, but the number of edge bends may be high.
public static final byte TREE
public static final byte SIMPLEX
public static final byte MEDIAN_SIMPLEX
SIMPLEX
, but more symmetric for the cost
of a few more bends.
public static final byte ROUTE_POLYLINE
public static final byte ROUTE_ORTHOGONAL
public static final byte LAYERING_HIERARCHICAL_TOPMOST
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.
public static final byte LAYERING_HIERARCHICAL_OPTIMAL
The layer distance of an edge is the absolute difference between the layer numbers of its source and target node. The layer assignment will minimize the overall sum of the layer distances of all edges in the layout.
public static final byte LAYERING_HIERARCHICAL_TIGHT_TREE
optimal layering
.
The quality of the result may not be as good as with optimal layering
but it is usually achieved faster.
public static final byte LAYERING_HIERARCHICAL_DOWNSHIFT
LAYERING_HIERARCHICAL_TOPMOST
by shifting
some nodes down.
The quality of the result is usually worse than the one produced by
LAYERING_HIERARCHICAL_TOPMOST
.
public static final byte LAYERING_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
data provider bound to the input graph using the key BFSLayerer.CORE_NODES
.
If this data provider is not given, then nodes that have no incoming edges are placed
in the first layer.
public static final byte LAYERING_FROM_SKETCH
It tries to find a layering that is similar to the one in the input graph. The layout algorithm may place nodes in the same layer, even though they are connected by an edge.
In a vertically oriented layout, nodes that overlap vertically are placed in the same layer. The same holds for a horizontally oriented layout in the case where the nodes overlap horizontally.
public static final byte LAYERING_USER_DEFINED
The nodes' layer assignment must be provided by a DataProvider
bound to the input graph
using key GivenLayersLayerer.LAYER_ID_KEY
.
This layering strategy allows edges whose source and target share a layer.
setLayeringStrategy(byte)
,
Constant Field Valuespublic static final byte LAYERING_STRATEGY_UNKNOWN
getLayeringStrategy()
,
Constant Field ValuesConstructor Detail |
---|
public HierarchicLayouter()
HierarchicLayouter
instance with the default settings.
Method Detail |
---|
public void setRoutingStyle(byte style)
ROUTE_POLYLINE
. Edges will be routed as polyline segments.style
- one of the predefined edge routing styles
java.lang.IllegalArgumentException
- if an unknown routing style is usedpublic byte getRoutingStyle()
setRoutingStyle(byte)
public void setPortConstraintOptimizationEnabled(boolean enabled)
PortConstraint
s, that are either
PortConstraint.ANY_SIDE
or null
.
PortConstraint
s are not optimized.enabled
- true
if optimization should be performed, false
otherwisepublic boolean isPortConstraintOptimizationEnabled()
PortConstraint
s that are either
PortConstraint.ANY_SIDE
or null
.
true
if optimization is performed, false
otherwisesetPortConstraintOptimizationEnabled(boolean)
public void setSameLayerEdgeRoutingOptimizationEnabled(boolean enabled)
PortConstraint
s don't impose the routing.
enabled
- true
if optimization should be performed, false
otherwisepublic boolean isSameLayerEdgeRoutingOptimizationEnabled()
PortConstraint
s don't impose the routing.
true
if optimization is performed, false
otherwisepublic void setLayoutStyle(byte style)
LINEAR_SEGMENTS
. Edges will be drawn with at most two bends per edge.style
- one of the predefined layout styles
java.lang.IllegalArgumentException
- if an unknown layout style is usedpublic byte getLayoutStyle()
-1
if the layout style is unknownpublic void setLayeringStrategy(byte strategy)
LAYERING_HIERARCHICAL_TIGHT_TREE
strategy
- one of the predefined layering strategies
java.lang.IllegalArgumentException
- if an unknown strategy is usedpublic byte getLayeringStrategy()
setLayeringStrategy(byte)
public void setLayerer(Layerer layerer)
Layerer
instance responsible for generating the layer assignment (first phase of
the layout algorithm).
layerer
- the given Layerer
instancepublic Layerer getLayerer()
Layerer
instance responsible for generating the layer assignment (first phase of
the layout algorithm).
Layerer
instancesetLayerer(Layerer)
public void setLayerSequencer(LayerSequencer sequencer)
LayerSequencer
instance responsible for calculating the sequence of nodes within
each layer (second phase of the layout algorithm).
sequencer
- the given LayerSequencer
instancepublic LayerSequencer getLayerSequencer()
LayerSequencer
instance responsible for calculating the sequence of nodes within
each layer (second phase of the layout algorithm).
LayerSequencer
instancesetLayerSequencer(LayerSequencer)
public void setDrawer(Drawer drawer)
Drawer
instance responsible for assigning the coordinates to the nodes (third
phase of the layout algorithm).
The Drawer
is responsible for the layout style of this layout algorithm.
drawer
- the given Drawer
instancepublic Drawer getDrawer()
Drawer
instance responsible for assigning the coordinates to the nodes (third
phase of the layout algorithm).
The Drawer
is responsible for the layout style of this layout algorithm.
Drawer
instancesetDrawer(Drawer)
public void setMinimalNodeDistance(double d)
All values have to be greater than or equal to 0
.
public double getMinimalNodeDistance()
All values have to be greater than or equal to 0
.
setMinimalNodeDistance(double)
public void setMinimalEdgeDistance(double d)
Minimum distance must be non-negative.
public double getMinimalEdgeDistance()
Minimum distance must be non-negative.
setMinimalEdgeDistance(double)
public void setMinimalLayerDistance(double d)
Minimum distance must be non-negative.
public double getMinimalLayerDistance()
Minimum distance must be non-negative.
setMinimalLayerDistance(double)
public double getMinimalFirstSegmentLength()
The minimum length should be greater than or equal to 0
.
If the value is 0.0d
the first segment does not need to be orthogonal.
setMinimalFirstSegmentLength(double)
public void setMinimalFirstSegmentLength(double minimalFirstSegmentLength)
The minimum length should be greater than or equal to 0
.
If the value is 0.0d
the first segment does not need to be orthogonal.
public void setRemoveFalseCrossings(boolean b)
A false crossing is a crossing between two edges that share a common terminal node.
public boolean getRemoveFalseCrossings()
A false crossing is a crossing between two edges that share a common terminal node.
setRemoveFalseCrossings(boolean)
public void setMaximalDuration(long msec)
Values have to be greater than or equal to 0
.
Long.MAX_VALUE
. The layout algorithm runs unrestricted.msec
- a non-negative value that specifies the time limit
java.lang.IllegalArgumentException
- if the maximum duration is negativegetMaximalDuration()
public long getMaximalDuration()
Values have to be greater than or equal to 0
.
setMaximalDuration(long)
public void setBendReductionThreshold(int t)
Values should be non-negative.
public int getBendReductionThreshold()
setBendReductionThreshold(int)
public boolean canLayoutCore(LayoutGraph graph)
canLayoutCore
in class CanonicMultiStageLayouter
graph
- the input graph
true
for all input graphspublic void doLayoutCore(LayoutGraph graph)
doLayoutCore
in class CanonicMultiStageLayouter
graph
- the input graphprotected NodeList[] getLayerSequence(LayoutGraph graph, NodeMap layerID, int maxLayer)
graph
- the input graphlayerID
- the NodeMap
that returns the zero-based index of the layer to which each node belongsmaxLayer
- the number of layers
NodeList
s containing nodes that belong to the same layer; the order of the nodes
within each such list represents the sequence of the nodes within their layerpublic MementoSupport getMementoSupport()
If there was no memento support registered with this instance before, this call will instantiate the memento support, otherwise the existing instance will be returned.
MementoSupport
instancepublic void disposeMementoSupport()
getMementoSupport()
.
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |