IBM ILOG Dojo Diagrammer 1.1.1 API Documentation
Legend: Array Boolean Constructor Date DomNode Error Function Namespace Number Object RegExp Singleton String

ibm_ilog.graphlayout.grid

Object » ibm_ilog.graphlayout.grid
dojo.require("ibm_ilog.graphlayout.grid.GridLayout");

Method Summary

  • GridLayout(source) The main class for the Grid Layout algorithm.

Attached Objects

Methods

GridLayout

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 GridLayout.setLayoutMode().) 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 GridLayout.setHorizontalGridOffset() and GridLayout.setVerticalGridOffset(). The margins can be specified using the methods GridLayout.setTopMargin(), GridLayout.setBottomMargin(), GridLayout.setLeftMargin(), and GridLayout.setRightMargin().

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

Sample drawing produced with the Grid Layout

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

Sample drawing produced with the Grid Layout

The following diagram shows the dimensional parameters of the layout in grid mode.

Sample drawing produced with the Grid Layout

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 GridLayout.setTopMargin(), GridLayout.setBottomMargin(), GridLayout.setLeftMargin(), and GridLayout.setRightMargin(). 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.

Sample drawing produced with the Grid Layout

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

Sample drawing produced with the Grid Layout

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

Sample drawing produced with the Grid Layout

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 GridLayout.setGlobalHorizontalAlignment() and GridLayout.setGlobalVerticalAlignment()). The alignment can be specified individually for each node (see GridLayout.setHorizontalAlignment() and GridLayout.setVerticalAlignment()).

An incremental mode is provided (see GridLayout.setIncrementalMode()). 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 ibm_ilog.graphlayout.GraphLayout.setFixed(). (See also ibm_ilog.graphlayout.GraphLayout.setPreserveFixedNodes().) 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 GridLayout.setNodeBoxInterface(), 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:

Sample drawing produced with the Grid Layout

ParameterTypeDescription
source