1 28 package net.sf.jasperreports.charts.fill; 29 30 import net.sf.jasperreports.charts.JRValueDataset; 31 import net.sf.jasperreports.engine.JRChartDataset; 32 import net.sf.jasperreports.engine.JRExpression; 33 import net.sf.jasperreports.engine.JRExpressionCollector; 34 import net.sf.jasperreports.engine.design.JRVerifier; 35 import net.sf.jasperreports.engine.fill.JRCalculator; 36 import net.sf.jasperreports.engine.fill.JRExpressionEvalException; 37 import net.sf.jasperreports.engine.fill.JRFillChartDataset; 38 import net.sf.jasperreports.engine.fill.JRFillObjectFactory; 39 40 import org.jfree.data.general.Dataset; 41 import org.jfree.data.general.DefaultValueDataset; 42 43 47 public class JRFillValueDataset extends JRFillChartDataset implements JRValueDataset 48 { 49 50 private Number value = null; 51 52 55 private DefaultValueDataset valueDataset = new DefaultValueDataset(); 56 57 58 61 public JRFillValueDataset(JRValueDataset valueDataset, 62 JRFillObjectFactory factory) 63 { 64 super(valueDataset, factory); 65 } 66 67 70 public JRExpression getValueExpression() 71 { 72 return ((JRValueDataset)parent).getValueExpression(); 73 } 74 75 76 79 protected void customInitialize() 80 { 81 valueDataset = new DefaultValueDataset(); 82 } 83 84 87 protected void customEvaluate(JRCalculator calculator) throws JRExpressionEvalException 88 { 89 value = (Number )calculator.evaluate(getValueExpression()); 90 } 91 92 95 protected void customIncrement() 96 { 97 valueDataset.setValue(value); 98 } 99 100 103 public Dataset getCustomDataset() 104 { 105 return valueDataset; 106 } 107 108 111 public byte getDatasetType() { 112 return JRChartDataset.VALUE_DATASET; 113 } 114 115 118 public void collectExpressions(JRExpressionCollector collector) 119 { 120 collector.collect(this); 121 } 122 123 public void validate(JRVerifier verifier) 124 { 125 verifier.verify(this); 126 } 127 128 } 129 | Popular Tags |