ilog.views.graphlayout.random
Class IlvRandomLayout

java.lang.Object
  extended by ilog.views.graphlayout.IlvGraphLayout
      extended by ilog.views.graphlayout.random.IlvRandomLayout
All Implemented Interfaces:
GraphModelListener, Serializable, EventListener

public class IlvRandomLayout
extends IlvGraphLayout

The main class for the Random Layout algorithm.

This is the simplest layout algorithm. The nodes are moved at randomly computed positions inside a user-defined region which can be specified using the method IlvGraphLayout.setLayoutRegion(IlvRect).

Sample drawing produced by the Random Layout algorithm:

See the corresponding chapter of the User's Manual for details on the algorithm, the types of graphs for which this algorithm can be used, the features and limitations, code samples, and so on.

Note that the initial position of the nodes (at the moment you start the layout) does not affect the resulting layout. However, nodes specified as fixed are not moved if you call the method IlvGraphLayout.setPreserveFixedNodes(boolean) with a true argument.

See Also:
Serialized Form

Field Summary
static int NO_RESHAPE_STYLE
          No links reshape option.
static int STRAIGHT_LINE_STYLE
          Straight-line links shape option.
 
Fields inherited from class ilog.views.graphlayout.IlvGraphLayout
INVERSE_VIEW_COORDINATES, MANAGER_COORDINATES, VIEW_COORDINATES
 
Constructor Summary
IlvRandomLayout()
          Creates a new instance of the Random Layout algorithm.
IlvRandomLayout(IlvRandomLayout source)
          Creates a new layout instance by copying an existing one.
 
Method Summary
 int checkAppropriateLink(Object link)
          Checks whether the input link is appropriate for this layout.
 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 IlvRandomLayoutGrapherProperty that stores the parameter settings of this layout class.
 int getLinkStyle()
          Returns the current option for the style of the shape of the links.
 IlvGraphicVector getMovingNodes()
          Returns the vector of nodes being moved by the graph layout algorithm.
protected  void init()
          Initializes instance variables.
protected  void layout(boolean redraw)
          Computes the layout using the Random Layout algorithm.
 void setLinkStyle(int style)
          Sets the style of the shape of the links.
 boolean supportsAllowedTime()
          Indicates that this layout class can stop the layout computation when the user-defined allowed time is exceeded.
 boolean supportsLayoutRegion()
          Indicates that this layout class can control the size of the drawing of the graph to fit (exactly or approximately) a user-defined region (a rectangle) or a user-defined manager view.
 boolean supportsPercentageComplete()
          Indicates that this layout class can estimate the percentage of completion during the run of the layout.
 boolean supportsPreserveFixedNodes()
          Indicates that this layout class allows the user to specify fixed nodes.
 boolean supportsRandomGenerator()
          Indicates that this layout class uses randomly generated numbers that can be initialized with a user-defined seed value.
 boolean supportsSaveParametersToNamedProperties()
          Indicates that this layout class can transfer the layout parameters to named properties.
 boolean supportsStopImmediately()
          Indicates that this layout class can interrupt the current run of the layout immediately in a controlled way.
 
