001: /*
002: * ============================================================================
003: * GNU Lesser General Public License
004: * ============================================================================
005: *
006: * JasperReports - Free Java report-generating library.
007: * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
022: *
023: * JasperSoft Corporation
024: * 303 Second Street, Suite 450 North
025: * San Francisco, CA 94107
026: * http://www.jaspersoft.com
027: */
028: package net.sf.jasperreports.charts.fill;
029:
030: import net.sf.jasperreports.charts.JRXyzSeries;
031: import net.sf.jasperreports.engine.JRException;
032: import net.sf.jasperreports.engine.JRExpression;
033: import net.sf.jasperreports.engine.JRHyperlink;
034: import net.sf.jasperreports.engine.JRHyperlinkHelper;
035: import net.sf.jasperreports.engine.JRPrintHyperlink;
036: import net.sf.jasperreports.engine.JRRuntimeException;
037: import net.sf.jasperreports.engine.fill.JRCalculator;
038: import net.sf.jasperreports.engine.fill.JRExpressionEvalException;
039: import net.sf.jasperreports.engine.fill.JRFillHyperlinkHelper;
040: import net.sf.jasperreports.engine.fill.JRFillObjectFactory;
041:
042: /**
043: * @author Flavius Sana (flavius_sana@users.sourceforge.net)
044: * @version $Id: JRFillXyzSeries.java 1720 2007-05-07 10:02:56Z lucianc $
045: */
046: public class JRFillXyzSeries implements JRXyzSeries {
047:
048: JRXyzSeries parent = null;
049:
050: private Comparable series = null;
051: private Number xValue = null;
052: private Number yValue = null;
053: private Number zValue = null;
054: private JRPrintHyperlink itemHyperlink;
055:
056: public JRFillXyzSeries(JRXyzSeries xyzSeries,
057: JRFillObjectFactory factory) {
058: factory.put(xyzSeries, this );
059: parent = xyzSeries;
060: }
061:
062: public JRExpression getSeriesExpression() {
063: return parent.getSeriesExpression();
064: }
065:
066: public JRExpression getXValueExpression() {
067: return parent.getXValueExpression();
068: }
069:
070: public JRExpression getYValueExpression() {
071: return parent.getYValueExpression();
072: }
073:
074: public JRExpression getZValueExpression() {
075: return parent.getZValueExpression();
076: }
077:
078: protected Comparable getSeries() {
079: return series;
080: }
081:
082: protected Number getXValue() {
083: return xValue;
084: }
085:
086: protected Number getYValue() {
087: return yValue;
088: }
089:
090: protected Number getZValue() {
091: return zValue;
092: }
093:
094: protected JRPrintHyperlink getPrintItemHyperlink() {
095: return itemHyperlink;
096: }
097:
098: protected void evaluate(JRCalculator calculator)
099: throws JRExpressionEvalException {
100: series = (Comparable) calculator
101: .evaluate(getSeriesExpression());
102: xValue = (Number) calculator.evaluate(getXValueExpression());
103: yValue = (Number) calculator.evaluate(getYValueExpression());
104: zValue = (Number) calculator.evaluate(getZValueExpression());
105:
106: if (hasItemHyperlinks()) {
107: evaluateItemHyperlink(calculator);
108: }
109: }
110:
111: protected void evaluateItemHyperlink(JRCalculator calculator)
112: throws JRExpressionEvalException {
113: try {
114: itemHyperlink = JRFillHyperlinkHelper.evaluateHyperlink(
115: getItemHyperlink(), calculator,
116: JRExpression.EVALUATION_DEFAULT);
117: } catch (JRExpressionEvalException e) {
118: throw e;
119: } catch (JRException e) {
120: throw new JRRuntimeException(e);
121: }
122: }
123:
124: public JRHyperlink getItemHyperlink() {
125: return parent.getItemHyperlink();
126: }
127:
128: public boolean hasItemHyperlinks() {
129: return !JRHyperlinkHelper.isEmpty(getItemHyperlink());
130: }
131:
132: }
|