ilog.views.graphlayout.grid
Class IlvGridLayout

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

public class IlvGridLayout
extends IlvGraphLayout

The main class for the Grid Layout algorithm.

The Grid Layout algorithm has two major modes: grid and row/column. (For details, see the method setLayoutMode(int).) In grid mode, the layout arranges the nodes of a graph in the cells of a grid (matrix). If a node is too large to fit into one grid cell (with a margin), it occupies multiple cells. The size of the grid cells can be specified using the methods setHorizontalGridOffset(float) and setVerticalGridOffset(float). The margins can be specified using the methods setTopMargin(float), setBottomMargin(float), setLeftMargin(float), and setRightMargin(float).

The following sample drawing shows a layout in the grid mode where the grid size has been specified so that each node fits into one grid cell. (Usually such layouts are more esthetic and appear to be more regular, but a larger area is left empty around the smallest nodes. This is generally the best option when all the nodes have the same size.)

The following sample drawing shows a layout in the grid mode where the grid size has been specified so that some nodes fit into one grid cell and other nodes occupy multiple cells. (Usually such layouts take less space if the nodes have a heterogeneous size.)
The following diagram shows the dimensional parameters of the layout in grid mode.

In row/column mode, the layout arranges the nodes of a graph either by rows or by columns (according to the specified option). The width of the rows is controlled by the width of the layout region parameter. The height of the columns is controlled by the height of the layout region parameter. The margins can be specified using the methods setTopMargin(float), setBottomMargin(float), setLeftMargin(float), and setRightMargin(float). The minimum horizontal distance between nodes is equal to the sum of the left and right margins. The minimum vertical distance between nodes is equal to the sum of the top and bottom margins.

For graphs with nodes of heterogeneous size, the row/column mode often allows a more compact layout than the grid mode.

The following sample drawing shows a layout in the row mode.

The following sample drawing shows a layout in the column mode.
The following diagram shows the dimensional parameters of the layout in row mode (the parameters for the column mode are analogous).

The algorithm is primarily designed for graphs without (visible) links between the nodes. If links exist, they are ignored by the Grid layout.

Several alignment options are provided (see setGlobalHorizontalAlignment(int) and setGlobalVerticalAlignment(int)). The alignment can be specified individually for each node (see setHorizontalAlignment(java.lang.Object, int) and setVerticalAlignment(java.lang.Object, int)).

An incremental mode is provided (see setIncrementalMode(boolean)). If the incremental mode is enabled, the stability of the layout is preserved as much as possible when new nodes are added, existing ones removed, or node sizes modified. This means that the nodes are placed at the same location, or in the same order, as in the previous layout whenever possible. In this mode, the layout algorithm processes the changes incrementally rather than redoing the entire layout for every change.

Nodes that the layout algorithm is not allowed to move can be specified using the method IlvGraphLayout.setFixed(java.lang.Object, boolean). (See also IlvGraphLayout.setPreserveFixedNodes(boolean).) In grid mode, nonfixed nodes are placed in such a way that they do not overlap the grid cells occupied by other fixed or nonfixed nodes. In row/column mode, nonfixed nodes are placed in such a way that they do not overlap fixed or nonfixed nodes. Of course, fixed nodes can overlap other fixed nodes.

The layout algorithm can take into account a different node size than the size corresponding to the bounding box of the node. Using setNodeBoxInterface(ilog.views.graphlayout.IlvNodeBoxInterface), you can specify an object that provides the box that has to be taken into account for each node. The following diagram shows the dimensional parameters of the layout in grid mode (the row/column case mode is analogous) when a node box that is different from the bounding box of the node is used:

Since:
JViews 3.5
See Also:
Serialized Form

Field Summary
static Comparator ASCENDING_AREA
          Ordering by ascending area option.
static Comparator ASCENDING_HEIGHT
          Ordering by ascending height option.
static Comparator ASCENDING_INDEX
          Ordering by ascending index option.
