|
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.orthogonal.OrthogonalGroupLayouter
public class OrthogonalGroupLayouter
This layout algorithm arranges hierarchically grouped graphs in an orthogonal fashion.
This layout algorithm arranges the elements of a given graph such that each edge is drawn as an alternating sequence of horizontal and vertical segments. All nodes belonging to the same group will be placed within the same rectangular area that represents this group. The positions and sizes of the group nodes are calculated by the layout algorithm.
The layout algorithm is well suited for small and medium-sized sparse grouped graphs and produces drawings with no overlapping nodes, few crossings and few bends.
Application domains of orthogonal drawings are software engineering, project management, function call graphs and object-oriented class diagrams.
Orthogonal layout of a grouped graph with default settings
Orthogonal layout of a graph with nested groups
The layout algorithm is based on the topology-shape-metrics approach and runs in three phases:
Each of the phases has to consider the grouping hierarchy.
A grouped graph denotes a graph structure in which conceptually, nodes can be declared children of another common
node, i.e. their parent. This can be applied recursively, i.e. parents can be declared children of other parents,
resulting in a hierarchy of nodes of possibly arbitrary depth.
The layout algorithm uses the following DataProvider
keys to look up the grouping information:
GroupingKeys.GROUP_DPKEY
, GroupingKeys.NODE_ID_DPKEY
and GroupingKeys.PARENT_NODE_ID_DPKEY
.
Furthermore, the user may specify insets
for each group node
using DataProvider key GroupingKeys.GROUP_NODE_INSETS_DPKEY
as well as
minimum size constraints using key GroupingKeys.MINIMUM_NODE_SIZE_DPKEY
.
EdgeLayoutDescriptor
instances can be used for specifying individual information (e.g. minimum lengths) for each
edge in the graph. The descriptors are bound to the graph using a DataProvider
registered with key
EDGE_LAYOUT_DESCRIPTOR_DPKEY
.
If there is no descriptor assigned to some edge, the
default descriptor
will be used.
OrthogonalGroupLayouter
is able to consider edge label data when arranging a graph. This means that the
layout algorithm will determine the positions of the nodes and edges such that the edge labels do not overlap with
the other elements. Integrated edge labeling can be activated using method
setIntegratedEdgeLabelingEnabled(boolean)
.
Field Summary | |
---|---|
static java.lang.Object |
EDGE_BEND_COST_DPKEY
A DataProvider key for providing bend costs for each edge
The layout algorithm considers the specified costs
during the bend minimization phase. |
static java.lang.Object |
EDGE_CROSSING_COST_DPKEY
A DataProvider key for providing crossing costs for each edge
The layout algorithm considers the specified
costs during the crossing minimization phase. |
static java.lang.Object |
EDGE_LAYOUT_DESCRIPTOR_DPKEY
A DataProvider key for providing layout information for each edge
If no edge layout descriptor is mapped to an edge, the
default edge layout descriptor will be used. |
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
OrthogonalGroupLayouter()
Creates a new OrthogonalGroupLayouter instance with default settings. |
Method Summary | |
---|---|
protected boolean |
canLayoutCore(LayoutGraph graph)
Checks whether or not the given graph can be handled by this layout algorithm. |
protected EdgeLayoutDescriptor |
createEdgeLayoutDescriptor()
Returns a new EdgeLayoutDescriptor instance that will be used during the various phases of the layout
algorithm to determine the drawing details of the edges of the graph. |
void |
doLayout(LayoutGraph graph)
Calculates an orthogonal layout for the given grouped graph. |
protected void |
doLayoutCore(LayoutGraph graph)
Calculates an orthogonal layout for the given grouped graph. |
LayoutStage |
getComponentLayouter()
Returns the LayoutStage that arranges the connected components of an input graph. |
EdgeLayoutDescriptor |
getEdgeLayoutDescriptor()
Returns the EdgeLayoutDescriptor instance used for all those edges that do not have a
specific layout descriptor assigned. |
int |
getGrid()
Returns the equidistant spacing between the horizontal and vertical grid lines. |
double |
getLayoutQuality()
Returns the desired layout quality. |
long |
getMaximumDuration()
Returns the preferred time limit in milliseconds. |
boolean |
isAlignDegreeOneNodesEnabled()
Returns whether or not degree-one nodes that have the same neighbur should be aligned. |
boolean |
isConsiderNodeLabelsEnabled()
Returns whether or not the layout algorithm considers node labels when calculating node positions to avoid overlaps. |
boolean |
isIntegratedEdgeLabelingEnabled()
Returns whether or not the layout algorithm preserves space and places edge labels. |
boolean |
isParallelRoutesPreferenceEnabled()
Returns whether or not parallel routes for parallel edges (multi-edges) are preferred over independent routes. |
boolean |
isPerceivedBendsOptimizationEnabled()
Returns whether or not the number of perceived bends are minimized. |
boolean |
isPostprocessingEnabled()
Returns whether or not an additional postprocessing step is applied that improves compactness and reduces the number of bends. |
void |
setAlignDegreeOneNodesEnabled(boolean alignDegreeOneNodesEnabled)
Specifies whether or not degree-one nodes that have the same neighbor should be aligned. |
void |
setComponentLayouter(LayoutStage layouter)
Specifies the LayoutStage that arranges the connected components of an input graph. |
void |
setComponentLayouterEnabled(boolean enabled)
Specifies whether or not the LayoutStage used for arranging the components of the graph is activated. |
void |
setConsiderNodeLabelsEnabled(boolean enabled)
Specifies whether or not the layout algorithm considers node labels when calculating node positions to avoid overlaps. |
void |
setEdgeLayoutDescriptor(EdgeLayoutDescriptor edgeLayoutDescriptor)
Specifies the EdgeLayoutDescriptor instance used for all those edges that do not have a
specific layout descriptor assigned. |
void |
setGrid(int grid)
Specifies the equidistant spacing between the horizontal and vertical grid lines. |
void |
setIntegratedEdgeLabelingEnabled(boolean enabled)
Specifies whether or not the layout algorithm preserves space and places edge labels. |
void |
setLayoutQuality(double q)
Specifies the desired layout quality. |
void |
setMaximumDuration(long maximumDuration)
Specifies the preferred time limit in milliseconds. |
void |
setOrientationLayouterEnabled(boolean enabled)
Specifies whether or not the LayoutStage that modifies the orientation of the layout is activated. |
void |
setParallelRoutesPreferenceEnabled(boolean parallelRoutesPreferenceEnabled)
Specifies whether or not parallel routes for parallel edges (multi-edges) are preferred over independent routes. |
void |
setPerceivedBendsOptimizationEnabled(boolean perceivedBendsOptimizationEnabled)
Specifies whether or not the number of perceived bends should be minimized. |
void |
setPostprocessingEnabled(boolean enable)
Specifies whether or not an additional postprocessing step should be applied that improves compactness and reduces the number of bends. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Object EDGE_LAYOUT_DESCRIPTOR_DPKEY
DataProvider
key for providing layout information for each edge
If no edge layout descriptor is mapped to an edge, the
default edge layout descriptor
will be used.
Different settings will affect the routing of the edges during the layout.
public static final java.lang.Object EDGE_CROSSING_COST_DPKEY
DataProvider
key for providing crossing costs for each edge
The layout algorithm considers the specified
costs during the crossing minimization phase. Edges with lower costs are more likely to have crossings.
If no individual costs are defined, each crossing has a cost of 1
.
public static final java.lang.Object EDGE_BEND_COST_DPKEY
DataProvider
key for providing bend costs for each edge
The layout algorithm considers the specified costs
during the bend minimization phase. Edges with lower costs are more likely to have bends.
If no individual costs are defined, each bend has a cost of 1
.
Constructor Detail |
---|
public OrthogonalGroupLayouter()
OrthogonalGroupLayouter
instance with default settings.
Method Detail |
---|
public long getMaximumDuration()
Depending on the specified value and the size of the input
graph, the layout algorithm may automatically disable properties setPostprocessingEnabled(boolean)
and setPerceivedBendsOptimizationEnabled(boolean)
.
These properties improve the layout quality but also increase the runtime, especially for larger graphs.
If the time limit is set to Long.MAX_VALUE
, the layout algorithm runs unrestricted.
Values have to be greater or equal to 0
.
setMaximumDuration(long)
public void setMaximumDuration(long maximumDuration)
Depending on the specified value and the size of the input
graph, the layout algorithm may automatically disable properties setPostprocessingEnabled(boolean)
and setPerceivedBendsOptimizationEnabled(boolean)
.
These properties improve the layout quality but also increase the runtime, especially for larger graphs.
If the time limit is set to Long.MAX_VALUE
, the layout algorithm runs unrestricted.
Values have to be greater or equal to 0
.
Long.MAX_VALUE
. The layout algorithm runs unrestricted.maximumDuration
- a non-negative value that specifies the preferred time limit
java.lang.IllegalArgumentException
- if the maximum duration is negativepublic boolean isAlignDegreeOneNodesEnabled()
true
if the degree-one nodes are aligned, false
otherwisesetAlignDegreeOneNodesEnabled(boolean)
public void setAlignDegreeOneNodesEnabled(boolean alignDegreeOneNodesEnabled)
public boolean isPostprocessingEnabled()
true
if the postprocessing step is applied, false
otherwisepublic void setPostprocessingEnabled(boolean enable)
public boolean isPerceivedBendsOptimizationEnabled()
A perceived bend is not a real bend. A node with two incident edges induces a perceived bend if the edges are not placed on opposite sides. Enabling this option especially prevents a helical arrangement of chains of nodes.
true
if the number of perceived bends is minimized, false
otherwisesetPerceivedBendsOptimizationEnabled(boolean)
public void setPerceivedBendsOptimizationEnabled(boolean perceivedBendsOptimizationEnabled)
A perceived bend is not a real bend. A node with two incident edges induces a perceived bend if the edges are not placed on opposite sides. Enabling this option especially prevents a helical arrangement of chains of nodes.
protected EdgeLayoutDescriptor createEdgeLayoutDescriptor()
EdgeLayoutDescriptor
instance that will be used during the various phases of the layout
algorithm to determine the drawing details of the edges of the graph.
This method may be overridden to create a new EdgeLayoutDescriptor
instance with different configuration
settings.
null
.EdgeLayoutDescriptor
instancepublic EdgeLayoutDescriptor getEdgeLayoutDescriptor()
EdgeLayoutDescriptor
instance used for all those edges that do not have a
specific layout descriptor
assigned.
By default, this method will return an EdgeLayoutDescriptor
instance created with
createEdgeLayoutDescriptor()
.
EdgeLayoutDescriptor
instancesetEdgeLayoutDescriptor(EdgeLayoutDescriptor)
,
EDGE_LAYOUT_DESCRIPTOR_DPKEY
public void setEdgeLayoutDescriptor(EdgeLayoutDescriptor edgeLayoutDescriptor)
EdgeLayoutDescriptor
instance used for all those edges that do not have a
specific layout descriptor
assigned.
EdgeLayoutDescriptor
edgeLayoutDescriptor
- the current EdgeLayoutDescriptor
instance
java.lang.IllegalArgumentException
- if the specified EdgeLayoutDescriptor
is null
EDGE_LAYOUT_DESCRIPTOR_DPKEY
public void setConsiderNodeLabelsEnabled(boolean enabled)
This method is a convenience method that assures that the
labeling algorithm
is of type
LabelLayoutTranslator
and LabelLayoutTranslator.setTranslateNodeLabelsEnabled(boolean)
is set to
true
.
enabled
- true
if the layout algorithm should take the node labels into account,
false
otherwisefalse | true |
public boolean isConsiderNodeLabelsEnabled()
This method is a convenience method that assures that the
labeling algorithm
is of type
LabelLayoutTranslator
and LabelLayoutTranslator.setTranslateNodeLabelsEnabled(boolean)
is set to
true
.
true
if the layout algorithm takes the node labels into account,
false
otherwise
java.lang.IllegalStateException
- if no properly configured LabelLayoutTranslator
is registered even though
this property was enabled earlier (can happen when manually specifying
the labeling algorithm
).setConsiderNodeLabelsEnabled(boolean)
public void setIntegratedEdgeLabelingEnabled(boolean enabled)
To define the desired placement for each label use PreferredPlacementDescriptor
.
This method also assures that the labeling algorithm
is of type LabelLayoutTranslator
and LabelLayoutTranslator.setTranslateEdgeLabelsEnabled(boolean)
is set to true
.
labeling algorithm
will be
overwritten and when disabling it, any currently specified labeling algorithm will be disabled via property
CanonicMultiStageLayouter.setLabelLayouterEnabled(boolean)
. Therefore, it is recommended to only use this convenience property
instead of manually changing the mentioned other properties.enabled
- true
if integrated edge labeling should be enabled, false
otherwisefalse | true |
public boolean isIntegratedEdgeLabelingEnabled()
To define the desired placement for each label use PreferredPlacementDescriptor
.
This method also assures that the labeling algorithm
is of type LabelLayoutTranslator
and LabelLayoutTranslator.setTranslateEdgeLabelsEnabled(boolean)
is set to true
.
labeling algorithm
will be
overwritten and when disabling it, any currently specified labeling algorithm will be disabled via property
CanonicMultiStageLayouter.setLabelLayouterEnabled(boolean)
. Therefore, it is recommended to only use this convenience property
instead of manually changing the mentioned other properties.true
if integrated edge labeling is enabled, false
otherwise
java.lang.IllegalStateException
- if no properly configured LabelLayoutTranslator
is registered even though
integrated labeling was enabled earlier (can happen when manually specifying
the labeling algorithm
).setIntegratedEdgeLabelingEnabled(boolean)
public boolean isParallelRoutesPreferenceEnabled()
When enabled, the algorithm routes multi-edges (edges that connect the same pair of nodes) in parallel, i.e.,
these edges connect to the same side of the nodes and have the same or a similar path.
Note that the path is not always exactly the same since the algorithm has to omit label-edge intersections
if integrated labeling
is enabled. If this setting is disabled, the
edges are simply independent and might as well connect to different node sides and get very different paths.
A parallel routing is suitable for a lot of diagrams (especially larger ones) as it helps to better recognize multi-edge structures. However, there are scenarios where the routes of such edges might as well be independent. For small examples the structure can also be clear if the edges connect to other node sides, especially when they are in consecutive order around the node.
CanonicMultiStageLayouter.isParallelEdgeLayouterEnabled()
is enabled, that is,
if parallel edges are not handled by this layout algorithm internally but by a specified stage.true
if parallel edges are routed in parallel,
false
otherwisesetParallelRoutesPreferenceEnabled(boolean)
public void setParallelRoutesPreferenceEnabled(boolean parallelRoutesPreferenceEnabled)
When enabled, the algorithm routes multi-edges (edges that connect the same pair of nodes) in parallel, i.e.,
these edges connect to the same side of the nodes and have the same or a similar path.
Note that the path is not always exactly the same since the algorithm has to omit label-edge intersections
if integrated labeling
is enabled. If this setting is disabled, the
edges are simply independent and might as well connect to different node sides and get very different paths.
A parallel routing is suitable for a lot of diagrams (especially larger ones) as it helps to better recognize multi-edge structures. However, there are scenarios where the routes of such edges might as well be independent. For small examples the structure can also be clear if the edges connect to other node sides, especially when they are in consecutive order around the node.
CanonicMultiStageLayouter.isParallelEdgeLayouterEnabled()
is enabled, that is,
if parallel edges are not handled by this layout algorithm internally but by a specified stage.parallelRoutesPreferenceEnabled
- true
if parallel edges should be routed in parallel,
false
otherwisetrue | false |
public void setLayoutQuality(double q)
The values should be inside the interval [0,1]
. Higher values result in less edge crossings and smaller
layout area. However, such values also increase the algorithm's running time.
public double getLayoutQuality()
The values should be inside the interval [0,1]
. Higher values result in less edge crossings and smaller
layout area. However, such values also increase the algorithm's running time.
[0,1]
setLayoutQuality(double)
public void setGrid(int grid)
Each node will be placed on a grid point. Edges will be routed such that their segments lie on grid lines, if possible.
The grid spacing has to be greater than 0
.
public void setComponentLayouter(LayoutStage layouter)
LayoutStage
that arranges the connected components of an input graph.
The component layouter should be implemented in such a way that isolated components inside groups are
handled separately. For example, instances of IsolatedGroupComponentLayouter
can be
used here.
If the component layouter should be customized, the suggested way is to obtain the current component layouter
using getComponentLayouter()
and cast it to ComponentLayouter
.
setComponentLayouter
in class CanonicMultiStageLayouter
layouter
- the LayoutStage
instanceCanonicMultiStageLayouter.getComponentLayouter()
,
CanonicMultiStageLayouter.setComponentLayouterEnabled(boolean)
,
ComponentLayouter
public LayoutStage getComponentLayouter()
LayoutStage
that arranges the connected components of an input graph.
The component layouter should be implemented in such a way that isolated components inside groups are
handled separately. For example, instances of IsolatedGroupComponentLayouter
can be
used here.
If the component layouter should be customized, the suggested way is to obtain the current component layouter
using getComponentLayouter()
and cast it to ComponentLayouter
.
getComponentLayouter
in class CanonicMultiStageLayouter
LayoutStage
instancesetComponentLayouter(LayoutStage)
public int getGrid()
Each node will be placed on a grid point. Edges will be routed such that their segments lie on grid lines, if possible.
setGrid(int)
public void setComponentLayouterEnabled(boolean enabled)
LayoutStage
used for arranging the components of the graph is activated.
setComponentLayouterEnabled
in class CanonicMultiStageLayouter
OrthogonalGroupLayouter
can only handle single components. Disabling ComponentLayouter
will lead to errors during execution.enabled
- true
if the stage that arranges the graph components is activated,
false
otherwiseCanonicMultiStageLayouter.isComponentLayouterEnabled()
,
setComponentLayouter(LayoutStage)
,
ComponentLayouter
public void setOrientationLayouterEnabled(boolean enabled)
LayoutStage
that modifies the orientation of the layout is activated.
setOrientationLayouterEnabled
in class CanonicMultiStageLayouter
LayoutOrientation.TOP_TO_BOTTOM
, the orientation of
the layout will not be modified.OrientationLayouter
has no significant effect.LayoutStage
is activated.enabled
- true
if the stage that modifies the orientation is activated,
false
otherwiseCanonicMultiStageLayouter.isOrientationLayouterEnabled()
,
CanonicMultiStageLayouter.setOrientationLayouter(LayoutStage)
,
CanonicMultiStageLayouter.setLayoutOrientation(byte)
,
OrientationLayouter
protected boolean canLayoutCore(LayoutGraph graph)
canLayoutCore
in class CanonicMultiStageLayouter
graph
- the input graph
true
if the input graph can be handled by the given layout algorithm, false
otherwiseprotected void doLayoutCore(LayoutGraph graph)
doLayoutCore
in class CanonicMultiStageLayouter
graph
- the input graphpublic void doLayout(LayoutGraph graph)
doLayout
in interface Layouter
doLayout
in class CanonicMultiStageLayouter
graph
- the input graphCanonicMultiStageLayouter.appendStage(LayoutStage)
,
CanonicMultiStageLayouter.prependStage(LayoutStage)
,
CanonicMultiStageLayouter.doLayoutCore(LayoutGraph)
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |