1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package ar.com.fdvs.dj.test;
31
32
33 import java.util.Date;
34
35 import net.sf.jasperreports.view.JasperDesignViewer;
36 import net.sf.jasperreports.view.JasperViewer;
37 import ar.com.fdvs.dj.domain.DynamicReport;
38 import ar.com.fdvs.dj.domain.Style;
39 import ar.com.fdvs.dj.domain.builders.FastReportBuilder;
40 import ar.com.fdvs.dj.domain.constants.Stretching;
41 import ar.com.fdvs.dj.domain.constants.VerticalAlign;
42
43 /***
44 * This test intends to show how to create multi line title and sub title
45 * @author mamana
46 *
47 */
48 public class MultiLineTitleReportTest extends BaseDjReportTest {
49
50 public DynamicReport buildReport() throws Exception {
51
52
53 /***
54 * Creates the DynamicReportBuilder and sets the basic options for
55 * the report
56 */
57 FastReportBuilder drb = new FastReportBuilder();
58 Style subtitleStyle = new Style("subtitle_style");
59 subtitleStyle.setStretchWithOverflow(true);
60 subtitleStyle.setStreching(Stretching.NO_STRETCH);
61 subtitleStyle.setVerticalAlign(VerticalAlign.TOP);
62
63 drb.addColumn("State", "state", String.class.getName(),30)
64 .addColumn("Branch", "branch", String.class.getName(),30)
65 .addColumn("Product Line", "productLine", String.class.getName(),50)
66 .addColumn("Item", "item", String.class.getName(),50)
67 .addColumn("Item Code", "id", Long.class.getName(),30,true)
68 .addColumn("Quantity", "quantity", Long.class.getName(),60,true)
69 .addColumn("Amount", "amount", Float.class.getName(),70,true)
70 .addGroups(2)
71 .setTitle("November 2006 //nsales report")
72 .setSubtitle("This report was generated at" + new Date() + "//n*** This information is confidential ***")
73 .setSubtitleHeight(new Integer(20))
74 .setSubtitleStyle(subtitleStyle)
75 .setUseFullPageWidth(true);
76
77 DynamicReport dr = drb.build();
78
79 return dr;
80 }
81
82 public static void main(String[] args) throws Exception {
83 MultiLineTitleReportTest test = new MultiLineTitleReportTest();
84 test.testReport();
85 test.exportToJRXML();
86 JasperViewer.viewReport(test.jp);
87 JasperDesignViewer.viewReportDesign(test.jr);
88 }
89
90 }