static Comparator ASCENDING_WIDTH
          Ordering by ascending width option.
static Comparator AUTOMATIC_ORDERING
          Automatic ordering option.
static int BOTTOM
          Bottom alignment option.
static int CENTER
          Center alignment option.
static Comparator DESCENDING_AREA
          Ordering by descending area option.
static Comparator DESCENDING_HEIGHT
          Ordering by height option.
static Comparator DESCENDING_INDEX
          Ordering by descending index option.
static Comparator DESCENDING_WIDTH
          Ordering by descending width option.
static int LEFT
          Left alignment option.
static int MIXED
          Mixed alignment option.
static int NO_INDEX
          No index code.
static Comparator NO_ORDERING
          No ordering option.
static int RIGHT
          Right alignment option.
static int TILE_TO_COLUMNS
          Tile-to-columns layout mode.
static int TILE_TO_GRID_FIXED_HEIGHT
          Tile-to-grid layout mode with fixed height of the grid.
static int TILE_TO_GRID_FIXED_WIDTH
          Tile-to-grid layout mode with fixed width of the grid.
static int TILE_TO_ROWS
          Tile-to-rows layout mode.
static int TOP
          Top alignment option.
 
Fields inherited from class ilog.views.graphlayout.IlvGraphLayout
INVERSE_VIEW_COORDINATES, MANAGER_COORDINATES, VIEW_COORDINATES
 
Constructor Summary
IlvGridLayout()
          Creates a new instance of the Grid Layout algorithm.
IlvGridLayout(IlvGridLayout source)
          Creates a new layout instance by copying an existing one.
 
Method Summary
 void checkAppropriateLinks()
          Throws an exception if the links are not appropriate for the 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 IlvGridLayoutGrapherProperty that stores the parameter settings of this layout class.
protected  IlvGraphLayoutNodeProperty createLayoutNodeProperty(String name, IlvGraphic node, boolean withDefaults)
          Returns a new instance of IlvGridLayoutNodeProperty that stores the parameter settings of this layout class for nodes.
 void detach()
          Detaches the graph model from the layout instance.
 float getBottomMargin()
          Returns the bottom margin.
 int getGlobalHorizontalAlignment()
          Returns the global horizontal alignment style.
 int getGlobalVerticalAlignment()
          Returns the global vertical alignment style.
 int getHorizontalAlignment(Object node)
          Returns the local horizontal alignment style of the node.
 float getHorizontalGridOffset()
          Returns the horizontal grid offset.
 int getIndex(Object node)
          Returns the index associated with a node.
 int getLayoutMode()
          Returns the current layout mode.
 float getLeftMargin()
          Returns the left margin.
 int getMaxNumberOfNodesPerRowOrColumn()
          Returns the maximum number of nodes per row in TILE_TO_ROWS mode or the maximum number of nodes per column in TILE_TO_COLUMNS mode.
 IlvGraphicVector getMovingNodes()
          Returns the vector of nodes being moved by the graph layout algorithm.
 IlvNodeBoxInterface getNodeBoxInterface()
          Returns the object that provides the rectangle defining the location and size of each node, if one is specified.
 Comparator getNodeComparator()
          Returns the comparator used for sorting the nodes.
 float getRightMargin()
          Returns the right margin.
 float getTopMargin()
          Returns the top margin.
 int getVerticalAlignment(Object node)
          Returns the local vertical alignment style of the node.
 float getVerticalGridOffset()
          Returns the vertical grid offset.
protected  void init()
          Initializes instance variables.
 boolean isIncrementalMode()
          Returns true if the incremental mode is enabled, and false otherwise.
