KickJava   Java API By Example, From Geeks To Geeks.

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


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

46 public class JRFillCategorySeries implements JRCategorySeries
47 {
48
49     /**
50      *
51      */

52     protected JRCategorySeries parent = null;
53
54     private Comparable JavaDoc series = null;
55     private Comparable JavaDoc category = null;
56     private Number JavaDoc value = null;
57     private String JavaDoc label = null;
58     private JRPrintHyperlink itemHyperlink;
59     
60     
61     /**
62      *
63      */

64     public JRFillCategorySeries(
65         JRCategorySeries categorySeries,
66         JRFillObjectFactory factory
67         )
68     {
69         factory.put(categorySeries, this);
70
71         parent = categorySeries;
72     }
73
74
75     /**
76      *
77      */

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

86     public JRExpression getCategoryExpression()
87     {
88         return parent.getCategoryExpression();
89     }
90         
91     /**
92      *
93      */

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

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

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

119     protected Comparable JavaDoc getCategory()
120     {
121         return category;
122     }
123         
124     /**
125      *
126      */

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

135     protected String JavaDoc getLabel()
136     {
137         return label;
138     }
139     
140     protected JRPrintHyperlink getPrintItemHyperlink()
141     {
142         return itemHyperlink;
143     }
144     
145     
146     /**
147      *
148      */

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