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.
IlvUniformLengthEdgesLayout
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
NO_RESHAPE_STYLE
Deprecated.
No links reshape option.
|
static int |
STRAIGHT_LINE_STYLE
Deprecated.
Straight-line links shape option.
|
INVERSE_VIEW_COORDINATES, MANAGER_COORDINATES, VIEW_COORDINATES
Constructor and Description |
---|
IlvSpringEmbedderLayout()
Deprecated.
Creates a new instance of the Spring Embedder layout algorithm.
|
IlvSpringEmbedderLayout(IlvSpringEmbedderLayout source)
Deprecated.
Creates a new layout instance by copying an existing one.
|
Modifier and Type | Method and Description |
---|---|
int |
checkAppropriateLink(Object link)
Deprecated.
Checks whether the input link is appropriate for this layout.
|
IlvGraphLayout |
copy()
Deprecated.
Copies the layout instance.
|
void |
copyParameters(IlvGraphLayout source)
Deprecated.
Copies the parameters from a given layout instance.
|
protected IlvGraphLayoutGrapherProperty |
createLayoutGrapherProperty(String name,
boolean withDefaults)
Deprecated.
Returns a new instance of
IlvSpringEmbedderLayoutGrapherProperty that stores the parameter
settings of this layout class. |
int |
getLinkStyle()
Deprecated.
Returns the current option for the style of the shape of the links.
|
IlvGraphicVector |
getMovingNodes()
Deprecated.
Returns the vector of nodes being moved by the graph layout algorithm.
|
double |
getSpringConstant()
Deprecated.
Returns the current spring constant.
|
protected void |
init()
Deprecated.
Initializes instance variables.
|
protected boolean |
isLayoutOfConnectedComponentsEnabledByDefault()
Deprecated.
Overridden version of the method from the superclass that always
returns
true . |
protected void |
layout(boolean redraw)
Deprecated.
Computes the layout using the Spring Embedder algorithm.
|
void |
setLinkStyle(int style)
Deprecated.
Sets the style of the shape of the links.
|
void |
setSpringConstant(double constant)
Deprecated.
Sets the constant for the springs.
|
boolean |
supportsAllowedTime()
Deprecated.
Indicates that this layout class can stop the layout computation in a
proper manner when the user-defined allowed time is exceeded.
|
boolean |
supportsAnimation()
Deprecated.
Indicates that this layout class supports the animation mechanism;
that is, it performs a redraw of the grapher after each iteration if
the method
setAnimate(boolean) is called with a
true argument. |
boolean |
supportsLayoutOfConnectedComponents()
Deprecated.
Indicates that this layout class can cut the attached graph into
connected components, apply itself to each connected component
separately, and then use the layout instance returned by the method
IlvGraphLayout.getLayoutOfConnectedComponents() to place the connected
components. |
boolean |
supportsLayoutRegion()
Deprecated.
Indicates that this layout class can control the size of the graph
drawing to fit (approximately) a user-defined region (a rectangle) or
a user-defined manager view.
|
boolean |
supportsLinkClipping()
Deprecated.
Indicates that this layout class can use a link clip interface to clip
the end points of a link.
|
boolean |
supportsLinkConnectionBox()
Deprecated.
Indicates that this layout class can use a link connection box
interface to calculate the end points of a link.
|
boolean |
supportsMemorySavings()
Deprecated.
Indicates that this layout class can perform the layout using two
partially different implementations: one that gives priority to
speed, the other that gives priority to memory usage.
|
boolean |
supportsPercentageComplete()
Deprecated.
Indicates that this layout class can determine the percentage of
completion during the run of layout.
|
boolean |
supportsPreserveFixedNodes()
Deprecated.
Indicates that this layout class allows the user to specify fixed
nodes.
|
boolean |
supportsRandomGenerator()
Deprecated.
Indicates that this layout class uses randomly generated numbers that
can be initialized with a user-defined seed value.
|
boolean |
supportsSaveParametersToNamedProperties()
Deprecated.
Indicates that this layout class can transfer the layout parameters to
named properties.
|
boolean |
supportsStopImmediately()
Deprecated.
Indicates that this layout class can interrupt the current run of the
layout immediately in a controlled way.
|
addGraphLayoutEventListener, addGraphLayoutParameterEventListener, afterLayoutOfSubgraph, attach, attach, beforeLayout, beforeLayoutOfSubgraph, callLayoutStepPerformedIfNeeded, checkAppropriateLinks, cleanGraphModel, cleanLink, cleanNode, clipAllLinks, clipLink, connectAllLinksToCenter, connectLinkToCenter, contentsChanged, createLayoutLinkProperty, createLayoutNodeProperty, createLayoutReport, detach, getAllowedTime, getAutoLayoutHandler, getBalanceSplineCurveThreshold, getCalcLayoutRegion, getCoordinatesMode, getGrapher, getGraphModel, getInstanceId, getLayout, getLayoutOfConnectedComponents, getLayoutOfConnectedComponentsReport, getLayoutRegion, getLayoutReport, getLayouts, getLinkClipInterface, getLinkConnectionBoxInterface, getMaxSplineCurveSize, getMinBusyTime, getMinSplineCurveSize, getParentLayout, getProperty, getProperty, getRecursiveLayout, getRemainingAllowedTime, getSeedValueForRandomGenerator, getSpecLayoutRegion, getSplineLinkFilter, increasePercentageComplete, isAnimate, isAutoLayout, isFitToView, isFixed, isGeometryUpToDate, isInputCheckEnabled, isLayoutNeeded, isLayoutOfConnectedComponentsEnabled, isLayoutRunning, isLayoutRunning, isLayoutTimeElapsed, isLocalRecursiveLayoutNeeded, isMemorySavings, isParametersUpToDate, isPreserveFixedLinks, isPreserveFixedNodes, isSplineRoutingEnabled, isStoppedImmediately, isStructureUpToDate, isUseDefaultParameters, isUseSeedValueForRandomGenerator, layoutStepPerformed, onParameterChanged, onParameterChanged, performAutoLayout, performLayout, performLayout, performLayout, PerformLayout, performSublayout, removeGraphLayoutEventListener, removeGraphLayoutParameterEventListener, setAllowedTime, setAnimate, setAutoCheckAppropriateLinksEnabled, setAutoLayout, setAutoLayoutHandler, setBalanceSplineCurveThreshold, setCoordinatesMode, setFixed, setGeometryUpToDate, setGrapher, setGraphModel, setInputCheckEnabled, setLayoutOfConnectedComponents, setLayoutOfConnectedComponentsEnabled, setLayoutRegion, setLayoutRegion, setLayoutRegion, setLayoutReport, setLayoutRunning, setLinkClipInterface, setLinkConnectionBoxInterface, setMaxSplineCurveSize, setMemorySavings, setMinBusyTime, setMinSplineCurveSize, setParametersUpToDate, setParentLayout, setPreserveFixedLinks, setPreserveFixedNodes, setProperty, setProperty, setSeedValueForRandomGenerator, setSplineLinkFilter, setSplineRoutingEnabled, setStructureUpToDate, setUseDefaultParameters, setUseSeedValueForRandomGenerator, stopImmediately, supportsPreserveFixedLinks, supportsSplineRouting, unfixAllLinks, unfixAllNodes, useAnimateRedraw
public static final int STRAIGHT_LINE_STYLE
setLinkStyle(int)
, the links are given a
straight-line shape.public static final int NO_RESHAPE_STYLE
setLinkStyle(int)
, the links are not reshaped.public IlvSpringEmbedderLayout()
IlvGraphLayout.attach(IlvGrapher)
. IlvGraphLayout.attach(IlvGraphModel)
. IlvGraphLayout.performLayout()
. public IlvSpringEmbedderLayout(IlvSpringEmbedderLayout source)
copy()
method. Any subclass should
provide a copy constructor.
The parameters of the source
layout are copied using the
method copyParameters(ilog.views.graphlayout.IlvGraphLayout)
.
source
- The layout instance that is copied.copy()
,
copyParameters(ilog.views.graphlayout.IlvGraphLayout)
protected void init()
You should not call this method directly. The method is called internally by the constructor without arguments and by the copy constructor. The method must be overridden by subclasses that need to initialize additional instance variables.
init
in class IlvGraphLayout
public IlvGraphLayout copy()
This method copies the layout instance by calling the copy constructor.
When performing a recursive layout of a nested graph, this method is
used by IlvLayoutProvider
to "clone" the layout instance of a
parent graph.
Note that the parameters which are specific to a node or a link are not copied. The other parameters, including the layout region specification and the link clip and link connection box interfaces, are also copied. A copy of the layout instance used for laying out the connected components is set on the new instance.
If a method of the type supportsXXX
is associated with a
parameter, the parameter is copied only if the corresponding method
returns true
.
copy
in class IlvGraphLayout
copyParameters(ilog.views.graphlayout.IlvGraphLayout)
public void copyParameters(IlvGraphLayout source)
Note that the parameters which are specific to a node or a link are not copied. The other parameters, including the layout region specification and the customization interfaces, are also copied. A copy of the layout instance used for laying out the connected components is set on this layout instance.
If a method of the type supportsXXX
is associated with a
parameter, the parameter is copied only if the corresponding method
returns true
.
copyParameters
in class IlvGraphLayout
source
- The layout instance from which the parameters are copied.copy()
protected boolean isLayoutOfConnectedComponentsEnabledByDefault()
true
.isLayoutOfConnectedComponentsEnabledByDefault
in class IlvGraphLayout
true
if the connected components layout mechanism
is enabled by default.IlvGraphLayout.setLayoutOfConnectedComponentsEnabled(boolean)
public final boolean supportsPreserveFixedNodes()
setPreserveFixedNodes(boolean)
is called with a
true
argument.supportsPreserveFixedNodes
in class IlvGraphLayout
true
IlvGraphLayout.setPreserveFixedNodes(boolean)
,
IlvGraphLayout.isPreserveFixedNodes()
public final boolean supportsLayoutRegion()
supportsLayoutRegion
in class IlvGraphLayout
true
IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView)
,
IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView, ilog.views.IlvRect)
,
IlvGraphLayout.setLayoutRegion(ilog.views.IlvRect)
,
IlvGraphLayout.getSpecLayoutRegion()
,
IlvGraphLayout.getCalcLayoutRegion()
public final boolean supportsRandomGenerator()
useSeedValueForRandomGenerator
with a true
argument.supportsRandomGenerator
in class IlvGraphLayout
true
IlvGraphLayout.setSeedValueForRandomGenerator(long)
,
IlvGraphLayout.getSeedValueForRandomGenerator()
,
IlvGraphLayout.setUseSeedValueForRandomGenerator(boolean)
,
IlvGraphLayout.isUseSeedValueForRandomGenerator()
public final boolean supportsAnimation()
setAnimate(boolean)
is called with a
true
argument.supportsAnimation
in class IlvGraphLayout
true
IlvGraphLayout.setAnimate(boolean)
,
IlvGraphLayout.isAnimate()
public final boolean supportsMemorySavings()
IlvGraphLayout.setMemorySavings(boolean)
. supportsMemorySavings
in class IlvGraphLayout
true
IlvGraphLayout.setMemorySavings(boolean)
,
IlvGraphLayout.isMemorySavings()
public final boolean supportsAllowedTime()
IlvGraphLayoutReport.STOPPED_AND_VALID
in this case.supportsAllowedTime
in class IlvGraphLayout
true
IlvGraphLayout.setAllowedTime(long)
,
IlvGraphLayout.getAllowedTime()
,
IlvGraphLayoutReport.getCode()
public final boolean supportsStopImmediately()
IlvGraphLayoutReport.STOPPED_AND_VALID
in this
case.supportsStopImmediately
in class IlvGraphLayout
true
IlvGraphLayout.stopImmediately()
,
IlvGraphLayout.isStoppedImmediately()
,
IlvGraphLayoutReport.getCode()
public final boolean supportsPercentageComplete()
supportsPercentageComplete
in class IlvGraphLayout
true
IlvGraphLayout.increasePercentageComplete(int)
,
IlvGraphLayoutReport.getPercentageComplete()
,
IlvJGraphLayoutProgressBar
public final boolean supportsLayoutOfConnectedComponents()
IlvGraphLayout.getLayoutOfConnectedComponents()
to place the connected
components. By default, this layout is an instance of IlvGridLayout
which can be
customized as needed.supportsLayoutOfConnectedComponents
in class IlvGraphLayout
true
IlvGraphLayout.getLayoutOfConnectedComponents()
,
IlvGraphLayout.isLayoutOfConnectedComponentsEnabled()
,
IlvGraphLayout.performLayout(boolean, boolean)
public final boolean supportsLinkConnectionBox()
The connection box interface is used only if link clipping is enabled
by setting a link clip interface and if the link style is straight
line. In this case, the layout algorithm calculates the virtual
center of the end nodes of each link by the link connection box
interface and obtains the final connection points by clipping with
the link clip interface. The virtual center is defined as the center
of the connection box shifted by the average of the tangential "top"
and "bottom" offset in the horizontal direction and by the average of
the tangential "left" and "right" offset in the vertical direction.
For instance, if the tangential offset is 20 at the top side and 10
at all other sides, the average shift offset is (20 + 10)/2 =
15
in the horizontal direction and (10 + 10)/2 =
10
in the vertical direction, hence the virtual center is at
connectionBox.center() + (15, 10)
.
If no link clipping is performed, the layout algorithm does not actively place the end points of links. It relies on the link connectors that are attached to the nodes to find appropriate connection points for the links.
supportsLinkConnectionBox
in class IlvGraphLayout
true
.IlvGraphLayout.setLinkConnectionBoxInterface(ilog.views.graphlayout.IlvLinkConnectionBoxInterface)
,
IlvGraphLayout.setLinkClipInterface(ilog.views.graphlayout.IlvLinkClipInterface)
,
IlvLinkConnector
,
setLinkStyle(int)
,
supportsLinkClipping()
public final boolean supportsLinkClipping()
Link clipping is performed only if the link style is straight line. If no link clip interface is given, the layout algorithm does not actively place the end points of links. It relies on the link connectors that are attached to the nodes to find appropriate connection points for the links.
supportsLinkClipping
in class IlvGraphLayout
true
.IlvGraphLayout.setLinkClipInterface(ilog.views.graphlayout.IlvLinkClipInterface)
,
IlvLinkConnector
,
setLinkStyle(int)
,
supportsLinkConnectionBox()
public final boolean supportsSaveParametersToNamedProperties()
.ivl
file.
supportsSaveParametersToNamedProperties
in class IlvGraphLayout
true
IlvGrapherAdapter.saveParametersToNamedProperties(IlvGraphLayout, boolean)
,
IlvGrapherAdapter.loadParametersFromNamedProperties(IlvGraphLayout)
,
IlvGrapherAdapter.removeParametersFromNamedProperties()
protected void layout(boolean redraw) throws IlvGraphLayoutException
IlvGraphLayout.performLayout()
.layout
in class IlvGraphLayout
redraw
- If true
, the attached graph model will be
asked to redraw the graph after layout. When the layout algorithm
moves the nodes and reshapes the links, it is required to pass the
value of the redraw
argument to the methods IlvGraphModel.moveNode(java.lang.Object, double, double, boolean)
and IlvGraphModel.reshapeLink(java.lang.Object, ilog.views.IlvPoint, ilog.views.IlvPoint[], int, int, ilog.views.IlvPoint, boolean)
.IlvInappropriateLinkException
- if the grapher contains links
that cannot be reshaped to a straight line and the link style is
STRAIGHT_LINE_STYLE
. (For details, see IlvInappropriateLinkException
.)IlvGraphLayoutException
- If an unusual situation occurs.
WARNING: this method can throw one of the subclasses of IlvGraphLayoutException
. Specifically, it can throw an IlvInappropriateGraphException
. It can also throw an IlvInappropriateLinkException
when inappropriate types of links
and/or link connectors are used in an IlvGrapher
. For
details, refer to the documentation of these exception classes.IlvGraphLayout.performLayout()
,
IlvGraphLayout.getCalcLayoutRegion()
public void setSpringConstant(double constant)
6.
to 18.
. A better range is from
12.
to 16.
.getSpringConstant()
public double getSpringConstant()
setSpringConstant(double)
public void setLinkStyle(int style)
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(ilog.views.graphlayout.IlvGraphModel, ilog.views.graphlayout.IlvLayoutProvider)
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
.
getLinkStyle()
public int getLinkStyle()
setLinkStyle(int)
public int checkAppropriateLink(Object link)
IlvGraphLayout.checkAppropriateLinks()
.
checkAppropriateLink
in class IlvGraphLayout
link
- The link to be checked.IlvGraphLayout.checkAppropriateLinks()
public IlvGraphicVector getMovingNodes()
IlvGrapherAdaper
in order to optimize for speed.getMovingNodes
in class IlvGraphLayout
protected IlvGraphLayoutGrapherProperty createLayoutGrapherProperty(String name, boolean withDefaults)
IlvSpringEmbedderLayoutGrapherProperty
that stores the parameter
settings of this layout class.
The method is used by IlvGrapherAdapter.saveParametersToNamedProperties(IlvGraphLayout,
boolean)
to create a named property that contains parameter settings
of this layout instance.
createLayoutGrapherProperty
in class IlvGraphLayout
IlvGraphLayoutGrapherProperty
,
IlvGrapherAdapter.saveParametersToNamedProperties(IlvGraphLayout, boolean)
,
IlvGrapherAdapter.loadParametersFromNamedProperties(IlvGraphLayout)
,
IlvGrapherAdapter.removeParametersFromNamedProperties()
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.