KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > crosstabs > fill > JRFillCrosstabMeasure


1 /*
2  * ============================================================================
3  * GNU Lesser General Public License
4  * ============================================================================
5  *
6  * JasperReports - Free Java report-generating library.
7  * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * JasperSoft Corporation
24  * 303 Second Street, Suite 450 North
25  * San Francisco, CA 94107
26  * http://www.jaspersoft.com
27  */

28 package net.sf.jasperreports.crosstabs.fill;
29
30 import net.sf.jasperreports.crosstabs.JRCrosstabMeasure;
31 import net.sf.jasperreports.engine.JRExpression;
32 import net.sf.jasperreports.engine.JRVariable;
33 import net.sf.jasperreports.engine.fill.JRDefaultIncrementerFactory;
34 import net.sf.jasperreports.engine.fill.JRExtendedIncrementerFactory;
35 import net.sf.jasperreports.engine.fill.JRFillObjectFactory;
36 import net.sf.jasperreports.engine.fill.JRFillVariable;
37 import net.sf.jasperreports.engine.fill.JRIncrementerFactoryCache;
38
39 /**
40  *
41  * @author Lucian Chirita (lucianc@users.sourceforge.net)
42  * @version $Id: JRFillCrosstabMeasure.java 1229 2006-04-19 13:27:35 +0300 (Wed, 19 Apr 2006) teodord $
43  */

44 public class JRFillCrosstabMeasure implements JRCrosstabMeasure
45 {
46     protected JRCrosstabMeasure parentMeasure;
47     protected JRFillVariable variable;
48     protected JRExtendedIncrementerFactory incrementerFactory;
49     protected JRPercentageCalculator percentageCalculator;
50
51     public JRFillCrosstabMeasure(JRCrosstabMeasure measure, JRFillObjectFactory factory)
52     {
53         factory.put(measure, this);
54         
55         parentMeasure = measure;
56         
57         variable = factory.getVariable(measure.getVariable());
58         
59         incrementerFactory = createIncrementerFactory();
60         percentageCalculator = createPercentageCalculator();
61     }
62
63     public String JavaDoc getName()
64     {
65         return parentMeasure.getName();
66     }
67
68     public String JavaDoc getValueClassName()
69     {
70         return parentMeasure.getValueClassName();
71     }
72
73     public Class JavaDoc getValueClass()
74     {
75         return parentMeasure.getValueClass();
76     }
77
78     public JRExpression getValueExpression()
79     {
80         return parentMeasure.getValueExpression();
81     }
82
83     public byte getCalculation()
84     {
85         return parentMeasure.getCalculation();
86     }
87
88     public String JavaDoc getIncrementerFactoryClassName()
89     {
90         return parentMeasure.getIncrementerFactoryClassName();
91     }
92
93     public Class JavaDoc getIncrementerFactoryClass()
94     {
95         return parentMeasure.getIncrementerFactoryClass();
96     }
97
98     public byte getPercentageOfType()
99     {
100         return parentMeasure.getPercentageOfType();
101     }
102
103     public JRVariable getVariable()
104     {
105         return variable;
106     }
107
108     public JRFillVariable getFillVariable()
109     {
110         return variable;
111     }
112     
113     
114     public JRExtendedIncrementerFactory getIncrementerFactory()
115     {
116         return incrementerFactory;
117     }
118     
119     
120     public JRPercentageCalculator getPercentageCalculator()
121     {
122         return percentageCalculator;
123     }
124
125     
126     private JRExtendedIncrementerFactory createIncrementerFactory()
127     {
128         JRExtendedIncrementerFactory incrFactory;
129
130         String JavaDoc incrementerFactoryClassName = getIncrementerFactoryClassName();
131         if (incrementerFactoryClassName == null)
132         {
133             incrFactory = JRDefaultIncrementerFactory.getFactory(getValueClass());
134         }
135         else
136         {
137             incrFactory = (JRExtendedIncrementerFactory) JRIncrementerFactoryCache.getInstance(getIncrementerFactoryClass());
138         }
139         
140         return incrFactory;
141     }
142
143     public JRPercentageCalculator createPercentageCalculator()
144     {
145         JRPercentageCalculator percentageCalc;
146         
147         if (getPercentageOfType() == JRCrosstabMeasure.PERCENTAGE_TYPE_GRAND_TOTAL)
148         {
149             percentageCalc = JRPercentageCalculatorFactory.getPercentageCalculator(getPercentageCalculatorClass(), getValueClass());
150         }
151         else
152         {
153             percentageCalc = null;
154         }
155         
156         return percentageCalc;
157     }
158
159     public String JavaDoc getPercentageCalculatorClassName()
160     {
161         return parentMeasure.getPercentageCalculatorClassName();
162     }
163
164     public Class JavaDoc getPercentageCalculatorClass()
165     {
166         return parentMeasure.getPercentageCalculatorClass();
167     }
168 }
169
Popular Tags