public static ILogicalTable logicalTable( IGridTable table, ILogicalTable columnOffsetsTable, ILogicalTable rowOffsetsTable) { int[] columnOffsets = null; if (columnOffsetsTable != null && columnOffsetsTable instanceof LogicalTable) { columnOffsets = ((LogicalTable)columnOffsetsTable).getColumnOffset(); } int[] rowOffsets = null; if (rowOffsetsTable != null && rowOffsetsTable instanceof LogicalTable) { rowOffsets = ((LogicalTable)rowOffsetsTable).getRowOffset(); } if (rowOffsets == null && columnOffsets == null) return LogicalTableHelper.logicalTable(table); return new LogicalTable(table, columnOffsets, rowOffsets); }
@Override public ICell getCell(int column, int row) { int r = rowOffset[row]; int c = columnOffset[column]; return getSource().getCell(c, r); } }
return new LogicalTable(gt, newColumnOffsets, getRowOffsets(table));
private static int[] getRowOffsets(ILogicalTable table) { if (table instanceof LogicalTable) { return ((LogicalTable)table).getRowOffset(); } return calculateRowOffsets(table.getHeight(), table.getSource()); }
private static int[] getColumnOffsets(ILogicalTable table) { if (table instanceof LogicalTable) { return ((LogicalTable)table).getColumnOffset(); } return calculateColumnOffsets(table.getWidth(), table.getSource()); }
/** * If there is no merged cells in the top row and left column - returns {@link SimpleLogicalTable} * in other case return {@link LogicalTable} * * @param table Original source grid table. * @return {@link ILogicalTable} table with correctly calculated height and width. */ public static ILogicalTable logicalTable(IGridTable table) { int width = calcLogicalColumns(table); int height = calcLogicalRows(table); if (width == table.getWidth() && height == table.getHeight()) { return new SimpleLogicalTable(table); } return new LogicalTable(table, width, height); }
return new LogicalTable(gt, columnsOffset, rowsOffset);
public ILogicalTable getSubtable(int column, int row, int width, int height) { if (width == 0 || height == 0) { return null; } int startRow = rowOffset[row]; int endRow = rowOffset[row + height]; int startColumn = columnOffset[column]; int endColumn = columnOffset[column + width]; return LogicalTableHelper.logicalTable( getSource().getSubtable(startColumn, startRow, endColumn - startColumn, endRow - startRow)); }