protected  void layout(boolean redraw)
          Computes the layout using the Grid Layout algorithm.
 void setBottomMargin(float margin)
          Sets the bottom margin parameter.
 void setGlobalHorizontalAlignment(int alignment)
          Sets the global horizontal alignment style.
 void setGlobalVerticalAlignment(int alignment)
          Sets the global vertical alignment style.
 void setHorizontalAlignment(Object node, int alignment)
          Sets the horizontal alignment style of an individual node.
 void setHorizontalGridOffset(float offset)
          Sets the spacing of the grid lines on the horizontal axis.
 void setIncrementalMode(boolean enable)
          Sets the incremental mode.
 void setIndex(Object node, int index)
          Sets the index of a node.
 void setLayoutMode(int mode)
          Sets the layout mode.
 void setLeftMargin(float margin)
          Sets the left margin parameter.
 void setMaxNumberOfNodesPerRowOrColumn(int nNodes)
          Sets the maximum number of nodes per row or per column.
 void setNodeBoxInterface(IlvNodeBoxInterface nodeBoxInterface)
          Sets an object that provides the rectangle defining the location and size of each node.
 void setNodeComparator(Comparator comparator)
          Sets the comparator used for sorting the nodes.
 void setRightMargin(float margin)
          Sets the right margin parameter.
 void setTopMargin(float margin)
          Sets the top margin parameter.
 void setVerticalAlignment(Object node, int alignment)
          Sets the vertical alignment style of an individual node.
 void setVerticalGridOffset(float offset)
          Sets the spacing of the grid lines on the vertical axis.
 boolean supportsAllowedTime()
          Indicates that this layout class can stop the layout computation in a proper manner when the user-defined allowed time is exceeded.
 boolean supportsLayoutRegion()
          Indicates that this layout class can control the size of the graph drawing to fit a user-defined region (a rectangle) or a user-defined manager view.
 boolean supportsPreserveFixedNodes()
          Indicates that this layout class allows the user to specify fixed nodes.
 boolean supportsSaveParametersToNamedProperties()
          Indicates that this layout class can transfer the layout parameters to named properties.
 boolean supportsStopImmediately()
          Indicates that this layout class can control the current run by interrupting the run of the layout immediately.
 
Methods inherited from class ilog.views.graphlayout.IlvGraphLayout
addGraphLayoutEventListener, addGraphLayoutParameterEventListener, afterLayoutOfSubgraph, attach, attach, beforeLayout, beforeLayoutOfSubgraph, callLayoutStepPerformedIfNeeded, checkAppropriateLink, cleanGraphModel, cleanLink, cleanNode, clipAllLinks, clipLink, contentsChanged, createLayoutLinkProperty, createLayoutReport, 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, supportsPercentageComplete, supportsPreserveFixedLinks, supportsRandomGenerator, supportsSplineRouting, unfixAllLinks, unfixAllNodes, useAnimateRedraw
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CENTER

public static final int CENTER
Center alignment option. When used as the argument of the method setGlobalHorizontalAlignment(int), all the nodes are horizontally centered in their grid cell or column. The alignment of an individual node can be set by setHorizontalAlignment(Object, int).

When used as the argument of the method setGlobalVerticalAlignment(int), all the nodes are vertically centered in their grid cell or row. The alignment of an individual node can be set by setVerticalAlignment(Object, int).

See Also:
Constant Field Values

LEFT

public static final int LEFT
Left alignment option. When used as the argument of the method setGlobalHorizontalAlignment(int), all the nodes are aligned to the left border of their grid cell or column. The alignment of an individual node can be set by setHorizontalAlignment(Object, int).

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Right alignment option. When used as the argument of the method setGlobalHorizontalAlignment(int), all the nodes are aligned to the right border of their grid cell or column. The alignment of an individual node can be set by setHorizontalAlignment(Object, int).

See Also:
Constant Field Values

TOP

public static final int TOP
Top alignment option. When used as the argument of the method setGlobalVerticalAlignment(int), all the nodes are aligned to the top border of their grid cell or row. The alignment of an individual node can be set by setVerticalAlignment(Object, int).

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
Bottom alignment option. When used as the argument of the method setGlobalVerticalAlignment(int), all the nodes are aligned to the bottom border of their grid cell or row. The alignment of an individual node can be set by setVerticalAlignment(Object, int).

