private void build() {
    FontBuilder boldFont = stl.fontArialBold().setFontSize(12);

    TextColumnBuilder<String> yearColumn = col.column("Year", "year", type.stringType());
    TextColumnBuilder<String> quarterColumn = col.column("Quarter", "quarter", type.stringType());
    TextColumnBuilder<Integer> stock1Column = col.column("Stock 1", "stock1", type.integerType());
    TextColumnBuilder<Integer> stock2Column = col.column("Stock 2", "stock2", type.integerType());
    TextColumnBuilder<Integer> stock3Column = col.column("Stock 3", "stock3", type.integerType());

    try {
      report()
          .setTemplate(Templates.reportTemplate)
          .columns(yearColumn, quarterColumn, stock1Column, stock2Column, stock3Column)
          .title(Templates.createTitleComponent("GroupedStackedBarChart"))
          .summary(
              cht.groupedStackedBarChart()
                  .setTitle("Grouped stacked bar chart")
                  .setTitleFont(boldFont)
                  .setCategory(yearColumn)
                  .series(
                      cht.groupedSerie(stock1Column).setGroup(quarterColumn),
                      cht.groupedSerie(stock2Column).setGroup(quarterColumn),
                      cht.groupedSerie(stock3Column).setGroup(quarterColumn)))
          .pageFooter(Templates.footerComponent)
          .setDataSource(createDataSource())
          .show();
    } catch (DRException e) {
      e.printStackTrace();
    }
  }
  private void build() {
    FontBuilder boldFont = stl.fontArialBold().setFontSize(12);

    TextColumnBuilder<Integer> xColumn = col.column("X", "x", type.integerType());
    TextColumnBuilder<Integer> yColumn = col.column("Y", "y", type.integerType());
    TextColumnBuilder<Integer> zColumn = col.column("Z", "z", type.integerType());

    try {
      report()
          .setTemplate(Templates.reportTemplate)
          .columns(xColumn, yColumn, zColumn)
          .title(Templates.createTitleComponent("XYBlockChart"))
          .summary(
              cht.xyBlockChart(0, 5, Color.WHITE)
                  .setTitle("XY block chart")
                  .setTitleFont(boldFont)
                  .setBlockAnchor(RectangleAnchor.BOTTOM_LEFT)
                  .paintScales(
                      cht.paintScale("Value 1", 1, Color.RED),
                      cht.paintScale("Value 2", 2, Color.GREEN),
                      cht.paintScale("Value 3", 3, Color.BLUE))
                  .setXValue(xColumn)
                  .series(cht.xyzSerie().setYValue(yColumn).setZValue(zColumn))
                  .setXAxisFormat(cht.axisFormat().setLabel("X"))
                  .setYAxisFormat(cht.axisFormat().setLabel("Y")))
          .pageFooter(Templates.footerComponent)
          .setDataSource(createDataSource())
          .show();
    } catch (DRException e) {
      e.printStackTrace();
    }
  }
  private void build() {
    TextColumnBuilder<String> itemColumn = col.column("Item", "item", type.stringType());
    TextColumnBuilder<Integer> stock1Column = col.column("Stock 1", "stock1", type.integerType());
    TextColumnBuilder<Integer> stock2Column = col.column("Stock 2", "stock2", type.integerType());
    TextColumnBuilder<Integer> stock3Column = col.column("Stock 3", "stock3", type.integerType());

    BarChartBuilder barChart =
        cht.barChart()
            .setShowPercentages(true)
            .setShowValues(true)
            .setPercentValuePattern("#,##0")
            .setCategory(itemColumn)
            .series(cht.serie(stock1Column), cht.serie(stock2Column), cht.serie(stock3Column));
    StackedBarChartBuilder stackedBarChart =
        cht.stackedBarChart()
            .setShowPercentages(true)
            .setShowValues(true)
            .setCategory(itemColumn)
            .series(cht.serie(stock1Column), cht.serie(stock2Column), cht.serie(stock3Column));
    LineChartBuilder lineChart =
        cht.lineChart()
            .setShowPercentages(true)
            .setShowValues(true)
            .setCategory(itemColumn)
            .series(cht.serie(stock1Column), cht.serie(stock2Column), cht.serie(stock3Column));
    AreaChartBuilder areaChart =
        cht.areaChart()
            .setShowPercentages(true)
            .setShowValues(true)
            .setCategory(itemColumn)
            .series(cht.serie(stock1Column), cht.serie(stock2Column), cht.serie(stock3Column));
    StackedBar3DChartBuilder stackedBar3DChart =
        cht.stackedBar3DChart()
            .setShowPercentages(true)
            .setShowValues(true)
            .setCategory(itemColumn)
            .series(cht.serie(stock1Column), cht.serie(stock2Column), cht.serie(stock3Column));
    PieChartBuilder pieChart =
        cht.pieChart()
            .setShowPercentages(true)
            .setShowValues(true)
            .setKey(itemColumn)
            .series(cht.serie(stock1Column));

    try {
      report()
          .setTemplate(Templates.reportTemplate)
          .columns(itemColumn, stock1Column, stock2Column, stock3Column)
          .title(Templates.createTitleComponent("ChartShowPercentages"))
          .summary(
              cmp.horizontalList(barChart, stackedBarChart),
              cmp.horizontalList(lineChart, areaChart),
              cmp.horizontalList(stackedBar3DChart, pieChart))
          .pageFooter(Templates.footerComponent)
          .setDataSource(createDataSource())
          .show();
    } catch (DRException e) {
      e.printStackTrace();
    }
  }
  @SuppressWarnings({"rawtypes", "unchecked"})
  public JasperReportBuilder build() throws DRException {
    JasperReportBuilder report = report();

    report
        .setTemplate(Templates.reportTemplate)
        .title(Templates.createTitleComponent("DynamicReport"));

    DynamicReport dynamicReport = data.getDynamicReport();
    List<DynamicColumn> columns = dynamicReport.getColumns();
    Map<String, TextColumnBuilder> drColumns = new HashMap<String, TextColumnBuilder>();

    for (DynamicColumn column : columns) {
      TextColumnBuilder drColumn =
          col.column(
              column.getTitle(), column.getName(), (DRIDataType) type.detectType(column.getType()));
      if (column.getPattern() != null) {
        drColumn.setPattern(column.getPattern());
      }
      if (column.getHorizontalAlignment() != null) {
        drColumn.setHorizontalAlignment(column.getHorizontalAlignment());
      }
      drColumns.put(column.getName(), drColumn);
      report.columns(drColumn);
    }

    for (String group : dynamicReport.getGroups()) {
      ColumnGroupBuilder group2 = grp.group(drColumns.get(group));
      report.groupBy(group2);

      for (String subtotal : dynamicReport.getSubtotals()) {
        report.subtotalsAtGroupFooter(group2, sbt.sum(drColumns.get(subtotal)));
      }
    }

    for (String subtotal : dynamicReport.getSubtotals()) {
      report.subtotalsAtSummary(sbt.sum(drColumns.get(subtotal)));
    }

    if (dynamicReport.getTitle() != null) {
      TextFieldBuilder<String> title =
          cmp.text(dynamicReport.getTitle())
              .setStyle(Templates.bold12CenteredStyle)
              .setHorizontalAlignment(HorizontalAlignment.CENTER);
      report.addTitle(title);
    }
    if (dynamicReport.isShowPageNumber()) {
      PageXofYBuilder pageXofY = cmp.pageXofY().setStyle(Templates.boldCenteredStyle);
      report.addPageFooter(pageXofY);
    }
    report.setDataSource(data.createDataSource());

    return report;
  }
 private void build() {
   try {
     report()
         .setTemplate(Templates.reportTemplate)
         .columns(
             col.column("Item", "item", type.stringType()),
             col.column("Quantity", "quantity", type.integerType()),
             col.column("Comments", "comments", type.listType()))
         .title(Templates.createTitleComponent("ColumnListDataType"))
         .pageFooter(Templates.footerComponent)
         .setDataSource(createDataSource())
         .show();
   } catch (DRException e) {
     e.printStackTrace();
   }
 }
  private void build() {
    ComponentBuilder<?, ?> cardComponent = createCardComponent();
    HorizontalListBuilder cards = cmp.horizontalFlowList();
    for (int i = 0; i < 10; i++) {
      cards.add(cardComponent);
    }

    try {
      report()
          .setTemplate(Templates.reportTemplate)
          .setTextStyle(stl.style())
          .setPageFormat(PageType.A5)
          .title(Templates.createTitleComponent("Card"), cards)
          .show();
    } catch (DRException e) {
      e.printStackTrace();
    }
  }
  private void build() {
    try {
      JasperHtmlExporterBuilder htmlExporter =
          export
              .htmlExporter("c:/report.html")
              .setImagesDirName("c:/images")
              .setOutputImagesToDir(true);

      report()
          .setTemplate(Templates.reportTemplate)
          .columns(
              col.column("Item", "item", type.stringType()),
              col.column("Quantity", "quantity", type.integerType()),
              col.column("Unit price", "unitprice", type.bigDecimalType()))
          .title(Templates.createTitleComponent("HtmlReport"))
          .pageFooter(Templates.footerComponent)
          .setDataSource(createDataSource())
          .toHtml(htmlExporter);
    } catch (DRException e) {
      e.printStackTrace();
    }
  }
  private void build() {
    FieldBuilder<Date> dateField = field("date", type.dateType());
    FieldBuilder<Integer> stock1Field = field("stock1", type.integerType());
    FieldBuilder<Integer> stock2Field = field("stock2", type.integerType());

    CategoryChartSerieBuilder stock1Serie = cht.serie(stock1Field).setLabel("Stock1");
    CategoryChartSerieBuilder stock2Serie = cht.serie(stock2Field).setLabel("Stock2");

    LineChartBuilder chart1 =
        cht.lineChart()
            .setCategory(new CategoryExpression())
            .series(stock1Serie)
            .setValueAxisFormat(cht.axisFormat().setLabel("Stock1"));

    BarChartBuilder chart2 =
        cht.barChart()
            .setCategory(new CategoryExpression())
            .series(stock2Serie)
            .setValueAxisFormat(cht.axisFormat().setLabel("Stock2"));

    try {
      report()
          .setTemplate(Templates.reportTemplate)
          .fields(dateField)
          .title(
              Templates.createTitleComponent("MultiAxisChart"),
              cht.multiAxisChart(chart1, chart2),
              cht.multiAxisChart()
                  .addChart(chart1, AxisPosition.LEFT_OR_TOP)
                  .addChart(chart2, AxisPosition.RIGHT_OR_BOTTOM))
          .pageFooter(Templates.footerComponent)
          .setDataSource(createDataSource())
          .show();
    } catch (DRException e) {
      e.printStackTrace();
    }
  }
  private void build() {

    try {
      report()
          .setTemplate(Templates.reportTemplate)
          .ignorePageWidth()
          .columns(
              col.column("ID", "id", type.integerType()),
              col.column("Item", "item", type.stringType()),
              col.column("Quantity", "quantity", type.integerType()),
              col.column("Unit price", "unitprice", type.bigDecimalType()),
              col.column("Order date", "orderdate", type.dateType()),
              col.column("Order date", "orderdate", type.dateYearToFractionType()),
              col.column("Order year", "orderdate", type.dateYearType()),
              col.column("Order month", "orderdate", type.dateMonthType()),
              col.column("Order day", "orderdate", type.dateDayType()))
          .title(Templates.createTitleComponent("DynamicPageWidth"))
          .pageFooter(Templates.footerComponent)
          .setDataSource(createDataSource())
          .show();
    } catch (DRException e) {
      e.printStackTrace();
    }
  }