IlvUniformLengthEdgesLayout
instead.
public class IlvSpringEmbedderLayout extends IlvGraphLayout
The Spring Embedder Layout algorithm can be used to lay out any type
of graph. It often provides a drawing with no edge crossings or few
edge crossings for small- and medium-sized graphs. The nodes are
placed inside a rectangle which is controlled by the layoutRegion
parameter. It is important to specify a
layout region that is in proportion to the number and size of the
nodes.
This algorithm is based on an analogy between graph drawings and mechanical systems: Nodes correspond to point masses and edges correspond to springs. Attractive and repulsive forces between each pair of nodes are defined depending on the distance between the nodes and the connectivity of the graph. The algorithm searches a sort of minimal-energy configuration of the graph, computing iteratively the positions of the nodes.
Sample drawings produced with the Spring Embedder algorithm:
See the corresponding chapter of the User's Manual for details on the algorithm, the types of graphs for which this algorithm can be used, the features and limitations, code samples, parameters, and so on.
Note that the initial position of the nodes (at the moment you start
the layout) does not affect the resulting layout However, nodes
specified as fixed are not moved if you call the method
setPreserveFixedNodes
with a true
argument.
CSS example:
SDM {
GraphLayout : true;
}
GraphLayout {
graphLayout : @#layout;
// optional settings for the graph layout renderer
}
Subobject#layout {
class : "ilog.views.graphlayout.springembedder.IlvSpringEmbedderLayout";
allowedTime : "3";
animate : "false";
coordinatesMode : "MANAGER_COORDINATES";
layoutOfConnectedComponentsEnabled : "false";
linkStyle : "STRAIGHT_LINE_STYLE";
memorySavings : "false";
minBusyTime : "3";
seedValueForRandomGenerator : "3";
springConstant : "3.0";
useSeedValueForRandomGenerator : "false";
}
CSS specification of per-node and per-link layout parameters:
The following table lists the per-object rendering properties of the GraphLayout
renderer:
Property | Type | Default | Description |
---|---|---|---|
GraphLayout | IlvGraphLayout | null | Lets you define a different graph layout algorithm for each subgraph. If one is not specified, the same algorithm is applied recursively to all subgraphs. |
LayoutFixed | String | false | Deprecated, replaced by Fixed. |
Fixed | String | false | Lets you specify that the node or link must not be moved or reshaped by the layout algorithm. |
LayoutGroup | String | null | Lets you apply the algorithm to different groups of objects, one group after the other. |
LayoutIgnored | boolean | false | If true , the object is ignored by the layout. |
The per-node and per-link layout parameters are specified in the style sheet through the CSS rules for nodes and links, not through the CSS rule for graph layout. For instance:
link.tag {
LinkStyle : "ORTHOGONAL_STYLE";
}
Note that the names of the node and link layout parameters use an initial capital, unlike the regular properties. See also the documentation of the class IlvGraphLayoutRenderer.
IlvUniformLengthEdgesLayout
Modifier and Type | Property and Description |
---|---|
long |
allowedTime
Deprecated.
Sets the upper limit for the duration of the layout algorithm. |
boolean |
animate
Deprecated.
If the argument is true , specifies that layout algorithms
that support the animation mechanism will require the graph model to
redraw the graph after each iteration or step. |
java.lang.String |
class
Deprecated.
Default constructor. |
int |
coordinatesMode
Deprecated.
Sets the coordinates mode to be used during layout. |
boolean |
layoutOfConnectedComponentsEnabled
Deprecated.
Sets whether the generic connected component layout mechanism is enabled. |
int |
linkStyle
Deprecated.
Sets the style of the shape of the links. |
boolean |
memorySavings
Deprecated.
Sets whether the layout algorithm uses the memory saving mode. |
long |
minBusyTime
Deprecated.
Sets the minimal time that the layout algorithm can be busy. |
long |
seedValueForRandomGenerator
Deprecated.
Sets the seed value for the random generator. |
double |
springConstant
Deprecated.
Sets the constant for the springs. |
boolean |
useSeedValueForRandomGenerator
Deprecated.
Sets whether the user-defined seed value should be used for the random generator. |
public java.lang.String class
class : "ilog.views.graphlayout.springembedder.IlvSpringEmbedderLayout";
public long allowedTime
When an iterative layout algorithm is used, the iterations can be
stopped when this time is exceeded. Noniterative algorithms can also
use this parameter as an upper limit for the computation time. The
default value is normally 32000
(32 seconds). Subclasses
that support this feature can use a different default value depending
on their particular behavior. Layout algorithms that are stopped in
this way set the result code of the layout report either to IlvGraphLayoutReport#STOPPED_AND_VALID
or to IlvGraphLayoutReport#STOPPED_AND_INVALID
.
When the connected components of disconnected graphs are laid out
separately (see #supportsLayoutOfConnectedComponents()
), the
specified allowed time is considered as the total time for the layout
of all the connected components plus the time for the connected
components layout.
Note that the layout algorithm may not obey exactly the allowed time specification.
Note for implementers of layout algorithms: the method #performLayout(boolean, boolean, boolean)
does NOT automatically
stop the layout when the allowed time is exceeded. It is the sole
responsibility of the implementation of the method #layout(boolean)
to do this.
A RuntimeException
is thrown if the layout does not
support this mechanism.
allowedTime : "3";
public boolean animate
true
, specifies that layout algorithms
that support the animation mechanism will require the graph model to
redraw the graph after each iteration or step.
The default value is false
.
A RuntimeException
is thrown if the layout does not
support this option.
Note that to obtain a redraw of an IlvGrapher
after each
iteration or step, the method #performLayout(boolean, boolean,
boolean)
must be called with the value true
for the
redraw
argument.
animate : "false";
public int coordinatesMode
Valid values are:
ilog.views.graphlayout.IlvGraphLayout#MANAGER_COORDINATES
- The
geometry of the graph is computed using the coordinate space of the
manager (that is, the attached IlvGrapher
) without applying
any transformation.
This mode should be used if you visualize the graph at zoom level 1, or you do not visualize it at all, or the graph contains only fully zoomable objects. In all these cases there is no need to take the transformer into account during the layout.
Note that in this mode the dimensional parameters of the layout algorithms are considered as being specified in manager coordinates.
ilog.views.graphlayout.IlvGraphLayout#VIEW_COORDINATES
-
The geometry of the graph is computed in the coordinate space of the
manager view. More exactly, all the coordinates are transformed using
the current reference transformer.
This mode should be used if you want the dimensional parameters of the layout algorithms to be considered as being specified in manager view coordinates.
ilog.views.graphlayout.IlvGraphLayout#INVERSE_VIEW_COORDINATES
- The
geometry of the graph is computed using the coordinate space of the
manager view and then applying the inverse transformation. This mode
is equivalent to the "manager coordinates" mode if the geometry of
the graphic objects strictly obeys the transformer. (A small
difference may exist because of the limited precision of the
computations.)
On the contrary, if some graphic objects are either nonzoomable (see
IlvGraphic#zoomable
) or semizoomable (for example, links with
a maximum line width), this mode gives different results than the
manager coordinates mode. These results are optimal if the graph is
visualized using the same transformer as the one taken into account
during the layout.
Note that in this mode the dimensional parameters of the layout algorithms are considered as being specified in manager coordinates.
The default value is IlvGraphLayout#INVERSE_VIEW_COORDINATES
.
This option is useful only if the attached graph model is an IlvGrapherAdapter
(or a subclass). Otherwise, it has no effect.
Note: the coordinates mode of the layout is used only while this
layout is running. If layout is not running, operations on the
grapher adapter use the coordinates mode that was set on the grapher
adapter directly (see IlvGrapherAdapter#setCoordinatesMode
).
coordinatesMode : "MANAGER_COORDINATES";
Allowed values: |
MANAGER_COORDINATES |
VIEW_COORDINATES |
INVERSE_VIEW_COORDINATES |
public boolean layoutOfConnectedComponentsEnabled
#supportsLayoutOfConnectedComponents()
), the method
#performLayout(boolean, boolean, boolean)
cuts the attached
graph model into connected components and lays out each connected
component separately. Then the connected components are placed using
the layout instance returned by the method #getLayoutOfConnectedComponents()
.
Notice that the connected component layout is not used if the graph is connected.
A RuntimeException
is thrown if the layout does not
support this mechanism.
The default value is the value returned by the method #isLayoutOfConnectedComponentsEnabledByDefault()
.
CSS example:
layoutOfConnectedComponentsEnabled : "false";
public int linkStyle
STRAIGHT_LINE_STYLE
(the links are given a straight-line
shape) and NO_RESHAPE_STYLE
(no reshape is performed on
the links).
This feature can be useful if the graph contains links that have
intermediate points and are not straight-line links, for instance
IlvPolylineLinkImage
links with intermediate points.
Note that when the graph attached to the layout is of type IlvGrapher
, the effect of the link reshaping depends on the type of
the links and the connectors installed at the node. For all link
styles, we recommend using links of type IlvPolylineLinkImage
and either no link connector
or any link connector except IlvFreeLinkConnector
. Other link or
connector types may cause an IlvInappropriateLinkException
during layout. You can use the method IlvGraphLayoutUtil#EnsureAppropriateLinks
before layout or when the
exception is caught to convert all links and link connectors to an
appropriate type.
The default value is STRAIGHT_LINE_STYLE
.
CSS example:
linkStyle : "STRAIGHT_LINE_STYLE";
Allowed values: | ||
STRAIGHT_LINE_STYLE |
Straight-line links | |
NO_RESHAPE_STYLE |
No link reshape |
public boolean memorySavings
true
, indicates that the layout algorithm is
to use the implementation that consumes less memory.
The default value of the parameter is false
.
This option should not have any effect on the resulting layout.
However, the implementation of the method #layout
is solely
responsible for the resulting layout.
A RuntimeException
is thrown if the layout does not
support this option.
memorySavings : "false";
public long minBusyTime
#layoutStepPerformed()
when the
method #callLayoutStepPerformedIfNeeded()
is used.
The objective is to avoid the overhead of #layoutStepPerformed()
becoming too high if the method is called too
often. Internal routines of layout algorithms usually call #callLayoutStepPerformedIfNeeded()
, which calls #layoutStepPerformed()
if the time since the last call was at least
the minimal busy time.
The default value is 50 (milliseconds).
minBusyTime : "3";
public long seedValueForRandomGenerator
0
. The user-defined seed value is used only if you call
setUseSeedValueForRandomGenerator(boolean)
with a
true
argument.
A RuntimeException
is thrown if the layout does not
support this mechanism.
seedValueForRandomGenerator : "3";
useSeedValueForRandomGenerator
public double springConstant
6.
to 18.
. A better range is from
12.
to 16.
.
springConstant : "3.0";
public boolean useSeedValueForRandomGenerator
A RuntimeException
is thrown if the layout does not
support this mechanism.
useSeedValueForRandomGenerator : "false";
seedValueForRandomGenerator
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.