private Matrix matrix;
public Matrix format(@NotNull final CellSet cellSet) {
// Compute how many rows are required to display the columns axis.
final CellSetAxis columnsAxis;
if (cellSet.getAxes().size() > 0) {
columnsAxis = cellSet.getAxes().get(0);
} else {
columnsAxis = null;
}
final AxisInfo columnsAxisInfo = computeAxisInfo(columnsAxis);
// Compute how many columns are required to display the rows axis.
final CellSetAxis rowsAxis;
if (cellSet.getAxes().size() > 1) {
rowsAxis = cellSet.getAxes().get(1);
} else {
rowsAxis = null;
}
final AxisInfo rowsAxisInfo = computeAxisInfo(rowsAxis);
if (cellSet.getAxes().size() > 2) {
final int[] dimensions = new int[cellSet.getAxes().size() - 2];
for (int i = 2; i < cellSet.getAxes().size(); i++) {
final CellSetAxis cellSetAxis = cellSet.getAxes().get(i);
dimensions[i - 2] = cellSetAxis.getPositions().size();
}
for (final int[] pageCoords : CoordinateIterator.iterate(dimensions)) {
matrix = formatPage(cellSet, pageCoords, columnsAxis, columnsAxisInfo, rowsAxis, rowsAxisInfo);
}
} else {