~brian-thomason/+junk/jasperreports3.7

« back to all changes in this revision

Viewing changes to src/net/sf/jasperreports/charts/fill/JRFillCategorySeries.java

  • Committer: Brian Thomason
  • Date: 2011-12-20 17:51:16 UTC
  • Revision ID: brian.thomason@canonical.com-20111220175116-apwo6unuaedvgzo3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * JasperReports - Free Java Reporting Library.
 
3
 * Copyright (C) 2001 - 2009 Jaspersoft Corporation. All rights reserved.
 
4
 * http://www.jaspersoft.com
 
5
 *
 
6
 * Unless you have purchased a commercial license agreement from Jaspersoft,
 
7
 * the following license terms apply:
 
8
 *
 
9
 * This program is part of JasperReports.
 
10
 *
 
11
 * JasperReports is free software: you can redistribute it and/or modify
 
12
 * it under the terms of the GNU Lesser General Public License as published by
 
13
 * the Free Software Foundation, either version 3 of the License, or
 
14
 * (at your option) any later version.
 
15
 *
 
16
 * JasperReports is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
19
 * GNU Lesser General Public License for more details.
 
20
 * 
 
21
 * You should have received a copy of the GNU Lesser General Public License
 
22
 * along with JasperReports. If not, see <http://www.gnu.org/licenses/>.
 
23
 */
 
24
package net.sf.jasperreports.charts.fill;
 
25
 
 
26
import net.sf.jasperreports.charts.JRCategorySeries;
 
27
import net.sf.jasperreports.engine.JRException;
 
28
import net.sf.jasperreports.engine.JRExpression;
 
29
import net.sf.jasperreports.engine.JRHyperlink;
 
30
import net.sf.jasperreports.engine.JRHyperlinkHelper;
 
31
import net.sf.jasperreports.engine.JRPrintHyperlink;
 
32
import net.sf.jasperreports.engine.JRRuntimeException;
 
33
import net.sf.jasperreports.engine.fill.JRCalculator;
 
34
import net.sf.jasperreports.engine.fill.JRExpressionEvalException;
 
35
import net.sf.jasperreports.engine.fill.JRFillHyperlinkHelper;
 
36
import net.sf.jasperreports.engine.fill.JRFillObjectFactory;
 
37
 
 
38
 
 
39
/**
 
40
 * @author Teodor Danciu (teodord@users.sourceforge.net)
 
41
 * @version $Id: JRFillCategorySeries.java 3876 2010-07-14 14:18:47Z shertage $
 
42
 */
 
43
public class JRFillCategorySeries implements JRCategorySeries
 
44
{
 
45
 
 
46
        /**
 
47
         *
 
48
         */
 
49
        protected JRCategorySeries parent = null;
 
50
 
 
51
        private Comparable series = null;
 
52
        private Comparable category = null;
 
53
        private Number value = null;
 
54
        private String label = null;
 
55
        private JRPrintHyperlink itemHyperlink;
 
56
        
 
57
        
 
58
        /**
 
59
         *
 
60
         */
 
61
        public JRFillCategorySeries(
 
62
                JRCategorySeries categorySeries, 
 
63
                JRFillObjectFactory factory
 
64
                )
 
65
        {
 
66
                factory.put(categorySeries, this);
 
67
 
 
68
                parent = categorySeries;
 
69
        }
 
70
 
 
71
 
 
72
        /**
 
73
         *
 
74
         */
 
75
        public JRExpression getSeriesExpression()
 
76
        {
 
77
                return parent.getSeriesExpression();
 
78
        }
 
79
                
 
80
        /**
 
81
         *
 
82
         */
 
83
        public JRExpression getCategoryExpression()
 
84
        {
 
85
                return parent.getCategoryExpression();
 
86
        }
 
87
                
 
88
        /**
 
89
         *
 
90
         */
 
91
        public JRExpression getValueExpression()
 
92
        {
 
93
                return parent.getValueExpression();
 
94
        }
 
95
                
 
96
        /**
 
97
         *
 
98
         */
 
99
        public JRExpression getLabelExpression()
 
100
        {
 
101
                return parent.getLabelExpression();
 
102
        }
 
103
        
 
104
        
 
105
        /**
 
106
         *
 
107
         */
 
108
        public Comparable getSeries()
 
109
        {
 
110
                return series;
 
111
        }
 
112
                
 
113
        /**
 
114
         *
 
115
         */
 
116
        public Comparable getCategory()
 
117
        {
 
118
                return category;
 
119
        }
 
120
                
 
121
        /**
 
122
         *
 
123
         */
 
124
        public Number getValue()
 
125
        {
 
126
                return value;
 
127
        }
 
128
                
 
129
        /**
 
130
         *
 
131
         */
 
132
        public String getLabel()
 
133
        {
 
134
                return label;
 
135
        }
 
136
        
 
137
        public JRPrintHyperlink getPrintItemHyperlink()
 
138
        {
 
139
                return itemHyperlink;
 
140
        }
 
141
        
 
142
        
 
143
        /**
 
144
         *
 
145
         */
 
146
        public void evaluate(JRCalculator calculator) throws JRExpressionEvalException
 
147
        {
 
148
                series = (Comparable)calculator.evaluate(getSeriesExpression()); 
 
149
                category = (Comparable)calculator.evaluate(getCategoryExpression()); 
 
150
                value = (Number)calculator.evaluate(getValueExpression());
 
151
                label = (String)calculator.evaluate(getLabelExpression());
 
152
                
 
153
                if (hasItemHyperlinks())
 
154
                {
 
155
                        evaluateItemHyperlink(calculator);
 
156
                }
 
157
        }
 
158
 
 
159
 
 
160
        public 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 boolean hasItemHyperlinks()
 
178
        {
 
179
                return !JRHyperlinkHelper.isEmpty(getItemHyperlink()); 
 
180
        }
 
181
 
 
182
 
 
183
        public JRHyperlink getItemHyperlink()
 
184
        {
 
185
                return parent.getItemHyperlink();
 
186
        }
 
187
 
 
188
        /**
 
189
         *
 
190
         */
 
191
        public Object clone() 
 
192
        {
 
193
                throw new UnsupportedOperationException();
 
194
        }
 
195
}