View Javadoc

1   /*
2    * DynamicJasper: A library for creating reports dynamically by specifying
3    * columns, groups, styles, etc. at runtime. It also saves a lot of development
4    * time in many cases! (http://sourceforge.net/projects/dynamicjasper)
5    *
6    * Copyright (C) 2008  FDV Solutions (http://www.fdvsolutions.com)
7    *
8    * This library is free software; you can redistribute it and/or
9    * modify it under the terms of the GNU Lesser General Public
10   *
11   * License as published by the Free Software Foundation; either
12   *
13   * version 2.1 of the License, or (at your option) any later version.
14   *
15   * This library is distributed in the hope that it will be useful,
16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   *
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19   *
20   * Lesser General Public License for more details.
21   *
22   * You should have received a copy of the GNU Lesser General Public
23   * License along with this library; if not, write to the Free Software
24   *
25   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
26   *
27   *
28   */
29  
30  package ar.com.fdvs.dj.test;
31  
32  
33  import java.util.Date;
34  
35  import net.sf.jasperreports.engine.JasperPrint;
36  import net.sf.jasperreports.engine.JasperReport;
37  import net.sf.jasperreports.view.JasperDesignViewer;
38  import net.sf.jasperreports.view.JasperViewer;
39  import ar.com.fdvs.dj.core.BarcodeTypes;
40  import ar.com.fdvs.dj.domain.DynamicReport;
41  import ar.com.fdvs.dj.domain.Style;
42  import ar.com.fdvs.dj.domain.builders.FastReportBuilder;
43  import ar.com.fdvs.dj.domain.builders.StyleBuilder;
44  import ar.com.fdvs.dj.domain.constants.HorizontalAlign;
45  import ar.com.fdvs.dj.domain.constants.ImageScaleMode;
46  
47  public class BarcodeColumnReportTest extends BaseDjReportTest {
48  
49  	private JasperPrint jp;
50  	private JasperReport jr;
51  
52  	public DynamicReport buildReport() throws Exception {
53  
54  
55  		Style style = new StyleBuilder(true).setHorizontalAlign(HorizontalAlign.CENTER).build();
56  		/***
57  		 * Creates the DynamicReportBuilder and sets the basic options for
58  		 * the report
59  		 */
60  		FastReportBuilder drb = new FastReportBuilder();
61  		drb.addColumn("State", "state", String.class.getName(),20)
62  			.addColumn("Branch", "branch", String.class.getName(),30)
63  			.addColumn("Quantity", "quantity", Long.class.getName(),60,true)
64  			.addColumn("Amount", "amount", Float.class.getName(),70,true)
65  			.addBarcodeColumn("Bar-Code", "amount", Long.class.getName(), BarcodeTypes.USD3, true, false,null, 100, true, ImageScaleMode.FILL, null)
66  			.addGroups(1)
67  			.setDetailHeight(30)
68  			.addField("productLine",  String.class.getName())
69  			.setTitle("November 2006 sales report")
70  			.setSubtitle("This report was generated at " + new Date())
71  			.setUseFullPageWidth(true);
72  
73  		DynamicReport dr = drb.build();
74  
75  		return dr;
76  	}
77  
78  	public static void main(String[] args) throws Exception {
79  		BarcodeColumnReportTest test = new BarcodeColumnReportTest();
80  		test.testReport();
81  		JasperViewer.viewReport(test.jp);	//finally display the report report
82  		JasperDesignViewer.viewReportDesign(test.jr);
83  	}
84  
85  }