1 28 package net.sf.jasperreports.charts.fill; 29 30 import net.sf.jasperreports.charts.JRCategorySeries; 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 JRFillCategorySeries implements JRCategorySeries 47 { 48 49 52 protected JRCategorySeries parent = null; 53 54 private Comparable series = null; 55 private Comparable category = null; 56 private Number value = null; 57 private String label = null; 58 private JRPrintHyperlink itemHyperlink; 59 60 61 64 public JRFillCategorySeries( 65 JRCategorySeries categorySeries, 66 JRFillObjectFactory factory 67 ) 68 { 69 factory.put(categorySeries, this); 70 71 parent = categorySeries; 72 } 73 74 75 78 public JRExpression getSeriesExpression() 79 { 80 return parent.getSeriesExpression(); 81 } 82 83 86 public JRExpression getCategoryExpression() 87 { 88 return parent.getCategoryExpression(); 89 } 90 91 94 public JRExpression getValueExpression() 95 { 96 return parent.getValueExpression(); 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 Comparable getCategory() 120 { 121 return category; 122 } 123 124 127 protected Number getValue() 128 { 129 return value; 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 category = (Comparable )calculator.evaluate(getCategoryExpression()); 153 value = (Number )calculator.evaluate(getValueExpression()); 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 boolean hasItemHyperlinks() 181 { 182 return getItemHyperlink() != null; 183 } 184 185 186 public JRHyperlink getItemHyperlink() 187 { 188 return parent.getItemHyperlink(); 189 } 190 191 } 192 | Popular Tags |