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.JRXySeries;
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 Teodor Danciu (teodord@users.sourceforge.net)
044: * @version $Id: JRFillXySeries.java 1720 2007-05-07 10:02:56Z lucianc $
045: */
046: public class JRFillXySeries implements JRXySeries {
047:
048: /**
049: *
050: */
051: protected JRXySeries parent = null;
052:
053: private Comparable series = null;
054: private Number xValue = null;
055: private Number yValue = null;
056: private String label = null;
057: private JRPrintHyperlink itemHyperlink;
058:
059: /**
060: *
061: */
062: public JRFillXySeries(JRXySeries xySeries,
063: JRFillObjectFactory factory) {
064: factory.put(xySeries, this );
065:
066: parent = xySeries;
067: }
068:
069: /**
070: *
071: */
072: public JRExpression getSeriesExpression() {
073: return parent.getSeriesExpression();
074: }
075:
076: /**
077: *
078: */
079: public JRExpression getXValueExpression() {
080: return parent.getXValueExpression();
081: }
082:
083: /**
084: *
085: */
086: public JRExpression getYValueExpression() {
087: return parent.getYValueExpression();
088: }
089:
090: /**
091: *
092: */
093: public JRExpression getLabelExpression() {
094: return parent.getLabelExpression();
095: }
096:
097: /**
098: *
099: */
100: protected Comparable getSeries() {
101: return series;
102: }
103:
104: /**
105: *
106: */
107: protected Number getXValue() {
108: return xValue;
109: }
110:
111: /**
112: *
113: */
114: protected Number getYValue() {
115: return yValue;
116: }
117:
118: /**
119: *
120: */
121: protected String getLabel() {
122: return label;
123: }
124:
125: protected JRPrintHyperlink getPrintItemHyperlink() {
126: return itemHyperlink;
127: }
128:
129: /**
130: *
131: */
132: protected void evaluate(JRCalculator calculator)
133: throws JRExpressionEvalException {
134: series = (Comparable) calculator
135: .evaluate(getSeriesExpression());
136: xValue = (Number) calculator.evaluate(getXValueExpression());
137: yValue = (Number) calculator.evaluate(getYValueExpression());
138: label = (String) calculator.evaluate(getLabelExpression());
139:
140: if (hasItemHyperlinks()) {
141: evaluateItemHyperlink(calculator);
142: }
143: }
144:
145: protected void evaluateItemHyperlink(JRCalculator calculator)
146: throws JRExpressionEvalException {
147: try {
148: itemHyperlink = JRFillHyperlinkHelper.evaluateHyperlink(
149: getItemHyperlink(), calculator,
150: JRExpression.EVALUATION_DEFAULT);
151: } catch (JRExpressionEvalException e) {
152: throw e;
153: } catch (JRException e) {
154: throw new JRRuntimeException(e);
155: }
156: }
157:
158: public JRHyperlink getItemHyperlink() {
159: return parent.getItemHyperlink();
160: }
161:
162: public boolean hasItemHyperlinks() {
163: return !JRHyperlinkHelper.isEmpty(getItemHyperlink());
164: }
165:
166: }
|