Methods inherited from class ilog.views.graphlayout.IlvGraphLayout
addGraphLayoutEventListener, addGraphLayoutParameterEventListener, afterLayoutOfSubgraph, attach, attach, beforeLayout, beforeLayoutOfSubgraph, callLayoutStepPerformedIfNeeded, checkAppropriateLinks, cleanGraphModel, cleanLink, cleanNode, clipAllLinks, clipLink, contentsChanged, createLayoutLinkProperty, createLayoutNodeProperty, createLayoutReport, detach, getAllowedTime, getAutoLayoutHandler, getBalanceSplineCurveThreshold, getCalcLayoutRegion, getCoordinatesMode, getGrapher, getGraphModel, getInstanceId, getLayout, getLayoutOfConnectedComponents, getLayoutOfConnectedComponentsReport, getLayoutRegion, getLayoutReport, getLayouts, getLinkClipInterface, getLinkConnectionBoxInterface, getMaxSplineCurveSize, getMinBusyTime, getMinSplineCurveSize, getParentLayout, getProperty, getProperty, getRecursiveLayout, getRemainingAllowedTime, getSeedValueForRandomGenerator, getSpecLayoutRegion, getSplineLinkFilter, increasePercentageComplete, isAnimate, isAutoLayout, isFitToView, isFixed, isGeometryUpToDate, isInputCheckEnabled, isLayoutNeeded, isLayoutOfConnectedComponentsEnabled, isLayoutOfConnectedComponentsEnabledByDefault, isLayoutRunning, isLayoutTimeElapsed, isMemorySavings, isParametersUpToDate, isPreserveFixedLinks, isPreserveFixedNodes, isSplineRoutingEnabled, isStoppedImmediately, isStructureUpToDate, isUseDefaultParameters, isUseSeedValueForRandomGenerator, layoutStepPerformed, onParameterChanged, onParameterChanged, performAutoLayout, performLayout, performLayout, performLayout, PerformLayout, performSublayout, removeGraphLayoutEventListener, removeGraphLayoutParameterEventListener, setAllowedTime, setAnimate, setAutoLayout, setAutoLayoutHandler, setBalanceSplineCurveThreshold, setCoordinatesMode, setFixed, setGeometryUpToDate, setGrapher, setGraphModel, setInputCheckEnabled, setLayoutOfConnectedComponents, setLayoutOfConnectedComponentsEnabled, setLayoutRegion, setLayoutRegion, setLayoutRegion, setLayoutReport, setLinkClipInterface, setLinkConnectionBoxInterface, setMaxSplineCurveSize, setMemorySavings, setMinBusyTime, setMinSplineCurveSize, setParametersUpToDate, setParentLayout, setPreserveFixedLinks, setPreserveFixedNodes, setProperty, setProperty, setSeedValueForRandomGenerator, setSplineLinkFilter, setSplineRoutingEnabled, setStructureUpToDate, setUseDefaultParameters, setUseSeedValueForRandomGenerator, stopImmediately, supportsAnimation, supportsLayoutOfConnectedComponents, supportsLinkClipping, supportsLinkConnectionBox, supportsMemorySavings, supportsPreserveFixedLinks, supportsSplineRouting, unfixAllLinks, unfixAllNodes, useAnimateRedraw
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRAIGHT_LINE_STYLE

public static final int STRAIGHT_LINE_STYLE
Straight-line links shape option. When used as an argument of setLinkStyle(int), the links are given a straight-line shape.

Since:
JViews 3.0
See Also:
Constant Field Values

NO_RESHAPE_STYLE

public static final int NO_RESHAPE_STYLE
No links reshape option. When used as an argument of setLinkStyle(int), the links are not reshaped.

Since:
JViews 3.0
See Also:
Constant Field Values
Constructor Detail

IlvRandomLayout

public IlvRandomLayout()
Creates a new instance of the Random Layout algorithm.
To indicate the grapher you want to lay out, use the method IlvGraphLayout.attach(IlvGrapher).
To indicate the graph model you want to lay out, use the method IlvGraphLayout.attach(IlvGraphModel).
To perform the layout, use the method IlvGraphLayout.performLayout().
To modify the layout parameters, use the different methods provided in this class and its superclass.

See Also:
IlvGraphLayout.attach(ilog.views.IlvGrapher), IlvGraphLayout.attach(ilog.views.graphlayout.IlvGraphModel), IlvGraphLayout.performLayout(), IlvGrapherAdapter.addLayer(ilog.views.IlvManagerLayer), IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)

IlvRandomLayout

public IlvRandomLayout(IlvRandomLayout source)
Creates a new layout instance by copying an existing one. This constructor is used by the copy() method. Any subclass should provide a copy constructor.

The parameters of the source layout are copied using the method copyParameters(ilog.views.graphlayout.IlvGraphLayout).

Parameters:
source - The layout instance that is copied.
Since:
JViews 5.0
Method Detail

init

protected void init()
Initializes instance variables.

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.

Overrides:
init in class IlvGraphLayout
Since:
JViews 5.0

copy

public IlvGraphLayout copy()
Copies the layout instance.

This method copies the layout instance by calling the copy constructor.

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 a method of the type supportsXXX is associated with a parameter, the parameter is copied only if the corresponding method returns true.

Specified by:
copy in class IlvGraphLayout
Returns:
A copy of the layout instance.
Since:
JViews 5.0
See Also:
copyParameters(ilog.views.graphlayout.IlvGraphLayout)