See Also:
Constant Field Values

MIXED

public static final int MIXED
Mixed alignment option. When used as the argument of the method setGlobalHorizontalAlignment(int) or setGlobalVerticalAlignment(int), each node can have a different alignment. The alignment of an individual node can be set by setHorizontalAlignment(Object, int) and setVerticalAlignment(Object, int).

See Also:
Constant Field Values

TILE_TO_ROWS

public static final int TILE_TO_ROWS
Tile-to-rows layout mode. When used as the argument of the method setLayoutMode(int), all the nodes are organized in rows and are vertically aligned with respect to the row border according to the vertical alignment option. In this mode, the grid offset parameters are not used and the height of the layout region IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView) controls the maximum total height of the layout.

See Also:
Constant Field Values

TILE_TO_COLUMNS

public static final int TILE_TO_COLUMNS
Tile-to-columns layout mode. When used as the argument of the method setLayoutMode(int), all the nodes are organized in columns and are horizontally aligned with respect to the row border according to the horizontal alignment option. In this mode, the grid offset parameters are not used and the width of the layout region IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView) controls the maximum total width of the layout.

See Also:
Constant Field Values

TILE_TO_GRID_FIXED_WIDTH

public static final int TILE_TO_GRID_FIXED_WIDTH
Tile-to-grid layout mode with fixed width of the grid. When used as the argument of the method setLayoutMode(int), the nodes are placed in the cells of a grid and the width of the layout region IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView)) controls the maximum width of the grid.

See Also:
Constant Field Values

TILE_TO_GRID_FIXED_HEIGHT

public static final int TILE_TO_GRID_FIXED_HEIGHT
Tile-to-grid layout mode with fixed height of the grid. When used as the argument of the method setLayoutMode(int), the nodes are placed in the cells of a grid and the height of the layout region IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView)) controls the maximum height of the grid.

See Also:
Constant Field Values

AUTOMATIC_ORDERING

public static final Comparator AUTOMATIC_ORDERING
Automatic ordering option. When used as the argument of the method setNodeComparator(java.util.Comparator), the algorithm is free to choose the order in such a way that it tries to reduce the total area occupied by the layout.

Since:
JViews 6.5

NO_ORDERING

public static final Comparator NO_ORDERING
No ordering option. When used as the argument of the method setNodeComparator(java.util.Comparator), the nodes are arranged in an arbitrary order.

Since:
JViews 6.5

DESCENDING_HEIGHT

public static final Comparator DESCENDING_HEIGHT
Ordering by height option. When used as the argument of the method setNodeComparator(java.util.Comparator), the nodes are arranged by height, starting at the upper-left corner with the tallest node. Ordering the nodes by height can save vertical space and produce a more compact layout.

Since:
JViews 6.5

ASCENDING_HEIGHT

public static final Comparator ASCENDING_HEIGHT
Ordering by ascending height option. When used as the argument of the method setNodeComparator(java.util.Comparator), the nodes are arranged by ascending height, starting at the upper-left corner with the node of the smallest height. Ordering the nodes by height can save vertical space and produce a more compact layout.

Since:
JViews 6.5

ASCENDING_WIDTH

public static final Comparator ASCENDING_WIDTH
Ordering by ascending width option. When used as the argument of the method setNodeComparator(java.util.Comparator), the nodes are arranged by ascending width, starting at the upper-left corner with the node of the smallest width.

Since:
JViews 6.5

DESCENDING_WIDTH

public static final Comparator DESCENDING_WIDTH
Ordering by descending width option. When used as the argument of the method setNodeComparator(java.util.Comparator), the nodes are arranged by width, starting at the upper-left corner with the node of the highest width.

Since:
JViews 6.5

ASCENDING_AREA

public static final Comparator ASCENDING_AREA
Ordering by ascending area option. When used as the argument of the method setNodeComparator(java.util.Comparator), the nodes are arranged by ascending area, starting at the upper-left corner with the node of the smallest area.

