KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > ReportElementFactory


1 /*
2  * Copyright (C) 2005 - 2006 JasperSoft Corporation. All rights reserved.
3  * http://www.jaspersoft.com.
4  *
5  * Unless you have purchased a commercial license agreement from JasperSoft,
6  * the following license terms apply:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as published by
10  * the Free Software Foundation.
11  *
12  * This program is distributed WITHOUT ANY WARRANTY; and without the
13  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
18  * or write to:
19  *
20  * Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330,
22  * Boston, MA USA 02111-1307
23  *
24  *
25  *
26  *
27  * ReportElementFactory.java
28  *
29  * Created on 22 July 2004, 22:55
30  *
31  */

32
33 package it.businesslogic.ireport;
34
35 import it.businesslogic.ireport.crosstab.CrosstabCell;
36
37
38
39 /**
40  *
41  * @author Robert Lamping
42  */

43 public class ReportElementFactory {
44     
45     /** Creates a new instance of ElementFactory */
46     public ReportElementFactory () {
47     }
48     
49     public static ReportElement create ( int newObjectType, int originX, int originY, int width, int height) {
50         // width and height can be positive and negative.
51
// most elements will abs the widht and height.
52
// Lines won't, because they need the direction.
53
// Many ReportElement classes must all be adapted to Math.abs all incoming width and height
54

55         ReportElement re = null;
56         
57         switch (newObjectType) {
58             case ReportElementType.RECTANGLE_ELEMENT :
59                 re = new RectangleReportElement ( originX,originY,width,height);
60                 break;
61             case ReportElementType.ROUND_RECTANGLE_ELEMENT:
62                 re = new RoundRectangleReportElement ( originX,originY,width,height);
63                 break;
64             case ReportElementType.ELLIPSE_ELEMENT:
65                 re = new EllipseReportElement ( originX,originY,width,height);
66                 break;
67             case ReportElementType.SUBREPORT_ELEMENT:
68                 re = new SubReportElement ( originX,originY,width,height);
69                 break;
70             case ReportElementType.IMAGE_ELEMENT:
71                 re = new ImageReportElement ( originX,originY,width,height);
72                 break;
73             case ReportElementType.CHART_ELEMENT:
74                 re = new ChartReportElement2 ( originX,originY,width,height);
75                 break;
76             case ReportElementType.STATICTEXT_ELEMENT:
77                 re = new StaticTextReportElement ( originX,originY,width,height);
78                 break;
79             case ReportElementType.LINE_ELEMENT:
80                 re = new LineReportElement ( originX,originY, width, height);
81                 break;
82             case ReportElementType.TEXTFIELD_ELEMENT:
83                 re = new TextFieldReportElement ( originX,originY,width,height);
84                 break;
85             case ReportElementType.BARCODE_ELEMENT:
86                 re = new BarcodeReportElement (originX, originY, width, height);
87                 break;
88             case ReportElementType.FRAME_ELEMENT:
89                 re = new FrameReportElement (originX, originY, width, height);
90                 break;
91             case ReportElementType.CROSSTAB_ELEMENT:
92                 re = new CrosstabReportElement (originX, originY, width, height);
93                 CrosstabCell cell = new CrosstabCell();
94                 cell.setWidth(30);
95                 cell.setHeight(25);
96                 cell.setParent((CrosstabReportElement)re);
97                 cell.setType( cell.DETAIL_CELL);
98                 ((CrosstabReportElement)re).getCells().add(cell);
99                 break;
100             case ReportElementType.BREAK_ELEMENT:
101                 re = new BreakReportElement (originX, originY, width, height);
102                 break;
103             default:
104                 re = new ReportElement ( originX,originY,width,height);
105         }
106         return re;
107     }
108     
109 }
110
111
112
113
114
Popular Tags