log.debug("Placing variables in "+type+" band...");
if ((variables != null) && (!variables.isEmpty())) {
Iterator it = variables.iterator();
while (it.hasNext()) {
ColumnsGroupVariable var = (ColumnsGroupVariable) it.next();
AbstractColumn col = var.getColumnToApplyOperation();
String variableName = col.getGroupVariableName(type, columnsGroup.getColumnToGroupBy().getColumnProperty().getProperty());
JRDesignExpression expression = new JRDesignExpression();
JRDesignTextField textField = new JRDesignTextField();
expression.setText("$V{" + variableName + "}");
expression.setValueClassName(col.getVariableClassName(var.getOperation()));
if (var.getOperation() != ColumnsGroupVariableOperation.COUNT)
textField.setPattern(col.getPattern());
textField.setKey(variableName);
textField.setExpression(expression);
if (DJConstants.FOOTER.equals(type)){
textField.setPositionType(JRDesignElement.POSITION_TYPE_FIX_RELATIVE_TO_TOP);
}
textField.setX(col.getPosX().intValue());
if (yOffset!=0)
textField.setY(yOffset);
// textField.setHeight(columnsGroup.getHeaderHeight().intValue());
textField.setHeight(2 + getReport().getOptions().getDetailHeight().intValue()); //XXX be carefull with the "2+ ..."
textField.setWidth(col.getWidth().intValue());
textField.setEvaluationTime(JRExpression.EVALUATION_TIME_GROUP);
textField.setEvaluationGroup(jgroup);
//Assign the style to the element.
//First we look for the specific element style, then the default style for the group variables
//and finally the column style.
Style defStyle = DJConstants.HEADER.equals(type)?columnsGroup.getDefaulHeaderStyle():columnsGroup.getDefaulFooterStyle();
if (var.getStyle() != null)
applyStyleToElement(var.getStyle(), textField);
else if (defStyle != null)
applyStyleToElement(defStyle, textField);
else {
//Last resource is tu use the column style, but a copy of it because
//the one in the internal cache can get modified by the layout manager (like in the odd row case)
Style style = col.getStyle();
try {
style = (Style) BeanUtils.cloneBean(style);
style.setName(null); //set to null to make applyStyleToElement(...) assign a name
} catch (Exception e) { }
applyStyleToElement(style, textField);