JRDesignBand band = new JRDesignBand();
band.setHeight(40);
Iterator iterator = fields.iterator();
int x = 0;
while(iterator.hasNext()) {
Field field = (Field)iterator.next();
if(isAggregable(field)) {
JRDesignLine line = new JRDesignLine();
line.setX(x);
line.setY(0);
line.setWidth(field.getColumnWidth());
line.setHeight(0);
band.addElement(line);
line.setY(2);
band.addElement(line);
JRDesignTextField textField = new JRDesignTextField();
textField.setX(x);
textField.setY(4);
textField.setWidth(field.getColumnWidth());
textField.setHeight(12);
textField.setTextAlignment(JRTextElement.TEXT_ALIGN_RIGHT);
textField.setFont(normalFont);
JRDesignExpression expression = new JRDesignExpression();
// Money (double) or Duration(long)
if(field.isMoney()) {
expression.setValueClass(getFieldClass(field, true));
textField.setPattern(getFieldPattern(field));
expression.setText("$V{" + getFieldName(field, true) + "Sum}");
} else if (field.isWork()) {
expression.setValueClass(String.class);
expression.setText("com.projity.datatype.DurationFormat.formatWork($V{" + getFieldName(field, true) + "Sum})" );
} else if(field.isDuration()) {
expression.setValueClass(String.class);
expression.setText("com.projity.datatype.DurationFormat.format($V{" + getFieldName(field, true) + "Sum})" );
}
textField.setExpression(expression);
band.addElement(textField);
}
x += field.getColumnWidth();
}
return band;
}