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.JRTimePeriodSeries;
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 Flavius Sana (flavius_sana@users.sourceforge.net)
046: * @version $Id: JRFillTimePeriodSeries.java 1720 2007-05-07 10:02:56Z lucianc $
047: */
048: public class JRFillTimePeriodSeries implements JRTimePeriodSeries {
049:
050: /**
051: *
052: */
053: protected JRTimePeriodSeries parent = null;
054:
055: private Comparable series = null;
056: private Date startDate = null;
057: private Date endDate = null;
058: private Number value = null;
059: private String label = null;
060: private JRPrintHyperlink itemHyperlink;
061:
062: public JRFillTimePeriodSeries(JRTimePeriodSeries timePeriodSeries,
063: JRFillObjectFactory factory) {
064: factory.put(timePeriodSeries, this );
065: parent = timePeriodSeries;
066: }
067:
068: public JRExpression getSeriesExpression() {
069: return parent.getSeriesExpression();
070: }
071:
072: public JRExpression getStartDateExpression() {
073: return parent.getStartDateExpression();
074: }
075:
076: public JRExpression getEndDateExpression() {
077: return parent.getEndDateExpression();
078: }
079:
080: public JRExpression getValueExpression() {
081: return parent.getValueExpression();
082: }
083:
084: public JRExpression getLabelExpression() {
085: return parent.getLabelExpression();
086: }
087:
088: protected Comparable getSeries() {
089: return series;
090: }
091:
092: protected Date getStartDate() {
093: return startDate;
094: }
095:
096: protected Date getEndDate() {
097: return endDate;
098: }
099:
100: protected Number getValue() {
101: return value;
102: }
103:
104: protected String getLabel() {
105: return label;
106: }
107:
108: protected void evaluate(JRCalculator calculator)
109: throws JRExpressionEvalException {
110: series = (Comparable) calculator
111: .evaluate(getSeriesExpression());
112: startDate = (Date) calculator
113: .evaluate(getStartDateExpression());
114: endDate = (Date) calculator.evaluate(getEndDateExpression());
115: value = (Number) calculator.evaluate(getValueExpression());
116: label = (String) calculator.evaluate(getLabelExpression());
117:
118: if (hasItemHyperlink()) {
119: evaluateItemHyperlink(calculator);
120: }
121: }
122:
123: protected void evaluateItemHyperlink(JRCalculator calculator)
124: throws JRExpressionEvalException {
125: try {
126: itemHyperlink = JRFillHyperlinkHelper.evaluateHyperlink(
127: getItemHyperlink(), calculator,
128: JRExpression.EVALUATION_DEFAULT);
129: } catch (JRExpressionEvalException e) {
130: throw e;
131: } catch (JRException e) {
132: throw new JRRuntimeException(e);
133: }
134: }
135:
136: public JRHyperlink getItemHyperlink() {
137: return parent.getItemHyperlink();
138: }
139:
140: public boolean hasItemHyperlink() {
141: return !JRHyperlinkHelper.isEmpty(getItemHyperlink());
142: }
143:
144: public JRPrintHyperlink getPrintItemHyperlink() {
145: return itemHyperlink;
146: }
147:
148: }
|