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