1 28 package net.sf.jasperreports.charts.fill; 29 30 import net.sf.jasperreports.charts.JRXySeries; 31 import net.sf.jasperreports.engine.JRException; 32 import net.sf.jasperreports.engine.JRExpression; 33 import net.sf.jasperreports.engine.JRHyperlink; 34 import net.sf.jasperreports.engine.JRPrintHyperlink; 35 import net.sf.jasperreports.engine.JRRuntimeException; 36 import net.sf.jasperreports.engine.fill.JRCalculator; 37 import net.sf.jasperreports.engine.fill.JRExpressionEvalException; 38 import net.sf.jasperreports.engine.fill.JRFillHyperlinkHelper; 39 import net.sf.jasperreports.engine.fill.JRFillObjectFactory; 40 41 42 46 public class JRFillXySeries implements JRXySeries 47 { 48 49 52 protected JRXySeries parent = null; 53 54 private Comparable series = null; 55 private Number xValue = null; 56 private Number yValue = null; 57 private String label = null; 58 private JRPrintHyperlink itemHyperlink; 59 60 61 64 public JRFillXySeries( 65 JRXySeries xySeries, 66 JRFillObjectFactory factory 67 ) 68 { 69 factory.put(xySeries, this); 70 71 parent = xySeries; 72 } 73 74 75 78 public JRExpression getSeriesExpression() 79 { 80 return parent.getSeriesExpression(); 81 } 82 83 86 public JRExpression getXValueExpression() 87 { 88 return parent.getXValueExpression(); 89 } 90 91 94 public JRExpression getYValueExpression() 95 { 96 return parent.getYValueExpression(); 97 } 98 99 102 public JRExpression getLabelExpression() 103 { 104 return parent.getLabelExpression(); 105 } 106 107 108 111 protected Comparable getSeries() 112 { 113 return series; 114 } 115 116 119 protected Number getXValue() 120 { 121 return xValue; 122 } 123 124 127 protected Number getYValue() 128 { 129 return yValue; 130 } 131 132 135 protected String getLabel() 136 { 137 return label; 138 } 139 140 protected JRPrintHyperlink getPrintItemHyperlink() 141 { 142 return itemHyperlink; 143 } 144 145 146 149 protected void evaluate(JRCalculator calculator) throws JRExpressionEvalException 150 { 151 series = (Comparable )calculator.evaluate(getSeriesExpression()); 152 xValue = (Number )calculator.evaluate(getXValueExpression()); 153 yValue = (Number )calculator.evaluate(getYValueExpression()); 154 label = (String )calculator.evaluate(getLabelExpression()); 155 156 if (hasItemHyperlinks()) 157 { 158 evaluateItemHyperlink(calculator); 159 } 160 } 161 162 163 protected void evaluateItemHyperlink(JRCalculator calculator) throws JRExpressionEvalException 164 { 165 try 166 { 167 itemHyperlink = JRFillHyperlinkHelper.evaluateHyperlink(getItemHyperlink(), calculator, JRExpression.EVALUATION_DEFAULT); 168 } 169 catch (JRExpressionEvalException e) 170 { 171 throw e; 172 } 173 catch (JRException e) 174 { 175 throw new JRRuntimeException(e); 176 } 177 } 178 179 180 public JRHyperlink getItemHyperlink() 181 { 182 return parent.getItemHyperlink(); 183 } 184 185 186 public boolean hasItemHyperlinks() 187 { 188 return getItemHyperlink() != null; 189 } 190 191 } 192 | Popular Tags |