001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * ReportElementFactory.java
028: *
029: * Created on 22 July 2004, 22:55
030: *
031: */
032:
033: package it.businesslogic.ireport;
034:
035: import it.businesslogic.ireport.crosstab.CrosstabCell;
036:
037: /**
038: *
039: * @author Robert Lamping
040: */
041: public class ReportElementFactory {
042:
043: /** Creates a new instance of ElementFactory */
044: public ReportElementFactory() {
045: }
046:
047: public static ReportElement create(int newObjectType, int originX,
048: int originY, int width, int height) {
049: // width and height can be positive and negative.
050: // most elements will abs the widht and height.
051: // Lines won't, because they need the direction.
052: // Many ReportElement classes must all be adapted to Math.abs all incoming width and height
053:
054: ReportElement re = null;
055:
056: switch (newObjectType) {
057: case ReportElementType.RECTANGLE_ELEMENT:
058: re = new RectangleReportElement(originX, originY, width,
059: height);
060: break;
061: case ReportElementType.ROUND_RECTANGLE_ELEMENT:
062: re = new RoundRectangleReportElement(originX, originY,
063: width, height);
064: break;
065: case ReportElementType.ELLIPSE_ELEMENT:
066: re = new EllipseReportElement(originX, originY, width,
067: height);
068: break;
069: case ReportElementType.SUBREPORT_ELEMENT:
070: re = new SubReportElement(originX, originY, width, height);
071: break;
072: case ReportElementType.IMAGE_ELEMENT:
073: re = new ImageReportElement(originX, originY, width, height);
074: break;
075: case ReportElementType.CHART_ELEMENT:
076: re = new ChartReportElement2(originX, originY, width,
077: height);
078: break;
079: case ReportElementType.STATICTEXT_ELEMENT:
080: re = new StaticTextReportElement(originX, originY, width,
081: height);
082: break;
083: case ReportElementType.LINE_ELEMENT:
084: re = new LineReportElement(originX, originY, width, height);
085: break;
086: case ReportElementType.TEXTFIELD_ELEMENT:
087: re = new TextFieldReportElement(originX, originY, width,
088: height);
089: break;
090: case ReportElementType.BARCODE_ELEMENT:
091: re = new BarcodeReportElement(originX, originY, width,
092: height);
093: break;
094: case ReportElementType.FRAME_ELEMENT:
095: re = new FrameReportElement(originX, originY, width, height);
096: break;
097: case ReportElementType.CROSSTAB_ELEMENT:
098: re = new CrosstabReportElement(originX, originY, width,
099: height);
100: CrosstabCell cell = new CrosstabCell();
101: cell.setWidth(30);
102: cell.setHeight(25);
103: cell.setParent((CrosstabReportElement) re);
104: cell.setType(cell.DETAIL_CELL);
105: ((CrosstabReportElement) re).getCells().add(cell);
106: break;
107: case ReportElementType.BREAK_ELEMENT:
108: re = new BreakReportElement(originX, originY, width, height);
109: break;
110: default:
111: re = new ReportElement(originX, originY, width, height);
112: }
113: return re;
114: }
115:
116: }
|