KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > charts > base > JRBaseValueDataset


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.charts.base;
29
30 import net.sf.jasperreports.charts.JRValueDataset;
31 import net.sf.jasperreports.engine.JRChartDataset;
32 import net.sf.jasperreports.engine.JRConstants;
33 import net.sf.jasperreports.engine.JRExpression;
34 import net.sf.jasperreports.engine.JRExpressionCollector;
35 import net.sf.jasperreports.engine.base.JRBaseChartDataset;
36 import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
37 import net.sf.jasperreports.engine.design.JRVerifier;
38
39
40 /**
41  * An immutable version of a dataset that generates a single value. A value
42  * dataset is suitable for using with charts that show a single value against
43  * a potential range, such as meter chart or a thermometer chart.
44  *
45  * @author Barry Klawans (bklawans@users.sourceforge.net)
46  * @version $Id: JRBaseValueDataset.java 1386 2006-09-06 00:33:02 +0300 (Wed, 06 Sep 2006) bklawans $
47  */

48 public class JRBaseValueDataset extends JRBaseChartDataset implements JRValueDataset
49 {
50
51
52     /**
53      *
54      */

55     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
56
57     /**
58      * The expression that returns the single value contained in this dataset.
59      */

60     protected JRExpression valueExpression = null;
61
62     
63     /**
64      * Construct a new dataset that is a copy of an existing one.
65      *
66      * @param dataset the dataset to copy
67      */

68     public JRBaseValueDataset(JRChartDataset dataset)
69     {
70         super(dataset);
71     }
72     
73     
74     /**
75      * Constructs a new dataset that is a copy of an existing one, and
76      * register all of the new dataset's expressions with the specified
77      * factory.
78      *
79      * @param dataset the datast to copy
80      * @param factory the factory to register the new dataset's expressions with
81      */

82     public JRBaseValueDataset(JRValueDataset dataset, JRBaseObjectFactory factory)
83     {
84         super(dataset, factory);
85
86         valueExpression = factory.getExpression(dataset.getValueExpression());
87     }
88
89
90     /**
91      *
92      */

93     public JRExpression getValueExpression()
94     {
95         return valueExpression;
96     }
97    
98     
99     /**
100      *
101      */

102     public byte getDatasetType() {
103         return JRChartDataset.VALUE_DATASET;
104     }
105         
106     /**
107      * Adds all the expression used by this plot with the specified collector.
108      * All collected expression that are also registered with a factory will
109      * be included with the report is compiled.
110      *
111      * @param collector the expression collector to use
112      */

113    public void collectExpressions(JRExpressionCollector collector)
114     {
115         collector.collect(this);
116     }
117
118     public void validate(JRVerifier verifier)
119     {
120         verifier.verify(this);
121     }
122
123 }
124
Popular Tags