copyParameters

public void copyParameters(IlvGraphLayout source)
Copies the parameters from a given layout instance.

Note that the parameters which are specific to a node or a link are not copied. The other parameters, including the layout region specification and the customization interfaces, are also copied.

If a method of the type supportsXXX is associated with a parameter, the parameter is copied only if the corresponding method returns true.

Overrides:
copyParameters in class IlvGraphLayout
Parameters:
source - The layout instance from which the parameters are copied.
Since:
JViews 5.0
See Also:
copy()

layout

protected void layout(boolean redraw)
               throws IlvGraphLayoutException
Computes the layout using the Random Layout algorithm. To start the layout, call the method IlvGraphLayout.performLayout().

Specified by:
layout in class IlvGraphLayout
Parameters:
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, float, float, boolean) and IlvGraphModel.reshapeLink(java.lang.Object, ilog.views.IlvPoint, ilog.views.IlvPoint[], int, int, ilog.views.IlvPoint, boolean).
Throws:
IlvInappropriateLinkException - if the grapher contains links that cannot be reshaped to a straight line and the link style is STRAIGHT_LINE_STYLE. (For details, see IlvInappropriateLinkException).
IlvGraphLayoutException - If an unusual situation occurs. WARNING: this method can throw one of the subclasses of IlvGraphLayoutException. Specifically, it can throw an IlvInappropriateGraphException. It can also throw an IlvInappropriateLinkException when inappropriate types of links and/or link connectors are used in an IlvGrapher. For details, refer to the documentation of these exception classes.
See Also:
IlvGraphLayout.performLayout()

supportsPreserveFixedNodes

public final boolean supportsPreserveFixedNodes()
Indicates that this layout class allows the user to specify fixed nodes. Fixed nodes are not moved during the layout if the method IlvGraphLayout.setPreserveFixedNodes(boolean) is called with a true argument.

Overrides:
supportsPreserveFixedNodes in class IlvGraphLayout
Returns:
Always true.
See Also:
IlvGraphLayout.setPreserveFixedNodes(boolean), IlvGraphLayout.isPreserveFixedNodes()

supportsLayoutRegion

public final boolean supportsLayoutRegion()
Indicates that this layout class can control the size of the drawing of the graph to fit (exactly or approximately) a user-defined region (a rectangle) or a user-defined manager view.

Overrides:
supportsLayoutRegion in class IlvGraphLayout
Returns:
Always true.
See Also:
IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView), IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView, ilog.views.IlvRect), IlvGraphLayout.setLayoutRegion(ilog.views.IlvRect), IlvGraphLayout.getSpecLayoutRegion(), IlvGraphLayout.getCalcLayoutRegion(), IlvGraphLayout

supportsPercentageComplete

public final boolean supportsPercentageComplete()
Indicates that this layout class can estimate the percentage of completion during the run of the layout.

Overrides:
supportsPercentageComplete in class IlvGraphLayout
Returns:
Always true.
Since:
JViews 3.5
See Also:
IlvGraphLayout.increasePercentageComplete(int), IlvGraphLayoutReport.getPercentageComplete(), IlvJGraphLayoutProgressBar

supportsRandomGenerator

public final boolean supportsRandomGenerator()
Indicates that this layout class uses randomly generated numbers that can be initialized with a user-defined seed value. When you perform the layout several times on the same graph and use the same user-defined seed value, you obtain the same drawing of the graph. If you want different drawings each time you perform the layout, you should modify the seed value and call the method IlvGraphLayout.setUseSeedValueForRandomGenerator(boolean) with a true argument.

Overrides:
supportsRandomGenerator in class IlvGraphLayout
Returns:
Always true.
See Also:
IlvGraphLayout.setSeedValueForRandomGenerator(long), IlvGraphLayout.getSeedValueForRandomGenerator(), IlvGraphLayout.setUseSeedValueForRandomGenerator(boolean), IlvGraphLayout.isUseSeedValueForRandomGenerator()

supportsAllowedTime

public final boolean supportsAllowedTime()
Indicates that this layout class can stop the layout computation when the user-defined allowed time is exceeded. The result code in the layout report is IlvGraphLayoutReport.STOPPED_AND_INVALID in this case.

