private void copyCells(JRCrosstab crosstab, JRBaseObjectFactory factory) { JRCrosstabCell[][] crossCells = crosstab.getCells(); if (crossCells != null) { this.cells = new JRCrosstabCell[rowGroups.length + 1][columnGroups.length + 1]; for (int i = 0; i <= rowGroups.length; i++) { for (int j = 0; j <= columnGroups.length; ++j) { this.cells[i][j] = factory.getCrosstabCell(crossCells[i][j]); } } } }
public static JRElement getElementByKey(JRCrosstab crosstab, String key) { JRElement element = null; if (crosstab.getHeaderCell() != null) { element = crosstab.getHeaderCell().getElementByKey(key); } if (element == null) { element = getHeadersElement(crosstab.getRowGroups(), key); } if (element == null) { element = getHeadersElement(crosstab.getColumnGroups(), key); } if (element == null) { if (crosstab instanceof JRDesignCrosstab) { List cellsList = ((JRDesignCrosstab) crosstab).getCellsList(); for (Iterator it = cellsList.iterator(); element == null && it.hasNext(); ) { JRCrosstabCell cell = (JRCrosstabCell) it.next(); element = cell.getContents().getElementByKey(key); } } else { JRCrosstabCell[][] cells = crosstab.getCells(); for (int i = cells.length - 1; element == null && i >= 0; --i) { for (int j = cells[i].length - 1; element == null && j >= 0; --j) { JRCrosstabCell cell = cells[i][j]; if (cell != null) { element = cell.getContents().getElementByKey(key); } } } } } if (element == null && crosstab.getWhenNoDataCell() != null) { element = crosstab.getWhenNoDataCell().getElementByKey(key); } return element; }