1 28 package net.sf.jasperreports.charts.fill; 29 30 import java.util.Date ; 31 32 import net.sf.jasperreports.charts.JRTimePeriodSeries; 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 46 public class JRFillTimePeriodSeries implements JRTimePeriodSeries { 47 48 51 protected JRTimePeriodSeries parent = null; 52 53 private Comparable series = null; 54 private Date startDate = null; 55 private Date endDate = null; 56 private Number value = null; 57 private String label = null; 58 private JRPrintHyperlink itemHyperlink; 59 60 61 public JRFillTimePeriodSeries( JRTimePeriodSeries timePeriodSeries, JRFillObjectFactory factory ){ 62 factory.put( timePeriodSeries, this ); 63 parent = timePeriodSeries; 64 } 65 66 67 public JRExpression getSeriesExpression(){ 68 return parent.getSeriesExpression(); 69 } 70 71 public JRExpression getStartDateExpression(){ 72 return parent.getStartDateExpression(); 73 } 74 75 public JRExpression getEndDateExpression(){ 76 return parent.getEndDateExpression(); 77 } 78 79 public JRExpression getValueExpression(){ 80 return parent.getValueExpression(); 81 } 82 83 public JRExpression getLabelExpression(){ 84 return parent.getLabelExpression(); 85 } 86 87 protected Comparable getSeries(){ 88 return series; 89 } 90 91 protected Date getStartDate(){ 92 return startDate; 93 } 94 95 protected Date getEndDate(){ 96 return endDate; 97 } 98 99 protected Number getValue(){ 100 return value; 101 } 102 103 protected String getLabel(){ 104 return label; 105 } 106 107 protected void evaluate( JRCalculator calculator ) throws JRExpressionEvalException { 108 series = (Comparable )calculator.evaluate( getSeriesExpression() ); 109 startDate = (Date )calculator.evaluate( getStartDateExpression() ); 110 endDate = (Date )calculator.evaluate( getEndDateExpression() ); 111 value= (Number )calculator.evaluate( getValueExpression() ); 112 label = (String )calculator.evaluate( getLabelExpression() ); 113 114 if (hasItemHyperlink()) 115 { 116 evaluateItemHyperlink(calculator); 117 } 118 } 119 120 121 protected void evaluateItemHyperlink(JRCalculator calculator) throws JRExpressionEvalException 122 { 123 try 124 { 125 itemHyperlink = JRFillHyperlinkHelper.evaluateHyperlink(getItemHyperlink(), calculator, JRExpression.EVALUATION_DEFAULT); 126 } 127 catch (JRExpressionEvalException e) 128 { 129 throw e; 130 } 131 catch (JRException e) 132 { 133 throw new JRRuntimeException(e); 134 } 135 } 136 137 138 public JRHyperlink getItemHyperlink() 139 { 140 return parent.getItemHyperlink(); 141 } 142 143 144 public boolean hasItemHyperlink() 145 { 146 return getItemHyperlink() != null; 147 } 148 149 150 public JRPrintHyperlink getPrintItemHyperlink() 151 { 152 return itemHyperlink; 153 } 154 155 156 } 157 | Popular Tags |