{
}
private MasterReport buildSampleReport()
{
MasterReport jfreeReport = new MasterReport();
jfreeReport.setName("Sample Group Report");
final int width = (int) jfreeReport.getPageDefinition().getWidth();
final String[] columns = {"column0", "column1", "column2", "column3", "type"};
final String numberFormat = "$#,##0.00";
jfreeReport.getPageHeader().addElement(messageField("Sample Group Report",//
true, 14, ElementAlignment.CENTER, new Rectangle(0, 0, width, 16)));
RelationalGroup group = new RelationalGroup();
group.setName("group");
group.addField("type");
// group.getHeader().setRepeat(true);
group.getHeader().addElement(label("Column 0", true, ElementAlignment.CENTER, new Rectangle(0, 0, 120, 14)));
group.getHeader().addElement(label("Column 1", true, ElementAlignment.CENTER, new Rectangle(130, 0, 120, 14)));
group.getHeader().addElement(label("Column 2", true, ElementAlignment.CENTER, new Rectangle(260, 0, 120, 14)));
group.getHeader().addElement(label("Column 3", true, ElementAlignment.CENTER, new Rectangle(390, 0, 70, 14)));
group.getHeader().addElement(HorizontalLineElementFactory.createHorizontalLine(16));
group.getHeader().setRepeat(false);
group.getHeader().setPagebreakBeforePrint(true);
group.getFooter().setPagebreakAfterPrint(true);
jfreeReport.addGroup(group);
// report data item elements
jfreeReport.getReportFooter().setPagebreakBeforePrint(true);
jfreeReport.getItemBand().addElement(textField(columns[0], false, new Rectangle(0, 0, 120, 14)));
jfreeReport.getItemBand().addElement(textField(columns[1], false, new Rectangle(130, 0, 120, 14)));
jfreeReport.getItemBand().addElement(textField(columns[2], false, new Rectangle(260, 0, 120, 14)));
jfreeReport.getItemBand().addElement(numberField(columns[3], false, numberFormat, new Rectangle(390, 0, 70, 14)));
// layout is built, so now fill in the report content to be display
final int length = 60;
final int breakpos = 20;
Object[][] data = new Object[length][5];
int type = 0;
for (int i = 0; i < length; i++)
{
if (i % breakpos == 0)
{
type++;
}
data[i][0] = "ROW-" + i + "-0";
data[i][1] = "ROW-" + i + "-1";
data[i][2] = "ROW-" + i + "-2";
data[i][3] = IntegerCache.getInteger(i);
data[i][4] = IntegerCache.getInteger(type);
}
jfreeReport.setDataFactory(new TableDataFactory("default", new DefaultTableModel(data, columns)));
return jfreeReport;
}