1 28 package net.sf.jasperreports.crosstabs.fill; 29 30 import net.sf.jasperreports.crosstabs.JRCrosstabMeasure; 31 import net.sf.jasperreports.engine.JRExpression; 32 import net.sf.jasperreports.engine.JRVariable; 33 import net.sf.jasperreports.engine.fill.JRDefaultIncrementerFactory; 34 import net.sf.jasperreports.engine.fill.JRExtendedIncrementerFactory; 35 import net.sf.jasperreports.engine.fill.JRFillObjectFactory; 36 import net.sf.jasperreports.engine.fill.JRFillVariable; 37 import net.sf.jasperreports.engine.fill.JRIncrementerFactoryCache; 38 39 44 public class JRFillCrosstabMeasure implements JRCrosstabMeasure 45 { 46 protected JRCrosstabMeasure parentMeasure; 47 protected JRFillVariable variable; 48 protected JRExtendedIncrementerFactory incrementerFactory; 49 protected JRPercentageCalculator percentageCalculator; 50 51 public JRFillCrosstabMeasure(JRCrosstabMeasure measure, JRFillObjectFactory factory) 52 { 53 factory.put(measure, this); 54 55 parentMeasure = measure; 56 57 variable = factory.getVariable(measure.getVariable()); 58 59 incrementerFactory = createIncrementerFactory(); 60 percentageCalculator = createPercentageCalculator(); 61 } 62 63 public String getName() 64 { 65 return parentMeasure.getName(); 66 } 67 68 public String getValueClassName() 69 { 70 return parentMeasure.getValueClassName(); 71 } 72 73 public Class getValueClass() 74 { 75 return parentMeasure.getValueClass(); 76 } 77 78 public JRExpression getValueExpression() 79 { 80 return parentMeasure.getValueExpression(); 81 } 82 83 public byte getCalculation() 84 { 85 return parentMeasure.getCalculation(); 86 } 87 88 public String getIncrementerFactoryClassName() 89 { 90 return parentMeasure.getIncrementerFactoryClassName(); 91 } 92 93 public Class getIncrementerFactoryClass() 94 { 95 return parentMeasure.getIncrementerFactoryClass(); 96 } 97 98 public byte getPercentageOfType() 99 { 100 return parentMeasure.getPercentageOfType(); 101 } 102 103 public JRVariable getVariable() 104 { 105 return variable; 106 } 107 108 public JRFillVariable getFillVariable() 109 { 110 return variable; 111 } 112 113 114 public JRExtendedIncrementerFactory getIncrementerFactory() 115 { 116 return incrementerFactory; 117 } 118 119 120 public JRPercentageCalculator getPercentageCalculator() 121 { 122 return percentageCalculator; 123 } 124 125 126 private JRExtendedIncrementerFactory createIncrementerFactory() 127 { 128 JRExtendedIncrementerFactory incrFactory; 129 130 String incrementerFactoryClassName = getIncrementerFactoryClassName(); 131 if (incrementerFactoryClassName == null) 132 { 133 incrFactory = JRDefaultIncrementerFactory.getFactory(getValueClass()); 134 } 135 else 136 { 137 incrFactory = (JRExtendedIncrementerFactory) JRIncrementerFactoryCache.getInstance(getIncrementerFactoryClass()); 138 } 139 140 return incrFactory; 141 } 142 143 public JRPercentageCalculator createPercentageCalculator() 144 { 145 JRPercentageCalculator percentageCalc; 146 147 if (getPercentageOfType() == JRCrosstabMeasure.PERCENTAGE_TYPE_GRAND_TOTAL) 148 { 149 percentageCalc = JRPercentageCalculatorFactory.getPercentageCalculator(getPercentageCalculatorClass(), getValueClass()); 150 } 151 else 152 { 153 percentageCalc = null; 154 } 155 156 return percentageCalc; 157 } 158 159 public String getPercentageCalculatorClassName() 160 { 161 return parentMeasure.getPercentageCalculatorClassName(); 162 } 163 164 public Class getPercentageCalculatorClass() 165 { 166 return parentMeasure.getPercentageCalculatorClass(); 167 } 168 } 169 | Popular Tags |