public class ClassicOrganicLayout extends MultiStageLayout
The organic layout style is characterized by a natural distribution of nodes. It is well suited to exhibit clusters and symmetric properties of a graph. Nodes are placed in a space-saving manner, close to their adjacent nodes. Distances between neighbors and edge lengths are highly uniform and edges are drawn as straight-line segments without bends.
Organic diagrams are well suited for visualizing relations in large networks, for example, in bioinformatics, enterprise networking, social networks visualization, mesh visualization or system management.
Organic layout obtained using default settings Organic layout exposing symmetries of the graph structure
This algorithm uses a force-directed approach to place the nodes of the input graph. The graph is modeled as a physical system with forces acting on it. Nodes are considered as electrically charged particles with mutually repulsive forces. Edges are modeled as springs that attract adjacent nodes. A good diagram is obtained from an equilibrium state of the system, i.e., the nodes are rearranged based on the physical forces until the system reaches a (local) minimum of the sum of the forces.
The tree beautifier
feature activates a special layout style for subgraphs
with a tree structure. These subgraphs will be arranged using an algorithm dedicated to tree graphs and incorporated
into the main organic diagram.
Several parameters for the internal force-directed drawing algorithm can be modified. For example, the
repulsion
, attraction
and initial temperature
can be controlled. This allows experts to configure and fine-tune the algorithm with respect to their needs.
Modifier and Type | Field and Description |
---|---|
static NodeDpKey<Boolean> |
AFFECTED_NODES_DPKEY
A
DataProvider key for marking the nodes that are part of the current scope
|
static NodeDpKey<Boolean> |
FIXED_GROUP_NODES_DPKEY
A
DataProvider key for marking group nodes as fixed
The content of a fixed group node will not be changed by this algorithm but be treated as fixed. |
static EdgeDpKey<Double> |
PREFERRED_EDGE_LENGTH_DPKEY
A
DataProvider key for defining an individual preferred length for each edge
|
Constructor and Description |
---|
ClassicOrganicLayout()
Creates a new
ClassicOrganicLayout with default settings. |
Modifier and Type | Method and Description |
---|---|
void |
applyLayoutCore(LayoutGraph graph)
Calculates an organic arrangement of the given graph.
|
void |
dispose()
Frees internal resources which were in use during a previous algorithm run.
|
int |
getAttraction()
Gets the edge attraction value.
|
double |
getFinalTemperature()
Gets the absolute, final temperature value, which will cause the algorithm to stop if the average temperature falls
under this value.
|
double |
getGravityFactor()
Gets the gravity factor whose magnitude determines the strength of the force towards the barycenter of the graph.
|
IGroupBoundsCalculator |
getGroupBoundsCalculator()
Gets the
IGroupBoundsCalculator instance used for calculating the size of group nodes. |
double |
getGroupNodeCompactness()
Gets the compactness of group nodes.
|
GroupsPolicy |
getGroupNodePolicy()
Gets the policy for the handling of group nodes.
|
InitialPlacement |
getInitialPlacement()
Gets the strategy for the initial placement of nodes.
|
double |
getInitialTemperature()
Gets the initial temperature for the force-directed layout process.
|
double |
getIterationFactor()
Gets the iteration factor which influences the maximum number of optimization iterations the algorithm may perform.
|
long |
getMaximumDuration()
Gets the maximum duration in milliseconds that this layout algorithm is allowed to run.
|
double |
getPreferredEdgeLength()
Gets the default preferred edge length.
|
int |
getRepulsion()
Gets the node repulsion value.
|
Scope |
getScope()
Gets the scope that determines which nodes are placed by this algorithm.
|
boolean |
isDeterministicModeEnabled()
Gets whether or not the deterministic mode of the layout algorithm is enabled.
|
boolean |
isMultiThreadingAllowed()
Gets whether or not the layout algorithm may use multi-threading to reduce the running time.
|
boolean |
isNodeSizeAware()
Gets whether or not to consider node sizes during layout calculation.
|
boolean |
isTreeBeautifierEnabled()
Gets whether or not to arrange subtrees of the input graph in a special, optimized tree style.
|
void |
setAttraction(int value)
Sets the edge attraction value.
|
void |
setDeterministicModeEnabled(boolean value)
Sets whether or not the deterministic mode of the layout algorithm is enabled.
|
void |
setFinalTemperature(double value)
Sets the absolute, final temperature value, which will cause the algorithm to stop if the average temperature falls
under this value.
|
void |
setGravityFactor(double value)
Sets the gravity factor whose magnitude determines the strength of the force towards the barycenter of the graph.
|
void |
setGroupBoundsCalculator(IGroupBoundsCalculator value)
Sets the
IGroupBoundsCalculator instance used for calculating the size of group nodes. |
void |
setGroupNodeCompactness(double value)
Sets the compactness of group nodes.
|
void |
setGroupNodePolicy(GroupsPolicy value)
Sets the policy for the handling of group nodes.
|
void |
setInitialPlacement(InitialPlacement value)
Sets the strategy for the initial placement of nodes.
|
void |
setInitialTemperature(double value)
Sets the initial temperature for the force-directed layout process.
|
void |
setIterationFactor(double value)
Sets the iteration factor which influences the maximum number of optimization iterations the algorithm may perform.
|
void |
setMaximumDuration(long value)
Sets the maximum duration in milliseconds that this layout algorithm is allowed to run.
|
void |
setMultiThreadingAllowed(boolean value)
Sets whether or not the layout algorithm may use multi-threading to reduce the running time.
|
void |
setNodeSizeAware(boolean value)
Sets whether or not to consider node sizes during layout calculation.
|
void |
setOrientationLayoutEnabled(boolean value)
Sets whether or not the
ILayoutStage that modifies the orientation of the layout is activated. |
void |
setPreferredEdgeLength(double value)
Sets the default preferred edge length.
|
void |
setRepulsion(int value)
Sets the node repulsion value.
|
void |
setScope(Scope value)
Sets the scope that determines which nodes are placed by this algorithm.
|
void |
setTreeBeautifierEnabled(boolean value)
Sets whether or not to arrange subtrees of the input graph in a special, optimized tree style.
|
appendStage, applyLayout, checkNodeSize, disableAllStages, getComponentLayout, getHideGroupsStage, getLabeling, getLayoutOrientation, getOrientationLayout, getParallelEdgeRouter, getSelfLoopRouter, getSubgraphLayout, isComponentLayoutEnabled, isHideGroupsStageEnabled, isLabelingEnabled, isOrientationLayoutEnabled, isParallelEdgeRouterEnabled, isSelfLoopRouterEnabled, isSubgraphLayoutEnabled, prependStage, removeStage, setComponentLayout, setComponentLayoutEnabled, setHideGroupsStage, setHideGroupsStageEnabled, setLabeling, setLabelingEnabled, setLayoutOrientation, setOrientationLayout, setParallelEdgeRouter, setParallelEdgeRouterEnabled, setSelfLoopRouter, setSelfLoopRouterEnabled, setSubgraphLayout, setSubgraphLayoutEnabled
public static final NodeDpKey<Boolean> AFFECTED_NODES_DPKEY
DataProvider
key for marking the nodes that are part of the current scope
scope
of the algorithm is set to Scope.SUBSET
or Scope.MAINLY_SUBSET
.setScope(Scope)
public static final NodeDpKey<Boolean> FIXED_GROUP_NODES_DPKEY
DataProvider
key for marking group nodes as fixed
The content of a fixed group node will not be changed by this algorithm but be treated as fixed.
The groups marked as fixed will be considered for the group node policy
settings GroupsPolicy.FIXED
and GroupsPolicy.LAYOUT
. When GroupsPolicy.IGNORE
is chosen, the
data provider registered with this key will be ignored.
public static final EdgeDpKey<Double> PREFERRED_EDGE_LENGTH_DPKEY
DataProvider
key for defining an individual preferred length for each edge
default preferred length
will be used for edges that have no individual length
defined. For those that have, the default preferred length will be ignored.public ClassicOrganicLayout()
ClassicOrganicLayout
with default settings.public void applyLayoutCore(LayoutGraph graph)
applyLayoutCore
in class MultiStageLayout
graph
- the input graphpublic void dispose()
public int getAttraction()
The attraction influences the attractive force associated with edges. A higher attraction value can lead to more compact drawings, whereas a lower value potentially enlarges drawings.
The attraction is defined to range from 0
to 2
.
IllegalArgumentException
- if the attraction value is negative or greater than 2
[0,2]
setAttraction(int)
public double getFinalTemperature()
The algorithm starts with an initial temperature. During the iterations of the layout process, this temperature decreases.
setInitialTemperature(double)
,
setFinalTemperature(double)
public double getGravityFactor()
2.0
.setGravityFactor(double)
public IGroupBoundsCalculator getGroupBoundsCalculator()
IGroupBoundsCalculator
instance used for calculating the size of group nodes.MinimumSizeGroupBoundsCalculator
IGroupBoundsCalculator
instancesetGroupBoundsCalculator(IGroupBoundsCalculator)
public double getGroupNodeCompactness()
The compactness ranges from 0
to 1
where 0
results in group nodes not affecting the overall
layout too much while 1
forces nodes in the same group to be clustered tightly.
The compactness values needs to lie within [0,1]
.
IllegalArgumentException
- if compactness value does not lie within the interval [0,1]
setGroupNodeCompactness(double)
public GroupsPolicy getGroupNodePolicy()
The group policy defines whether this algorithm ignores
groups, leaves them fixed
or actively arranges
them.
IllegalArgumentException
- if the given policy is unknownis grouped
.GroupsPolicy.LAYOUT
setGroupNodePolicy(GroupsPolicy)
public InitialPlacement getInitialPlacement()
The initial placement has an influence on the final result, because this force-directed algorithm starts with some positions and then uses forces between nodes to finally aim for a stable result drawing.
IllegalArgumentException
- if the given initial placement mode is unknownInitialPlacement.AS_IS
if the changes to the input layout should be kept minimum and InitialPlacement.ZERO
if a neutral start placement should be used.InitialPlacement.ZERO
setInitialPlacement(InitialPlacement)
public double getInitialTemperature()
The algorithm starts with an initial temperature. During the iterations of the layout process, this temperature
decreases and if it reaches a certain limit, the process terminates. This limit can be controlled using
FinalTemperature
.
The initial temperature will be multiplied by the preferred edge length
and then
assigned as the actual initial heat of nodes.
setFinalTemperature(double)
,
setInitialTemperature(double)
public double getIterationFactor()
setIterationFactor(double)
public long getMaximumDuration()
The duration needs to be non-negative.
IllegalArgumentException
- if the specified duration has a negative valuesetMaximumDuration(long)
public double getPreferredEdgeLength()
The default preferred edge length will be used for edges that don't have an individual length preference defined via a IDataProvider
registered with key PREFERRED_EDGE_LENGTH_DPKEY
.
The preferred edge length needs to be non-negative.
IllegalArgumentException
- if the specified edge length is negativesetPreferredEdgeLength(double)
public int getRepulsion()
The repulsion influences the forces between nodes. A higher repulsion value can lead to more compact drawings, whereas a lower repulsion value potentially enlarges drawings.
The repulsion is defined to range from 0
to 2
.
IllegalArgumentException
- if the repulsion value is negative or greater than 2
[0,2]
setRepulsion(int)
public Scope getScope()
IllegalArgumentException
- if the given scope is unknownIDataProvider
registered with key AFFECTED_NODES_DPKEY
. If this IDataProvider
is missing, all nodes will be
arranged.Scope.ALL
AFFECTED_NODES_DPKEY
,
setScope(Scope)
public boolean isDeterministicModeEnabled()
In deterministic mode, the layout algorithm will yield the same results if the exact same input and same settings are given as input.
false
. The layout algorithm is non-deterministic.true
if the layout algorithm operates in deterministic mode, false
otherwisesetDeterministicModeEnabled(boolean)
public boolean isMultiThreadingAllowed()
false
. The layout algorithm runs single-threaded.true
if multi-threading is used, false
otherwisesetMultiThreadingAllowed(boolean)
public boolean isNodeSizeAware()
If this feature is disabled, overlaps between nodes (e.g. due to large node sizes) may occur.
true
. Node sizes are considered.true
if the sizes of nodes are taken into account, false
otherwisesetNodeSizeAware(boolean)
public boolean isTreeBeautifierEnabled()
Subtrees will be arranged in a balloon-like fashion
.
If this feature is disabled, subgraphs with a tree structure are arranged using the same style as for the rest of the graph.
In case that the input graph is a tree
and this feature is enabled, the whole graph will be drawn in a tree-like style.
balloon-like fashion
.false
. Subtrees are not handled differently.true
if subtrees are arranged in an special way, false
otherwisesetTreeBeautifierEnabled(boolean)
public void setAttraction(int value)
The attraction influences the attractive force associated with edges. A higher attraction value can lead to more compact drawings, whereas a lower value potentially enlarges drawings.
The attraction is defined to range from 0
to 2
.
IllegalArgumentException
- if the attraction value is negative or greater than 2
value
- the edge attraction value from the interval [0,2]
getAttraction()
public void setDeterministicModeEnabled(boolean value)
In deterministic mode, the layout algorithm will yield the same results if the exact same input and same settings are given as input.
false
. The layout algorithm is non-deterministic.value
- true
if the layout algorithm operates in deterministic mode, false
otherwiseisDeterministicModeEnabled()
public void setFinalTemperature(double value)
The algorithm starts with an initial temperature. During the iterations of the layout process, this temperature decreases.
value
- the final temperature valuesetInitialTemperature(double)
,
getFinalTemperature()
public void setGravityFactor(double value)
2.0
.value
- the gravity factorgetGravityFactor()
public void setGroupBoundsCalculator(IGroupBoundsCalculator value)
IGroupBoundsCalculator
instance used for calculating the size of group nodes.MinimumSizeGroupBoundsCalculator
value
- the IGroupBoundsCalculator
instancegetGroupBoundsCalculator()
public void setGroupNodeCompactness(double value)
The compactness ranges from 0
to 1
where 0
results in group nodes not affecting the overall
layout too much while 1
forces nodes in the same group to be clustered tightly.
The compactness values needs to lie within [0,1]
.
IllegalArgumentException
- if compactness value does not lie within the interval [0,1]
value
- the compactness value for group nodesgetGroupNodeCompactness()
public void setGroupNodePolicy(GroupsPolicy value)
The group policy defines whether this algorithm ignores
groups, leaves them fixed
or actively arranges
them.
IllegalArgumentException
- if the given policy is unknownis grouped
.GroupsPolicy.LAYOUT
value
- one of the predefined group node policiesgetGroupNodePolicy()
public void setInitialPlacement(InitialPlacement value)
The initial placement has an influence on the final result, because this force-directed algorithm starts with some positions and then uses forces between nodes to finally aim for a stable result drawing.
IllegalArgumentException
- if the given initial placement mode is unknownInitialPlacement.AS_IS
if the changes to the input layout should be kept minimum and InitialPlacement.ZERO
if a neutral start placement should be used.InitialPlacement.ZERO
value
- one of the predefined initial placement modesgetInitialPlacement()
public void setInitialTemperature(double value)
The algorithm starts with an initial temperature. During the iterations of the layout process, this temperature
decreases and if it reaches a certain limit, the process terminates. This limit can be controlled using
FinalTemperature
.
The initial temperature will be multiplied by the preferred edge length
and then
assigned as the actual initial heat of nodes.
value
- the initial temperature valuesetFinalTemperature(double)
,
getInitialTemperature()
public void setIterationFactor(double value)
value
- the iteration factor influencing the maximum number of allowed iterationsgetIterationFactor()
public void setMaximumDuration(long value)
The duration needs to be non-negative.
IllegalArgumentException
- if the specified duration has a negative valuevalue
- the non-negative duration in millisecondsgetMaximumDuration()
public void setMultiThreadingAllowed(boolean value)
false
. The layout algorithm runs single-threaded.value
- true
if multi-threading is used, false
otherwiseisMultiThreadingAllowed()
public void setNodeSizeAware(boolean value)
If this feature is disabled, overlaps between nodes (e.g. due to large node sizes) may occur.
true
. Node sizes are considered.value
- true
if the sizes of nodes are taken into account, false
otherwiseisNodeSizeAware()
public void setOrientationLayoutEnabled(boolean value)
ILayoutStage
that modifies the orientation of the layout is activated.setOrientationLayoutEnabled
in class MultiStageLayout
LayoutOrientation.TOP_TO_BOTTOM
, the orientation of the layout will not be
modified.OrientationLayout
has no significant
effect.true
. The orientation ILayoutStage
is activated.value
- true
if the stage that modifies the orientation is activated, false
otherwiseMultiStageLayout.isOrientationLayoutEnabled()
,
MultiStageLayout.setOrientationLayout(ILayoutStage)
,
MultiStageLayout.setLayoutOrientation(com.yworks.yfiles.layout.LayoutOrientation)
,
OrientationLayout
public void setPreferredEdgeLength(double value)
The default preferred edge length will be used for edges that don't have an individual length preference defined via a IDataProvider
registered with key PREFERRED_EDGE_LENGTH_DPKEY
.
The preferred edge length needs to be non-negative.
IllegalArgumentException
- if the specified edge length is negativevalue
- the non-negative preferred edge lengthgetPreferredEdgeLength()
public void setRepulsion(int value)
The repulsion influences the forces between nodes. A higher repulsion value can lead to more compact drawings, whereas a lower repulsion value potentially enlarges drawings.
The repulsion is defined to range from 0
to 2
.
IllegalArgumentException
- if the repulsion value is negative or greater than 2
value
- the node repulsion value from the interval [0,2]
getRepulsion()
public void setScope(Scope value)
IllegalArgumentException
- if the given scope is unknownIDataProvider
registered with key AFFECTED_NODES_DPKEY
. If this IDataProvider
is missing, all nodes will be
arranged.Scope.ALL
value
- one of the predefined scopesAFFECTED_NODES_DPKEY
,
getScope()
public void setTreeBeautifierEnabled(boolean value)
Subtrees will be arranged in a balloon-like fashion
.
If this feature is disabled, subgraphs with a tree structure are arranged using the same style as for the rest of the graph.
In case that the input graph is a tree
and this feature is enabled, the whole graph will be drawn in a tree-like style.
balloon-like fashion
.false
. Subtrees are not handled differently.value
- true
if subtrees are arranged in an special way, false
otherwiseisTreeBeautifierEnabled()