Since:
JViews 6.5

DESCENDING_AREA

public static final Comparator DESCENDING_AREA
Ordering by descending area option. When used as the argument of the method setNodeComparator(java.util.Comparator), the nodes are arranged by area, starting at the upper-left corner with the node of the highest area.

Since:
JViews 6.5

ASCENDING_INDEX

public static final Comparator ASCENDING_INDEX
Ordering by ascending index option. When used as the argument of the method setNodeComparator(java.util.Comparator), the nodes are arranged in the order of their indexes, starting at the upper-left corner with the node with the smallest index. Nodes that do not have an index are placed after the nodes for which an index is specified. Ordering by index allows you to specify a particular order for the nodes.

Since:
JViews 6.5
See Also:
setIndex(java.lang.Object, int)

DESCENDING_INDEX

public static final Comparator DESCENDING_INDEX
Ordering by descending index option. When used as the argument of the method setNodeComparator(java.util.Comparator), the nodes are arranged in the order of their indexes, starting at the upper-left corner with the node with the highest index. Nodes that do not have an index are placed after the nodes for which an index is specified. Ordering by index allows you to specify a particular order for the nodes.

Since:
JViews 6.5
See Also:
setIndex(java.lang.Object, int)

NO_INDEX

public static final int NO_INDEX
No index code. This value is returned by the method getIndex(java.lang.Object) when a node has no index value.

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

IlvGridLayout

public IlvGridLayout()
Creates a new instance of the Grid 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(IlvGrapher), IlvGraphLayout.attach(IlvGraphModel), IlvGraphLayout.performLayout(), IlvGrapherAdapter.addLayer(ilog.views.IlvManagerLayer), IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)

IlvGridLayout

public IlvGridLayout(IlvGridLayout 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
See Also:
copy(), copyParameters(ilog.views.graphlayout.IlvGraphLayout)
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 node box interface, 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

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 node box interface, 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

layout

protected void layout(boolean redraw)
               throws IlvGraphLayoutException
Computes the layout using the Grid 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:
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()

detach

public void detach()
Detaches the graph model from the layout instance. When you attach a new graph model to the layout instance, you do not need to detach the old graph model because this is done automatically when you call IlvGraphLayout.attach(IlvGraphModel).

The method performs cleaning operations on the graph model. In addition to the cleaning operations in the base class, the Grid Layout algorithm removes the alignment specifications of individual nodes.

Note that you must call this method when you no longer need the layout instance. Otherwise, some objects may not be garbage collected.

Overrides:
detach in class IlvGraphLayout
See Also:
IlvGraphLayout.attach(IlvGraphModel), setHorizontalAlignment(java.lang.Object, int), setVerticalAlignment(java.lang.Object, int)

supportsLayoutRegion

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

If the layout mode (see setLayoutMode(int)) is TILE_TO_GRID_FIXED_WIDTH, the width of the layout region determines the maximum width of the layout (the maximum number of columns).

If the layout mode is TILE_TO_GRID_FIXED_HEIGHT, the height of the layout region determines the maximum height of the layout (the maximum number of rows).

If the layout mode is TILE_TO_ROWS, the width of the layout region determines the maximum width of the rows.

If the layout mode is TILE_TO_COLUMNS, the height of the layout region determines the maximum height of the columns.

However, if the width of a node is larger than the maximum width of the layout or the height of the node is larger than the maximum height of the layout, the bounding box of the node will be placed partially out of the specified layout region.

In all layout modes, the coordinates of the top-left corner of the layout region determines the coordinates of the top-left border of the layout.

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()

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. Nonfixed nodes are placed in such a manner that overlaps with fixed nodes are avoided.

Overrides:
supportsPreserveFixedNodes in class IlvGraphLayout
Returns:
Always true.
See Also:
IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter), IlvGraphLayout.setPreserveFixedNodes(boolean), IlvGraphLayout.isPreserveFixedNodes()

supportsAllowedTime

