1 28 package net.sf.jasperreports.charts.fill; 29 30 import java.util.Date ; 31 32 import net.sf.jasperreports.charts.JRTimeSeries; 33 import net.sf.jasperreports.engine.JRException; 34 import net.sf.jasperreports.engine.JRExpression; 35 import net.sf.jasperreports.engine.JRHyperlink; 36 import net.sf.jasperreports.engine.JRPrintHyperlink; 37 import net.sf.jasperreports.engine.JRRuntimeException; 38 import net.sf.jasperreports.engine.fill.JRCalculator; 39 import net.sf.jasperreports.engine.fill.JRExpressionEvalException; 40 import net.sf.jasperreports.engine.fill.JRFillHyperlinkHelper; 41 import net.sf.jasperreports.engine.fill.JRFillObjectFactory; 42 43 44 48 public class JRFillTimeSeries implements JRTimeSeries 49 { 50 51 54 protected JRTimeSeries parent = null; 55 56 private Comparable series = null; 57 private Date timePeriod = null; 58 private Number value = null; 59 private String label = null; 60 private JRPrintHyperlink itemHyperlink; 61 62 63 66 public JRFillTimeSeries( 67 JRTimeSeries timeSeries, 68 JRFillObjectFactory factory 69 ) 70 { 71 factory.put(timeSeries, this); 72 73 parent = timeSeries; 74 } 75 76 77 80 public JRExpression getSeriesExpression() 81 { 82 return parent.getSeriesExpression(); 83 } 84 85 88 public JRExpression getTimePeriodExpression() 89 { 90 return parent.getTimePeriodExpression(); 91 } 92 93 96 public JRExpression getValueExpression() 97 { 98 return parent.getValueExpression(); 99 } 100 101 104 public JRExpression getLabelExpression() 105 { 106 return parent.getLabelExpression(); 107 } 108 109 110 113 protected Comparable getSeries() 114 { 115 return series; 116 } 117 118 121 protected Date getTimePeriod() 122 { 123 return timePeriod; 124 } 125 126 129 protected Number getValue() 130 { 131 return value; 132 } 133 134 137 protected String getLabel() 138 { 139 return label; 140 } 141 142 143 146 protected void evaluate(JRCalculator calculator) throws JRExpressionEvalException 147 { 148 series = (Comparable )calculator.evaluate(getSeriesExpression()); 149 timePeriod = (Date )calculator.evaluate(getTimePeriodExpression()); 150 value = (Number )calculator.evaluate(getValueExpression()); 151 label = (String )calculator.evaluate(getLabelExpression()); 152 153 if (hasItemHyperlink()) 154 { 155 evaluateItemHyperlink(calculator); 156 } 157 } 158 159 160 protected void evaluateItemHyperlink(JRCalculator calculator) throws JRExpressionEvalException 161 { 162 try 163 { 164 itemHyperlink = JRFillHyperlinkHelper.evaluateHyperlink(getItemHyperlink(), calculator, JRExpression.EVALUATION_DEFAULT); 165 } 166 catch (JRExpressionEvalException e) 167 { 168 throw e; 169 } 170 catch (JRException e) 171 { 172 throw new JRRuntimeException(e); 173 } 174 } 175 176 177 public JRHyperlink getItemHyperlink() 178 { 179 return parent.getItemHyperlink(); 180 } 181 182 183 public boolean hasItemHyperlink() 184 { 185 return getItemHyperlink() != null; 186 } 187 188 189 public JRPrintHyperlink getPrintItemHyperlink() 190 { 191 return itemHyperlink; 192 } 193 194 } 195 | Popular Tags |