*/
protected void layoutGroups() {
log.debug("Starting groups layout...");
for (Iterator iter = getReport().getColumnsGroups().iterator(); iter.hasNext();) {
DJGroup columnsGroup = (DJGroup) iter.next();
JRDesignGroup jgroup = getJRGroupFromDJGroup(columnsGroup);
jgroup.setStartNewPage(columnsGroup.getStartInNewPage().booleanValue());
jgroup.setStartNewColumn(columnsGroup.getStartInNewColumn().booleanValue());
jgroup.setReprintHeaderOnEachPage(columnsGroup.getReprintHeaderOnEachPage().booleanValue());
JRDesignBand header = (JRDesignBand) jgroup.getGroupHeader();
JRDesignBand footer = (JRDesignBand) jgroup.getGroupFooter();
//double check to prevent NPE
if (header == null){
header = new JRDesignBand();
jgroup.setGroupHeader(header);
}
if (footer == null){
footer = new JRDesignBand();
jgroup.setGroupFooter(footer);
}
header.setHeight(columnsGroup.getHeaderHeight().intValue());
// footer.setHeight( getFooterVariableHeight(columnsGroup));
footer.setHeight( columnsGroup.getFooterHeight().intValue());
header.setSplitAllowed(columnsGroup.isAllowHeaderSplit());
footer.setSplitAllowed(columnsGroup.isAllowFooterSplit());
if (columnsGroup.getLayout().isPrintHeaders()) {
boolean found = false;
boolean skipPreviousGroupHeaders = false;
int groupIdx = getReport().getColumnsGroups().indexOf(columnsGroup);
if (groupIdx>0){
DJGroup prevG = (DJGroup) getReport().getColumnsGroups().get(groupIdx-1);
if(!(prevG.getColumnToGroupBy() instanceof GlobalGroupColumn))
skipPreviousGroupHeaders = !prevG.getLayout().isShowValueForEachRow();
}
for (Iterator iterator = getVisibleColumns().iterator(); iterator.hasNext();) {
AbstractColumn col = (AbstractColumn) iterator.next();
//If in a nested group, header for column prior to this groups column
//depends on configuration
if (col.equals(columnsGroup.getColumnToGroupBy())) {
found = true;
}
if (!found && skipPreviousGroupHeaders){
continue;
}
JRDesignTextField designTextField = createColumnNameTextField(columnsGroup, col);
designTextField.setPositionType(JRDesignElement.POSITION_TYPE_FLOAT); //XXX changed to see what happens (must come from the column position property)
designTextField.setStretchType(JRDesignElement.STRETCH_TYPE_NO_STRETCH); //XXX changed to see what happens (must come from the column property)
header.addElement(designTextField);
}
}
DJGroupLabel label = columnsGroup.getFooterLabel();
if (label != null /*&& !footerVariables.isEmpty()*/) {
List footerVariables = columnsGroup.getFooterVariables();
PropertyColumn col = columnsGroup.getColumnToGroupBy();
JRDesignBand band = (JRDesignBand)jgroup.getGroupFooter();
int x = 0, y = 0;
//max width
int width = getDesign().getPageWidth() - getDesign().getLeftMargin() - getDesign().getRightMargin();
int height = label.getHeight();
int yOffset = 0;