public final boolean supportsAllowedTime()
Indicates that this layout class can stop the layout computation in a proper manner when the user-defined allowed time is exceeded. If the allowed time elapses before termination of the Grid Layout algorithm, the result code in the layout report is IlvGraphLayoutReport.STOPPED_AND_INVALID.

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

supportsStopImmediately

public boolean supportsStopImmediately()
Indicates that this layout class can control the current run by interrupting the run of the layout immediately. If the algorithm is stopped before termination, the result code in the layout report is IlvGraphLayoutReport.STOPPED_AND_INVALID.

Overrides:
supportsStopImmediately in class IlvGraphLayout
Returns:
Always true.
See Also:
IlvGraphLayout.stopImmediately(), IlvGraphLayout.isStoppedImmediately()

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.
See Also:
IlvGrapherAdapter.saveParametersToNamedProperties(IlvGraphLayout, boolean), IlvGrapherAdapter.loadParametersFromNamedProperties(IlvGraphLayout), IlvGrapherAdapter.removeParametersFromNamedProperties()

setLayoutMode

public void setLayoutMode(int mode)
Sets the layout mode. Valid values are:

The default value is TILE_TO_GRID_FIXED_WIDTH.

See Also:
getLayoutMode(), setGlobalHorizontalAlignment(int), setGlobalVerticalAlignment(int), setHorizontalAlignment(java.lang.Object, int), setVerticalAlignment(java.lang.Object, int)

getLayoutMode

public int getLayoutMode()
Returns the current layout mode.

See Also:
setLayoutMode(int)

setIncrementalMode

public void setIncrementalMode(boolean enable)
Sets the incremental mode.

If the incremental mode is enabled, the stability of the layout is preserved as much as possible when new nodes are added, existing ones removed, or node sizes modified. This means that the nodes are placed at the same location or in the same order as in the previous layout whenever possible. In this mode, the layout algorithm processes the changes incrementally rather than redoing the entire layout for every change.

To preserve the stability, the incremental mode can keep some regions free. Therefore, the total area of the layout can be larger than when nonincremental mode is used.

Note that the layout is redone from scratch after a change in one of the following parameters:

The default value is false (disabled).


isIncrementalMode

public boolean isIncrementalMode()
Returns true if the incremental mode is enabled, and false otherwise.

See Also:
setIncrementalMode(boolean)

setGlobalHorizontalAlignment

public void setGlobalHorizontalAlignment(int alignment)
Sets the global horizontal alignment style. This method controls the horizontal alignment of nodes either inside their grid cell if the layout mode (see setLayoutMode(int)) is TILE_TO_GRID_FIXED_WIDTH or TILE_TO_GRID_FIXED_HEIGHT, or inside the columns if the layout mode is TILE_TO_COLUMNS. This parameter is not used if the layout mode (see setLayoutMode(int)) is TILE_TO_ROWS.

Valid values are:

The default value is CENTER.

See Also:
getGlobalHorizontalAlignment(), setGlobalVerticalAlignment(int), setHorizontalAlignment(java.lang.Object, int), setLayoutMode(int)

getGlobalHorizontalAlignment

public int getGlobalHorizontalAlignment()
Returns the global horizontal alignment style.

See Also:
setGlobalHorizontalAlignment(int)

setHorizontalAlignment

public void setHorizontalAlignment(Object node,
                                   int alignment)
Sets the horizontal alignment style of an individual node. This alignment style is used only if the global horizontal alignment is set to MIXED. Otherwise, all nodes have the alignment style that is specified as the global alignment style.

The parameter controls the horizontal alignment of nodes either inside their grid cell if the layout mode (see setLayoutMode(int)) is TILE_TO_GRID_FIXED_WIDTH or TILE_TO_GRID_FIXED_HEIGHT, or inside the columns if the layout mode is TILE_TO_COLUMNS.

This parameter is not used if the layout mode (see setLayoutMode(int)) is TILE_TO_ROWS.

Valid values are:

The default value is CENTER.

