KickJava   Java API By Example, From Geeks To Geeks.

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


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.JRTimePeriodSeries;
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  * @author Flavius Sana (flavius_sana@users.sourceforge.net)
44  * @version $Id: JRFillTimePeriodSeries.java 1364 2006-08-31 18:13:20 +0300 (Thu, 31 Aug 2006) lucianc $
45  */

46 public class JRFillTimePeriodSeries implements JRTimePeriodSeries {
47
48     /**
49      *
50      */

51     protected JRTimePeriodSeries parent = null;
52     
53     private Comparable JavaDoc series = null;
54     private Date JavaDoc startDate = null;
55     private Date JavaDoc endDate = null;
56     private Number JavaDoc value = null;
57     private String JavaDoc label = null;
58     private JRPrintHyperlink itemHyperlink;
59     
60     
61     public JRFillTimePeriodSeries( JRTimePeriodSeries timePeriodSeries, JRFillObjectFactory factory ){
62         factory.put( timePeriodSeries, this );
63         parent = timePeriodSeries;
64     }
65     
66     
67     public JRExpression getSeriesExpression(){
68         return parent.getSeriesExpression();
69     }
70     
71     public JRExpression getStartDateExpression(){
72         return parent.getStartDateExpression();
73     }
74     
75     public JRExpression getEndDateExpression(){
76         return parent.getEndDateExpression();
77     }
78     
79     public JRExpression getValueExpression(){
80         return parent.getValueExpression();
81     }
82     
83     public JRExpression getLabelExpression(){
84         return parent.getLabelExpression();
85     }
86     
87     protected Comparable JavaDoc getSeries(){
88         return series;
89     }
90     
91     protected Date JavaDoc getStartDate(){
92         return startDate;
93     }
94     
95     protected Date JavaDoc getEndDate(){
96         return endDate;
97     }
98     
99     protected Number JavaDoc getValue(){
100         return value;
101     }
102     
103     protected String JavaDoc getLabel(){
104         return label;
105     }
106     
107     protected void evaluate( JRCalculator calculator ) throws JRExpressionEvalException {
108         series = (Comparable JavaDoc)calculator.evaluate( getSeriesExpression() );
109         startDate = (Date JavaDoc)calculator.evaluate( getStartDateExpression() );
110         endDate = (Date JavaDoc)calculator.evaluate( getEndDateExpression() );
111         value= (Number JavaDoc)calculator.evaluate( getValueExpression() );
112         label = (String JavaDoc)calculator.evaluate( getLabelExpression() );
113         
114         if (hasItemHyperlink())
115         {
116             evaluateItemHyperlink(calculator);
117         }
118     }
119
120
121     protected void evaluateItemHyperlink(JRCalculator calculator) throws JRExpressionEvalException
122     {
123         try
124         {
125             itemHyperlink = JRFillHyperlinkHelper.evaluateHyperlink(getItemHyperlink(), calculator, JRExpression.EVALUATION_DEFAULT);
126         }
127         catch (JRExpressionEvalException e)
128         {
129             throw e;
130         }
131         catch (JRException e)
132         {
133             throw new JRRuntimeException(e);
134         }
135     }
136
137
138     public JRHyperlink getItemHyperlink()
139     {
140         return parent.getItemHyperlink();
141     }
142
143
144     public boolean hasItemHyperlink()
145     {
146         return getItemHyperlink() != null;
147     }
148
149     
150     public JRPrintHyperlink getPrintItemHyperlink()
151     {
152         return itemHyperlink;
153     }
154     
155     
156 }
157
Popular Tags