protected void addSummaryGroup(List<FillColumn> fillColumns, Map<JRExpression, BuiltinExpressionEvaluator> builtinEvaluators)
{
JRDesignGroup summaryGroup = new JRDesignGroup();
summaryGroup.setName(SUMMARY_GROUP_NAME);//TODO check for uniqueness
JRDesignBand groupFooter = new JRDesignBand();
groupFooter.setSplitType(SplitTypeEnum.PREVENT);
groupFooter.setHeight(pageFooter.getHeight());
// we need to put everything in a frame so that we can tell the frame
// not to print when there are no detail bands on the current page
//
// we can't do that directly to the band since its print when expression
// is evaluated too soon
JRDesignFrame footerFrame = new JRDesignFrame();
footerFrame.setX(0);
footerFrame.setY(0);
footerFrame.setWidth(computeTableWidth(fillColumns));
footerFrame.setHeight(pageFooter.getHeight());
footerFrame.getLineBox().setPadding(0);
footerFrame.getLineBox().getPen().setLineWidth(0f);
footerFrame.setRemoveLineWhenBlank(true);
// we only need an empty expression object here
// the evaluation logic is separate
JRDesignExpression footerPrintWhen = new JRDesignExpression();
builtinEvaluators.put(footerPrintWhen, new SummaryGroupFooterPrintWhenEvaluator());
footerFrame.setPrintWhenExpression(footerPrintWhen);
// clone the contents of the page footer in the frame
List footerElements = pageFooter.getChildren();
for (Iterator iterator = footerElements.iterator(); iterator
.hasNext();)
{
JRChild child = (JRChild) iterator.next();
JRChild childClone = (JRChild) child.clone(footerFrame);
if (childClone instanceof JRElement)
{
footerFrame.addElement((JRElement) childClone);
}
else if (childClone instanceof JRElementGroup)
{
footerFrame.addElementGroup((JRElementGroup) childClone);
}
else
{
throw new JRRuntimeException("Uknown child type "
+ childClone.getClass().getName());
}
}
groupFooter.addElement(footerFrame);
((JRDesignSection) summaryGroup.getGroupFooterSection()).addBand(groupFooter);
mainDataset.addScriptlet(TABLE_SCRIPTLET_NAME, TableReportScriptlet.class);
mainDataset.addFirstGroup(summaryGroup);
}