See Also:
getHorizontalAlignment(java.lang.Object), setGlobalHorizontalAlignment(int)

getHorizontalAlignment

public int getHorizontalAlignment(Object node)
Returns the local horizontal alignment style of the node.

See Also:
setHorizontalAlignment(java.lang.Object, int), setGlobalHorizontalAlignment(int)

setGlobalVerticalAlignment

public void setGlobalVerticalAlignment(int alignment)
Sets the global vertical alignment style. This method controls the vertical alignment of nodes either inside their grid cell if the layout mode (see setLayoutMode(int)) is TILE_TO_GRID_FIXED_WIDTH or TILE_TO_GRID_FIXED_HEIGHT, or inside the rows if the layout mode is TILE_TO_ROWS. This parameter is not used if the layout mode (see setLayoutMode(int)) is TILE_TO_COLUMNS.

Valid values are:

The default value is CENTER.

See Also:
getGlobalVerticalAlignment(), setGlobalHorizontalAlignment(int), setVerticalAlignment(java.lang.Object, int), setLayoutMode(int)

getGlobalVerticalAlignment

public int getGlobalVerticalAlignment()
Returns the global vertical alignment style.

See Also:
setGlobalVerticalAlignment(int)

setVerticalAlignment

public void setVerticalAlignment(Object node,
                                 int alignment)
Sets the vertical alignment style of an individual node. This alignment style is used only if the global vertical alignment is set to MIXED. Otherwise, all nodes have the alignment style that is specified as the global alignment style.

The parameter controls the vertical alignment of nodes either inside their grid cell if the layout mode (see setLayoutMode(int)) is TILE_TO_GRID_FIXED_WIDTH or TILE_TO_GRID_FIXED_HEIGHT, or inside the rows if the layout mode is TILE_TO_ROWS.

This parameter is not used if the layout mode (see setLayoutMode(int)) is TILE_TO_COLUMNS.

Valid values are:

The default value is CENTER.

See Also:
getVerticalAlignment(java.lang.Object), setGlobalVerticalAlignment(int)

getVerticalAlignment

public int getVerticalAlignment(Object node)
Returns the local vertical alignment style of the node.

See Also:
setVerticalAlignment(java.lang.Object, int), setGlobalVerticalAlignment(int)

setNodeComparator

public final void setNodeComparator(Comparator comparator)
Sets the comparator used for sorting the nodes. The valid values are the following: The default value is AUTOMATIC_ORDERING.

The ordering of the nodes starts at the upper-left corner.

Note that in incremental mode (see setIncrementalMode(boolean)) or when nodes are fixed (see IlvGraphLayout.setFixed(java.lang.Object, boolean)) the order of the nodes is not guaranteed to obey the comparator, since this specification competes with the other constraints.

Note also that, if the layout mode is TILE_TO_GRID_FIXED_WIDTH or TILE_TO_GRID_FIXED_HEIGHT, the order options are applied only for nodes whose size (including margins) is smaller than the grid cell size (see setHorizontalGridOffset(float) and setVerticalGridOffset(float)).

Since:
JViews 6.5
See Also:
getNodeComparator()

getNodeComparator

public Comparator getNodeComparator()
Returns the comparator used for sorting the nodes.

Since:
JViews 6.5

setIndex

public void setIndex(Object node,
                     int index)
Sets the index of a node. When the layout is performed, the nodes for which indexes have been specified are arranged in the order corresponding to their index (starting in the upper-left corner with the smallest index). The nodes for which indexes have not been specified are arranged after them. You can specify the class field NO_INDEX as an index value if you want to reset an index you previously specified.

Note that index must not be negative. The values of the indexes for consecutive nodes are not necessarily consecutive. Only the order of the values is important.

Since:
JViews 6.5
See Also:
getIndex(java.lang.Object)

getIndex

public int getIndex(Object node)
Returns the index associated with a node. It returns NO_INDEX if node has no index.

Since:
JViews 6.5
See Also: