001: /*
002: * ============================================================================
003: * GNU Lesser General Public License
004: * ============================================================================
005: *
006: * JasperReports - Free Java report-generating library.
007: * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
022: *
023: * JasperSoft Corporation
024: * 303 Second Street, Suite 450 North
025: * San Francisco, CA 94107
026: * http://www.jaspersoft.com
027: */
028: package net.sf.jasperreports.crosstabs.fill;
029:
030: import net.sf.jasperreports.crosstabs.JRCrosstabMeasure;
031: import net.sf.jasperreports.engine.JRExpression;
032: import net.sf.jasperreports.engine.JRVariable;
033: import net.sf.jasperreports.engine.fill.JRDefaultIncrementerFactory;
034: import net.sf.jasperreports.engine.fill.JRExtendedIncrementerFactory;
035: import net.sf.jasperreports.engine.fill.JRFillObjectFactory;
036: import net.sf.jasperreports.engine.fill.JRFillVariable;
037: import net.sf.jasperreports.engine.fill.JRIncrementerFactoryCache;
038:
039: /**
040: *
041: * @author Lucian Chirita (lucianc@users.sourceforge.net)
042: * @version $Id: JRFillCrosstabMeasure.java 1229 2006-04-19 10:27:35Z teodord $
043: */
044: public class JRFillCrosstabMeasure implements JRCrosstabMeasure {
045: protected JRCrosstabMeasure parentMeasure;
046: protected JRFillVariable variable;
047: protected JRExtendedIncrementerFactory incrementerFactory;
048: protected JRPercentageCalculator percentageCalculator;
049:
050: public JRFillCrosstabMeasure(JRCrosstabMeasure measure,
051: JRFillObjectFactory factory) {
052: factory.put(measure, this );
053:
054: parentMeasure = measure;
055:
056: variable = factory.getVariable(measure.getVariable());
057:
058: incrementerFactory = createIncrementerFactory();
059: percentageCalculator = createPercentageCalculator();
060: }
061:
062: public String getName() {
063: return parentMeasure.getName();
064: }
065:
066: public String getValueClassName() {
067: return parentMeasure.getValueClassName();
068: }
069:
070: public Class getValueClass() {
071: return parentMeasure.getValueClass();
072: }
073:
074: public JRExpression getValueExpression() {
075: return parentMeasure.getValueExpression();
076: }
077:
078: public byte getCalculation() {
079: return parentMeasure.getCalculation();
080: }
081:
082: public String getIncrementerFactoryClassName() {
083: return parentMeasure.getIncrementerFactoryClassName();
084: }
085:
086: public Class getIncrementerFactoryClass() {
087: return parentMeasure.getIncrementerFactoryClass();
088: }
089:
090: public byte getPercentageOfType() {
091: return parentMeasure.getPercentageOfType();
092: }
093:
094: public JRVariable getVariable() {
095: return variable;
096: }
097:
098: public JRFillVariable getFillVariable() {
099: return variable;
100: }
101:
102: public JRExtendedIncrementerFactory getIncrementerFactory() {
103: return incrementerFactory;
104: }
105:
106: public JRPercentageCalculator getPercentageCalculator() {
107: return percentageCalculator;
108: }
109:
110: private JRExtendedIncrementerFactory createIncrementerFactory() {
111: JRExtendedIncrementerFactory incrFactory;
112:
113: String incrementerFactoryClassName = getIncrementerFactoryClassName();
114: if (incrementerFactoryClassName == null) {
115: incrFactory = JRDefaultIncrementerFactory
116: .getFactory(getValueClass());
117: } else {
118: incrFactory = (JRExtendedIncrementerFactory) JRIncrementerFactoryCache
119: .getInstance(getIncrementerFactoryClass());
120: }
121:
122: return incrFactory;
123: }
124:
125: public JRPercentageCalculator createPercentageCalculator() {
126: JRPercentageCalculator percentageCalc;
127:
128: if (getPercentageOfType() == JRCrosstabMeasure.PERCENTAGE_TYPE_GRAND_TOTAL) {
129: percentageCalc = JRPercentageCalculatorFactory
130: .getPercentageCalculator(
131: getPercentageCalculatorClass(),
132: getValueClass());
133: } else {
134: percentageCalc = null;
135: }
136:
137: return percentageCalc;
138: }
139:
140: public String getPercentageCalculatorClassName() {
141: return parentMeasure.getPercentageCalculatorClassName();
142: }
143:
144: public Class getPercentageCalculatorClass() {
145: return parentMeasure.getPercentageCalculatorClass();
146: }
147: }
|