//retrieve the class for each of the columns
String columnClasses = controller.getConfig().getInitParameter("col_classes");
context.put("col_classes", getCellClasses(columnClasses));
PortletSet set = controller.getPortlets();
// normalize the constraints and calculate max num of rows needed
Enumeration en = set.getPortlets();
int row = 0;
int col = 0;
while (en.hasMoreElements())
{
Portlet p = (Portlet) en.nextElement();
PortletSet.Constraints
constraints = p.getPortletConfig().getConstraints();
if ((constraints != null)
&& (constraints.getColumn() != null)
&& (constraints.getRow() != null))
{
col = constraints.getColumn().intValue();
if (col > colNum)
{
constraints.setColumn(new Integer(col % colNum));
}
row = constraints.getRow().intValue();
if (row > rowNum)
{
rowNum = row;
}
}
}
row = (int) Math.ceil(set.size() / colNum);
if (row > rowNum)
{
rowNum = row;
}
if ( logger.isDebugEnabled() ) {
logger.debug("Controller calculated setSize " + set.size() + " row " + row + " colNum: " + colNum + " rowNum: " + rowNum);
}
// initialize the result position table and the work list
List[] table = new List[colNum];
List filler = Collections.nCopies(rowNum + 1, null);
for (int i = 0; i < colNum; i++)
{
table[i] = new ArrayList();
table[i].addAll(filler);
}
List work = new ArrayList();
//position the constrained elements and keep a reference to the
//others
for (int i = 0; i < set.size(); i++)
{
Portlet p = set.getPortletAt(i);
PortletSet.Constraints
constraints = p.getPortletConfig().getConstraints();
if ((constraints != null)