KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > crosstabs > design > JRDesignCrosstabMeasure


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.design;
29
30 import java.beans.PropertyChangeListener JavaDoc;
31 import java.beans.PropertyChangeSupport JavaDoc;
32
33 import net.sf.jasperreports.crosstabs.base.JRBaseCrosstabMeasure;
34 import net.sf.jasperreports.engine.JRConstants;
35 import net.sf.jasperreports.engine.JRExpression;
36 import net.sf.jasperreports.engine.JRVariable;
37 import net.sf.jasperreports.engine.design.JRDesignVariable;
38
39 /**
40  * Crosstab measure implementation to be used for report designing.
41  *
42  * @author Lucian Chirita (lucianc@users.sourceforge.net)
43  * @version $Id: JRDesignCrosstabMeasure.java 1244 2006-04-28 11:22:38 +0300 (Fri, 28 Apr 2006) lucianc $
44  */

45 public class JRDesignCrosstabMeasure extends JRBaseCrosstabMeasure
46 {
47     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
48     
49     public static final String JavaDoc PROPERTY_VALUE_CLASS = "valueClassName";
50
51     /** Property change support mechanism. */
52     private transient PropertyChangeSupport JavaDoc propSupport;
53     
54     private JRDesignVariable designVariable;
55     
56     
57     /**
58      * Creates a crosstab measure.
59      */

60     public JRDesignCrosstabMeasure()
61     {
62         super();
63         
64         variable = designVariable = new JRDesignVariable();
65         designVariable.setCalculation(JRVariable.CALCULATION_SYSTEM);
66         designVariable.setSystemDefined(true);
67     }
68
69     
70     /**
71      * Sets the calculation type.
72      *
73      * @param calculation the calculation type
74      * @see net.sf.jasperreports.crosstabs.JRCrosstabMeasure#getCalculation()
75      */

76     public void setCalculation(byte calculation)
77     {
78         this.calculation = calculation;
79     }
80
81     
82     /**
83      * Sets the measure value expression.
84      *
85      * @param expression the measure value expression.
86      * @see net.sf.jasperreports.crosstabs.JRCrosstabMeasure#getValueExpression()
87      */

88     public void setValueExpression(JRExpression expression)
89     {
90         this.expression = expression;
91     }
92
93     
94     /**
95      * Sets the incrementer factory class name.
96      *
97      * @param incrementerFactoryClassName the incrementer factory class name
98      * @see net.sf.jasperreports.crosstabs.JRCrosstabMeasure#getIncrementerFactoryClassName()
99      */

100     public void setIncrementerFactoryClassName(String JavaDoc incrementerFactoryClassName)
101     {
102         this.incrementerFactoryClassName = incrementerFactoryClassName;
103         this.incrementerFactoryClass = null;
104     }
105
106     
107     /**
108      * Sets the measure name.
109      *
110      * @param name the measure name
111      * @see net.sf.jasperreports.crosstabs.JRCrosstabMeasure#getName()
112      */

113     public void setName(String JavaDoc name)
114     {
115         this.name = name;
116         designVariable.setName(name);
117     }
118
119     
120     /**
121      * Sets the percentage calculation type.
122      *
123      * @param percentageOfType the percentage calculation type
124      * @see net.sf.jasperreports.crosstabs.JRCrosstabMeasure#getPercentageOfType()
125      */

126     public void setPercentageOfType(byte percentageOfType)
127     {
128         this.percentageOfType = percentageOfType;
129     }
130
131     
132     /**
133      * Sets the percentage calculator class name.
134      *
135      * @param percentageCalculatorClassName the percentage calculator class name
136      * @see net.sf.jasperreports.crosstabs.JRCrosstabMeasure#getPercentageCalculatorClassName()
137      */

138     public void setPercentageCalculatorClassName(String JavaDoc percentageCalculatorClassName)
139     {
140         this.percentageCalculatorClassName = percentageCalculatorClassName;
141         this.percentageCalculatorClass = null;
142     }
143
144     
145     /**
146      * Sets the measure value class name.
147      *
148      * @param valueClassName the measure value class name
149      * @see net.sf.jasperreports.crosstabs.JRCrosstabMeasure#getValueClassName()
150      */

151     public void setValueClassName(String JavaDoc valueClassName)
152     {
153         String JavaDoc oldValue = this.valueClassName;
154         
155         this.valueClassName = valueClassName;
156         this.valueClass = null;
157         designVariable.setValueClassName(valueClassName);
158         
159         getPropertyChangeSupport().firePropertyChange(PROPERTY_VALUE_CLASS, oldValue,
160                 this.valueClassName);
161     }
162     
163
164     /**
165      * Add a property listener to listen to all properties of this class.
166      *
167      * @param l
168      * The property listener to add.
169      *
170      * @see #removePropertyChangeListener(PropertyChangeListener)
171      */

172     public void addPropertyChangeListener(PropertyChangeListener JavaDoc l)
173     {
174         getPropertyChangeSupport().addPropertyChangeListener(l);
175     }
176
177     /**
178      * Add a property listener to receive property change events for only one
179      * specific property.
180      *
181      * @param propName
182      * The property to listen to.
183      * @param l
184      * The property listener to add.
185      *
186      * @see #removePropertyChangeListener(String, PropertyChangeListener)
187      */

188     public void addPropertyChangeListener(String JavaDoc propName, PropertyChangeListener JavaDoc l)
189     {
190         getPropertyChangeSupport().addPropertyChangeListener(propName, l);
191     }
192
193     /**
194      * Remove a property change listener registered for all properties.
195      *
196      * This will only remove listeners that were added through the
197      * {@link #addPropertyChangeListener(PropertyChangeListener) addPropertyChangeListener(PropertyChangeListener)}
198      * method.
199      *
200      * @param l
201      * The listener to remove.
202      */

203     public void removePropertyChangeListener(PropertyChangeListener JavaDoc l)
204     {
205         getPropertyChangeSupport().removePropertyChangeListener(l);
206     }
207
208     /**
209      * Remove a property change listener registered for a specific property.
210      *
211      * @param propName
212      * The property to listen to.
213      * @param l
214      * The listener to remove.
215      */

216     public void removePropertyChangeListener(String JavaDoc propName, PropertyChangeListener JavaDoc l)
217     {
218         getPropertyChangeSupport().removePropertyChangeListener(propName, l);
219     }
220
221     /**
222      * Get the property change support object for this class. Because the
223      * property change support object has to be transient, it may need to be
224      * created.
225      *
226      * @return The property change support object.
227      */

228     protected PropertyChangeSupport JavaDoc getPropertyChangeSupport()
229     {
230         if (propSupport == null)
231         {
232             propSupport = new PropertyChangeSupport JavaDoc(this);
233         }
234         return propSupport;
235     }
236 }
237
Popular Tags