The GL algorithm

The Grid Layout (GL) has two main modes: grid and row/column.
  • 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 in one grid cell (with margins), it occupies multiple cells. The size of the grid cells and the margins are parameters of the algorithm.
  • 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 horizontal and vertical margins between the nodes are parameters of the algorithm.
GL Example
In CSS
The following sample CSS specification uses the Grid Layout algorithm. The CSS specification can be loaded as a style file into an application that uses the IlvDiagrammer class (see Graph layout in Rogue Wave JViews Diagrammer).
SDM {
    GraphLayout : "true";
    LinkLayout  : "false";
}

GraphLayout {
    graphLayout                : "Grid";
    layoutMode                 : "TILE_TO_GRID_FIXED_HEIGHT";
    globalHorizontalAlignment  : "LEFT";
    globalVerticalAlignment    : "TOP";
    incrementalMode            : "true";
    horizontalGridOffset       : "50";
    verticalGridOffset         : "70";
}
In Java™
The following code sample uses the IlvGridLayout class. This code sample shows how to perform a Grid Layout on a grapher directly without using a diagram component or any style sheet:
 ...
import ilog.views.*;
import ilog.views.graphic.*;
import ilog.views.graphlayout.*;
import ilog.views.graphlayout.grid.*;
 ...
IlvGrapher grapher = new IlvGrapher();
IlvManagerView view = new IlvManagerView(grapher);
 
 ... /*  Fill in the grapher with nodes and links here */
 
IlvGridLayout layout = new IlvGridLayout();
layout.attach(grapher);
 
try {
        IlvGraphLayoutReport layoutReport = layout.performLayout();

        int code = layoutReport.getCode();

        System.out.println("Layout completed (" +
          layoutReport.codeToString(code) + ")");
}
catch (IlvGraphLayoutException e) {
        System.err.println(e.getMessage());
}