Overrides:
supportsAllowedTime in class IlvGraphLayout
Returns:
Always true.
Since:
JViews 3.5
See Also:
IlvGraphLayout.setAllowedTime(long), IlvGraphLayout.getAllowedTime(), IlvGraphLayoutReport.getCode()

supportsStopImmediately

public boolean supportsStopImmediately()
Indicates that this layout class can interrupt the current run of the layout immediately in a controlled way. The result code in the layout report is IlvGraphLayoutReport.STOPPED_AND_INVALID in this case.

Overrides:
supportsStopImmediately in class IlvGraphLayout
Returns:
Always true.
Since:
JViews 3.5
See Also:
IlvGraphLayout.stopImmediately(), IlvGraphLayout.isStoppedImmediately(), IlvGraphLayoutReport.getCode()

supportsSaveParametersToNamedProperties

public boolean supportsSaveParametersToNamedProperties()
Indicates that this layout class can transfer the layout parameters to named properties. This mechanism can be used if layout parameters must be stored persistently in an .ivl file.

Overrides:
supportsSaveParametersToNamedProperties in class IlvGraphLayout
Returns:
Always true.
Since:
JViews 3.5
See Also:
IlvGrapherAdapter.saveParametersToNamedProperties(IlvGraphLayout, boolean), IlvGrapherAdapter.loadParametersFromNamedProperties(IlvGraphLayout), IlvGrapherAdapter.removeParametersFromNamedProperties()

setLinkStyle

public void setLinkStyle(int style)
Sets the style of the shape of the links. Valid values are STRAIGHT_LINE_STYLE (the links are given a straight-line shape) and NO_RESHAPE_STYLE (no reshape is performed on the links).

This feature can be useful if the graph contains links that have intermediate points and are not straight-line links; for instance, IlvPolylineLinkImage links with intermediate points.

Note that when the graph attached to the layout is of type IlvGrapher, the effect of the link reshaping depends on the type of the links and the connectors installed at the node. For all link styles, we recommend using links of type IlvPolylineLinkImage and either no link connector or any link connector except IlvFreeLinkConnector. Other link or connector types may cause an IlvInappropriateLinkException during layout. You can use the method IlvGraphLayoutUtil.EnsureAppropriateLinks(ilog.views.graphlayout.IlvGraphModel, ilog.views.graphlayout.IlvLayoutProvider) before layout or when the exception is caught to convert all links and link connectors to an appropriate type.

The default value is STRAIGHT_LINE_STYLE.

Since:
JViews 3.0
See Also:
getLinkStyle()

getLinkStyle

public int getLinkStyle()
Returns the current option for the style of the shape of the links.

Since:
JViews 3.0
See Also:
setLinkStyle(int)

checkAppropriateLink

public int checkAppropriateLink(Object link)
Checks whether the input link is appropriate for this layout. You should not call this method directly. It is called by IlvGraphLayout.checkAppropriateLinks().

Overrides:
checkAppropriateLink in class IlvGraphLayout
Parameters:
link - The link to be checked.
Returns:
The exception type for the link.
Since:
JViews 5.0
See Also:
IlvGraphLayout.checkAppropriateLinks()

getMovingNodes

public IlvGraphicVector getMovingNodes()
Returns the vector of nodes being moved by the graph layout algorithm. You should not call this method. It is only used when the graph model is an IlvGrapherAdapter in order to optimize for speed.

Overrides:
getMovingNodes in class IlvGraphLayout
Since:
JViews 5.5

createLayoutGrapherProperty

protected IlvGraphLayoutGrapherProperty createLayoutGrapherProperty(String name,
                                                                    boolean withDefaults)
Returns a new instance of IlvRandomLayoutGrapherProperty that stores the parameter settings of this layout class.

The method is used by IlvGrapherAdapter.saveParametersToNamedProperties(IlvGraphLayout, boolean) to create a named property that contains parameter settings of this layout instance.

Overrides:
createLayoutGrapherProperty in class IlvGraphLayout
Since:
JViews 3.5
See Also:
IlvGraphLayoutGrapherProperty, IlvGrapherAdapter.saveParametersToNamedProperties(IlvGraphLayout, boolean), IlvGrapherAdapter.loadParametersFromNamedProperties(IlvGraphLayout), IlvGrapherAdapter.removeParametersFromNamedProperties()


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.