コード例 #1
0
  private static ComponentBuilder<?, ?> createTitle(String lastName, String firstName) {
    final VerticalListBuilder list = cmp.verticalList();
    list.add(
        cmp.text("Statement of Giving")
            .setStyle(stl.style().bold())
            .setHorizontalAlignment(HorizontalAlignment.CENTER));
    list.add(
        cmp.horizontalList()
            .setStyle(stl.style(10).setHorizontalAlignment(HorizontalAlignment.LEFT))
            .setGap(50)
            .add(cmp.hListCell(createNameComponent(lastName, firstName)).heightFixedOnTop())
            .add(cmp.hListCell(createChurchAddressComponent()).heightFixedOnTop()),
        cmp.verticalGap(10));

    return list;
  }
コード例 #2
0
  public static JasperReportBuilder createGivingStatement(String lastName, String firstName) {
    final StyleBuilder boldStyle = stl.style().bold();
    final StyleBuilder boldStyleSmall = stl.style().bold().setFontSize(8);
    final StyleBuilder boldCenteredStyle =
        stl.style(boldStyle).setHorizontalAlignment(HorizontalAlignment.CENTER);
    final StyleBuilder columnTitleStyle =
        stl.style(boldCenteredStyle)
            .setBorder(stl.pen1Point())
            .setBackgroundColor(Color.LIGHT_GRAY);

    final TextColumnBuilder<String> dateColumn = col.column("Date", "date", type.stringType());
    final TextColumnBuilder<String> fundTypeColumn =
        col.column("Fund Type", "fundType", type.stringType());
    final TextColumnBuilder<Short> checkNumberColumn =
        col.column("Check #", "checkNumber", type.shortType());

    final List<TextColumnBuilder<?>> columnList = new ArrayList<TextColumnBuilder<?>>();
    columnList.add(dateColumn);
    columnList.add(fundTypeColumn);
    columnList.add(checkNumberColumn);

    final List<AggregationSubtotalBuilder<BigDecimal>> subtotalBuilders =
        new ArrayList<AggregationSubtotalBuilder<BigDecimal>>();
    final List<String> categories = Settings.getInstance().getCategories();
    for (String category : categories) {
      final TextColumnBuilder<BigDecimal> categoryColumn =
          col.column(category, category, type.bigDecimalType());
      columnList.add(categoryColumn);
      subtotalBuilders.add(sbt.sum(categoryColumn));
    }
    final TextColumnBuilder<BigDecimal> totalsColumn =
        col.column("Total", "total", type.bigDecimalType());
    columnList.add(totalsColumn);
    subtotalBuilders.add(sbt.sum(totalsColumn));

    final AggregationSubtotalBuilder<?>[] sbtBuilders =
        new AggregationSubtotalBuilder<?>[subtotalBuilders.size()];
    subtotalBuilders.toArray(sbtBuilders);

    final TextColumnBuilder<?>[] columns = new TextColumnBuilder<?>[columnList.size()];
    columnList.toArray(columns);

    final VerticalListBuilder summary = cmp.verticalList();
    summary.add(cmp.verticalGap(5));
    summary.add(
        cmp.text(
                "Donor did not receive any goods or services in connection with the donations listed.")
            .setStyle(boldStyleSmall));
    summary.add(cmp.verticalGap(15));
    summary.add(cmp.text("Authorized Signature: ").setStyle(boldStyle));
    summary.add(cmp.verticalGap(10));
    summary.add(
        cmp.text("                                            ").setStyle(stl.style().underline()));

    return report() // create new report design
        .setTemplate(Templates.reportTemplate)
        .setColumnTitleStyle(columnTitleStyle)
        .highlightDetailEvenRows()
        .columns(columns)
        .title(createTitle(lastName, firstName))
        .pageFooter(cmp.pageXofY().setStyle(boldCenteredStyle))
        .setDataSource(createDataSource(lastName, firstName))
        .subtotalsAtSummary(sbtBuilders)
        .setPageMargin(DynamicReports.margin(40))
        .summary(summary);
  }