|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecty.layout.CanonicMultiStageLayouter
y.layout.grouping.CactusGroupLayouter
public class CactusGroupLayouter
This layout algorithm arranges grouped graphs in a recursive structure.
CactusGroupLayouter
is designed to arrange directed and undirected, hierarchically grouped graphs. All members
of a group are placed adjacent to the group node along its circular border, resembling the structure of a cactus. The
group hierarchy of the graph is represented implicitly by the position of the nodes. Non-hierarchical edges
are routed through the centers of all nodes on a path through the hierarchy tree, connecting the edge's endpoints.
Sample cactus drawing of a large graph with default settings
Cactus group layout algorithms are commonly used for visualizing relational data and for producing diagrams of high quality that are able to showcase hierarchic properties of the graph. They especially address the concern of recognizability between identical subtrees.
The algorithm executes the following steps
The algorithm features the possibility to collapse the hierarchy at one or more of its groups, to gather all direct
and indirect members of the specified group or groups along their boundary. Collapsed groups can be specified using the
DataProvider
registered with COLLAPSED_SUBTREE_ROOTS_DPKEY
.
The CactusGroupLayouter
allows for integrated node labeling
.
Node labels are placed automatically without generating overlaps with other labels or graph elements. Note that
for nodes with multiple labels such overlaps may occur.
There are different ways
to place node labels.
The algorithm supports edge bundling
and all its included features for non-hierarchical edges of the graph.
Defining a preferred wedge angle
has a great influence on the layout style.
Subtrees at the hierarchy's root get a certain amount of radial space to be placed around the root node, such that
a large preferred angle will generally lead to more compact drawings while a smaller angle will focus the drawing
towards a singular direction.
The CactusGroupLayouter
supports customizing the overlap between nodes and their parent nodes. The overlap can be set
individually for each node by registering a DataProvider
with PARENT_OVERLAP_RATIO_DPKEY
.
Since it is computationally not very complex, CactusGroupLayouter
is well suited for large graphs. It
performs well even for huge graphs.
Field Summary | |
---|---|
static java.lang.Object |
COLLAPSED_SUBTREE_ROOTS_DPKEY
A DataProvider key for specifying the roots of collapsed subtrees in the hierarchy.
|
static byte |
GROUP_SIZING_POLICY_ADAPTIVE
Policy for sizing group nodes individually that optimizes for compact drawings. |
static byte |
GROUP_SIZING_POLICY_COMPACT
Policy for sizing group nodes individually that optimizes for compact drawings. |
static byte |
GROUP_SIZING_POLICY_STABLE
Policy for sizing group nodes individually that optimizes for compact drawings which can be collapsed at any group without producing overlaps. |
static java.lang.Object |
PARENT_OVERLAP_RATIO_DPKEY
A DataProvider key for specifying the overlap of nodes with their parent in the hierarchy.
|
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
CactusGroupLayouter()
Creates a new CactusGroupLayouter instance with default settings. |
Method Summary | |
---|---|
protected boolean |
canLayoutCore(LayoutGraph graph)
Accepts all graphs. |
protected void |
doLayoutCore(LayoutGraph graph)
Arranges the given grouped graph in the style of a cactus group layout. |
java.util.Comparator |
getDefaultNodeComparator()
Returns the default policy for ordering subtree roots around their common parent. |
EdgeBundling |
getEdgeBundling()
Returns the EdgeBundling instance that defines the settings of the edge bundling feature. |
byte |
getGroupSizingPolicy()
Returns the policy defining how group node sizes are determined. |
java.util.Comparator |
getNodeComparator()
Returns a Comparator for children of the same parent node, by which the order of the subtrees
around their parent is determined. |
byte |
getNodeLabelingPolicy()
Returns the policy defining how node labels are placed by the integrated node labeling mechanism (for example, the desired label orientation). |
double |
getNodeLabelSpacing()
Returns the spacing used for node labels when integrated node labeling is enabled. |
double |
getPreferredRootWedge()
Returns the maximum angle on which the root's children can be distributed around its center. |
boolean |
isFromSketchModeEnabled()
Returns whether or not the order of subtrees around a root may be changed by the algorithm. |
boolean |
isIntegratedNodeLabelingEnabled()
Returns whether or not the layout algorithm automatically places node labels. |
boolean |
isNodeLabelConsiderationEnabled()
Returns whether the algorithm actively prevents node label overlaps when computing the layout. |
void |
setFromSketchModeEnabled(boolean fromSketchModeEnabled)
Specifies whether or not the order of subtrees around a root may be changed by the algorithm. |
void |
setGroupSizingPolicy(byte groupSizingPolicy)
Specifies the policy defining how group node sizes are determined. |
void |
setIntegratedNodeLabelingEnabled(boolean integratedNodeLabelingEnabled)
Specifies whether or not the layout algorithm automatically places node labels. |
void |
setNodeComparator(java.util.Comparator comp)
Specifies a Comparator for children of the same parent node, by which the order of the subtrees
around their parent is determined. |
void |
setNodeLabelConsiderationEnabled(boolean nodeLabelConsiderationEnabled)
Specifies whether the algorithm actively prevents node label overlaps when computing the layout. |
void |
setNodeLabelingPolicy(byte nodeLabelingPolicy)
Specifies the policy defining how node labels are placed by the integrated node labeling mechanism (for example, the desired label orientation). |
void |
setNodeLabelSpacing(double nodeLabelSpacing)
Specifies the spacing used for node labels when integrated node labeling is enabled. |
void |
setPreferredRootWedge(double preferredRootWedge)
Specifies the maximum angle on which the root's children can be distributed around its center. |
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 COLLAPSED_SUBTREE_ROOTS_DPKEY
DataProvider
key for specifying the roots of collapsed subtrees in the hierarchy.
If the data provider entry for a group node is set to false
all children of the node are placed on its
border and their respective descendants are arranged recursively. If the entry is however set to true
,
all descendants of the node are placed depending on whether they are inner nodes or leaves. Inner nodes are
positioned at the center of the node whereas leaves are placed on its border in place of child nodes.
The entries of leaf nodes in the hierarchy have no effect.
public static final java.lang.Object PARENT_OVERLAP_RATIO_DPKEY
DataProvider
key for specifying the overlap of nodes with their parent in the hierarchy.
Generally, the cactus group layout algorithm places all child nodes in the hierarchy such that they are touching their respective parent node. However, an overlap can be specified as a fraction of the child's radius, by which the node will be moved towards the parent node's center.
public static final byte GROUP_SIZING_POLICY_COMPACT
The size of group nodes is determined individually for each group so as to maximize the compactness of the drawing without producing overlaps. With this policy, some emphasis is placed on maintaining the group sizes in the remaining graph when collapsing subtrees.
public static final byte GROUP_SIZING_POLICY_ADAPTIVE
The size of group nodes is determined individually for each group so as to maximize the compactness of the drawing without producing overlaps. This policy places less emphasis on maintaining the group sizes in the remaining graph when collapsing subtrees than other policies.
public static final byte GROUP_SIZING_POLICY_STABLE
The size of group nodes is determined individually for each group so as to produce the most compact drawing while reserving enough space to collapse any subtree without producing overlaps or necessitating a change in the layout of the remaining graph.
Constructor Detail |
---|
public CactusGroupLayouter()
CactusGroupLayouter
instance with default settings.
Method Detail |
---|
public boolean isFromSketchModeEnabled()
true
if subtree order is fixed, false
otherwise.setFromSketchModeEnabled(boolean)
public void setFromSketchModeEnabled(boolean fromSketchModeEnabled)
fromSketchModeEnabled
- true
if subtree order is fixed, false
otherwise.isFromSketchModeEnabled()
public void setNodeLabelSpacing(double nodeLabelSpacing)
For ray-like label placement of leaf nodes, the spacing defines the distance between labels and the node they belong to
(e.g. for ray-like label placement
).
For labels of inner nodes, the spacing specifies the distance between the labels (if there are multiple labels).
The spacing must have a non-negative value.
integrated node labeling
is enabled.nodeLabelSpacing
- the non-negative node label spacing
java.lang.IllegalArgumentException
- if the given spacing value is negativesetIntegratedNodeLabelingEnabled(boolean)
![]() Node label spacing set to 2.0 | ![]() Node label spacing set to 10.0 |
public double getNodeLabelSpacing()
For ray-like label placement of leaf nodes, the spacing defines the distance between labels and the node they belong to
(e.g. for ray-like label placement
).
For labels of inner nodes, the spacing specifies the distance between the labels (if there are multiple labels).
The spacing must have a non-negative value.
integrated node labeling
is enabled.setIntegratedNodeLabelingEnabled(boolean)
,
setNodeLabelSpacing(double)
public void setNodeComparator(java.util.Comparator comp)
Comparator
for children of the same parent node, by which the order of the subtrees
around their parent is determined.
Comparator
in combination with a custom sorting procedure that symmetrically
arranges the elements in ascending and then descending order around the largest element. If a custom Comparator
is
specified, the algorithm does however strictly adhere to the ascending order specified by it.Comparator
is ignored if the from-sketch mode
is enabled.Comparator
. Subtrees are ordered symmetrically by the number of leaves they contain.comp
- the Comparator
to sort the children around their parent nodegetNodeComparator()
public java.util.Comparator getNodeComparator()
Comparator
for children of the same parent node, by which the order of the subtrees
around their parent is determined.
Comparator
in combination with a custom sorting procedure that symmetrically
arranges the elements in ascending and then descending order around the largest element. If a custom Comparator
is
specified, the algorithm does however strictly adhere to the ascending order specified by it.Comparator
is ignored if the from-sketch mode
is enabled.Comparator
. Subtrees are ordered symmetrically by the number of leaves they contain.Comparator
to sort the children around their parent nodesetNodeComparator(Comparator)
public boolean isNodeLabelConsiderationEnabled()
true
if node label overlaps are prevented, false
otherwise.setNodeLabelConsiderationEnabled(boolean)
public void setNodeLabelConsiderationEnabled(boolean nodeLabelConsiderationEnabled)
public byte getNodeLabelingPolicy()
integrated
node labeling
is enabled.setNodeLabelingPolicy(byte)
,
setIntegratedNodeLabelingEnabled(boolean)
public void setNodeLabelingPolicy(byte nodeLabelingPolicy)
integrated
node labeling
is enabled.NodeLabelingPolicy.NODE_LABELING_MIXED
nodeLabelingPolicy
- one of the predefined node labeling policies
java.lang.IllegalArgumentException
- if an unknown labeling policy is givengetNodeLabelingPolicy()
,
setIntegratedNodeLabelingEnabled(boolean)
public byte getGroupSizingPolicy()
setGroupSizingPolicy(byte)
public void setGroupSizingPolicy(byte groupSizingPolicy)
GROUP_SIZING_POLICY_ADAPTIVE
groupSizingPolicy
- One of the predefined group sizing policies
java.lang.IllegalArgumentException
- if an unknown group sizing policy is givengetGroupSizingPolicy()
public boolean isIntegratedNodeLabelingEnabled()
If enabled, this layout algorithm will calculate the positions for the node labels assuring that no overlaps occur.
Different labeling strategies may be selected using setNodeLabelingPolicy(byte)
.
FreeNodeLabelModel
as the NodeLabelModel
for the nodes.true
if integrated node labeling is enabled, false
otherwise.setIntegratedNodeLabelingEnabled(boolean)
public void setIntegratedNodeLabelingEnabled(boolean integratedNodeLabelingEnabled)
If enabled, this layout algorithm will calculate the positions for the node labels assuring that no overlaps occur.
Different labeling strategies may be selected using setNodeLabelingPolicy(byte)
.
FreeNodeLabelModel
as the NodeLabelModel
for the nodes.integratedNodeLabelingEnabled
- true
if integrated node labeling should be enabled,
false
otherwise.setNodeLabelingPolicy(byte)
,
isIntegratedNodeLabelingEnabled()
public double getPreferredRootWedge()
setPreferredRootWedge(double)
public void setPreferredRootWedge(double preferredRootWedge)
preferredRootWedge
- the angle on which the root's children are distributed.
java.lang.IllegalArgumentException
- if a negative angle, or an angle of more than 360
degrees is specified.getPreferredRootWedge()
![]() 180 degrees | ![]() 360 degrees |
public EdgeBundling getEdgeBundling()
EdgeBundling
instance that defines the settings of the edge bundling feature.
The specified EdgeBundling
defines global bundling properties. Settings for individual
edges can be defined by assigning an EdgeBundleDescriptor
to an edge using a DataProvider
registered with key EdgeBundling.EDGE_BUNDLE_DESCRIPTOR_DPKEY
.
default
bundle descriptor
which has bundling
enabled.EdgeBundling
instance defining the edge bundling setuppublic java.util.Comparator getDefaultNodeComparator()
CactusGroupLayouter
arranges nodes in a radial fashion around their parent node. The order is determined
by a comparator specified with setNodeComparator(Comparator)
. By default all subtrees are arranged
according to the number of leaves they contain, placing the largest subtrees in the center and smaller subtrees
towards beginning and end of the order.
From Sketch mode
is enabled.setNodeComparator(Comparator)
protected boolean canLayoutCore(LayoutGraph graph)
canLayoutCore
in class CanonicMultiStageLayouter
graph
- the input graph
true
for all graphsprotected void doLayoutCore(LayoutGraph graph)
doLayoutCore
in class CanonicMultiStageLayouter
graph
- the grouped input graph
|
© Copyright 2000-2025, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |