KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > charts > fill > JRFillTimeSeries


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.fill;
29
30 import java.util.Date JavaDoc;
31
32 import net.sf.jasperreports.charts.JRTimeSeries;
33 import net.sf.jasperreports.engine.JRException;
34 import net.sf.jasperreports.engine.JRExpression;
35 import net.sf.jasperreports.engine.JRHyperlink;
36 import net.sf.jasperreports.engine.JRPrintHyperlink;
37 import net.sf.jasperreports.engine.JRRuntimeException;
38 import net.sf.jasperreports.engine.fill.JRCalculator;
39 import net.sf.jasperreports.engine.fill.JRExpressionEvalException;
40 import net.sf.jasperreports.engine.fill.JRFillHyperlinkHelper;
41 import net.sf.jasperreports.engine.fill.JRFillObjectFactory;
42
43
44 /**
45  * @author Teodor Danciu (teodord@users.sourceforge.net)
46  * @version $Id: JRFillTimeSeries.java 1364 2006-08-31 18:13:20 +0300 (Thu, 31 Aug 2006) lucianc $
47  */

48 public class JRFillTimeSeries implements JRTimeSeries
49 {
50
51     /**
52      *
53      */

54     protected JRTimeSeries parent = null;
55
56     private Comparable JavaDoc series = null;
57     private Date JavaDoc timePeriod = null;
58     private Number JavaDoc value = null;
59     private String JavaDoc label = null;
60     private JRPrintHyperlink itemHyperlink;
61     
62     
63     /**
64      *
65      */

66     public JRFillTimeSeries(
67         JRTimeSeries timeSeries,
68         JRFillObjectFactory factory
69         )
70     {
71         factory.put(timeSeries, this);
72
73         parent = timeSeries;
74     }
75
76
77     /**
78      *
79      */

80     public JRExpression getSeriesExpression()
81     {
82         return parent.getSeriesExpression();
83     }
84         
85     /**
86      *
87      */

88     public JRExpression getTimePeriodExpression()
89     {
90         return parent.getTimePeriodExpression();
91     }
92         
93     /**
94      *
95      */

96     public JRExpression getValueExpression()
97     {
98         return parent.getValueExpression();
99     }
100         
101     /**
102      *
103      */

104     public JRExpression getLabelExpression()
105     {
106         return parent.getLabelExpression();
107     }
108     
109     
110     /**
111      *
112      */

113     protected Comparable JavaDoc getSeries()
114     {
115         return series;
116     }
117         
118     /**
119      *
120      */

121     protected Date JavaDoc getTimePeriod()
122     {
123         return timePeriod;
124     }
125         
126     /**
127      *
128      */

129     protected Number JavaDoc getValue()
130     {
131         return value;
132     }
133         
134     /**
135      *
136      */

137     protected String JavaDoc getLabel()
138     {
139         return label;
140     }
141     
142     
143     /**
144      *
145      */

146     protected void evaluate(JRCalculator calculator) throws JRExpressionEvalException
147     {
148         series = (Comparable JavaDoc)calculator.evaluate(getSeriesExpression());
149         timePeriod = (Date JavaDoc)calculator.evaluate(getTimePeriodExpression());
150         value = (Number JavaDoc)calculator.evaluate(getValueExpression());
151         label = (String JavaDoc)calculator.evaluate(getLabelExpression());
152     
153         if (hasItemHyperlink())
154         {
155             evaluateItemHyperlink(calculator);
156         }
157     }
158
159
160     protected void evaluateItemHyperlink(JRCalculator calculator) throws JRExpressionEvalException
161     {
162         try
163         {
164             itemHyperlink = JRFillHyperlinkHelper.evaluateHyperlink(getItemHyperlink(), calculator, JRExpression.EVALUATION_DEFAULT);
165         }
166         catch (JRExpressionEvalException e)
167         {
168             throw e;
169         }
170         catch (JRException e)
171         {
172             throw new JRRuntimeException(e);
173         }
174     }
175
176
177     public JRHyperlink getItemHyperlink()
178     {
179         return parent.getItemHyperlink();
180     }
181
182
183     public boolean hasItemHyperlink()
184     {
185         return getItemHyperlink() != null;
186     }
187
188     
189     public JRPrintHyperlink getPrintItemHyperlink()
190     {
191         return itemHyperlink;
192     }
193
194 }
195
Popular Tags