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.awt.Color;
34 import java.util.Date;
35
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.builders.StyleBuilder;
41 import ar.com.fdvs.dj.domain.constants.Border;
42 import ar.com.fdvs.dj.domain.constants.HorizontalAlign;
43 import ar.com.fdvs.dj.domain.constants.ImageScaleMode;
44 import ar.com.fdvs.dj.domain.constants.Stretching;
45
46 public class ImageColumnReportTest extends BaseDjReportTest {
47
48 public DynamicReport buildReport() throws Exception {
49
50
51 Style style = new StyleBuilder(false).setHorizontalAlign(HorizontalAlign.CENTER)
52 .setStretching(Stretching.RELATIVE_TO_TALLEST_OBJECT)
53 .setBorderColor(Color.BLACK).setBorder(Border.THIN()).build();
54
55
56
57
58 FastReportBuilder drb = new FastReportBuilder();
59 drb.addColumn("State", "state", String.class.getName(),30)
60 .addColumn("Branch", "branch", String.class.getName(),30)
61 .addColumn("Product Line", "productLine", String.class.getName(),50)
62 .addImageColumn("IMG", "image", 50, true,ImageScaleMode.FILL ,style)
63 .addColumn("Item", "item", String.class.getName(),20)
64 .addColumn("Item Code", "id", Long.class.getName(),30,true)
65 .addColumn("Quantity", "quantity", Long.class.getName(),60,true)
66 .addColumn("Amount", "amount", Float.class.getName(),70,true)
67 .addGroups(2)
68 .setDetailHeight(17)
69 .setTitle("November " + getYear() +" sales report")
70 .setSubtitle("This report was generated at " + new Date())
71 .setUseFullPageWidth(true);
72
73
74 DynamicReport dr = drb.build();
75
76 return dr;
77 }
78
79 public static void main(String[] args) throws Exception {
80 ImageColumnReportTest test = new ImageColumnReportTest();
81 test.testReport();
82 JasperViewer.viewReport(test.jp);
83 }
84
85 }