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.JRValueDataset;
031: import net.sf.jasperreports.engine.JRChartDataset;
032: import net.sf.jasperreports.engine.JRExpression;
033: import net.sf.jasperreports.engine.JRExpressionCollector;
034: import net.sf.jasperreports.engine.design.JRVerifier;
035: import net.sf.jasperreports.engine.fill.JRCalculator;
036: import net.sf.jasperreports.engine.fill.JRExpressionEvalException;
037: import net.sf.jasperreports.engine.fill.JRFillChartDataset;
038: import net.sf.jasperreports.engine.fill.JRFillObjectFactory;
039:
040: import org.jfree.data.general.Dataset;
041: import org.jfree.data.general.DefaultValueDataset;
042:
043: /**
044: * @author Barry Klawans (bklawans@users.sourceforge.net)
045: * @version $Id: JRFillValueDataset.java 1794 2007-07-30 09:07:50Z teodord $
046: */
047: public class JRFillValueDataset extends JRFillChartDataset implements
048: JRValueDataset {
049:
050: private Number value = null;
051:
052: /**
053: *
054: */
055: private DefaultValueDataset valueDataset = new DefaultValueDataset();
056:
057: /**
058: *
059: */
060: public JRFillValueDataset(JRValueDataset valueDataset,
061: JRFillObjectFactory factory) {
062: super (valueDataset, factory);
063: }
064:
065: /**
066: *
067: */
068: public JRExpression getValueExpression() {
069: return ((JRValueDataset) parent).getValueExpression();
070: }
071:
072: /**
073: *
074: */
075: protected void customInitialize() {
076: valueDataset = new DefaultValueDataset();
077: }
078:
079: /**
080: *
081: */
082: protected void customEvaluate(JRCalculator calculator)
083: throws JRExpressionEvalException {
084: value = (Number) calculator.evaluate(getValueExpression());
085: }
086:
087: /**
088: *
089: */
090: protected void customIncrement() {
091: valueDataset.setValue(value);
092: }
093:
094: /**
095: *
096: */
097: public Dataset getCustomDataset() {
098: return valueDataset;
099: }
100:
101: /**
102: *
103: */
104: public byte getDatasetType() {
105: return JRChartDataset.VALUE_DATASET;
106: }
107:
108: /**
109: *
110: */
111: public void collectExpressions(JRExpressionCollector collector) {
112: collector.collect(this );
113: }
114:
115: public void validate(JRVerifier verifier) {
116: verifier.verify(this);
117: }
118:
119: }
|