|
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.organic.SmartOrganicLayouter
public class SmartOrganicLayouter
This class can be used as a convenience class to gain access to a variety of organic layout algorithms. Its strength lies in being able to conveniently specify a ratio between quality and running time, as well as the ability to specify the degree of the compactness of the drawing and to guarantee non-overlapping nodes.
Field Summary | |
---|---|
static Object |
GROUP_NODE_MODE_DATA
The data provider key for specifying how to handle group nodes. |
static Object |
GROUP_NODE_MODE_FIX_BOUNDS
Group node mode constant that can be used to tag a group node. |
static Object |
GROUP_NODE_MODE_FIX_CONTENTS
Group node mode constant that can be used to tag a group node. |
static Object |
GROUP_NODE_MODE_NORMAL
Group node mode constant that can be used to tag a group node. |
static Object |
NODE_SUBSET_DATA
The data provider key for specifying the node subset to be laid out. |
static Object |
PREFERRED_EDGE_LENGTH_DATA
The data provider key for specifying the preferred edge lengths for each edge The algorithm expects to find DataProvider.getInt(Object) integer values associated with
each edge. |
static byte |
SCOPE_ALL
Scope constant - used for laying out all nodes. |
static byte |
SCOPE_MAINLY_SUBSET
Scope constant - used for laying out mainly the subset of the nodes. |
static byte |
SCOPE_SUBSET
Scope constant - used for laying out the subset of nodes only. |
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
SmartOrganicLayouter()
Creates a new SmartOrganicLayouter instance |
Method Summary | |
---|---|
protected boolean |
canLayoutCore(LayoutGraph graph)
Subclasses have to provide information whether or not they can layout the given graph. |
protected void |
configureComponentLayouter(LayoutGraph graph,
ComponentLayouter layouter)
Configures the ComponentLayouter
and graph instance to adhere to the NODE_SUBSET_DATA in case
SCOPE_ALL is not set, and to use getMinimalNodeDistance() also for distances between components. |
void |
doLayout(LayoutGraph layoutGraph)
Calculates a layout for the given graph. |
protected void |
doLayoutCore(LayoutGraph graph)
Subclasses have to provide core layout code in this method. |
double |
getAutoClusteringQuality()
Returns the quality ratio of the clustering algorithm. |
double |
getCompactness()
Returns the property for the compactness of the resulting layout. |
GroupBoundsCalculator |
getGroupBoundsCalculator()
Returns the GroupBoundsCalculator instance used for calculating the size of group nodes. |
double |
getGroupNodeCompactness()
Returns the group node compactness factor. |
long |
getMaximumDuration()
Returns the maximum duration this algorithm is allowed to run. |
double |
getMinimalNodeDistance()
Returns the current minimal node distance this algorithm should enforce if the node overlaps allowance property is set to true . |
OutputRestriction |
getOutputRestriction()
Returns the current OutputRestriction instance set for this instance. |
double |
getPreferredEdgeLength()
Returns the currently set default preferred edge length. |
double |
getPreferredMinimalNodeDistance()
Returns the current preferred minimal node distance this algorithm should use for pairs of nodes that are not directly connected by adjacent edges. |
double |
getQualityTimeRatio()
Returns the quality to time ratio. |
byte |
getScope()
Returns the scope of the layout. |
boolean |
isAutoClusteringEnabled()
Returns whether or not a clustering algorithm should be applied. |
boolean |
isAutomaticGroupNodeCompactionEnabled()
Returns whether or not the automatic group node compaction is used. |
boolean |
isConsiderNodeLabelsEnabled()
Returns whether or not node labels are considered for the next layout run. |
boolean |
isDeterministic()
Returns whether the algorithm will behave deterministically in the next layout run. |
boolean |
isNodeEdgeOverlapAvoided()
Returns whether this algorithm is configured to try to avoid node/edge overlaps. |
boolean |
isNodeOverlapsAllowed()
Returns whether node overlaps are allowed (but not encouraged) for the next run. |
boolean |
isNodeSizeAware()
Determines whether the algorithm should consider the size of the nodes for the layout. |
boolean |
isSmartComponentLayoutEnabled()
Determines whether this instance should configure the ComponentLayouter
in such a way that it respects the scope's settings SCOPE_SUBSET and
SCOPE_MAINLY_SUBSET by keeping other nodes pinned, even if they reside in different components. |
void |
setAutoClusteringEnabled(boolean autoClusteringEnabled)
Specifies whether or not a clustering algorithm should be applied to the input graph. |
void |
setAutoClusteringQuality(double autoClusteringQuality)
Specifies the quality measure of the clustering algorithm, if option setAutoClusteringEnabled(boolean) is enabled,
Possible values are all doubles d with 0 <= d <= 1. |
void |
setAutomaticGroupNodeCompactionEnabled(boolean enabled)
Specifies whether or not to use the automatic group node compaction. |
void |
setCompactness(double compactness)
Sets the compactness property for the next layout run. |
void |
setConsiderNodeLabelsEnabled(boolean considerNodeLabelsEnabled)
Specifies whether or not to consider node labels for the next layout run. |
void |
setDeterministic(boolean deterministic)
Sets this algorithm to deterministic mode. |
void |
setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
Sets the GroupBoundsCalculator instance used for calculating the size of group nodes. |
void |
setGroupNodeCompactness(double groupNodeCompactness)
Sets the compactness of group nodes. |
void |
setMaximumDuration(long maximumDurationMillis)
Sets the soft limit for the maximum duration this algorithm is allowed to execute. |
void |
setMinimalNodeDistance(double minimalNodeDistance)
Sets the minimal node distance this algorithm should enforce between all pairs of nodes for the next run. |
void |
setNodeEdgeOverlapAvoided(boolean nodeEdgeOverlapAvoided)
Specifies whether or not to try to avoid node/edge overlaps. |
void |
setNodeOverlapsAllowed(boolean nodeOverlapsAllowed)
Determines whether the next layout run should enforce non-overlapping nodes. |
void |
setNodeSizeAware(boolean nodeSizeAware)
Specifies whether or not to consider node sizes for the next layout run. |
void |
setOutputRestriction(OutputRestriction restriction)
Sets a restriction on the output generated by this layouter |
void |
setPreferredEdgeLength(double preferredEdgeLength)
Sets the default preferred edge length for the next algorithm run. |
void |
setPreferredMinimalNodeDistance(double preferredMinimalNodeDistance)
Sets the minimal node distance this algorithm should try to obey for the next run. |
void |
setQualityTimeRatio(double qualityTimeRatio)
Specifies the quality to time ratio. |
void |
setScope(byte scope)
Sets the scope for the next layout run. |
void |
setSmartComponentLayoutEnabled(boolean smartComponentLayoutEnabled)
Sets whether this instance should configure the ComponentLayouter
in such a way that it respects the scope's settings SCOPE_SUBSET and
SCOPE_MAINLY_SUBSET by keeping other nodes pinned, even if they reside in different components. |
protected void |
unconfigureComponentLayouter(LayoutGraph graph,
ComponentLayouter layouter)
Resets the ComponentLayouter from the previous
configureComponentLayouter(y.layout.LayoutGraph,y.layout.ComponentLayouter)
call. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte SCOPE_ALL
setScope(byte)
,
Constant Field Valuespublic static final byte SCOPE_SUBSET
DataProvider
for key NODE_SUBSET_DATA
.
setScope(byte)
,
Constant Field Valuespublic static final byte SCOPE_MAINLY_SUBSET
DataProvider
for key NODE_SUBSET_DATA
.
setScope(byte)
,
Constant Field Valuespublic static final Object NODE_SUBSET_DATA
boolean
that indicates whether the node belongs
to the "sphere of action".
setScope(byte)
public static final Object GROUP_NODE_MODE_DATA
null
:
null
will be treated like GROUP_NODE_MODE_NORMAL
.
public static final Object GROUP_NODE_MODE_NORMAL
GROUP_NODE_MODE_DATA
DataProvider key to associate this constant
with a group node to indicate that it should be treated like an ordinary group node.
public static final Object GROUP_NODE_MODE_FIX_BOUNDS
GROUP_NODE_MODE_DATA
DataProvider key to associate this constant
with a group node to indicate that its bounds should be treated as fixed an
its contents should never exceed those bounds.
public static final Object GROUP_NODE_MODE_FIX_CONTENTS
GROUP_NODE_MODE_DATA
DataProvider key to associate this constant
with a group node to indicate that it can be moved like an ordinary group node however its
contents should remain fixed relative to the position of the group node.
Note that this implicitly fixes all descendants of the group node.
public static final Object PREFERRED_EDGE_LENGTH_DATA
DataProvider.getInt(Object)
integer values associated with
each edge.
Constructor Detail |
---|
public SmartOrganicLayouter()
Method Detail |
---|
public double getGroupNodeCompactness()
setAutomaticGroupNodeCompactionEnabled(boolean)
is disabled.
By default this value is 0.4
.
setGroupNodeCompactness(double)
,
setAutomaticGroupNodeCompactionEnabled(boolean)
public void setGroupNodeCompactness(double groupNodeCompactness)
setAutomaticGroupNodeCompactionEnabled(boolean)
is disabled.
By default this value is 0.4
.
IllegalArgumentException
- if compactness value does not lie in [0..1]groupNodeCompactness
- the new value.setAutomaticGroupNodeCompactionEnabled(boolean)
public boolean isAutomaticGroupNodeCompactionEnabled()
setCompactness(double)
). The value specified by option setGroupNodeCompactness(double)
is
ignored.
By default this option is enabled.
setAutomaticGroupNodeCompactionEnabled(boolean)
,
setGroupNodeCompactness(double)
,
setCompactness(double)
public void setAutomaticGroupNodeCompactionEnabled(boolean enabled)
setCompactness(double)
). The value specified by option setGroupNodeCompactness(double)
is
ignored.
By default this option is enabled.
enabled
- whether to use the automatic group node compaction.setGroupNodeCompactness(double)
,
setCompactness(double)
public boolean isAutoClusteringEnabled()
By default, automatic clustering is not enabled.
setAutoClusteringEnabled(boolean)
public void setAutoClusteringEnabled(boolean autoClusteringEnabled)
By default, automatic clustering is not enabled.
Note: the runtime of the clustering algorithm does not depend on the specified maximal duration (see method setMaximumDuration(long)
).
autoClusteringEnabled
- whether the clustering should be applied.public double getAutoClusteringQuality()
setAutoClusteringQuality(double)
public void setAutoClusteringQuality(double autoClusteringQuality)
setAutoClusteringEnabled(boolean)
is enabled,
Possible values are all doubles d with 0 <= d <= 1.
The higher d the higher the clustering quality.
Default value is 1.
Note: the expected runtime of the clustering algorithm increases with d.
The runtime does not depend on the specified maximal duration (see method setMaximumDuration(long)
).
autoClusteringQuality
- the quality ratio.public boolean isConsiderNodeLabelsEnabled()
Default value is false
.
true
, the labels of nodes are taken
into account for the next layout run.setConsiderNodeLabelsEnabled(boolean)
public void setConsiderNodeLabelsEnabled(boolean considerNodeLabelsEnabled)
setNodeSizeAware(boolean)
, i.e.
node sizes are always considered.
Default value is false
.
considerNodeLabelsEnabled
- if true
, the labels of nodes are taken
into account for the next layout run.isConsiderNodeLabelsEnabled()
public GroupBoundsCalculator getGroupBoundsCalculator()
GroupBoundsCalculator
instance used for calculating the size of group nodes.
The default is MinimumSizeGroupBoundsCalculator
.
public boolean isSmartComponentLayoutEnabled()
ComponentLayouter
in such a way that it respects the scope's
settings SCOPE_SUBSET
and
SCOPE_MAINLY_SUBSET
by keeping other nodes pinned, even if they reside in different components.
The default is false
.
configure
the component layouter instance.isSmartComponentLayoutEnabled()
public void setSmartComponentLayoutEnabled(boolean smartComponentLayoutEnabled)
ComponentLayouter
in such a way that it respects the scope's
settings SCOPE_SUBSET
and
SCOPE_MAINLY_SUBSET
by keeping other nodes pinned, even if they reside in different components.
The default is false
.
isSmartComponentLayoutEnabled()
public void setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
GroupBoundsCalculator
instance used for calculating the size of group nodes.
The default is MinimumSizeGroupBoundsCalculator
.
NullPointerException
- if the argument is null
groupBoundsCalculator
- the instance to usepublic boolean isNodeEdgeOverlapAvoided()
By default, this option is not enabled.
setNodeEdgeOverlapAvoided(boolean)
public void setNodeEdgeOverlapAvoided(boolean nodeEdgeOverlapAvoided)
false
.
Note that the current implementation does not guarantee the non-existence
of overlaps but tries to avoid them.
nodeEdgeOverlapAvoided
- if true
, the algorithm tries to
avoid node/edge overlaps.protected void configureComponentLayouter(LayoutGraph graph, ComponentLayouter layouter)
ComponentLayouter
and graph instance to adhere to the NODE_SUBSET_DATA
in case
SCOPE_ALL
is not set, and to use getMinimalNodeDistance()
also for distances between components.
This will result in the component layouter not rearranging components if they contain
pinned-down nodes.
graph
- the graph that will be arrangedlayouter
- the layouter to reconfigureunconfigureComponentLayouter(y.layout.LayoutGraph,y.layout.ComponentLayouter)
,
setSmartComponentLayoutEnabled(boolean)
public void doLayout(LayoutGraph layoutGraph)
CanonicMultiStageLayouter
doLayout
in interface Layouter
doLayout
in class CanonicMultiStageLayouter
protected void unconfigureComponentLayouter(LayoutGraph graph, ComponentLayouter layouter)
ComponentLayouter
from the previous
configureComponentLayouter(y.layout.LayoutGraph,y.layout.ComponentLayouter)
call.
graph
- the graph that has been arrangedlayouter
- the layouter to reset.configureComponentLayouter(y.layout.LayoutGraph,y.layout.ComponentLayouter)
,
setSmartComponentLayoutEnabled(boolean)
protected boolean canLayoutCore(LayoutGraph graph)
CanonicMultiStageLayouter
canLayoutCore
in class CanonicMultiStageLayouter
protected void doLayoutCore(LayoutGraph graph)
CanonicMultiStageLayouter
doLayoutCore
in class CanonicMultiStageLayouter
public double getQualityTimeRatio()
The default value is 0.6
.
public void setQualityTimeRatio(double qualityTimeRatio)
The default value is 0.6
.
IllegalArgumentException
- if the specified ratio is less than
0
or greater than 1
.qualityTimeRatio
- a value between 0.0 (low quality, fast)
and 1.0 (high quality, slow)getQualityTimeRatio()
public long getMaximumDuration()
By default, the maximum duration is set to 30 seconds.
public void setMaximumDuration(long maximumDurationMillis)
By default, the maximum duration is set to 30 seconds.
IllegalArgumentException
- if the specified duration is less than
0
.maximumDurationMillis
- the new soft limit for the duration in millisecondspublic byte getScope()
SCOPE_ALL
, SCOPE_SUBSET
, or SCOPE_MAINLY_SUBSET
setScope(byte)
public void setScope(byte scope)
Defaults to SCOPE_ALL
.
Note:
For all scopes but SCOPE_ALL
, a data provider for key
NODE_SUBSET_DATA
has to be registered.
scope
- the new scope, should be one of SCOPE_ALL
, SCOPE_SUBSET
, or SCOPE_MAINLY_SUBSET
getScope()
,
NODE_SUBSET_DATA
public double getCompactness()
The default value is 0.5
.
public void setCompactness(double compactness)
0.5d
being a "normal" compactness.
The default value is 0.5
.
IllegalArgumentException
- if the specified value is less than
0
or greater than 1
.compactness
- the new compactness value [0.0d .. 1.0d]public double getPreferredEdgeLength()
double
DataProvider instance bound to the graph using the
PREFERRED_EDGE_LENGTH_DATA
key.
public void setPreferredEdgeLength(double preferredEdgeLength)
preferredEdgeLength
- the new default preferred edge lengthgetPreferredEdgeLength()
public double getPreferredMinimalNodeDistance()
public void setPreferredMinimalNodeDistance(double preferredMinimalNodeDistance)
preferredMinimalNodeDistance
- the new preferred minimal distance between two nodes that are not directly connected to each otherpublic boolean isNodeSizeAware()
true
the algorithm will take the node size into account
for given preferred edge lengths.
public void setNodeSizeAware(boolean nodeSizeAware)
nodeSizeAware
- if true
, the sizes of nodes are taken
into account for the next layout run.public boolean isDeterministic()
public void setDeterministic(boolean deterministic)
true
, the algorithm will yield
the same results if given the exact same input and same settings.
deterministic
- whether to operate in deterministic modepublic double getMinimalNodeDistance()
true
.
The default value is 0
.
public void setMinimalNodeDistance(double minimalNodeDistance)
The default value is 0
.
minimalNodeDistance
- the minimal distance between nodes that are not interconnected by a common edgesetNodeOverlapsAllowed(boolean)
public boolean isNodeOverlapsAllowed()
By default, node overlaps are not allowed.
Note: if scope is set to SCOPE_SUBSET or SCOPE_MAINLY_SUBSET, there might be some overlapping nodes even if this option is set to false.
public void setNodeOverlapsAllowed(boolean nodeOverlapsAllowed)
By default, node overlaps are not allowed.
Note: if scope is set to SCOPE_SUBSET or SCOPE_MAINLY_SUBSET, there might be some overlapping nodes even if this option is set to false.
nodeOverlapsAllowed
- whether to allow node overlapssetMinimalNodeDistance(double)
,
setScope(byte)
public void setOutputRestriction(OutputRestriction restriction)
restriction
- the restriction to useOutputRestriction.NONE
,
OutputRestriction
public OutputRestriction getOutputRestriction()
OutputRestriction.NONE
.
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |