* where the col(n) is the outer most column, and row(n) is the outer most row in the crosstab
*
* The cell with null/null is the inner most cell in the crosstab
*/
DJCrosstabColumn auxCol = new DJCrosstabColumn();
DJCrosstabRow auxRow = new DJCrosstabRow();
try {
BeanUtils.copyProperties(auxCol, djcross.getColumns().get(djcross.getColumns().size()-1));
BeanUtils.copyProperties(auxRow, djcross.getRows().get(djcross.getRows().size()-1));
} catch (Exception e) {
log.error(e.getMessage(),e); //must not happend
}
auxCol.setProperty(null);
auxRow.setProperty(null);
List auxColsList = new ArrayList(djcross.getColumns());
auxColsList.add(auxCol);
List auxRowsList = new ArrayList(djcross.getRows());
auxRowsList.add(auxRow);
DJCrosstabColumn[] auxCols = (DJCrosstabColumn[]) auxColsList.toArray(new DJCrosstabColumn[]{});
DJCrosstabRow[] auxRows = (DJCrosstabRow[]) auxRowsList.toArray(new DJCrosstabRow[]{});
for (int i = auxCols.length-1; i >= 0; i--) {
for (int j = auxRows.length-1; j >= 0; j--) {
DJCrosstabColumn crosstabColumn = auxCols[i];
DJCrosstabRow crosstabRow = auxRows[j];
JRDesignCrosstabCell cell = new JRDesignCrosstabCell();
cell.setWidth(new Integer(crosstabColumn.getWidth()));
cell.setHeight(new Integer(crosstabRow.getHeight()));
if (crosstabColumn.getProperty() != null)
cell.setColumnTotalGroup(crosstabColumn.getProperty().getProperty());
if (crosstabRow.getProperty() != null)
cell.setRowTotalGroup(crosstabRow.getProperty().getProperty());
JRDesignCellContents contents = new JRDesignCellContents();
JRDesignTextField element = new JRDesignTextField();
element.setWidth(crosstabColumn.getWidth());
element.setHeight(crosstabRow.getHeight());
JRDesignExpression measureExp = new JRDesignExpression();
DJCrosstabMeasure measure = djcross.getMeasure(0);
measureExp.setValueClassName(measure.getProperty().getValueClassName());
measureExp.setText("$V{"+measure.getProperty().getProperty()+"}");
element.setExpression(measureExp);
/**
* Is there any style for this object?
*/
if (crosstabRow.getProperty() == null && crosstabColumn.getProperty() == null && measure.getStyle() != null ){
//this is the inner most cell
layoutManager.applyStyleToElement(measure.getStyle() , element);
} else if (crosstabRow.getTotalStyle() != null) {
layoutManager.applyStyleToElement(crosstabRow.getTotalStyle(), element);
}
else if (crosstabColumn.getTotalStyle() != null) {
layoutManager.applyStyleToElement(crosstabColumn.getTotalStyle(), element);
}