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 package ar.com.fdvs.dj.test;
29
30 import ar.com.fdvs.dj.core.DynamicJasperHelper;
31 import ar.com.fdvs.dj.domain.AutoText;
32 import ar.com.fdvs.dj.domain.DynamicReport;
33 import ar.com.fdvs.dj.domain.Style;
34 import ar.com.fdvs.dj.domain.builders.FastReportBuilder;
35 import ar.com.fdvs.dj.domain.builders.StyleBuilder;
36 import ar.com.fdvs.dj.domain.constants.Font;
37 import net.sf.jasperreports.view.JasperDesignViewer;
38 import net.sf.jasperreports.view.JasperViewer;
39
40 import java.awt.*;
41 import java.util.Date;
42 import java.util.HashMap;
43 import java.util.Locale;
44
45 public class BuiltinFontsReportTest extends BaseDjReportTest {
46
47 public DynamicReport buildReport() throws Exception {
48
49 FastReportBuilder drb = new FastReportBuilder();
50 drb.addColumn("State", "state", String.class.getName(),30)
51 .addColumn("Branch", "branch", String.class.getName(),30)
52 .addColumn("Product Line", "productLine", String.class.getName(),50)
53 .addColumn("Item", "item", String.class.getName(),50)
54 .addColumn("Item Code", "id", Long.class.getName(),30,true)
55 .addColumn("Quantity", "quantity", Long.class.getName(),60,true)
56 .addColumn("Amount", "amount", Float.class.getName(),70,true)
57 .addGroups(2)
58 .setTitle("November " + getYear() +" sales report")
59 .setSubtitle("This report was generated at " + new Date())
60 .setUseFullPageWidth(true);
61
62
63 Style style1 = new StyleBuilder(true).setFont(Font.ARIAL_MEDIUM).build();
64 Style style2 = new StyleBuilder(true).setFont(Font.COMIC_SANS_MEDIUM).build();
65 Style style3 = new StyleBuilder(true).setFont(Font.COURIER_NEW_MEDIUM).build();
66 Style style4 = new StyleBuilder(true).setFont(Font.GEORGIA_MEDIUM).build();
67 Style style5 = new StyleBuilder(true).setFont(Font.MONOSPACED_MEDIUM).build();
68 Style style6 = new StyleBuilder(true).setFont(Font.TIMES_NEW_ROMAN_MEDIUM).build();
69 Style style7 = new StyleBuilder(true).setFont(Font.VERDANA_MEDIUM).build();
70
71
72 drb.addAutoText("Testing the font Arial", AutoText.POSITION_HEADER, AutoText.ALIGNMENT_LEFT,300, style1);
73 drb.addAutoText("Testing the font Comic Sans MS", AutoText.POSITION_HEADER, AutoText.ALIGNMENT_LEFT,300, style2);
74 drb.addAutoText("Testing the font Courrier New", AutoText.POSITION_HEADER, AutoText.ALIGNMENT_LEFT,300, style3);
75 drb.addAutoText("Testing the font Georgia", AutoText.POSITION_HEADER, AutoText.ALIGNMENT_LEFT,300, style4);
76 drb.addAutoText("Testing the font Monospaced", AutoText.POSITION_HEADER, AutoText.ALIGNMENT_LEFT,300, style5);
77 drb.addAutoText("Testing the font Times New Roman", AutoText.POSITION_HEADER, AutoText.ALIGNMENT_LEFT,300, style6);
78 drb.addAutoText("Testing the font Verdana", AutoText.POSITION_HEADER, AutoText.ALIGNMENT_LEFT,300, style7);
79
80
81 DynamicReport dr = drb.build();
82
83
84 return dr;
85 }
86
87 public static void main(String[] args) throws Exception {
88 BuiltinFontsReportTest test = new BuiltinFontsReportTest();
89 test.testReport();
90 JasperViewer.viewReport(test.jp);
91 JasperDesignViewer.viewReportDesign(DynamicJasperHelper.generateJasperReport(test.dr, test.getLayoutManager(),new HashMap()));
92 }
93
94 }