public abstract class IlvGraphLayout extends Object implements Serializable, GraphModelListener
JViews provides special support for applications that need to display
graphs (also called networks) of nodes and links. Using the IlvGrapher
class, any graphic object can be defined to behave like a
node and can be connected to other nodes with links, which themselves
can have many different forms. Used in conjunction with layout
algorithms, this feature is often used to create network topologies
for telecommunications networks and system management applications.
The usage of the Graph Layout algorithms is not restricted to
applications using an IlvGrapher
to store and display the
graph. You can use external graph data source structures. This is
achieved through the generic graph model (see IlvGraphModel
).
This abstract class defines the API that is necessary to allow the
graph layout algorithms to work. To use an external graph, all you
need to do is to implement an adapter that connects the graph with the
generic graph model. For details, see the class IlvGraphModel
.
The class IlvGraphLayout
is abstract and cannot be used
directly. You must use one of its concrete subclasses.
You can also create your own subclasses to implement other layout
algorithms. Note that, in order to be applied on any graph, the
layout algorithms must be written using the API of IlvGraphModel
instead of the API of IlvGrapher
.
The class contains layout parameters or options that can be useful for
different layout algorithms. The implementation of the layout(boolean)
method is solely responsible for whether or not the
current settings of the parameters are taken into account.
Note that all layout parameters that are specific to nodes or links,
such as the "fixed" attribute (see setFixed(Object, boolean)
,
isFixed(Object)
), can be accessed only while the graph that
contains the nodes or links is attached to the layout instance. Also,
if the attached graph model is an IlvGrapherAdapter
, layout
parameters that are specific to nodes or links must be set after
specifying filtering rules (see IlvGrapherAdapter.addLayer(ilog.views.IlvManagerLayer)
,
IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)
).
If the documentation does not indicate a different coordinate space,
all dimensional parameters are expressed in the same coordinate space
as the position and dimension of the nodes and the link points. In
particular, when laying out an IlvGrapher
, the dimensional
parameters are expressed by default in the coordinate space of the
manager, not in the coordinate space of the view (IlvManagerView
). However, optionally, the coordinate space of the
view can be used. For details, see setCoordinatesMode(int)
.
If you want to perform the layout on a subset of the nodes and links
of and IlvGrapher
, you can use a filter (see the class IlvLayoutGraphicFilter
and the method IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)
, or the method IlvGrapherAdapter.addLayer(ilog.views.IlvManagerLayer)
). The filter allows the layout algorithm
to determine, for each node and link of a graph, if it must be taken
into account or can be ignored.
If you want to perform the layout recursively over a nested graph
(for instance, an IlvGrapher
contained in another IlvGrapher
), you can use the method performLayout(boolean,
boolean, boolean)
and pass true
for the
traverse
argument. Alternatively, you can use the method
PerformLayout(IlvGraphModel, IlvLayoutProvider, boolean,
boolean, boolean)
.
To learn more about the layout algorithms and the corresponding
IlvGraphLayout
subclasses, read the sections of the
Reference Manual describing those classes and the JViews Graph Layout
User's Manual.
Note that when implementing a subclass of IlvGraphLayout
,
the initialization of all instance variables of the subclass needs to
be done in the overridden implementation of the method init()
. This is to prevent execution of methods of the subclasses
before the initialization of the instance variables of the subclasses.
Note also that you must call the method detach()
when you no
longer need the layout instance, otherwise some objects may not be
garbage collected. This is necessary only if the layout instance is
directly created by your code. Calling detach()
is not
necessary if the layout instance is created internally by the JViews
Graph Layout library, when using an IlvDefaultLayoutProvider
for recursive layout.
IlvBusLayout
,
IlvCircularLayout
,
IlvGridLayout
,
IlvHierarchicalLayout
,
IlvLinkLayout
,
IlvShortLinkLayout
,
IlvLongLinkLayout
,
IlvRandomLayout
,
IlvSpringEmbedderLayout
,
IlvTopologicalMeshLayout
,
IlvTreeLayout
,
IlvUniformLengthEdgesLayout
,
IlvGraphModel
,
IlvGrapherAdapter
,
IlvGrapher
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
INVERSE_VIEW_COORDINATES
Inverse view coordinates mode.
|
static int |
MANAGER_COORDINATES
Manager coordinates mode.
|
static int |
VIEW_COORDINATES
View coordinates mode.
|
Constructor and Description |
---|
IlvGraphLayout()
Creates a new instance of the layout algorithm.
|
IlvGraphLayout(IlvGraphLayout source)
Creates a new layout instance by copying an existing one.
|
Modifier and Type | Method and Description |
---|---|
void |
addGraphLayoutEventListener(GraphLayoutEventListener listener)
Adds a listener for the layout events delivered during the layout.
|
void |
addGraphLayoutParameterEventListener(GraphLayoutParameterEventListener listener)
Adds a listener for the layout parameter events delivered when layout
parameters change.
|
protected void |
afterLayoutOfSubgraph(IlvGraphModel subgraph)
Performs postprocessing operations after the layout of each subgraph
or connected component.
|
void |
attach(IlvGrapher grapher)
Sets the grapher to be laid out.
|
void |
attach(IlvGraphModel graphModel)
Sets the graph model to be laid out.
|
protected void |
beforeLayout(boolean redraw)
Performs preprocessing operations before the layout of the entire
graph.
|
protected void |
beforeLayoutOfSubgraph(IlvGraphModel subgraph)
Performs preprocessing operations before the layout of each subgraph
or connected component.
|
void |
callLayoutStepPerformedIfNeeded()
Calls
layoutStepPerformed when necessary. |
int |
checkAppropriateLink(Object link)
Checks whether the input link is appropriate for this layout.
|
void |
checkAppropriateLinks()
Throws an exception if the links are not appropriate for the layout.
|
void |
cleanGraphModel(IlvGraphModel graphModel)
Cleans a graph model.
|
void |
cleanLink(IlvGraphModel graphModel,
Object link)
Cleans a link.
|
void |
cleanNode(IlvGraphModel graphModel,
Object node)
Cleans a node.
|
void |
clipAllLinks(boolean toCenter,
boolean redraw)
Clips all links at their end nodes by using the link clip interface.
|
void |
clipLink(Object link,
boolean toCenter,
boolean atFromSide,
boolean atToSide,
boolean redraw)
Clips the link at both end nodes by using the link clip interface and
the link connection box interface.
|
void |
connectAllLinksToCenter(boolean redraw)
Connects all links to the center of their end nodes.
|
void |
connectLinkToCenter(Object link,
boolean atFromSide,
boolean atToSide,
boolean redraw)
Connects the link to the node center at both end nodes by using the
link connection box interface.
|
void |
contentsChanged(GraphModelEvent event)
Called when the structure or the geometry of the graph changes.
|
abstract IlvGraphLayout |
copy()
Copies the layout instance.
|
void |
copyParameters(IlvGraphLayout source)
Copies the parameters from a given layout instance.
|
protected IlvGraphLayoutGrapherProperty |
createLayoutGrapherProperty(String name,
boolean withDefaults)
Returns a new instance of a named property that can store the
parameter settings of this layout class.
|
protected IlvGraphLayoutLinkProperty |
createLayoutLinkProperty(String name,
IlvGraphic link,
boolean withDefaults)
Returns a new instance of a named property that can store the
parameter settings of this layout class for links.
|
protected IlvGraphLayoutNodeProperty |
createLayoutNodeProperty(String name,
IlvGraphic node,
boolean withDefaults)
Returns a new instance of a named property that can store the
parameter settings of this layout class for nodes.
|
IlvGraphLayoutReport |
createLayoutReport()
Returns a new instance of the layout report.
|
void |
detach()
Detaches the graph model from the layout instance.
|
long |
getAllowedTime()
Returns the currently allowed time for the layout algorithm in
milliseconds.
|
IlvAutoLayoutHandler |
getAutoLayoutHandler()
Returns the auto layout handler.
|
double |
getBalanceSplineCurveThreshold()
Returns the threshold for spline curves at bends which the optimized
spline control point routing uses to balance the curve.
|
IlvRect |
getCalcLayoutRegion()
Returns a copy of the rectangle that defines the layout region
parameter.
|
int |
getCoordinatesMode()
Returns the current coordinates mode.
|
IlvGrapher |
getGrapher()
Returns the
IlvGrapher that contains the nodes and links to be
laid out. |
IlvGraphModel |
getGraphModel()
Returns the graph model to lay out if a graph model is attached.
|
int |
getInstanceId()
A utility method that returns a unique integer value for each layout
instance in the same Java program.
|
IlvGraphLayout |
getLayout(Object subgraph)
Returns the layout instance for a subgraph of the nested graph
encapsulated by the graph model of this layout instance.
|
IlvGraphLayout |
getLayoutOfConnectedComponents()
Returns the layout instance that lays out the connected components of
the graph.
|
IlvGraphLayoutReport |
getLayoutOfConnectedComponentsReport()
Returns the layout report containing information about the behavior of
the connected components layout.
|
IlvRect |
getLayoutRegion()
Returns a copy of the rectangle that defines the layout region, as
specified using the method
setLayoutRegion(IlvRect) , or
null if no rectangle has been specified, or the
specified rectangle was null . |
IlvGraphLayoutReport |
getLayoutReport()
Returns the layout report, that is, the object that contains
information about the behavior of the layout algorithm.
|
Enumeration |
getLayouts(boolean preOrder)
Returns the instances of
IlvGraphLayout for the nested
graph encapsulated by the graph model of this layout instance. |
IlvLinkClipInterface |
getLinkClipInterface()
Returns the clip interface used for the connection points of links
during layout.
|
IlvLinkConnectionBoxInterface |
getLinkConnectionBoxInterface()
Returns the link connection box interface used to calculate the
connection points of links during layout.
|
double |
getMaxSplineCurveSize()
Returns the maximum curve size used when spline control point
optimization routing is enabled.
|
long |
getMinBusyTime()
Returns the minimal time that the layout algorithm can be busy between
two calls of
layoutStepPerformed() when the method callLayoutStepPerformedIfNeeded() is used. |
double |
getMinSplineCurveSize()
Returns the minimum curve size used when optimized spline control
points routing is enabled.
|
IlvGraphicVector |
getMovingNodes()
Returns the vector of nodes being moved by the graph layout algorithm.
|
IlvGraphLayout |
getParentLayout()
Returns the parent layout.
|
Object |
getProperty(IlvGraphModel graphModel,
Object nodeOrLink,
String key)
Returns the value of a property of the layout instance.
|
Object |
getProperty(String key)
Returns the value of a property of the layout instance.
|
IlvRecursiveLayout |
getRecursiveLayout()
Returns the instance of Recursive Layout that is used to perform this
layout recursively when you call
performLayout(boolean,
boolean, boolean) with the traverse flag set to true . |
long |
getRemainingAllowedTime()
Returns the remaining allowed time.
|
long |
getSeedValueForRandomGenerator()
Returns the user-defined seed value for the random generator.
|
IlvRect |
getSpecLayoutRegion()
Returns a copy of the rectangle that defines the layout region, as
specified using the methods
setLayoutRegion(IlvManagerView,
IlvRect) , setLayoutRegion(IlvManagerView) , or setLayoutRegion(IlvRect) . |
IlvSplineLinkFilter |
getSplineLinkFilter()
Returns the filter that detects which links are suitable for optimized
spline routing.
|
void |
increasePercentageComplete(int newPercentage)
Increases the percentage of completion that is stored in the layout
report to the input value.
|
protected void |
init()
Initializes instance variables.
|
boolean |
isAnimate()
Returns
true if the layout can perform a redraw of the
graph model after each iteration or step of the layout algorithm. |
boolean |
isAutoLayout()
Returns
true if the auto layout mode is enabled. |
boolean |
isFitToView()
Returns
true if the graph drawing must fit (exactly or
approximately) an area of a specific manager view. |
boolean |
isFixed(Object nodeOrLink)
Returns whether the node or link is specified as fixed.
|
boolean |
isGeometryUpToDate()
Returns whether the geometry of the graph is up to date.
|
boolean |
isInputCheckEnabled()
Returns
true if the checks for the nodes and/or links are
enabled. |
protected boolean |
isLayoutNeeded()
Verifies that it is necessary to perform the layout.
|
boolean |
isLayoutOfConnectedComponentsEnabled()
Indicates whether the connected component layout mechanism is enabled.
|
protected boolean |
isLayoutOfConnectedComponentsEnabledByDefault()
Returns
true if the connected components layout mechanism
is enabled by default. |
boolean |
isLayoutRunning()
Indicates whether the layout algorithm is running or not.
|
boolean |
isLayoutRunning(boolean checkParents)
Indicates whether this layout algorithm is running or not.
|
protected boolean |
isLayoutTimeElapsed()
Returns
true if, at the moment the method is called, the
allowed layout time is exceeded; returns false
otherwise. |
boolean |
isLocalRecursiveLayoutNeeded(IlvLayoutProvider layoutProvider,
IlvGraphLayout recLayout,
IlvGraphModel rootModel,
boolean traverse)
Checks whether layout is needed when layout is performed recursively
on a hierarchy of nested subgraphs.
|
boolean |
isMemorySavings()
Returns the current setting specifying whether priority is given to
speed or memory usage.
|
boolean |
isParametersUpToDate()
Returns whether the layout parameters are up to date.
|
boolean |
isPreserveFixedLinks()
Returns
true if the layout is not allowed to reshape the
links indicated as fixed by the user. |
boolean |
isPreserveFixedNodes()
Returns
true if the layout is not allowed to move the
nodes indicated as fixed by the user. |
boolean |
isSplineRoutingEnabled()
Tests whether the calculation of optimized spline control points is
enabled.
|
boolean |
isStoppedImmediately()
Returns
true if the method stopImmediately() was
called. |
boolean |
isStructureUpToDate()
Returns whether the structure of the graph is up to date.
|
boolean |
isUseDefaultParameters()
Returns the current options for the parameters.
|
boolean |
isUseSeedValueForRandomGenerator()
Returns
true if the user-defined seed value is used for
the random generator and false otherwise. |
protected abstract void |
layout(boolean redraw)
Executes the layout.
|
void |
layoutStepPerformed()
Notifies the listeners of the layout events (if any).
|
void |
onParameterChanged(Object nodeOrLink,
String parameterName)
Called when a layout parameter for a specific node or link has
changed.
|
void |
onParameterChanged(String parameterName)
Called when a global layout parameter has changed.
|
protected void |
performAutoLayout()
Performs the layout again following a structural or geometric change
of the graph.
|
IlvGraphLayoutReport |
performLayout()
Starts the layout algorithm using the currently attached graph model
and the current settings for the layout parameters.
|
IlvGraphLayoutReport |
performLayout(boolean force,
boolean redraw)
Starts the layout algorithm using the currently attached graph model
and the current settings for the layout parameters.
|
int |
performLayout(boolean force,
boolean redraw,
boolean traverse)
Starts the layout algorithm using the currently attached graph model
and the current settings for the layout parameters.
|
static int |
PerformLayout(IlvGraphModel graphModel,
IlvLayoutProvider layoutProvider,
boolean force,
boolean redraw,
boolean traverse)
Applies layout instances recursively to the specified graph model.
|
protected int |
performSublayout(Object subgraph,
IlvGraphLayout layout,
boolean force,
boolean redraw)
Starts the input layout algorithm.
|
void |
removeGraphLayoutEventListener(GraphLayoutEventListener listener)
Removes a listener for the layout events delivered during the layout.
|
void |
removeGraphLayoutParameterEventListener(GraphLayoutParameterEventListener listener)
Removes a listener for the layout parameter events when layout
parameters change.
|
void |
setAllowedTime(long time)
Sets the upper limit for the duration of the layout algorithm.
|
void |
setAnimate(boolean option)
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. |
boolean |
setAutoCheckAppropriateLinksEnabled(boolean enable)
Sets whether the layout checks whether links are appropriate.
|
void |
setAutoLayout(boolean enable)
Sets whether the auto layout mode is enabled.
|
void |
setAutoLayoutHandler(IlvAutoLayoutHandler handler)
Sets the auto layout handler.
|
void |
setBalanceSplineCurveThreshold(double threshold)
Sets the threshold for spline curves at bends which the optimized
spline control point routing uses to balance the curve.
|
void |
setCoordinatesMode(int mode)
Sets the coordinates mode to be used during layout.
|
void |
setFixed(Object nodeOrLink,
boolean fixed)
Sets the specified node or link as fixed.
|
void |
setGeometryUpToDate(boolean uptodate)
Sets whether the geometry of the graph is up to date.
|
void |
setGrapher(IlvGrapher grapher)
Sets the grapher to be laid out.
|
void |
setGraphModel(IlvGraphModel graphModel)
Sets the graph model to be laid out.
|
void |
setInputCheckEnabled(boolean enable)
Sets whether the checks for the nodes and/or links provided as
arguments for the different methods of the layout algorithms are
enabled.
|
void |
setLayoutOfConnectedComponents(IlvGraphLayout layout)
Sets the layout instance that lays out the connected components of the
graph.
|
void |
setLayoutOfConnectedComponentsEnabled(boolean enable)
Sets whether the generic connected component layout mechanism is
enabled.
|
void |
setLayoutRegion(IlvManagerView view)
Sets the layout region as the visible area of a given manager view.
|
void |
setLayoutRegion(IlvManagerView view,
IlvRect rect)
Sets the layout region as a rectangle (the argument
rect ), with the dimensions of the rectangle being given
in the coordinates of the manager view (the argument
view ). |
void |
setLayoutRegion(IlvRect rect)
Sets the layout region as a rectangle
rect ), with the
dimensions of the rectangle being given in manager (graph model)
coordinates. |
protected void |
setLayoutReport(IlvGraphLayoutReport report)
Sets the layout report, that is, the object that contains information
about the behavior of the layout algorithm.
|
void |
setLayoutRunning(boolean running,
boolean fromParents)
Sets whether layout is running.
|
void |
setLinkClipInterface(IlvLinkClipInterface linkClipInterface)
Sets the clip interface for the connection points of links.
|
void |
setLinkConnectionBoxInterface(IlvLinkConnectionBoxInterface linkConnectionBoxInterface)
Sets the link connection box interface for the connection points of
links.
|
void |
setMaxSplineCurveSize(double size)
Sets the maximum curve size used when optimized spline control point
routing is enabled.
|
void |
setMemorySavings(boolean option)
Sets whether the layout algorithm uses the memory saving mode.
|
void |
setMinBusyTime(long time)
Sets the minimal time that the layout algorithm can be busy.
|
void |
setMinSplineCurveSize(double size)
Sets the minimum curve size used when optimized spline control point
routing is enabled.
|
void |
setParametersUpToDate(boolean uptodate)
Sets whether the parameters of the graph layout are up to date.
|
void |
setParentLayout(IlvGraphLayout parent)
Sets the parent layout of this layout instance.
|
void |
setPreserveFixedLinks(boolean option)
Sets whether the layout avoids movement of fixed links.
|
void |
setPreserveFixedNodes(boolean option)
Sets whether the layout avoids movement of fixed nodes.
|
Object |
setProperty(IlvGraphModel graphModel,
Object nodeOrLink,
String key,
Object value)
Sets the value of a property for a node or a link, using a given graph
model.
|
Object |
setProperty(String key,
Object value)
Sets the value of a property for the layout instance.
|
void |
setSeedValueForRandomGenerator(long seed)
Sets the seed value for the random generator.
|
void |
setSplineLinkFilter(IlvSplineLinkFilter filter)
Sets the filter that detects which links are suitable for optimized
spline routing.
|
void |
setSplineRoutingEnabled(boolean flag)
Sets whether the calculation of optimized spline control points is
enabled.
|
void |
setStructureUpToDate(boolean uptodate)
Sets whether the structure of the graph is up to date.
|
void |
setUseDefaultParameters(boolean option)
If the argument is
true , specifies that the layout uses
the default values of all the parameters, that is, the getter methods
return the default values. |
void |
setUseSeedValueForRandomGenerator(boolean option)
Sets whether the user-defined seed value should be used for the random
generator.
|
boolean |
stopImmediately()
Stops the running layout algorithm as soon as possible.
|
boolean |
supportsAllowedTime()
Indicates whether the layout class can stop the layout computation
when a user-defined allowed time is exceeded.
|
boolean |
supportsAnimation()
Indicates whether the layout class can perform a redraw of the graph
model after each step or iteration.
|
boolean |
supportsLayoutOfConnectedComponents()
Indicates whether the layout class can cut the attached graph into
connected components, apply itself on each connected component
separately, and then use the layout instance returned by the method
getLayoutOfConnectedComponents() to position the connected
components. |
boolean |
supportsLayoutRegion()
Indicates whether the layout class can control the position and/or
size of the graph drawing according to a user-defined region (a
rectangle) or a user-defined area of a manager view.
|
boolean |
supportsLinkClipping()
Indicates whether the layout class can use a link clip interface to
clip the end points of a link.
|
boolean |
supportsLinkConnectionBox()
Indicates whether the layout class can use a link connection box
interface to calculate the end points of a link.
|
boolean |
supportsMemorySavings()
Indicates whether the 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()
Indicates whether the layout class can estimate the percentage of
completion during the run of layout.
|
boolean |
supportsPreserveFixedLinks()
Indicates whether the layout class allows the user to specify fixed
links.
|
boolean |
supportsPreserveFixedNodes()
Indicates whether the layout class allows the user to specify fixed
nodes.
|
boolean |
supportsRandomGenerator()
Indicates whether the layout class uses randomly generated numbers (or
randomly chosen parameters) for which it can accept a user-defined
seed value.
|
boolean |
supportsSaveParametersToNamedProperties()
Indicates whether the layout class can transfer the layout parameters
to named properties.
|
boolean |
supportsSplineRouting()
Indicates whether the layout class supports the generic optimization
of spline control points.
|
boolean |
supportsStopImmediately()
Indicates whether the layout class can interrupt the current run of
layout immediately in a controlled way.
|
void |
unfixAllLinks()
Removes the fixed attribute from all links in the graph model.
|
void |
unfixAllNodes()
Removes the fixed attribute from all nodes in the graph model.
|
boolean |
useAnimateRedraw()
Returns
true if animation is supported and enabled for
this graph layout or any sublayout. |
public static final int INVERSE_VIEW_COORDINATES
setCoordinatesMode(int)
, the geometry of the graph is
computed by inverting the coordinate system of the view.setCoordinatesMode(int)
,
setCoordinatesMode(int)
,
Constant Field Valuespublic static final int MANAGER_COORDINATES
setCoordinatesMode(int)
, the geometry of the graph is
computed in the coordinate system of the manager.setCoordinatesMode(int)
,
setCoordinatesMode(int)
,
Constant Field Valuespublic static final int VIEW_COORDINATES
setCoordinatesMode(int)
, the geometry of the graph is computed in
the coordinate system of the view.setCoordinatesMode(int)
,
setCoordinatesMode(int)
,
Constant Field Valuespublic IlvGraphLayout()
public IlvGraphLayout(IlvGraphLayout source)
copy()
method. Any subclass
should provide a copy constructor.
The parameters of the source
layout are copied using the
method copyParameters(IlvGraphLayout)
. The attached graph is
not copied.
source
- The layout instance that is copied.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 link clip and link connection box interfaces,
are also copied. If the method supportsLayoutOfConnectedComponents()
returns true
, 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
.
Subclasses that need to copy additional parameters must override this method. The method can be implemented as follows:
public void copyParameters(IlvGraphLayout source) { super.copyParameters(source); // MyLayout is the name of the subclass if (source instanceof MyLayout) { MyLayout msource = (MyLayout)source; // copy the attribute of the subclass setMyParameter(msource.getMyParameter()); } }
source
- The layout instance from which the parameters are copied.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. The initialization of all the instance variables of the subclasses must be done in this method.
public abstract IlvGraphLayout copy()
This method must return a copy of this layout instance by calling a constructor defined as follows:
public <CLASSNAME>(<CLASSNAME> source)
.
When performing a recursive layout on 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. If the method supportsLayoutOfConnectedComponents()
returns true
, 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
.
public final int getInstanceId()
public void attach(IlvGrapher grapher)
IlvGrapherAdapter
to encapsulate the grapher. Then, the
adapter is attached to the layout instance by calling the method
attach(IlvGraphModel)
.
You must attach the grapher before performing the layout, that is,
before calling the method performLayout()
, and before
specifying layout parameters for specific nodes or links.
The method does nothing if the grapher is already attached.
You can get the IlvGrapherAdapter
instance created by
this method using getGraphModel()
. However, notice that you
are not allowed to do the following:
detach()
has
been called on the layout instance.IlvGrapherAdapter
and attach it
using attach(IlvGraphModel)
.
To determine whether a given IlvGraphModel
instance has
been created using attach(IlvGrapher)
, you can
use the method IlvGraphModel.getOriginatingLayout()
. This
method returns a non-null
object if the model has not
been created using attach(IlvGrapher)
.
grapher
- The grapher.attach(ilog.views.graphlayout.IlvGraphModel)
,
detach()
,
getGraphModel()
,
getGrapher()
public void attach(IlvGraphModel graphModel)
You must attach the graph model before performing the layout, that
is, before calling the method performLayout()
, and before
specifying layout parameters for specific nodes or links.
This method first calls detach()
if a graph model is already
attached. After attaching the model, the method IlvGraphModel.afterAttach(ilog.views.graphlayout.IlvGraphLayout)
is called, passing this layout instance as
argument. The method does nothing if the graph model is already
attached.
graphModel
- The graph model to lay out.attach(ilog.views.IlvGrapher)
,
detach()
,
getGraphModel()
public void detach()
When a new graph model is attached to the layout instance, it is not
necessary to detach the previously attached graph model because this
is done automatically when the method attach(IlvGraphModel)
is called.
This method performs cleaning operations on the graph model (for
example, properties added to the graph model objects and graph model
listeners are removed). The method cleanGraphModel(IlvGraphModel)
is called with the currently
attached graph model as the argument. The methods cleanNode(IlvGraphModel, Object)
and cleanLink(IlvGraphModel, Object)
are called for each node and link
returned by the methods IlvGraphModel.getNodes()
, IlvGraphModel.getLinks()
and IlvGraphModel.getInterGraphLinks()
.
If the model currently attached is an IlvGrapherAdapter
internally created using the method attach(IlvGrapher)
, the
method IlvGraphModel.dispose()
is called on it. Notice that in
this case you can no longer use the adapter instance.
Subclasses can override this method to remove additional information stored in the layout instance.
After detaching the model, the method IlvGraphModel.afterDetach(ilog.views.graphlayout.IlvGraphLayout)
is called, passing this layout instance
as an argument. If the model has been internally created using the
method attach(IlvGrapher)
, the method IlvGraphModel.afterDetach(ilog.views.graphlayout.IlvGraphLayout)
is called just before disposing of the
model.
Note that you must call this method when you no longer need the layout instance; otherwise, some objects may not be garbage collected.
public void cleanGraphModel(IlvGraphModel graphModel)
Subclasses can override this method to remove additional information stored in the graph model.
graphModel
- The graph model to be cleaned.detach()
,
IlvGraphModel.dispose()
public void cleanNode(IlvGraphModel graphModel, Object node)
The method is automatically called by contentsChanged(GraphModelEvent)
whenever a GraphModelEvent
of type GraphModelEvent.NODE_REMOVED
is received.
Subclasses can override this method to remove additional information stored in the nodes.
Notice that the method may be called multiple times for the same
node. At the time this method is called, the node may already be
removed; therefore, overridden versions of this method should be
implemented so that they work even if the object is no longer a node
of graphModel
.
graphModel
- The graph model to which the node
belongs.node
- The node to be cleaned.detach()
,
IlvGraphModel.dispose()
public void cleanLink(IlvGraphModel graphModel, Object link)
The method is automatically called by contentsChanged(GraphModelEvent)
whenever a GraphModelEvent
of type GraphModelEvent.LINK_REMOVED
is received.
Subclasses can override this method to remove additional information stored in the links.
Notice that the method may be called multiple times for the same
link. At the time this method is called, the link may already be
removed; therefore, overridden versions of this method should be
implemented so that they work even if the object is no longer a link
of graphModel
.
graphModel
- The graph model to which the link
belongs.link
- The link to be cleaned.detach()
,
IlvGraphModel.dispose()
public void setGraphModel(IlvGraphModel graphModel)
attach(IlvGrapher)
or attach(IlvGraphModel)
.attach(IlvGrapher)
,
attach(IlvGraphModel)
public IlvGraphModel getGraphModel()
null
.
If an IlvGrapher
object is attached directly using attach(IlvGrapher)
, the method returns the instance of IlvGrapherAdapter
that has been created internally. In this case the
model cannot be used once the detach()
method has been called
and cannot be attached to any other layout instance.
During the layout of a disconnected graph by a layout class that
supports the connected components layout mechanism (see supportsLayoutOfConnectedComponents()
) and for which this mechanism
is enabled (see isLayoutOfConnectedComponentsEnabled()
), the
method getGraphModel()
may return a different graph model
from the one originally attached using the method attach(IlvGraphModel)
. For details, see the method performLayout(boolean, boolean, boolean)
.
attach(ilog.views.graphlayout.IlvGraphModel)
,
attach(ilog.views.IlvGrapher)
public void setGrapher(IlvGrapher grapher)
attach(IlvGrapher)
.attach(ilog.views.IlvGrapher)
,
getGrapher()
public IlvGrapher getGrapher()
IlvGrapher
that contains the nodes and links to be
laid out.
The method returns null
if no graph is attached to the
layout instance. Otherwise, it returns the object returned by the
method IlvGraphModel.getGrapher()
called on the attached graph
model.
This means that the method returns the instance of IlvGrapher
that has been attached directly using the method attach(IlvGrapher)
or indirectly by passing an IlvGrapherAdapter
as an argument to the method attach(IlvGraphModel)
. If the nodes and links are not contained in
an IlvGrapher
, the method returns null
.
public void setParentLayout(IlvGraphLayout parent)
getParentLayout()
public IlvGraphLayout getParentLayout()
A
creates
or uses another layout instance B
to accomplish a part
of or the total layout work, the layout instance A
is
called the "parent" of the layout instance B
. The parent
layout instance is responsible for declaring itself as a parent of
B
by calling the method setParentLayout(ilog.views.graphlayout.IlvGraphLayout)
on it.
The layout instance B
is called a sublayout of
A
.
Sublayouts never have their own local layout listeners. Layout events have parent layouts as the source.
The method returns null
if the layout instance has no
parent.
setParentLayout(IlvGraphLayout)
public IlvGraphLayoutReport createLayoutReport()
IlvGraphLayoutReport
.
You can overwrite this method in order to create subclasses of
IlvGraphLayoutReport
.
This method is called by performLayout()
. The returned
object is stored internally in the layout instance and will be
returned by the method performLayout()
.
Use this method to obtain information about the behavior of the
layout algorithm if the information is added to the layout report in
the implementation of the layout(boolean)
method, where it
can be obtained using getLayoutReport()
.
While the layout(boolean)
method is running, you can also
obtain the layout report outside this method using the layout event
listener mechanism (see addGraphLayoutEventListener(ilog.views.graphlayout.GraphLayoutEventListener)
).
getLayoutReport()
,
IlvGraphLayoutReport
,
performLayout(boolean, boolean, boolean)
,
addGraphLayoutEventListener(ilog.views.graphlayout.GraphLayoutEventListener)
protected void setLayoutReport(IlvGraphLayoutReport report)
This method is called automatically by performLayout()
with
the layout report created using the method createLayoutReport()
. Subclasses can override this method to
perform additional actions.
report
- New layout report.createLayoutReport()
,
getLayoutReport()
,
performLayout(boolean, boolean, boolean)
public final IlvGraphLayoutReport getLayoutReport()
If this method is called after the method performLayout()
was called for the first time on this layout instance, it returns the
instance of the layout report created by createLayoutReport()
. Otherwise, it returns null
.
createLayoutReport()
,
setLayoutReport(IlvGraphLayoutReport)
public IlvGraphLayoutReport performLayout() throws IlvGraphLayoutException
This method simply calls performLayout(boolean, boolean)
with the force
argument set to false
and
the redraw
argument set to true
.
The layout report returned by performLayout(boolean,
boolean)
is returned.
public IlvGraphLayoutReport performLayout(boolean force, boolean redraw) throws IlvGraphLayoutException
The method first calls createLayoutReport()
to obtain a new
instance of the layout report. This instance is stored internally and
can be used to obtain information about the behavior of the layout
algorithm when the method returns. The implementation of the layout(boolean)
method is solely responsible for adding this information to
the layout report. Note that subclasses of
IlvGraphLayout
can override the method createLayoutReport()
in order to return a subclass of of IlvGraphLayoutReport
when additional information needs to be stored
in the report.
If the graph is empty (that is, it does not contain any node) the
appropriate code (IlvGraphLayoutReport.EMPTY_GRAPHER
) is
stored in the layout report and the method returns.
If the argument force
is false
, the method
calls isLayoutNeeded()
to determine if it is necessary to
perform the layout. If this method returns false
, the
appropriate code (IlvGraphLayoutReport.NOT_NEEDED
) is stored
in the layout report and the method returns.
Otherwise, if the argument force
is true
or
isLayoutNeeded()
returns true
, the method
IlvGraphModel.beforeLayout(ilog.views.graphlayout.IlvGraphLayout, boolean)
is called on the attached graph
model. The redraw
argument is passed to this method.
Then the method layout(boolean)
, which executes the layout algorithm,
is called.
Instead of directly calling the method layout(boolean)
on the
attached graph model, layout classes which support the connected
components layout (see supportsLayoutOfConnectedComponents()
)
and for which this mechanism is enabled (see isLayoutOfConnectedComponentsEnabled()
first cut the graph model into
connected components. Then each connected component is laid out
separately by a call of the method layout(boolean)
. To do this, the
attached graph model is temporarily changed into an internally
generated graph model corresponding to each of the connected
components of the original graph. Finally, the layout instance
returned by the method getLayoutOfConnectedComponents()
is
used to position the connected components.
Note that while the layout(boolean)
method is running, you can also
obtain the layout report outside this method using the layout event
listener mechanism (see addGraphLayoutEventListener(ilog.views.graphlayout.GraphLayoutEventListener)
).
If the layout is successfully performed (that is, if the method
IlvGraphLayoutReport.getCode()
called on the layout report
instance returns IlvGraphLayoutReport.LAYOUT_DONE
or IlvGraphLayoutReport.STOPPED_AND_VALID
), the layout instance is
notified that the structure, the geometry, and the parameters are now
up-to-date (see the methods isStructureUpToDate()
, isGeometryUpToDate()
, and isParametersUpToDate()
).
In any case, if the method IlvGraphModel.beforeLayout(ilog.views.graphlayout.IlvGraphLayout, boolean)
has
been called, the method IlvGraphModel.afterLayout(ilog.views.graphlayout.IlvGraphLayout, ilog.views.graphlayout.IlvGraphLayoutReport, boolean)
is finally
called on the attached graph model. The redraw
argument
is passed to this method.
force
- If true
, the method isLayoutNeeded()
is not called. No check is made to determine if it is necessary to
perform the layout.redraw
- If true
, the attached graph model will be
asked to redraw the graph after layout. To move the nodes and to
reshape the links, the implementation of this method passes 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)
.IlvGraphLayoutException
- A new instance of
IlvGraphLayoutException
is thrown if one of the
following occurs:
null
.createLayoutReport()
is null
.
The method also throws any IlvGraphLayoutException
thrown by the method layout(boolean)
. In particular, the following
subclasses of IlvGraphLayoutException
can be thrown:
performLayout()
,
performLayout(boolean, boolean, boolean)
,
PerformLayout(IlvGraphModel, IlvLayoutProvider, boolean, boolean, boolean)
,
IlvGraphModel.performLayout(ilog.views.graphlayout.IlvLayoutProvider, boolean, boolean, boolean)
,
layout(boolean)
,
isLayoutNeeded()
,
isStructureUpToDate()
,
isGeometryUpToDate()
,
isParametersUpToDate()
,
IlvGrapherAdapter.addLayer(ilog.views.IlvManagerLayer)
,
IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)
public int performLayout(boolean force, boolean redraw, boolean traverse) throws IlvGraphLayoutException
If the argument traverse
is false
, the
method simply calls performLayout(boolean, boolean)
passing
the force
and redraw
arguments. Note that
if the attached graph is a nested graph, this applies the layout only
on the topmost graph and does not apply recursively on the subgraphs.
In this case, the return value is the result code stored in the
layout report (see IlvGraphLayoutReport.getCode()
).
If the argument traverse
is true
, the
layout is applied to the attached graph model and recursively to all
subgraph models of the attached graph model. In fact, clones of this
layout are attached and used for the subgraph models. This is
equivalent to getRecursiveLayout().performLayout(force,
redraw)
. In this case, the return value is the combined result
code of all layout calls:
IlvGraphLayoutReport.EMPTY_GRAPHER
- The graph is
empty.IlvGraphLayoutReport.NOT_NEEDED
- The layout was
up-to-date in the graph and in all subgraphs.IlvGraphLayoutReport.LAYOUT_DONE
- The layout was
successfully done in the graph and in all subgraphs, as needed.IlvGraphLayoutReport.STOPPED_AND_VALID
- The layout was
successfully done in the graph and in all subgraphs, as needed, but
some layouts of subgraphs run out of time before completion and
stored the result code IlvGraphLayoutReport.STOPPED_AND_VALID
in their layout reports.IlvGraphLayoutReport.STOPPED_AND_INVALID
- The layout
was not completed. The method stopImmediately()
was called, or the layout of one of the subgraphs run out of time
before completion and stored the result code IlvGraphLayoutReport.STOPPED_AND_INVALID
in its layout report. In
this case, the entire recursion stopped immediately, and the layouts
of the remaining subgraphs was not done.getRecursiveLayout().getLayoutReport()
. To
get the report of the layout of a specific subgraph, you can call
getRecursiveLayout().getLayoutReport(subgraph)
. You can
also install a graph layout event listener via
getRecursiveLayout().addSubLayoutEventListener(listener)
that will receive the events from the sublayouts, so you can detect
during the recursive layout which sublayout is started or finished.
For instance, the implementation of
GraphLayoutEventListener
can be:
public void layoutStepPerformed(GraphLayoutEvent event) { if (event.isLayoutFinished()) { IlvGraphLayoutReport layoutReport = event.getLayoutReport(); if (layoutReport != null) { IlvGraphLayout layout = (IlvGraphLayout)event.getSource(); System.out.println("layout finished on " + layout.getGraphModel() + " with code:" + layoutReport.codeToString(layoutReport.getCode())); } }
This method is the simplest way to apply a single layout recursively
on an entire nested graph. If different layout algorithms need to be
used for different subgraphs, or some subgraphs should not be laid
out at all, you should explicitly allocate a Recursive Layout and
either use the internal provider mode or the specified provider mode
(see IlvRecursiveLayout
).
force
- If true
, the method isLayoutNeeded()
is not called. No check is made to determine if it is necessary to
perform the layout.redraw
- If true
, the attached graph model will be
asked to redraw the graph after layout. To move the nodes and
reshape the links, the implementation of this method passes 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)
.traverse
- If true
, the layout is applied to the
attached graph model and recursively to all subgraph models of the
attached graph model. Otherwise, it is only applied on the attached
graph model.IlvGraphLayoutReport.getCode()
).IlvGraphLayoutException
- A new instance of
IlvGraphLayoutException
is thrown if one of the
following occurs:
null
.createLayoutReport()
is null
.
The method also throws any IlvGraphLayoutException
thrown by the method layout(boolean)
. In particular, the following
subclasses of IlvGraphLayoutException
can be thrown:
performLayout()
,
performLayout(boolean, boolean)
,
PerformLayout(IlvGraphModel, IlvLayoutProvider, boolean, boolean, boolean)
,
IlvGraphModel.performLayout(IlvLayoutProvider, boolean, boolean, boolean)
,
layout(boolean)
,
isLayoutNeeded()
,
isStructureUpToDate()
,
isGeometryUpToDate()
,
isParametersUpToDate()
,
IlvRecursiveLayout
,
IlvGrapherAdapter.addLayer(ilog.views.IlvManagerLayer)
,
IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)
public static int PerformLayout(IlvGraphModel graphModel, IlvLayoutProvider layoutProvider, boolean force, boolean redraw, boolean traverse) throws IlvGraphLayoutException
This convenience method calls the method IlvGraphModel.performLayout(IlvLayoutProvider, boolean, boolean,
boolean)
on graphModel
passing the
layoutProvider
, force
, redraw
,
and traverse
arguments.
For details, see IlvGraphModel.performLayout(IlvLayoutProvider, boolean, boolean,
boolean)
.
graphModel
- The graph model to be laid out.layoutProvider
- The object that provides a layout instance to be
used for laying out each subgraph.force
- This parameter is passed to the method performLayout(boolean, boolean)
.redraw
- This parameter is passed to the method performLayout(boolean, boolean)
.traverse
- If false
, the layout instance provided by
layoutProvider
is applied to the specified graph model
only. If true
, the layout instances provided by the
layoutProvider
layout are applied to the specified
graph model and then recursively to all its subgraph models.IlvGraphLayoutReport.getCode()
).IlvGraphLayoutException
performLayout()
,
performLayout(boolean, boolean)
,
performLayout(boolean, boolean, boolean)
,
IlvGraphModel.performLayout(IlvLayoutProvider, boolean, boolean, boolean)
protected int performSublayout(Object subgraph, IlvGraphLayout layout, boolean force, boolean redraw) throws IlvGraphLayoutException
subgraph
- The subgraph if used during nested layout, or
null
.layout
- The sublayout to be performed.force
- If true
, no check is made to determine if it
is necessary to perform the layout.redraw
- If true
, the attached graph model will be
asked to redraw the graph after layout.IlvGraphLayoutReport.getCode()
.IlvGraphLayoutException
public void checkAppropriateLinks() throws IlvInappropriateLinkException
Performing a layout may throw an
IlvInappropriateLinkException
if the layout cannot deal
with the links of the graph. With an IlvGrapher
,
it is recommended using links of type IlvPolylineLinkImage
and link connectors of type
IlvFreeLinkConnector
to avoid the
exception (see the documentation of IlvInappropriateLinkException
for details).
Sometimes it is useful to check in advance whether layout would throw
an IlvInappropriateLinkException
, without performing a
time-consuming layout. You can call the method checkAppropriateLinks()
for this purpose. If it does not throw an
IlvInappropriateLinkException
, then performing layout will
also not throw an IlvInappropriateLinkException
. (Notice that
performing layout may still throw other exceptions.) You can control
which checks are done with IlvGraphModel.setLinkCheckEnabled(boolean)
and IlvGraphModel.setConnectionPointCheckEnabled(boolean)
The typical usage is to call checkAppropriateLinks()
to
catch the exception and to call IlvGraphLayoutUtil.EnsureAppropriateLinks(ilog.views.graphlayout.IlvGraphModel, ilog.views.graphlayout.IlvLayoutProvider)
in order to replace the
inappropriate links and/or link connectors with new links.
This method is overridden by the subclasses of
IlvGraphLayout
to perform specific tests, depending on
the layout parameters. By default, this method iterates over all
links and calls the method checkAppropriateLink(Object)
for
each link. It combines the returned code and throws the exception, if
necessary.
On a nested graph, it does not perform the check recursively, but
only for the attached graph. You can traverse all layout instances
obtained by getLayouts(boolean)
and perform the check for all
subgraphs.
IlvInappropriateLinkException
performLayout(boolean, boolean, boolean)
,
performLayout(boolean, boolean)
,
checkAppropriateLink(java.lang.Object)
,
IlvGraphModel.setLinkCheckEnabled(boolean)
,
IlvGraphModel.setConnectionPointCheckEnabled(boolean)
,
IlvGraphLayoutUtil.EnsureAppropriateLinks(ilog.views.graphlayout.IlvGraphModel, ilog.views.graphlayout.IlvLayoutProvider)
,
IlvInappropriateLinkException
public int checkAppropriateLink(Object link)
0
if the link is appropriate. Otherwise,
the return value is one of the codes that are possible for IlvInappropriateLinkException.getType()
.
You should not call this method directly. It is called by checkAppropriateLinks()
. This method is overridden by the subclasses
of IlvGraphLayout
to perform specific tests.
The default implementation always returns 0
.
link
- The link to be checked. It is not a fixed link.checkAppropriateLinks()
,
IlvInappropriateLinkException
public boolean setAutoCheckAppropriateLinksEnabled(boolean enable)
public IlvGraphicVector getMovingNodes()
IlvGrapherAdaper
in order to optimize for speed.
If you implement a new layout algorithm (subclass of
IlvGraphLayout
), you can override this method to return
the nodes in advance that will be moved by the layout algorithm. If
the layout algorithm cannot predict which nodes will move, then the
method should return null
. The resulting layout is the
same, but its calculation in an IlvGrapherAdaper
may be
a little bit slower. The default implementation returns
null
.public IlvRecursiveLayout getRecursiveLayout()
performLayout(boolean,
boolean, boolean)
with the traverse flag set to true
.
The returned instance of Recursive Layout uses this layout as a
reference layout, and it is attached to the same graph model as this
graph model. You should call this method only when a graph model is
attached. You should not detach the returned layout nor attach it to
any other graph model.
You can use this instance of Recursive Layout to set parameters per node or link for the layout of a subgraph, and to save or load the settings from the named properties.
The returned instance always uses the reference layout mode (see
IlvRecursiveLayout.getLayoutMode()
). You should not use
IlvRecursiveLayout.setLoadLayoutModeFromNamesProperties(boolean)
on
the returned instance.
performLayout(boolean, boolean, boolean)
,
IlvRecursiveLayout.getLayout(Object)
public Enumeration getLayouts(boolean preOrder)
IlvGraphLayout
for the nested
graph encapsulated by the graph model of this layout instance.
This method returns this layout instance and recursively the layout instances for all subgraphs that are clones of this layout instance. The order of the enumeration can be preorder (that is, the layout of the parent graph comes before the layout of the subgraphs) or postorder (that is, the layout of the subgraphs comes before the layout of the parent graph).
This method is equivalent to
getRecursiveLayout().getLayouts(preOrder)
.
preOrder
- If true
, the layout instances are returned
in preorder, otherwise in postorder.getRecursiveLayout()
,
performLayout(boolean, boolean, boolean)
,
IlvRecursiveLayout.getLayouts(boolean)
public IlvGraphLayout getLayout(Object subgraph)
This method is equivalent to
getRecursiveLayout().getLayout(subgraph)
.
subgraph
- The subgraph object. This must not be the root graph.getRecursiveLayout()
,
performLayout(boolean, boolean, boolean)
,
IlvRecursiveLayout.getLayout(java.lang.Object)
protected boolean isLayoutNeeded()
IlvGraphModel.isLayoutNeeded(IlvGraphLayout)
on the attached
graph model, with this layout instance as argument.
If no graph model is attached, the method returns false
.
Basically, the method returns false
if no changes
occurred on the graph model (no nodes or links were inserted,
removed, reshaped, or moved) and no parameters changed since the last
time the layout was successfully performed using this layout
instance. Otherwise, the method returns true
.
true
if it is necessary to perform the layout,
false
otherwise.isStructureUpToDate()
,
isGeometryUpToDate()
,
isParametersUpToDate()
,
IlvGraphModel.isLayoutNeeded(IlvGraphLayout)
public boolean isLocalRecursiveLayoutNeeded(IlvLayoutProvider layoutProvider, IlvGraphLayout recLayout, IlvGraphModel rootModel, boolean traverse)
This method is called on the layout of the parent graph before the
layout of the subgraphs is started. This allows the parent layout to
negotiate with the subgraph layouts whether the parent layout treats
the subgraphs as well, or whether the layouts of the subgraphs must
run individually. If this method returns false
, this
layout is not performed, because some parent layout can handle the
subgraph already.
The method is only called during a recursive layout (started either
by IlvRecursiveLayout
or by PerformLayout(ilog.views.graphlayout.IlvGraphModel, ilog.views.graphlayout.IlvLayoutProvider, boolean, boolean, boolean)
). The
default implementation returns always true
.
layoutProvider
- The object that provides a layout instance to be
used for laying out each subgraph.recLayout
- The recursive layout that started the recursive
application of layouts. This can be null
.rootModel
- The graph model that is the root of the nesting
hierarchy of graph models.traverse
- If false
, this layout is intended to be
only applied to its own graph model. If true
, this
layout is intended to be applied to its graph model and the layout
instances provided by the layoutProvider
are intended
to be applied recursively to all nested subgraph models. The
traverse flag is basically passed through from the call of performLayout(boolean, boolean, boolean)
.true
if it is necessary to perform the layout,
false
otherwise.isLayoutNeeded()
,
performLayout(boolean, boolean, boolean)
,
PerformLayout(IlvGraphModel, IlvLayoutProvider, boolean, boolean, boolean)
,
IlvRecursiveLayout
protected abstract void layout(boolean redraw) throws IlvGraphLayoutException
This method must be implemented by each layout algorithm (subclasses
of IlvGraphLayout
). This method computes the coordinates
of the nodes in the attached graph model and moves the nodes to the
new positions using the method IlvGraphModel.moveNode(java.lang.Object, double, double, boolean)
.
The method can also perform reshape operations on the links using the
method IlvGraphModel.reshapeLink(java.lang.Object, ilog.views.IlvPoint, ilog.views.IlvPoint[], int, int, ilog.views.IlvPoint, boolean)
. Any implementation of this
method must pass, for the redraw
argument of these two
methods, the same value as the one it receives.
When using a subclass of IlvGraphLayout
, refer to the
documentation of the subclass to know when this method throws an
exception.
When writing the implementation of this method, you can obtain an
instance of the layout report using getLayoutReport()
and
store particular information about the behavior of the layout
algorithm in the layout report. You can also notify the layout event
listeners using the method layoutStepPerformed()
.
When the layout algorithm is finished and if the layout is performed
successfully, you must call the method IlvGraphLayoutReport.setCode(int)
with the argument IlvGraphLayoutReport.LAYOUT_DONE
on the layout report instance.
protected void layout(boolean redraw) throws IlvGraphLayoutException { // obtain the graph model IlvGraphModel graphModel = getGraphModel(); // obtain the layout report IlvGraphLayoutReport layoutReport = getLayoutReport(); boolean atLeastOneNodeMoved = false; // obtain the layout region IlvRect rect = getCalcLayoutRegion(); double xMin = rect.x; double yMin = rect.y; double xMax = rect.x + rect.width; double yMax = rect.y + rect.height; // initialize the random generator Random random = (isUseSeedValueForRandomGenerator()) ? new Random(getSeedValueForRandomGenerator()) : new Random(); // get an enumeration of the nodes Enumeration nodes = graphModel.getNodes(); // browse the nodes while (nodes.hasMoreElements()) { Object node = nodes.nextElement(); // skip fixed nodes if (isPreserveFixedNodes() && isFixed(node)) continue; // compute coordinates double x = xMin + (xMax - xMin) * random.nextDouble(); double y = yMin + (yMax - yMin) * random.nextDouble(); // move the node to the computed position graphModel.moveNode(node, x, y, redraw); atLeastOneNodeMoved = true; // notify listeners on layout events layoutStepPerformed(); } if (atLeastOneNodeMoved) layoutReport.setCode(IlvGraphLayoutReport.LAYOUT_DONE); else layoutReport.setCode(IlvGraphLayoutReport.NO_MOVEABLE_NODE); }
Note that, beginning with JViews 3.5, the signature of the old method
protected abstract void layout()
has changed. When
writing a new layout algorithm, the method layout(boolean)
must be implemented instead.
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)
.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.performLayout(boolean, boolean, boolean)
,
getLayoutReport()
,
layoutStepPerformed()
,
IlvGraphModel
protected void beforeLayout(boolean redraw)
The default implementation calls IlvGraphModel.beforeLayout(IlvGraphLayout, boolean)
. Subclasses can
override this method to perform some initialization operations when
appropriate.
beforeLayoutOfSubgraph(IlvGraphModel)
protected void beforeLayoutOfSubgraph(IlvGraphModel subgraph)
The default implementation does nothing. Subclasses can override this method to perform some initialization operations when appropriate.
subgraph
- Subgraph where layout is about to be performed.performLayout(boolean, boolean, boolean)
,
afterLayoutOfSubgraph(IlvGraphModel)
protected void afterLayoutOfSubgraph(IlvGraphModel subgraph)
The default implementation does nothing. Subclasses can override this method to perform some cleanup operations when appropriate.
subgraph
- Subgraph or connected component where layout has just
been performed.performLayout(boolean, boolean, boolean)
,
afterLayoutOfSubgraph(IlvGraphModel)
public final boolean isLayoutRunning()
true
if the layout has been started and is not yet
completed. It returns false
otherwise.
The layout is considered as started once the method performLayout()
is called. It is considered as completed after this
method returns or throws an exception.
performLayout(boolean, boolean, boolean)
public final boolean isLayoutRunning(boolean checkParents)
If the parameter checkParents
is false
,
this method returns the same result as isLayoutRunning()
,
that is, it checks only the current layout . If the parameter
checkParents
is true
, this method
additionally checks whether any controlling parent layout is
currently running.
checkParents
- Indicates that this method should also check whether
any controlling parent layout is currently running.true
if this layout is currently running or (if
checkParents
is enabled) if any parent layout is
currently running.performLayout()
,
isLayoutRunning()
public void setLayoutRunning(boolean running, boolean fromParents)
running
- Whether layout is running or not.fromParents
- Whether this is a notification from a parent layout
or from this layout instance.public void addGraphLayoutEventListener(GraphLayoutEventListener listener)
If you add a listener, you can receive information during the
execution of the layout (after each iteration, for example). You can
use a listener in this way, for example, to implement a progress bar.
(See IlvJGraphLayoutProgressBar
.)
Note that to have a listener notified, the subclass of
IlvGraphLayout
must call layoutStepPerformed()
.
public void removeGraphLayoutEventListener(GraphLayoutEventListener listener)
public void addGraphLayoutParameterEventListener(GraphLayoutParameterEventListener listener)
If you add a listener, you can receive an event each time the method
onParameterChanged(java.lang.String)
and setParametersUpToDate(boolean)
is
called, that is, each time a layout parameter changes and each time
the layout was successfully performed. You can use a listener in this
way, for example, to update a display that shows the current values
of the layout parameters or to update the a flag indicating whether
the set of layout parameters must be saved to a file.
public void removeGraphLayoutParameterEventListener(GraphLayoutParameterEventListener listener)
addGraphLayoutParameterEventListener(GraphLayoutParameterEventListener listener)
public void layoutStepPerformed()
This method is intended to be called from the implementation of the
method layout(boolean)
.
public final void callLayoutStepPerformedIfNeeded()
layoutStepPerformed
when necessary.
This method is provided for convenience in the implementation of
layout algorithms. It calls layoutStepPerformed()
when the
last call finished earlier than the minimal busy time before this
call. It avoids calling layoutStepPerformed()
when the
layout time has elapsed or when the layout is notified to stop
immediately, if the algorithm supports these features.
This mechanism is used by some algorithms to avoid the overhead of
layoutStepPerformed()
becoming too high if it is called too
often. Internal routines of layout algorithms can use this method
often without worrying that too many layout events are raised.
Layout algorithms call layoutStepPerformed()
directly
instead of using this method when it is necessary to report a
specific state (for example, when the layout report sets the code
IlvGraphLayoutReport.LAYOUT_STARTED
or IlvGraphLayoutReport.LAYOUT_FINISHED
).
GraphLayoutEvent
,
IlvGraphLayoutReport
,
layoutStepPerformed()
,
setMinBusyTime(long)
,
setAllowedTime(long)
,
stopImmediately()
public void setMinBusyTime(long time)
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).
layoutStepPerformed()
,
callLayoutStepPerformedIfNeeded()
,
getMinBusyTime()
public long getMinBusyTime()
layoutStepPerformed()
when the method callLayoutStepPerformedIfNeeded()
is used.layoutStepPerformed()
,
callLayoutStepPerformedIfNeeded()
,
setMinBusyTime(long)
public void setStructureUpToDate(boolean uptodate)
If the argument is false
, notifies the layout instance
that the structure of the graph was changed since the last time the
layout was successfully performed.
Usually you do not need to call this method. The method is
automatically called with a true
argument each time the
layout is successfully performed.
isStructureUpToDate()
,
isLayoutNeeded()
public boolean isStructureUpToDate()
Returns false
if at least one modification occurred in
the structure of the graph model (a node or link was added or
removed) since the last time the layout was successfully performed on
the same graph model using this layout instance or if the layout has
never been performed successfully on the same graph model. The
following are considered to be modifications of the structure: adding
or removing a node or link , modifying the filter (see IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)
), or modifying one of the layers to be
taken into account during the layout (see IlvGrapherAdapter.addLayer(ilog.views.IlvManagerLayer)
).
Returns true
if no changes occurred.
This method is automatically called by isLayoutNeeded()
.
Note that when the layout is performed successfully (that is, IlvGraphLayoutReport.getCode()
called on the layout report returns
IlvGraphLayoutReport.LAYOUT_DONE
), the layout instance is
automatically notified that the structure is now up-to-date. It is
also automatically notified of the topological modifications of the
graph model using a manager-contents-changed listener.
performLayout(boolean, boolean)
,
isLayoutNeeded()
,
setStructureUpToDate(boolean)
public void setGeometryUpToDate(boolean uptodate)
If the argument is false
, notifies the layout instance
that the geometry of the graph was changed since the last time the
layout was successfully performed.
Usually you do not need to call this method. The method is
automatically called with a true
argument each time the
layout is successfully performed.
isGeometryUpToDate()
,
isLayoutNeeded()
public boolean isGeometryUpToDate()
Returns false
if at least one node or link was moved or
reshaped since the last time the layout was successfully performed on
the same graph model or if the layout has never been performed
successfully on the same graph model.
Returns true
if no changes occurred.
This method is automatically called by isLayoutNeeded()
.
Note that when the layout is performed successfully (that is, IlvGraphLayoutReport.getCode()
called on the layout report returns
IlvGraphLayoutReport.LAYOUT_DONE
), the layout instance is
automatically notified that the geometry of the graph is now
up-to-date. It is also automatically notified of the modifications
of the geometry of the graph model using a manager-contents-changed
listener.
public void setCoordinatesMode(int mode)
Valid values are:
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.
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.
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 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(int)
).
public int getCoordinatesMode()
setCoordinatesMode(int)
public void onParameterChanged(String parameterName)
Global layout parameters affect all or many nodes and links. It calls
setParametersUpToDate(boolean)
with a false
argument to
notify the layout instance that the layout is not anymore up to date.
It also fires a graph layout parameter event.
If you add new global parameters in your own subclass of
IlvGraphLayout
, you should call this method each time
they are modified.
parameterName
- Name of the parameter whose value has been changed.addGraphLayoutParameterEventListener(GraphLayoutParameterEventListener)
,
removeGraphLayoutParameterEventListener(GraphLayoutParameterEventListener)
,
GraphLayoutParameterEvent
,
setParametersUpToDate(boolean)
public void onParameterChanged(Object nodeOrLink, String parameterName)
It calls setParametersUpToDate(boolean)
with a false
argument to notify the layout instance that the layout is not
up-to-date. It also fires a graph layout parameter event.
If you add new parameters for specific nodes and links to your own
subclass of IlvGraphLayout
, you should call this method
each time they are modified.
nodeOrLink
- Node or link instance for which a parameter has been
changed.parameterName
- Name of the parameter whose value has been changed.addGraphLayoutParameterEventListener(GraphLayoutParameterEventListener)
,
removeGraphLayoutParameterEventListener(GraphLayoutParameterEventListener)
,
GraphLayoutParameterEvent
,
setParametersUpToDate(boolean)
public void setParametersUpToDate(boolean uptodate)
If the argument is false
, notifies the layout instance
that a parameter value was changed.
This method is automatically called with a false
argument each time the value of a parameter is changed using the
methods provided in this class or in its subclasses provided in
JViews.
The method is automatically called with a true
argument
each time the layout is successfully performed.
public boolean isParametersUpToDate()
Returns false
if at least one parameter was modified
since the last time the layout was successfully performed on the same
graph or if the layout has never been performed successfully on the
same graph.
Returns true
if no parameters changed since the last
time the layout was successfully performed on the same graph model.
If a layout class supports the layout of the connected components
(that is, supportsLayoutOfConnectedComponents()
returns
true
) and if this mechanism is enabled (that is, isLayoutOfConnectedComponentsEnabled()
returns true
),
an additional test is performed to check that the layout of the
connected components is up-to-date. Therefore, the method returns
false
if the graph is disconnected and the method isParametersUpToDate()
called on the layout instance returned by
getLayoutOfConnectedComponents()
returns false
.
If a layout class supports the layout region mechanism (that is,
supportsLayoutRegion()
returns true
) and if a
manager view must be taken into account for the computation of the
layout region in manager coordinates (see getCalcLayoutRegion()
), an additional test is performed to verify
that the size of the manager view has changed. The method returns
false
if a change occurred. Note that any change of the
manager view through calls to setLayoutRegion(IlvManagerView,
IlvRect)
or setLayoutRegion(IlvManagerView)
is considered
as a parameter change.
This method is automatically called by isLayoutNeeded()
.
Note that when the layout is performed successfully (that is, IlvGraphLayoutReport.getCode()
called on the layout report returns
IlvGraphLayoutReport.LAYOUT_DONE
), the layout instance is
automatically notified that the parameters are now up-to-date.
public void setUseDefaultParameters(boolean option)
true
, specifies that the layout uses
the default values of all the parameters, that is, the getter methods
return the default values.
The default value of this parameter is false
.
isUseDefaultParameters()
public boolean isUseDefaultParameters()
setUseDefaultParameters(boolean)
public void setInputCheckEnabled(boolean enable)
If enabled, methods that require a node or a link as an argument
check whether the object they receive is really a node or a link in
the attached graph (using the methods IlvGraphModel.isNode(Object)
and IlvGraphModel.isLink(Object)
).
The checks can be disabled to avoid their overhead cost. The default
value is true
.
isInputCheckEnabled()
public final boolean isInputCheckEnabled()
true
if the checks for the nodes and/or links are
enabled. Returns false
otherwise.setInputCheckEnabled(boolean)
public boolean supportsPreserveFixedNodes()
The default implementation always returns false
.
Subclasses can override this method in order to return
true
, that is, to indicate that this option is
supported.
Note that fixed nodes can be handled differently by different layout algorithms. Some layout algorithms can adapt the layout of the non-fixed nodes to take into account the current positions of the fixed nodes. For details, refer to the documentation of the layout algorithm.
false
.setPreserveFixedNodes(boolean)
,
isPreserveFixedNodes()
,
setFixed(Object, boolean)
,
isFixed(Object)
,
unfixAllNodes()
public void setPreserveFixedNodes(boolean option)
true
, specifies that the layout is not
allowed to move the nodes indicated as fixed by the user. If the
argument is false
, the layout is free to move all the
nodes of the graph. (This does not change the setting for the fixed
nodes, which can still be used at any time in the future.)
The default value is false
.
A RuntimeException
is thrown if the layout class does
not support this option.
Note that fixed nodes can be handled differently by different layout algorithms. Some layout algorithms can adapt the layout of the nonfixed nodes to take into account the current positions of the fixed nodes. For details, refer to the documentation of the layout algorithm.
public boolean isPreserveFixedNodes()
true
if the layout is not allowed to move the
nodes indicated as fixed by the user. Returns false
if
the layout is free to move all the nodes.
Always returns false
if the layout does not support this
option.
Note that fixed nodes can be handled differently by different layout algorithms. Some layout algorithms can adapt the layout of the nonfixed nodes to take into account the current positions of the fixed nodes. For details, refer to the documentation of the layout algorithm.
public void setFixed(Object nodeOrLink, boolean fixed)
Fixed nodes are not moved during the layout only if the method
isPreserveFixedNodes()
returns true
. By
default, no node is fixed.
Fixed links are not reshaped during the layout only if the method
isPreserveFixedLinks()
returns true
. By
default, no link is fixed.
If the argument nodeOrLink
is a node, a
RuntimeException
is thrown if the layout class does not
support fixed nodes. If the argument nodeOrLink
is a
link, a RuntimeException
is thrown if the layout class
does not support fixed links. An
IllegalArgumentException
is thrown if the node or link
does not belong to the attached graph model.
nodeOrLink
- Node or link instance which is part of the graph
model.fixed
- Indicates whether the object should remain fixed or not.setFixed(IlvGraphic, boolean)
.isFixed(Object)
,
supportsPreserveFixedNodes()
,
setPreserveFixedNodes(boolean)
,
isPreserveFixedNodes()
,
unfixAllNodes()
,
supportsPreserveFixedLinks()
,
setPreserveFixedLinks(boolean)
,
isPreserveFixedLinks()
,
unfixAllLinks()
public boolean isFixed(Object nodeOrLink)
nodeOrLink
- Node or link instance present in the graph model
attached to this layout.true
if the node or link is specified as fixed.isFixed(IlvGraphic)
.setFixed(Object, boolean)
,
setPreserveFixedNodes(boolean)
,
isPreserveFixedNodes()
,
unfixAllNodes()
,
supportsPreserveFixedNodes()
,
setPreserveFixedLinks(boolean)
,
isPreserveFixedLinks()
,
unfixAllLinks()
,
supportsPreserveFixedLinks()
public void unfixAllNodes()
RuntimeException
is thrown if the layout class does
not support this option or if there is no attached graph model.public boolean supportsPreserveFixedLinks()
The default implementation always returns false
.
Subclasses can override this method in order to return
true
; that is, to indicate that this option is
supported.
false
.setPreserveFixedLinks(boolean)
,
isPreserveFixedLinks()
,
setFixed(Object, boolean)
,
isFixed(Object)
,
unfixAllLinks()
public void setPreserveFixedLinks(boolean option)
true
, specifies that the layout is not
allowed to reshape the links indicated as fixed by the user. If the
argument is false
, the layout is free to reshape all the
links of the graph. (This does not change the setting for the fixed
links, which can still be used at any time in the future.) false
.
A RuntimeException
is thrown if the layout class does
not support this option.
isPreserveFixedLinks()
,
setFixed(Object, boolean)
,
isFixed(Object)
,
supportsPreserveFixedLinks()
,
unfixAllLinks()
public boolean isPreserveFixedLinks()
true
if the layout is not allowed to reshape the
links indicated as fixed by the user. Returns false
if
the layout is free to reshape all the links.
Always returns false
if the layout does not support
this option.
setPreserveFixedLinks(boolean)
,
setFixed(Object, boolean)
,
isFixed(Object)
,
supportsPreserveFixedLinks()
,
unfixAllLinks()
public void unfixAllLinks()
A RuntimeException
is thrown if the layout class does
not support this option or if there is no attached graph model.
supportsPreserveFixedLinks()
,
setPreserveFixedLinks(boolean)
,
isPreserveFixedLinks()
,
setFixed(Object, boolean)
,
isFixed(Object)
public boolean supportsAnimation()
false
.
Subclasses can override this method in order to return
true
, that is, to indicate that this option is
supported.
false
.setAnimate(boolean)
,
isAnimate()
public void setAnimate(boolean option)
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.
isAnimate()
,
supportsAnimation()
public boolean isAnimate()
true
if the layout can perform a redraw of the
graph model after each iteration or step of the layout algorithm.
The subclasses of IlvGraphLayout
supporting this
mechanism must override supportsAnimation()
and make it
return true
.
Always returns false
if the layout does not support this
option.
setAnimate(boolean)
,
supportsAnimation()
public boolean useAnimateRedraw()
true
if animation is supported and enabled for
this graph layout or any sublayout. In this case, the
IlvGrapherAdapter
uses a special redraw mechanism. The
method is part of JViews internals. You should not use it, but use
isAnimate()
instead.isAnimate()
,
supportsAnimation()
public boolean supportsPercentageComplete()
The default implementation always returns false
.
Subclasses can override this method in order to return
true
; that is, to indicate that this option is
supported.
false
.increasePercentageComplete(int)
,
IlvGraphLayoutReport.getPercentageComplete()
,
IlvJGraphLayoutProgressBar
public void increasePercentageComplete(int newPercentage)
newPercentage
- New percentage of completionsupportsPercentageComplete()
,
IlvGraphLayoutReport.getPercentageComplete()
public boolean supportsStopImmediately()
The default implementation always returns false
.
Subclasses can override this method in order to return
true
, that is, to indicate that this option is
supported.
false
.stopImmediately()
,
isStoppedImmediately()
,
stopImmediately()
public boolean stopImmediately()
This method only sets the flag isStoppedImmediately()
to
true
; it is the responsibility of the implementation of
the method layout(boolean)
to react in an appropriate way.
Layout algorithms that support the immediate stop feature should
check the flag isStoppedImmediately()
from time to time and
react when this flag changes to true
.
You can use this method when multiple threads are in use for layout
and GUI control. The GUI control thread calls this method to notify
the layout thread that the layout run must be stopped. This method
returns true
if it is possible to stop or
false
otherwise. The layout algorithm will perform final
cleanup operations before terminating. Therefore, the layout thread
will continue until the cleanup operations are finished. The GUI
thread, however, returns immediately from this method.
Layout algorithms that are stopped in this way set the result code of
the layout report to IlvGraphLayoutReport.STOPPED_AND_VALID
or IlvGraphLayoutReport.STOPPED_AND_INVALID
.
true
if it was possible to indicate to this layout
to stop its execution, false
if this layout does not
support this feature or if it cannot be stopped.IlvGraphLayoutReport.getCode()
,
supportsStopImmediately()
,
isStoppedImmediately()
public boolean isStoppedImmediately()
true
if the method stopImmediately()
was
called. Layout algorithm classes can use this method to recognize
that it was requested to stop the current layout run.true
if the method stopImmediately
was
called.stopImmediately()
public void setLayoutOfConnectedComponentsEnabled(boolean enable)
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()
.
enable
- Set to true
to enable the connected component
layout mechanism, or false
to disable.
isLayoutOfConnectedComponentsEnabled()
,
performLayout(boolean, boolean, boolean)
public boolean isLayoutOfConnectedComponentsEnabled()
The default value is the value returned by the method isLayoutOfConnectedComponentsEnabledByDefault()
.
setLayoutOfConnectedComponentsEnabled(boolean)
protected boolean isLayoutOfConnectedComponentsEnabledByDefault()
true
if the connected components layout mechanism
is enabled by default. Otherwise, the method returns
false
.
The default implementation always returns false
.
Subclasses can override this method in order to return
true
, that is, to indicate that the connected components
layout is enabled by default.
true
if the connected components layout mechanism
is enabled by default.setLayoutOfConnectedComponentsEnabled(boolean)
public void setLayoutOfConnectedComponents(IlvGraphLayout layout)
getLayoutOfConnectedComponents()
is used. You can call this
method with a null
argument to return to the default
connected components layout instance.
A RuntimeException
is thrown if the layout does not
support this mechanism.
Note the following points:
layout
- The layout instance to set, or null
to return
to the default layout instance.getLayoutOfConnectedComponents()
,
setLayoutOfConnectedComponentsEnabled(boolean)
,
performLayout(boolean, boolean, boolean)
public IlvGraphLayout getLayoutOfConnectedComponents()
The method returns null
if the layout instance does not
support the layout of connected components. that is, if the method
supportsLayoutOfConnectedComponents()
returns
false
.
Otherwise, if a layout instance has been specified using the method
setLayoutOfConnectedComponents(IlvGraphLayout)
, this
instance is returned. If no layout instance has been specified using
the method setLayoutOfConnectedComponents(IlvGraphLayout)
,
the method returns an instance of IlvGridLayout
. Its layout
region parameter is set by default to the rectangle (0, 0, 800,
800)
. The layout mode parameter is set to IlvGridLayout.TILE_TO_ROWS
.
Note that the layout instance returned by this method cannot be used independently as long as it is set as a connected component layout.
public final IlvGraphLayoutReport getLayoutOfConnectedComponentsReport()
This method returns the instance of the layout report created by the connected components layout instance.
If the last run of the layout did not use the connected components
layout (because either the graph was connected, or the layout does
not support this feature, or this feature was disabled, or an
exception occurred during the layout process), the method returns
null
.
supportsLayoutOfConnectedComponents()
,
isLayoutOfConnectedComponentsEnabled()
,
getLayoutOfConnectedComponents()
public boolean supportsMemorySavings()
setMemorySavings(boolean)
. The amount of memory savings
depends on the implementation of the subclass of
IlvGraphLayout
. This setting does not affect the
resulting layout.
The default implementation always returns false
.
Subclasses can override this method in order to return
true
, that is, to indicate that this option is
supported.
false
.setMemorySavings(boolean)
,
isMemorySavings()
public boolean isMemorySavings()
Always returns false
if the layout does not support this
option.
public void setMemorySavings(boolean option)
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(boolean)
is solely
responsible for the resulting layout.
A RuntimeException
is thrown if the layout does not
support this option.
public boolean supportsLayoutRegion()
The default implementation always returns false
.
Subclasses can override this method in order to return
true
, that is, to indicate that this option is
supported.
public void setLayoutRegion(IlvManagerView view)
Usually the view
argument is the manager view that is
used for displaying the attached graph.
For subclasses that support this parameter, the layout region is usually the rectangle that the graph must fit (exactly or approximately) after the layout is performed, or the rectangle that influences the position and/or size of the resulting layout. The way the layout region parameter is taken into account is the sole responsibility of the subclasses.
Note that each call to getSpecLayoutRegion()
or getCalcLayoutRegion()
recomputes the layout region according to the
current size and transformer of the view. The layout region returned
by these methods is transformed from view coordinates to manager
coordinates. (However, the transformation to manager coordinates is
not done if the coordinates mode is VIEW_COORDINATES
.) If the
transformer is changed after the layout, the graph may no longer fit
the visible area of the view.
RuntimeException
is thrown if the layout does not
support this mechanism.public void setLayoutRegion(IlvManagerView view, IlvRect rect)
rect
), with the dimensions of the rectangle being given
in the coordinates of the manager view (the argument
view
). The region's new position is specified by
rect.x
and rect.y
, and its new size is
specified by rect.width
and rect.height
.
Usually the view
argument is the manager view that is
used for displaying the attached graph.
For subclasses that support this parameter, the layout region is usually the rectangle that the graph must fit (exactly or approximately) after the layout is performed, or the rectangle that influences the position and/or size of the resulting layout. The way the layout region parameter is taken into account is the sole responsibility of the subclasses.
Note that each call to getSpecLayoutRegion()
or getCalcLayoutRegion()
recomputes the layout region according to the
current transformer of the view. The layout region returned by these
methods is transformed from view coordinates to manager coordinates.
(However, the transformation to manager coordinates is not done if
the coordinates mode is VIEW_COORDINATES
.) If the
transformer is changed after the layout, the graph may no longer fit
the specified rectangle.
A RuntimeException
is thrown if the layout does not
support this mechanism, view
is null
, or
the width or height of rect
is 0
.
view
- The manager view whose current transformer is to be used by
getCalcLayoutRegion()
to translate the dimensions of
the rect
argument from manager view coordinates to
manager coordinates.rect
- The region of the view
that the layout must
fit. Its dimensions must be given in view
coordinates.supportsLayoutRegion()
,
setLayoutRegion(ilog.views.IlvManagerView)
,
setLayoutRegion(ilog.views.IlvRect)
,
getSpecLayoutRegion()
,
getCalcLayoutRegion()
,
isFitToView()
public void setLayoutRegion(IlvRect rect)
rect
), with the
dimensions of the rectangle being given in manager (graph model)
coordinates. The region's new position is specified by
rect.x
and rect.y
, and its new size is
specified by rect.width
and rect.height
.
For subclasses that support this parameter, the layout region is usually the rectangle that the graph must fit (exactly or approximately) after the layout is performed, or the rectangle which influences the position and/or size of the resulting layout. The way the layout region parameter is taken into account is the sole responsibility of the subclasses.
You should use this method if you want to perform the layout with no
manager view attached to the graph model or if you want to define the
region to fit in the manager coordinates. If you want the layout to
fit a region of a manager view, with its dimensions in manager view
coordinates, use the method setLayoutRegion(IlvManagerView,
IlvRect)
. If you want to revert to the default layout region, that
is the layout region which is computed by default if none of the
setLayoutRegion
methods has been called , you can call
this method with a null
argument.
A RuntimeException
is thrown if the layout does not
support this mechanism, or if the width or height of
rect
is 0
.
rect
- The rectangle for the layout region, or null
.supportsLayoutRegion()
,
setLayoutRegion(ilog.views.IlvManagerView)
,
setLayoutRegion(ilog.views.IlvManagerView, ilog.views.IlvRect)
,
getSpecLayoutRegion()
,
getCalcLayoutRegion()
,
isFitToView()
public IlvRect getSpecLayoutRegion()
setLayoutRegion(IlvManagerView,
IlvRect)
, setLayoutRegion(IlvManagerView)
, or setLayoutRegion(IlvRect)
.
If the attached graph is an IlvGrapher
object or an
IlvGrapherAdapter
object, the dimensions of the
rectangle are in manager coordinates, and not in manager view
coordinates.
Several cases can occur depending on whether the last method called
was setLayoutRegion(IlvManagerView, IlvRect)
, setLayoutRegion(IlvManagerView)
, or setLayoutRegion(IlvRect)
.
1. If the last method was setLayoutRegion(IlvRect)
, this method returns a copy of the
rectangle passed as the argument to this method with no
transformation.
2. If the last method was& setLayoutRegion(IlvManagerView, IlvRect)
, this method returns a
copy of the rectangle passed as the argument to this method
transformed to manager coordinates using the transformer of the
specified view. (However, the transformation to manager coordinates
is not done if the coordinates mode is VIEW_COORDINATES
.)
3. If the last method was setLayoutRegion(IlvManagerView)
, this method returns a rectangle
with the attributes x=0, y=0 and the width and height equal to the
current width and height of the view (the method Component.getSize()
is used) transformed to manager coordinates
using the current transformer of the view. (However, the
transformation to manager coordinates is not done if the coordinates
mode is VIEW_COORDINATES
.)
4. The default behavior
corresponds to the case where none of these methods is called. If the
attached graph is an IlvGrapher
(IlvGrapherAdapter
) and at least one manager view is
attached to it, it returns a rectangle with the dimensions x=0, y=0
and the width and height equal to the current width and height of the
first attached view, transformed to manager coordinates using the
transformer of the view. (However, the transformation to manager
coordinates is not done if the coordinates mode is VIEW_COORDINATES
.) If no view is attached, or the width or height
of the view is zero, the method returns null
.
The implementation of the method layout(boolean)
in
subclasses of IlvGraphLayout
is solely responsible for
whether the rectangle returned by this method is taken into account
when calculating the layout, and in which manner.
Note that the value returned by the method isUseDefaultParameters()
does not affect the results of this method.
null
in the following cases:
supportsLayoutRegion()
returns false
).setLayoutRegion(IlvManagerView)
and the view has a width or height
equal to zero. (Note that an IlvManagerView
has its correct
size only when it becomes visible).setLayoutRegion
and
IlvGrapher
, orIlvGrapher
has a width or height
equal to zero. (Note that an IlvManagerView
has its correct
size only when it becomes visible.)
Note that, except when specified using setLayoutRegion(IlvRect)
, the layout region can change with time
(for example, because the size of the view passed as the argument to
setLayoutRegion(IlvManagerView)
changes, or its transformer
is changed).
supportsLayoutRegion()
,
setLayoutRegion(ilog.views.IlvManagerView, ilog.views.IlvRect)
,
setLayoutRegion(ilog.views.IlvManagerView)
,
setLayoutRegion(ilog.views.IlvRect)
,
getCalcLayoutRegion()
public IlvRect getLayoutRegion()
setLayoutRegion(IlvRect)
, or
null
if no rectangle has been specified, or the
specified rectangle was null
.
This method only exists for compatibility with the Java Bean specification.
getSpecLayoutRegion()
public IlvRect getCalcLayoutRegion()
This method first tries to use the layout region specification by
calling getSpecLayoutRegion()
. If this method returns a
non-null
rectangle, the rectangle is returned.
Otherwise, the method tries to estimate an appropriate layout region
according to the number and size of the nodes in the attached graph.
If no graph is attached or the attached graph is empty, this method
returns a default rectangle (0, 0, 1000, 1000)
.
supportsLayoutRegion()
,
setLayoutRegion(ilog.views.IlvManagerView, ilog.views.IlvRect)
,
setLayoutRegion(ilog.views.IlvManagerView)
,
setLayoutRegion(ilog.views.IlvRect)
,
getSpecLayoutRegion()
public boolean isFitToView()
true
if the graph drawing must fit (exactly or
approximately) an area of a specific manager view. This is the case
when the layout region is set by a view passed to the method setLayoutRegion(ilog.views.IlvManagerView)
or setLayoutRegion(ilog.views.IlvManagerView, ilog.views.IlvRect)
.
Otherwise, the method returns false
.true
if the graph drawing must fit (exactly or
approximately) an area of a specific manager view.supportsLayoutRegion()
,
setLayoutRegion(ilog.views.IlvManagerView, ilog.views.IlvRect)
,
setLayoutRegion(ilog.views.IlvManagerView)
,
setLayoutRegion(ilog.views.IlvRect)
public boolean supportsRandomGenerator()
setUseSeedValueForRandomGenerator(boolean)
with a true
argument.
For example, you can use this parameter in the implementation of the
method layout(boolean)
in the following way:
Random random; if (isUseSeedValueForRandomGenerator()) random = new Random(getSeedValueForRandomGenerator()); else random = new Random();
The default implementation always returns false
.
Subclasses can override this method in order to return
true
, that is, to indicate that this option is
supported.
false
.setSeedValueForRandomGenerator(long)
,
getSeedValueForRandomGenerator()
,
setUseSeedValueForRandomGenerator(boolean)
,
isUseSeedValueForRandomGenerator()
public void setSeedValueForRandomGenerator(long seed)
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.
public long getSeedValueForRandomGenerator()
For example, you can use this parameter in the implementation of the
method layout(boolean)
in the following way:
Random random; if (isUseSeedValueForRandomGenerator()) random = new Random(getSeedValueForRandomGenerator()); else random = new Random();
A RuntimeException
is thrown if the layout does not
support this mechanism.
public void setUseSeedValueForRandomGenerator(boolean option)
A RuntimeException
is thrown if the layout does not
support this mechanism.
public boolean isUseSeedValueForRandomGenerator()
true
if the user-defined seed value is used for
the random generator and false
otherwise. For example,
you can use this parameter in the implementation of the method layout(boolean)
in the following way:
Random random; if (isUseSeedValueForRandomGenerator()) random = new Random(getSeedValueForRandomGenerator()); else random = new Random();
A RuntimeException
is thrown if the layout does not
support this mechanism.
public boolean supportsAllowedTime()
The default implementation always returns false
.
Subclasses can override this method in order to return
true
, that is, to indicate that this option is
supported.
false
.setAllowedTime(long)
,
getAllowedTime()
,
isLayoutTimeElapsed()
public long getAllowedTime()
Note that the method performLayout
does NOT
automatically stop the layout when the allowed time is exceeded. It
is entirely the responsibility of the implementation of the method
layout(boolean)
to do this.
Returns java.lang.Long.MAX_VALUE
if the layout does not
support this mechanism.
public void setAllowedTime(long time)
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.
time
- The allowed time in milliseconds.supportsAllowedTime()
,
getAllowedTime()
,
isLayoutTimeElapsed()
,
IlvGraphLayoutReport.getCode()
protected boolean isLayoutTimeElapsed()
true
if, at the moment the method is called, the
allowed layout time is exceeded; returns false
otherwise.
You can call this method inside the implementation of the method
layout(boolean)
.
false
if the layout does not support this
mechanism.getRemainingAllowedTime()
,
supportsAllowedTime()
,
setAllowedTime(long)
,
getAllowedTime()
public final long getRemainingAllowedTime()
getAllowedTime()
, and the time elapsed since the beginning of
layout execution.isLayoutTimeElapsed()
,
supportsAllowedTime()
,
setAllowedTime(long)
,
getAllowedTime()
public boolean supportsLayoutOfConnectedComponents()
getLayoutOfConnectedComponents()
to position the connected
components.
The default implementation always returns false
.
Subclasses can override this method in order to return
true
, that is, to indicate that this option is
supported.
false
.getLayoutOfConnectedComponents()
,
isLayoutOfConnectedComponentsEnabled()
,
performLayout(boolean, boolean, boolean)
public void contentsChanged(GraphModelEvent event)
GraphModelListener
interface.
If the type of the event is GraphModelEvent.STRUCTURE_CHANGED
, the method setStructureUpToDate(boolean)
is called with a false
argument.
Or, if the type of the event is GraphModelEvent.GEOMETRY_CHANGED
, the method setGeometryUpToDate(boolean)
is called with a false
argument.
The method then calls cleanNode(IlvGraphModel, Object)
if
the type of the event is GraphModelEvent.NODE_REMOVED
or
cleanLink(IlvGraphModel, Object)
if the type of the event is
GraphModelEvent.LINK_REMOVED
. The node or link that is passed
to the method called is obtained using GraphModelEvent.getNodeOrLink()
.
If auto layout is enabled (that is, isAutoLayout()
returns
true
), the method then calls performAutoLayout()
to redo the layout.
contentsChanged
in interface GraphModelListener
event
- The event indicating the change that has occurred in the
graph model.isAutoLayout()
,
performAutoLayout()
public void setAutoLayoutHandler(IlvAutoLayoutHandler handler)
handler
- The auto layout handler.getAutoLayoutHandler()
,
setAutoLayout(boolean)
,
performAutoLayout()
public IlvAutoLayoutHandler getAutoLayoutHandler()
setAutoLayoutHandler(ilog.views.graphlayout.IlvAutoLayoutHandler)
,
setAutoLayout(boolean)
,
performAutoLayout()
protected void performAutoLayout()
You should not call this method directly. The method is called by
contentsChanged(ilog.views.graphlayout.GraphModelEvent)
. The default implementation checks whether
an auto layout handler is installed. If a handler is installed, it
calls IlvAutoLayoutHandler.performAutoLayout(Object, Vector)
,
passing this
as layout and null
as vector.
Otherwise it simply calls the method performLayout(boolean,
boolean)
with both force
and redraw
arguments of true
.
public void setAutoLayout(boolean enable)
true
, the layout is automatically performed each time
the layout instance is notified that the geometry or the structure of
the graph has changed.
The default value is false
.
To avoid unnecessary re-computation of the layout when performing a
sequence of several changes, you should call the method IlvManager.setContentsAdjusting(boolean)
with a true
argument
before the changes and with a false
argument after the
changes. In this case, the layout is recomputed only at the end of
the sequence of changes. Note that this is not necessary when reading
an .ivl
file.
public final boolean isAutoLayout()
true
if the auto layout mode is enabled. It
returns false
otherwise.setAutoLayout(boolean)
public boolean supportsLinkConnectionBox()
If the layout class supports this feature and a connection box
interface object is set using the method setLinkConnectionBoxInterface(IlvLinkConnectionBoxInterface)
, the
layout algorithm uses this object to calculate the connection points
for links. If the layout class additionally supports link clipping
and a link clip interface is set, the layout algorithm calculates the
initial connection points with the link connection box interface and
obtains the final connection points by clipping with the link clip
interface.
The default implementation always returns false
.
Subclasses can override this method in order to return
true
, that is, to indicate that this option is
supported.
false
.setLinkConnectionBoxInterface(IlvLinkConnectionBoxInterface)
,
setLinkClipInterface(ilog.views.graphlayout.IlvLinkClipInterface)
,
supportsLinkClipping()
,
clipLink(java.lang.Object, boolean, boolean, boolean, boolean)
public void setLinkConnectionBoxInterface(IlvLinkConnectionBoxInterface linkConnectionBoxInterface)
By default, the layout algorithm places the connection points of the
links relative to the bounding box of the nodes (see IlvGraphic.boundingBox(ilog.views.IlvTransformer)
and IlvGraphModel.boundingBox(java.lang.Object)
).
By setting a link connection box interface, the links can be
connected relative to a different box (see IlvLinkConnectionBoxInterface.getBox(IlvGraphModel, Object)
). It is
furthermore possible to "shift" the links tangentially by using the
method IlvLinkConnectionBoxInterface.getTangentialOffset(IlvGraphModel,
Object, int)
from the interface IlvLinkConnectionBoxInterface
:
You can call this method with a null
argument to restore
the default behavior.
A RuntimeException
is thrown if the layout does not
support this mechanism.
supportsLinkConnectionBox()
,
supportsLinkClipping()
,
getLinkConnectionBoxInterface()
public IlvLinkConnectionBoxInterface getLinkConnectionBoxInterface()
Returns null
if none is specified.
supportsLinkConnectionBox()
,
setLinkConnectionBoxInterface(IlvLinkConnectionBoxInterface)
public boolean supportsLinkClipping()
If the layout class supports this feature and a clip interface object
is set using the method setLinkClipInterface(ilog.views.graphlayout.IlvLinkClipInterface)
, the layout
algorithm uses this object to calculate clipped connection points for
links. If the layout class additionally supports the link connection
box and a link connection box interface is set, the layout algorithm
calculates the initial connection points with the link connection box
interface and obtains the final connection points by clipping with
the link clip interface.
The default implementation always returns false
.
Subclasses can override this method in order to return
true
, that is, to indicate that this option is
supported.
false
.setLinkClipInterface(ilog.views.graphlayout.IlvLinkClipInterface)
,
setLinkConnectionBoxInterface(IlvLinkConnectionBoxInterface)
,
supportsLinkConnectionBox()
,
clipLink(java.lang.Object, boolean, boolean, boolean, boolean)
public void setLinkClipInterface(IlvLinkClipInterface linkClipInterface)
IlvGraphic.boundingBox(ilog.views.IlvTransformer)
and IlvGraphModel.boundingBox(java.lang.Object)
) by default.
If the layout class supports the link connection box and link clipping, it calculates the initial connection points with the link connection box interface and obtains the final connection points by clipping with the link clip interface.
You can call this method with a null
argument to restore
the default behavior.
A RuntimeException
is thrown if the layout does not
support this mechanism.
supportsLinkClipping()
,
supportsLinkConnectionBox()
,
getLinkClipInterface()
public IlvLinkClipInterface getLinkClipInterface()
null
if none is specified.supportsLinkClipping()
,
setLinkClipInterface(ilog.views.graphlayout.IlvLinkClipInterface)
public void clipLink(Object link, boolean toCenter, boolean atFromSide, boolean atToSide, boolean redraw) throws IlvInappropriateLinkException
If the parameter toCenter
is true
, the link
is clipped such that it points to the center of the end nodes. If a
link connection box is set, it uses the virtual center of the
connection box instead of the center of the end nodes. 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)
.
link
- The link to be clipped.toCenter
- If true
, the link is clipped such that it
points to the (virtual) center of the end nodes. If
false
, the link is clipped such that it points to the
current connection points of the link.atFromSide
- true
if the link should be clipped at its
source node.atToSide
- true
if the link should be clipped at its
target node.redraw
- Whether the link needs to be redrawn.IlvInappropriateLinkException
supportsLinkClipping()
,
supportsLinkConnectionBox()
,
setLinkClipInterface(ilog.views.graphlayout.IlvLinkClipInterface)
,
setLinkConnectionBoxInterface(IlvLinkConnectionBoxInterface)
public void clipAllLinks(boolean toCenter, boolean redraw) throws IlvInappropriateLinkException
If the parameter toCenter
is true, each link is clipped
such that it points to the center of its end nodes. If a link
connection box is set, it uses the virtual center of the connection
box instead of the center of the end nodes. 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 in
the top direction and 10 in all other directions, the average shift
offset is in the horizontal direction (20 + 10)/2 = 15
and in the vertical direction (10 + 10)/2 = 10
, hence
the virtual center is at
connectionBox.center() + (15, 10)
.
toCenter
- If true
, the link is clipped such that it
points to the (virtual) center of the end nodes. If
false
, the link is clipped such that it points to the
current connection points of the link.redraw
- Whether the links need to be redrawn.IlvInappropriateLinkException
supportsLinkClipping()
,
setLinkClipInterface(ilog.views.graphlayout.IlvLinkClipInterface)
public void connectLinkToCenter(Object link, boolean atFromSide, boolean atToSide, boolean redraw) throws IlvInappropriateLinkException
If a link connection box is set, it uses the virtual center of the
connection box instead of the center of the bounding boxes of the end
nodes. 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)
.
link
- The link to be connected.atFromSide
- true
if the link should be connected at
its source node.atToSide
- true
if the link should be connected at its
target node.redraw
- Whether the link needs to be redrawn.IlvInappropriateLinkException
supportsLinkConnectionBox()
,
setLinkConnectionBoxInterface(IlvLinkConnectionBoxInterface)
public void connectAllLinksToCenter(boolean redraw) throws IlvInappropriateLinkException
If a link connection box is set, it uses the virtual center of the
connection box instead of the center of the bounding boxes of the end
nodes. 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)
.
redraw
- Whether the links need to be redrawn.IlvInappropriateLinkException
supportsLinkConnectionBox()
,
setLinkConnectionBoxInterface(IlvLinkConnectionBoxInterface)
public boolean supportsSplineRouting()
If spline links such as IlvSplineLinkImage
and IlvGeneralLink
are used, the bend points
calculated by the layout algorithm are often suboptimal. A generic
optimization mechanism is available that can be enabled by calling
setSplineRoutingEnabled(boolean)
.
Subclasses can override this method in order to return
true
, that is, to indicate that this option is
supported. Subclasses that do not route the links and always use
straight links cannot benefit from the generic mechanism.
false
.setSplineRoutingEnabled(boolean)
,
setMinSplineCurveSize(double)
,
setMaxSplineCurveSize(double)
,
setBalanceSplineCurveThreshold(double)
,
setSplineLinkFilter(IlvSplineLinkFilter)
public void setSplineRoutingEnabled(boolean flag)
If spline links such as IlvSplineLinkImage
and IlvGeneralLink
are used, the bend points
calculated by the layout algorithm are often suboptimal.
If the layout algorithm supports generic spline optimization, this
option enables the optimization of spline control points. Such
optimization improves the result only if the splines use a smoothness
between 0.1 and 0.9. See IlvSplineLinkImage.setSmoothness(double)
and IlvGeneralLink.setCurved(double)
for more
information. It does not affect links that are not reshaped by the
layout algorithm or that are routed as straight lines.
This is an expert option. It is disabled by default.
flag
- Set to true
to enable the optimization of
spline control points.isSplineRoutingEnabled()
,
supportsSplineRouting()
public boolean isSplineRoutingEnabled()
true
is returned.setSplineRoutingEnabled(boolean)
,
supportsSplineRouting()
public void setMinSplineCurveSize(double size)
The parameter works only if the layout supports the generic spline optimization routing, and if it is enabled.
Bends in a spline have a size that is described roughly by the triangle the surrounds the curve part of a bend. Spline routing tries to set the side length of this triangle at each bend between the minimum curve size and the maximum curve size.
The default value is 5
.
size
- The minimum spline curve sizegetMinSplineCurveSize()
,
setMaxSplineCurveSize(double)
,
setSplineRoutingEnabled(boolean)
,
supportsSplineRouting()
public double getMinSplineCurveSize()
setMinSplineCurveSize(double)
,
setSplineRoutingEnabled(boolean)
,
supportsSplineRouting()
public void setMaxSplineCurveSize(double size)
The parameter works only if the layout supports the generic spline optimization routing, and if it is enabled.
Bends in a spline have a size that is described roughly by the triangle the surrounds the curve part of a bend. Spline routing tries to set the side length of this triangle at each bend between the minimum curve size and the maximum curve size.
The default value is 30
.
size
- The maximum spline curve sizegetMaxSplineCurveSize()
,
setMinSplineCurveSize(double)
,
setSplineRoutingEnabled(boolean)
,
supportsSplineRouting()
public double getMaxSplineCurveSize()
setMaxSplineCurveSize(double)
,
setSplineRoutingEnabled(boolean)
,
supportsSplineRouting()
public void setBalanceSplineCurveThreshold(double threshold)
The parameter works only if the layout supports generic spline optimization routing, and if it is enabled.
Bends in a spline have a size that is described roughly by the triangle the surrounds the curve part of a bend.
If the side length of the triangle is larger than the threshold, the algorithm tries to create a isosceles triangle. This results in more balanced bend curves.
If the side length of the triangle is smaller than the threshold, it uses non-isosceles triangles. Using isosceles triangles, the bend curve looks too sharp.
The default value is 10
.
threshold
- The balance spline curve threshold.getBalanceSplineCurveThreshold()
,
setSplineRoutingEnabled(boolean)
,
supportsSplineRouting()
public double getBalanceSplineCurveThreshold()
setBalanceSplineCurveThreshold(double)
,
setSplineRoutingEnabled(boolean)
,
supportsSplineRouting()
public void setSplineLinkFilter(IlvSplineLinkFilter filter)
The parameter works only if the layout supports the generic spline optimization routing, and if it is enabled.
The filter detects which objects are splines, so that the optimized spline routing is only applied to splines, not to normal polyline links.
The default spline link filter detects all links where the method
IlvLinkImage.isSpline()
returns true. That is, it
detects IlvSplineLinkImage
, IlvCompositeLink
and IlvGeneralLink
with appropriate parameter
settings as splines.
getSplineLinkFilter()
,
setSplineRoutingEnabled(boolean)
,
supportsSplineRouting()
public IlvSplineLinkFilter getSplineLinkFilter()
setSplineLinkFilter(IlvSplineLinkFilter)
,
setSplineRoutingEnabled(boolean)
,
supportsSplineRouting()
public boolean supportsSaveParametersToNamedProperties()
.ivl
file.
The default implementation always returns false
.
Subclasses can override this method in order to return
true
, that is, to indicate that this option is
supported.
If subclasses override this method, they should also override the
methods createLayoutGrapherProperty(java.lang.String, boolean)
, createLayoutLinkProperty(java.lang.String, ilog.views.IlvGraphic, boolean)
and createLayoutNodeProperty(java.lang.String, ilog.views.IlvGraphic, boolean)
to
create the corresponding named properties (subclasses of IlvGraphLayoutGrapherProperty
, IlvGraphLayoutNodeProperty
,
and IlvGraphLayoutLinkProperty
) that can store all layout
parameters.
protected IlvGraphLayoutGrapherProperty createLayoutGrapherProperty(String name, boolean withDefaults)
IlvGraphLayoutGrapherProperty
.
If you create a subclass of IlvGraphLayout
that contains
additional layout parameters, and you want these parameters to be
stored in .ivl
files using the method IlvGrapherAdapter.saveParametersToNamedProperties(ilog.views.graphlayout.IlvGraphLayout, boolean)
, you need to
create a subclass of IlvGraphLayoutGrapherProperty
that can
write the additional layout parameters to a file. In this case, you
must override this method in order to create the subclass of IlvGraphLayoutGrapherProperty
.
The method is used by IlvGrapherAdapter.saveParametersToNamedProperties(ilog.views.graphlayout.IlvGraphLayout, boolean)
to create a named
property that contains the parameter settings of a layout instance.
supportsSaveParametersToNamedProperties()
,
IlvGraphLayoutGrapherProperty
,
IlvGrapherAdapter.saveParametersToNamedProperties(ilog.views.graphlayout.IlvGraphLayout, boolean)
,
IlvGrapherAdapter.loadParametersFromNamedProperties(ilog.views.graphlayout.IlvGraphLayout)
,
IlvGrapherAdapter.removeParametersFromNamedProperties()
protected IlvGraphLayoutNodeProperty createLayoutNodeProperty(String name, IlvGraphic node, boolean withDefaults)
IlvGraphLayoutNodeProperty
.
If you create a subclass of IlvGraphLayout
that contains
additional layout parameters for each node, and if you want these
parameters to be stored in .ivl
files using the method
IlvGrapherAdapter.saveParametersToNamedProperties(ilog.views.graphlayout.IlvGraphLayout, boolean)
, you need
to create a subclass of IlvGraphLayoutNodeProperty
that can
write the additional layout parameters to a file. In this case, you
must override this method in order to create the subclass of IlvGraphLayoutNodeProperty
.
The method is used by IlvGrapherAdapter.saveParametersToNamedProperties(ilog.views.graphlayout.IlvGraphLayout, boolean)
to create a named
property for a node that contains parameter settings of a layout
instance for this node.
supportsSaveParametersToNamedProperties()
,
IlvGraphLayoutNodeProperty
,
IlvGrapherAdapter.saveParametersToNamedProperties(ilog.views.graphlayout.IlvGraphLayout, boolean)
,
IlvGrapherAdapter.loadParametersFromNamedProperties(ilog.views.graphlayout.IlvGraphLayout)
,
IlvGrapherAdapter.removeParametersFromNamedProperties()
protected IlvGraphLayoutLinkProperty createLayoutLinkProperty(String name, IlvGraphic link, boolean withDefaults)
IlvGraphLayoutLinkProperty
.
If you create a subclass of IlvGraphLayout
that contains
additional layout parameters for each link, and if you want these
parameters to be stored in .ivl
files using the method
IlvGrapherAdapter.saveParametersToNamedProperties(ilog.views.graphlayout.IlvGraphLayout, boolean)
, you need
to create a subclass of IlvGraphLayoutLinkProperty
that can
write the additional layout parameters to a file. In this case, you
must override this method in order to create the subclass of IlvGraphLayoutLinkProperty
.
The method is used by IlvGrapherAdapter.saveParametersToNamedProperties(ilog.views.graphlayout.IlvGraphLayout, boolean)
to create a named
property for a link that contains parameter settings of a layout
instance for this link.
supportsSaveParametersToNamedProperties()
,
IlvGraphLayoutLinkProperty
,
IlvGrapherAdapter.saveParametersToNamedProperties(ilog.views.graphlayout.IlvGraphLayout, boolean)
,
IlvGrapherAdapter.loadParametersFromNamedProperties(ilog.views.graphlayout.IlvGraphLayout)
,
IlvGrapherAdapter.removeParametersFromNamedProperties()
public final Object setProperty(String key, Object value)
value
is null
, the property is removed.
Otherwise, the property value is set to value
.key
- The key string for the property.value
- The new value of the property.key
, or
null
if none.getProperty(String)
public final Object getProperty(String key)
null
if the property does not exist.key
- The key string for the property.key
.setProperty(String, Object)
public final Object setProperty(IlvGraphModel graphModel, Object nodeOrLink, String key, Object value)
If value
is null
, the property is removed.
Otherwise, the property value is set to value
.
Notice that the method does not check whether the node or link
actually belongs to graphModel
. The input graph model
does not need to be the graph model currently attached to this layout
instance.
graphModel
- The graph model used for storing the property.nodeOrLink
- The node or link for which the property is to be set.key
- The key string for the property.value
- The new value of the property.key
, or
null
if none.getProperty(IlvGraphModel, Object, String)
public final Object getProperty(IlvGraphModel graphModel, Object nodeOrLink, String key)
null
if the property does not exist.
The method does not check that the specified node or link belongs to
the specified graphModel
. Also, the specified graph
model does not need to be the graph model currently attached to this
layout instance.
graphModel
- The graph model used for storing the property.nodeOrLink
- The node or link for which the property is to be
retrieved.key
- The key string for the property.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.