KickJava   Java API By Example, From Geeks To Geeks.

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


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

45 public class JRFillXyzSeries implements JRXyzSeries {
46     
47     JRXyzSeries parent = null;
48     
49     private Comparable JavaDoc series = null;
50     private Number JavaDoc xValue = null;
51     private Number JavaDoc yValue = null;
52     private Number JavaDoc zValue = null;
53     private JRPrintHyperlink itemHyperlink;
54     
55     public JRFillXyzSeries( JRXyzSeries xyzSeries, JRFillObjectFactory factory ){
56         factory.put( xyzSeries, this );
57         parent = xyzSeries;
58     }
59     
60     public JRExpression getSeriesExpression(){
61         return parent.getSeriesExpression();
62     }
63     
64     public JRExpression getXValueExpression(){
65         return parent.getXValueExpression();
66     }
67     
68     public JRExpression getYValueExpression(){
69         return parent.getYValueExpression();
70     }
71     
72     public JRExpression getZValueExpression(){
73         return parent.getZValueExpression();
74     }
75     
76     
77     protected Comparable JavaDoc getSeries(){
78         return series;
79     }
80     
81     protected Number JavaDoc getXValue(){
82         return xValue;
83     }
84     
85     protected Number JavaDoc getYValue(){
86         return yValue;
87     }
88     
89     protected Number JavaDoc getZValue(){
90         return zValue;
91     }
92     
93     protected JRPrintHyperlink getPrintItemHyperlink()
94     {
95         return itemHyperlink;
96     }
97     
98     protected void evaluate( JRCalculator calculator ) throws JRExpressionEvalException {
99         series = (Comparable JavaDoc)calculator.evaluate( getSeriesExpression() );
100         xValue = (Number JavaDoc)calculator.evaluate( getXValueExpression() );
101         yValue = (Number JavaDoc)calculator.evaluate( getYValueExpression() );
102         zValue = (Number JavaDoc)calculator.evaluate( getZValueExpression() );
103         
104         if (hasItemHyperlinks())
105         {
106             evaluateItemHyperlink(calculator);
107         }
108     }
109
110     protected void evaluateItemHyperlink(JRCalculator calculator) throws JRExpressionEvalException
111     {
112         try
113         {
114             itemHyperlink = JRFillHyperlinkHelper.evaluateHyperlink(getItemHyperlink(), calculator, JRExpression.EVALUATION_DEFAULT);
115         }
116         catch (JRExpressionEvalException e)
117         {
118             throw e;
119         }
120         catch (JRException e)
121         {
122             throw new JRRuntimeException(e);
123         }
124     }
125
126     public JRHyperlink getItemHyperlink()
127     {
128         return parent.getItemHyperlink();
129     }
130     
131     public boolean hasItemHyperlinks()
132     {
133         return getItemHyperlink() != null;
134     }
135
136 }
137
Popular Tags