first commit

This commit is contained in:
2025-07-28 13:56:49 +05:30
commit e9eb805edb
3438 changed files with 520990 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package net.sf.jasperreports.engine.fill;
public abstract class AbstractValueProvider {
private static AbstractValueProvider currentValueProvider = new AbstractValueProvider() {
public Object getValue(JRCalculable calculable) {
return calculable.getValue();
}
};
private static AbstractValueProvider estimatedValueProvider = new AbstractValueProvider() {
public Object getValue(JRCalculable calculable) {
return ((JRFillVariable)calculable).getEstimatedValue();
}
};
public static AbstractValueProvider getCurrentValueProvider() {
return currentValueProvider;
}
public static AbstractValueProvider getEstimatedValueProvider() {
return estimatedValueProvider;
}
public abstract Object getValue(JRCalculable paramJRCalculable);
}

View File

@@ -0,0 +1,45 @@
package net.sf.jasperreports.engine.fill;
import java.util.HashSet;
import java.util.Set;
class DistinctCountHolder {
private Set distinctValues = null;
private Object lastValue = null;
public DistinctCountHolder() {
this.distinctValues = new HashSet();
}
public DistinctCountHolder(Set distinctValues) {
this.distinctValues = distinctValues;
}
public DistinctCountHolder(DistinctCountHolder holder, Object lastValue) {
this.distinctValues = holder.getDistinctValues();
this.lastValue = lastValue;
}
public void init() {
this.distinctValues = new HashSet();
}
public Set getDistinctValues() {
return this.distinctValues;
}
public Object getLastValue() {
return this.lastValue;
}
public void addLastValue() {
if (this.lastValue != null)
this.distinctValues.add(this.lastValue);
this.lastValue = null;
}
public long getCount() {
return (this.distinctValues.size() + ((this.lastValue == null || this.distinctValues.contains(this.lastValue)) ? 0 : 1));
}
}

View File

@@ -0,0 +1,13 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRException;
public abstract class JRAbstractExtendedIncrementer implements JRExtendedIncrementer {
public Object increment(JRFillVariable variable, Object expressionValue, AbstractValueProvider valueProvider) throws JRException {
return increment(variable, expressionValue, valueProvider);
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) throws JRException {
return increment(calculable, calculableValue.getValue(), valueProvider);
}
}

View File

@@ -0,0 +1,7 @@
package net.sf.jasperreports.engine.fill;
public abstract class JRAbstractExtendedIncrementerFactory implements JRExtendedIncrementerFactory {
public JRIncrementer getIncrementer(byte calculation) {
return getExtendedIncrementer(calculation);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,26 @@
package net.sf.jasperreports.engine.fill;
import java.math.BigDecimal;
class JRBigDecimalAverageIncrementer extends JRAbstractExtendedIncrementer {
private static JRBigDecimalAverageIncrementer mainInstance = new JRBigDecimalAverageIncrementer();
public static JRBigDecimalAverageIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
if (expressionValue == null) {
if (variable.isInitialized())
return null;
return variable.getValue();
}
BigDecimal countValue = (BigDecimal)valueProvider.getValue(variable.getHelperVariable((byte)0));
BigDecimal sumValue = (BigDecimal)valueProvider.getValue(variable.getHelperVariable((byte)1));
return sumValue.divide(countValue, 4);
}
public Object initialValue() {
return JRBigDecimalIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,34 @@
package net.sf.jasperreports.engine.fill;
import java.math.BigDecimal;
class JRBigDecimalCountIncrementer extends JRAbstractExtendedIncrementer {
private static JRBigDecimalCountIncrementer mainInstance = new JRBigDecimalCountIncrementer();
public static JRBigDecimalCountIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
BigDecimal value = (BigDecimal)variable.getIncrementedValue();
if (value == null || variable.isInitialized())
value = JRBigDecimalIncrementerFactory.ZERO;
if (expressionValue == null)
return value;
return value.add(JRBigDecimalIncrementerFactory.ONE);
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
BigDecimal value = (BigDecimal)calculable.getIncrementedValue();
BigDecimal combineValue = (BigDecimal)calculableValue.getValue();
if (value == null || calculable.isInitialized())
value = JRBigDecimalIncrementerFactory.ZERO;
if (combineValue == null)
return value;
return value.add(combineValue);
}
public Object initialValue() {
return JRBigDecimalIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,27 @@
package net.sf.jasperreports.engine.fill;
import java.math.BigDecimal;
class JRBigDecimalDistinctCountIncrementer extends JRAbstractExtendedIncrementer {
private static JRBigDecimalDistinctCountIncrementer mainInstance = new JRBigDecimalDistinctCountIncrementer();
public static JRBigDecimalDistinctCountIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
DistinctCountHolder holder = (DistinctCountHolder)valueProvider.getValue(variable.getHelperVariable((byte)0));
if (variable.isInitialized())
holder.init();
return new BigDecimal(holder.getCount());
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
DistinctCountHolder holder = (DistinctCountHolder)valueProvider.getValue(calculable.getHelperVariable((byte)0));
return new BigDecimal(holder.getCount());
}
public Object initialValue() {
return JRBigDecimalIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,45 @@
package net.sf.jasperreports.engine.fill;
import java.math.BigDecimal;
public class JRBigDecimalIncrementerFactory extends JRAbstractExtendedIncrementerFactory {
protected static final BigDecimal ZERO = new BigDecimal("0");
protected static final BigDecimal ONE = new BigDecimal("1");
private static JRBigDecimalIncrementerFactory mainInstance = new JRBigDecimalIncrementerFactory();
public static JRBigDecimalIncrementerFactory getInstance() {
return mainInstance;
}
public JRExtendedIncrementer getExtendedIncrementer(byte calculation) {
JRExtendedIncrementer incrementer = null;
switch (calculation) {
case 1:
incrementer = JRBigDecimalCountIncrementer.getInstance();
return incrementer;
case 2:
incrementer = JRBigDecimalSumIncrementer.getInstance();
return incrementer;
case 3:
incrementer = JRBigDecimalAverageIncrementer.getInstance();
return incrementer;
case 4:
case 5:
incrementer = JRComparableIncrementerFactory.getInstance().getExtendedIncrementer(calculation);
return incrementer;
case 6:
incrementer = JRBigDecimalStandardDeviationIncrementer.getInstance();
return incrementer;
case 7:
incrementer = JRBigDecimalVarianceIncrementer.getInstance();
return incrementer;
case 10:
incrementer = JRBigDecimalDistinctCountIncrementer.getInstance();
return incrementer;
}
incrementer = JRDefaultIncrementerFactory.getInstance().getExtendedIncrementer(calculation);
return incrementer;
}
}

View File

@@ -0,0 +1,25 @@
package net.sf.jasperreports.engine.fill;
import java.math.BigDecimal;
class JRBigDecimalStandardDeviationIncrementer extends JRAbstractExtendedIncrementer {
private static JRBigDecimalStandardDeviationIncrementer mainInstance = new JRBigDecimalStandardDeviationIncrementer();
public static JRBigDecimalStandardDeviationIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
if (expressionValue == null) {
if (variable.isInitialized())
return null;
return variable.getValue();
}
Number varianceValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)2));
return new BigDecimal(Math.sqrt(varianceValue.doubleValue()));
}
public Object initialValue() {
return JRBigDecimalIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,28 @@
package net.sf.jasperreports.engine.fill;
import java.math.BigDecimal;
class JRBigDecimalSumIncrementer extends JRAbstractExtendedIncrementer {
private static JRBigDecimalSumIncrementer mainInstance = new JRBigDecimalSumIncrementer();
public static JRBigDecimalSumIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
BigDecimal value = (BigDecimal)variable.getIncrementedValue();
BigDecimal newValue = (BigDecimal)expressionValue;
if (newValue == null) {
if (variable.isInitialized())
return null;
return value;
}
if (value == null || variable.isInitialized())
value = JRBigDecimalIncrementerFactory.ZERO;
return value.add(newValue);
}
public Object initialValue() {
return JRBigDecimalIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,54 @@
package net.sf.jasperreports.engine.fill;
import java.math.BigDecimal;
class JRBigDecimalVarianceIncrementer extends JRAbstractExtendedIncrementer {
private static JRBigDecimalVarianceIncrementer mainInstance = new JRBigDecimalVarianceIncrementer();
public static JRBigDecimalVarianceIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
BigDecimal value = (BigDecimal)variable.getIncrementedValue();
BigDecimal newValue = (BigDecimal)expressionValue;
if (newValue == null) {
if (variable.isInitialized())
return null;
return value;
}
if (value == null || variable.isInitialized())
return JRBigDecimalIncrementerFactory.ZERO;
BigDecimal countValue = (BigDecimal)valueProvider.getValue(variable.getHelperVariable((byte)0));
BigDecimal sumValue = (BigDecimal)valueProvider.getValue(variable.getHelperVariable((byte)1));
return countValue.subtract(JRBigDecimalIncrementerFactory.ONE).multiply(value).divide(countValue, 4).add(sumValue.divide(countValue, 4).subtract(newValue).multiply(sumValue.divide(countValue, 4).subtract(newValue)).divide(countValue.subtract(JRBigDecimalIncrementerFactory.ONE), 4));
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
BigDecimal value = (BigDecimal)calculable.getIncrementedValue();
if (calculableValue.getValue() == null) {
if (calculable.isInitialized())
return null;
return value;
}
if (value == null || calculable.isInitialized())
return calculableValue.getIncrementedValue();
BigDecimal v1 = value;
BigDecimal c1 = (BigDecimal)valueProvider.getValue(calculable.getHelperVariable((byte)0));
BigDecimal s1 = (BigDecimal)valueProvider.getValue(calculable.getHelperVariable((byte)1));
BigDecimal v2 = (BigDecimal)calculableValue.getIncrementedValue();
BigDecimal c2 = (BigDecimal)valueProvider.getValue(calculableValue.getHelperVariable((byte)0));
BigDecimal s2 = (BigDecimal)valueProvider.getValue(calculableValue.getHelperVariable((byte)1));
c1 = c1.subtract(c2);
s1 = s1.subtract(s2);
BigDecimal c = c1.add(c2);
BigDecimal x1 = s1.divide(c, 4);
BigDecimal x2 = s2.divide(c, 4);
BigDecimal x3 = x1.multiply(x2);
return c1.divide(c, 4).multiply(v1).add(c2.divide(c, 4).multiply(v2)).add(c2.divide(c1, 4).multiply(x1).multiply(x1)).add(c1.divide(c2, 4).multiply(x2).multiply(x2)).subtract(x3).subtract(x3);
}
public Object initialValue() {
return JRBigDecimalIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,24 @@
package net.sf.jasperreports.engine.fill;
class JRByteAverageIncrementer extends JRAbstractExtendedIncrementer {
private static JRByteAverageIncrementer mainInstance = new JRByteAverageIncrementer();
public static JRByteAverageIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
if (expressionValue == null) {
if (variable.isInitialized())
return null;
return variable.getValue();
}
Number countValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)0));
Number sumValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)1));
return new Byte((byte)(sumValue.byteValue() / countValue.byteValue()));
}
public Object initialValue() {
return JRByteIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,32 @@
package net.sf.jasperreports.engine.fill;
class JRByteCountIncrementer extends JRAbstractExtendedIncrementer {
private static JRByteCountIncrementer mainInstance = new JRByteCountIncrementer();
public static JRByteCountIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Number value = (Number)variable.getIncrementedValue();
if (value == null || variable.isInitialized())
value = JRByteIncrementerFactory.ZERO;
if (expressionValue == null)
return value;
return new Byte((byte)(value.byteValue() + 1));
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
Number value = (Number)calculable.getIncrementedValue();
Number combineValue = (Number)calculableValue.getValue();
if (value == null || calculable.isInitialized())
value = JRByteIncrementerFactory.ZERO;
if (combineValue == null)
return value;
return new Byte((byte)(value.byteValue() + combineValue.byteValue()));
}
public Object initialValue() {
return JRByteIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,25 @@
package net.sf.jasperreports.engine.fill;
class JRByteDistinctCountIncrementer extends JRAbstractExtendedIncrementer {
private static JRByteDistinctCountIncrementer mainInstance = new JRByteDistinctCountIncrementer();
public static JRByteDistinctCountIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
DistinctCountHolder holder = (DistinctCountHolder)valueProvider.getValue(variable.getHelperVariable((byte)0));
if (variable.isInitialized())
holder.init();
return new Byte((byte)(int)holder.getCount());
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
DistinctCountHolder holder = (DistinctCountHolder)valueProvider.getValue(calculable.getHelperVariable((byte)0));
return new Byte((byte)(int)holder.getCount());
}
public Object initialValue() {
return JRByteIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,41 @@
package net.sf.jasperreports.engine.fill;
public class JRByteIncrementerFactory extends JRAbstractExtendedIncrementerFactory {
protected static final Byte ZERO = new Byte((byte)0);
private static JRByteIncrementerFactory mainInstance = new JRByteIncrementerFactory();
public static JRByteIncrementerFactory getInstance() {
return mainInstance;
}
public JRExtendedIncrementer getExtendedIncrementer(byte calculation) {
JRExtendedIncrementer incrementer = null;
switch (calculation) {
case 1:
incrementer = JRByteCountIncrementer.getInstance();
return incrementer;
case 2:
incrementer = JRByteSumIncrementer.getInstance();
return incrementer;
case 3:
incrementer = JRByteAverageIncrementer.getInstance();
return incrementer;
case 4:
case 5:
incrementer = JRComparableIncrementerFactory.getInstance().getExtendedIncrementer(calculation);
return incrementer;
case 6:
incrementer = JRByteStandardDeviationIncrementer.getInstance();
return incrementer;
case 7:
incrementer = JRByteVarianceIncrementer.getInstance();
return incrementer;
case 10:
incrementer = JRByteDistinctCountIncrementer.getInstance();
return incrementer;
}
incrementer = JRDefaultIncrementerFactory.getInstance().getExtendedIncrementer(calculation);
return incrementer;
}
}

View File

@@ -0,0 +1,23 @@
package net.sf.jasperreports.engine.fill;
class JRByteStandardDeviationIncrementer extends JRAbstractExtendedIncrementer {
private static JRByteStandardDeviationIncrementer mainInstance = new JRByteStandardDeviationIncrementer();
public static JRByteStandardDeviationIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
if (expressionValue == null) {
if (variable.isInitialized())
return null;
return variable.getValue();
}
Number varianceValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)2));
return new Byte((byte)(int)Math.sqrt(varianceValue.doubleValue()));
}
public Object initialValue() {
return JRByteIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,26 @@
package net.sf.jasperreports.engine.fill;
class JRByteSumIncrementer extends JRAbstractExtendedIncrementer {
private static JRByteSumIncrementer mainInstance = new JRByteSumIncrementer();
public static JRByteSumIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Number value = (Number)variable.getIncrementedValue();
Number newValue = (Number)expressionValue;
if (newValue == null) {
if (variable.isInitialized())
return null;
return value;
}
if (value == null || variable.isInitialized())
value = JRByteIncrementerFactory.ZERO;
return new Byte((byte)(value.byteValue() + newValue.byteValue()));
}
public Object initialValue() {
return JRByteIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,49 @@
package net.sf.jasperreports.engine.fill;
class JRByteVarianceIncrementer extends JRAbstractExtendedIncrementer {
private static JRByteVarianceIncrementer mainInstance = new JRByteVarianceIncrementer();
public static JRByteVarianceIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Number value = (Number)variable.getIncrementedValue();
Number newValue = (Number)expressionValue;
if (newValue == null) {
if (variable.isInitialized())
return null;
return value;
}
if (value == null || variable.isInitialized())
return JRByteIncrementerFactory.ZERO;
Number countValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)0));
Number sumValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)1));
return new Byte((byte)((countValue.byteValue() - 1) * value.byteValue() / countValue.byteValue() + (sumValue.byteValue() / countValue.byteValue() - newValue.byteValue()) * (sumValue.byteValue() / countValue.byteValue() - newValue.byteValue()) / (countValue.byteValue() - 1)));
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
Number value = (Number)calculable.getIncrementedValue();
if (calculableValue.getValue() == null) {
if (calculable.isInitialized())
return null;
return value;
}
if (value == null || calculable.isInitialized())
return new Byte(((Number)calculableValue.getIncrementedValue()).byteValue());
float v1 = value.floatValue();
float c1 = ((Number)valueProvider.getValue(calculable.getHelperVariable((byte)0))).floatValue();
float s1 = ((Number)valueProvider.getValue(calculable.getHelperVariable((byte)1))).floatValue();
float v2 = ((Number)calculableValue.getIncrementedValue()).floatValue();
float c2 = ((Number)valueProvider.getValue(calculableValue.getHelperVariable((byte)0))).floatValue();
float s2 = ((Number)valueProvider.getValue(calculableValue.getHelperVariable((byte)1))).floatValue();
c1 -= c2;
s1 -= s2;
float c = c1 + c2;
return new Byte((byte)(int)(c1 / c * v1 + c2 / c * v2 + c2 / c1 * s1 / c * s1 / c + c1 / c2 * s2 / c * s2 / c - 2.0F * s1 / c * s2 / c));
}
public Object initialValue() {
return JRByteIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,21 @@
package net.sf.jasperreports.engine.fill;
public interface JRCalculable {
public static final byte HELPER_COUNT = 0;
public static final byte HELPER_SUM = 1;
public static final byte HELPER_VARIANCE = 2;
public static final int HELPER_SIZE = 3;
boolean isInitialized();
void setInitialized(boolean paramBoolean);
Object getIncrementedValue();
Object getValue();
JRCalculable getHelperVariable(byte paramByte);
}

View File

@@ -0,0 +1,252 @@
package net.sf.jasperreports.engine.fill;
import java.util.Map;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
public class JRCalculator implements JRFillExpressionEvaluator {
protected Map parsm = null;
protected Map fldsm = null;
protected Map varsm = null;
protected JRFillVariable[] variables = null;
protected JRFillGroup[] groups = null;
protected JRFillElementDataset[] datasets = null;
private JRFillVariable pageNumber = null;
private JRFillVariable columnNumber = null;
private final JREvaluator evaluator;
protected JRCalculator(JREvaluator evaluator) {
this.evaluator = evaluator;
}
protected void init(JRFillDataset dataset) throws JRException {
this.parsm = dataset.parametersMap;
this.fldsm = dataset.fieldsMap;
this.varsm = dataset.variablesMap;
this.variables = dataset.variables;
this.groups = dataset.groups;
this.datasets = dataset.elementDatasets;
this.pageNumber = (JRFillVariable)this.varsm.get("PAGE_NUMBER");
this.columnNumber = (JRFillVariable)this.varsm.get("COLUMN_NUMBER");
byte whenResourceMissingType = dataset.getWhenResourceMissingType();
this.evaluator.init(this.parsm, this.fldsm, this.varsm, whenResourceMissingType);
}
public JRFillVariable getPageNumber() {
return this.pageNumber;
}
public JRFillVariable getColumnNumber() {
return this.columnNumber;
}
public void calculateVariables() throws JRException {
if (this.variables != null && this.variables.length > 0)
for (int i = 0; i < this.variables.length; i++) {
JRFillVariable variable = this.variables[i];
Object expressionValue = evaluate(variable.getExpression());
Object newValue = variable.getIncrementer().increment(variable, expressionValue, AbstractValueProvider.getCurrentValueProvider());
variable.setValue(newValue);
variable.setInitialized(false);
if (variable.getIncrementType() == 5)
variable.setIncrementedValue(variable.getValue());
}
if (this.datasets != null && this.datasets.length > 0)
for (int i = 0; i < this.datasets.length; i++) {
JRFillElementDataset elementDataset = this.datasets[i];
elementDataset.evaluate(this);
if (elementDataset.getIncrementType() == 5)
elementDataset.increment();
}
}
public void estimateVariables() throws JRException {
if (this.variables != null && this.variables.length > 0) {
JRFillVariable variable = null;
Object expressionValue = null;
Object newValue = null;
for (int i = 0; i < this.variables.length; i++) {
variable = this.variables[i];
expressionValue = evaluateEstimated(variable.getExpression());
newValue = variable.getIncrementer().increment(variable, expressionValue, AbstractValueProvider.getEstimatedValueProvider());
variable.setEstimatedValue(newValue);
}
}
}
public void estimateGroupRuptures() throws JRException {
JRFillGroup group = null;
Object oldValue = null;
Object estimatedValue = null;
boolean groupHasChanged = false;
boolean isTopLevelChange = false;
if (this.groups != null && this.groups.length > 0)
for (int i = 0; i < this.groups.length; i++) {
group = this.groups[i];
isTopLevelChange = false;
if (!groupHasChanged) {
oldValue = evaluateOld(group.getExpression());
estimatedValue = evaluateEstimated(group.getExpression());
if ((oldValue == null && estimatedValue != null) || (oldValue != null && !oldValue.equals(estimatedValue))) {
groupHasChanged = true;
isTopLevelChange = true;
}
}
group.setHasChanged(groupHasChanged);
group.setTopLevelChange(isTopLevelChange);
}
}
public void initializeVariables(byte resetType) throws JRException {
if (this.variables != null && this.variables.length > 0)
for (int i = 0; i < this.variables.length; i++) {
incrementVariable(this.variables[i], resetType);
initializeVariable(this.variables[i], resetType);
}
if (this.datasets != null && this.datasets.length > 0)
for (int i = 0; i < this.datasets.length; i++) {
incrementDataset(this.datasets[i], resetType);
initializeDataset(this.datasets[i], resetType);
}
}
private void incrementVariable(JRFillVariable variable, byte incrementType) {
if (variable.getIncrementType() != 5) {
boolean toIncrement = false;
switch (incrementType) {
case 1:
toIncrement = true;
break;
case 2:
toIncrement = (variable.getIncrementType() == 2 || variable.getIncrementType() == 3);
break;
case 3:
toIncrement = (variable.getIncrementType() == 3);
break;
case 4:
if (variable.getIncrementType() == 4) {
JRFillGroup group = (JRFillGroup)variable.getIncrementGroup();
toIncrement = group.hasChanged();
}
break;
}
if (toIncrement)
variable.setIncrementedValue(variable.getValue());
} else {
variable.setIncrementedValue(variable.getValue());
}
}
private void incrementDataset(JRFillElementDataset elementDataset, byte incrementType) {
if (elementDataset.getIncrementType() != 5) {
boolean toIncrement = false;
switch (incrementType) {
case 1:
toIncrement = true;
break;
case 2:
toIncrement = (elementDataset.getIncrementType() == 2 || elementDataset.getIncrementType() == 3);
break;
case 3:
toIncrement = (elementDataset.getIncrementType() == 3);
break;
case 4:
if (elementDataset.getIncrementType() == 4) {
JRFillGroup group = (JRFillGroup)elementDataset.getIncrementGroup();
toIncrement = group.hasChanged();
}
break;
}
if (toIncrement)
elementDataset.increment();
}
}
private void initializeVariable(JRFillVariable variable, byte resetType) throws JRException {
if (variable.getResetType() != 5) {
boolean toInitialize = false;
switch (resetType) {
case 1:
toInitialize = true;
break;
case 2:
toInitialize = (variable.getResetType() == 2 || variable.getResetType() == 3);
break;
case 3:
toInitialize = (variable.getResetType() == 3);
break;
case 4:
if (variable.getResetType() == 4) {
JRFillGroup group = (JRFillGroup)variable.getResetGroup();
toInitialize = group.hasChanged();
}
break;
}
if (toInitialize) {
variable.setValue(evaluate(variable.getInitialValueExpression()));
variable.setInitialized(true);
variable.setIncrementedValue(null);
}
} else {
variable.setValue(evaluate(variable.getExpression()));
variable.setIncrementedValue(variable.getValue());
}
}
private void initializeDataset(JRFillElementDataset elementDataset, byte resetType) {
boolean toInitialize = false;
switch (resetType) {
case 1:
toInitialize = true;
break;
case 2:
toInitialize = (elementDataset.getResetType() == 2 || elementDataset.getResetType() == 3);
break;
case 3:
toInitialize = (elementDataset.getResetType() == 3);
break;
case 4:
if (elementDataset.getResetType() == 4) {
JRFillGroup group = (JRFillGroup)elementDataset.getResetGroup();
toInitialize = group.hasChanged();
}
break;
}
if (toInitialize)
elementDataset.initialize();
}
public Object evaluate(JRExpression expression, byte evaluationType) throws JRException {
Object value = null;
switch (evaluationType) {
case 1:
value = evaluateOld(expression);
return value;
case 2:
value = evaluateEstimated(expression);
return value;
}
value = evaluate(expression);
return value;
}
public Object evaluateOld(JRExpression expression) throws JRExpressionEvalException {
return this.evaluator.evaluateOld(expression);
}
public Object evaluateEstimated(JRExpression expression) throws JRExpressionEvalException {
return this.evaluator.evaluateEstimated(expression);
}
public Object evaluate(JRExpression expression) throws JRExpressionEvalException {
return this.evaluator.evaluate(expression);
}
}

View File

@@ -0,0 +1,49 @@
package net.sf.jasperreports.engine.fill;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import net.sf.jasperreports.engine.JRRuntimeException;
public class JRClonePool {
private final JRFillCloneable original;
private final LinkedList availableClones;
private final boolean trackLockedClones;
private final Set lockedClones;
public JRClonePool(JRFillCloneable original, boolean trackLockedClones, boolean useOriginal) {
this.original = original;
this.availableClones = new LinkedList();
this.trackLockedClones = trackLockedClones;
if (trackLockedClones) {
this.lockedClones = new HashSet();
} else {
this.lockedClones = null;
}
if (useOriginal)
this.availableClones.add(original);
}
public Object getClone() {
JRFillCloneable clone;
if (this.availableClones.isEmpty()) {
JRFillCloneFactory factory = new JRFillCloneFactory();
clone = this.original.createClone(factory);
} else {
clone = this.availableClones.removeFirst();
}
if (this.trackLockedClones)
this.lockedClones.add(clone);
return clone;
}
public void releaseClone(Object clone) {
if (this.trackLockedClones)
if (!this.lockedClones.remove(clone))
throw new JRRuntimeException("Cannot release clone.");
this.availableClones.addLast(clone);
}
}

View File

@@ -0,0 +1,21 @@
package net.sf.jasperreports.engine.fill;
class JRComparableHighestIncrementer extends JRAbstractExtendedIncrementer {
private static JRComparableHighestIncrementer mainInstance = new JRComparableHighestIncrementer();
public static JRComparableHighestIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Comparable value = (Comparable)variable.getIncrementedValue();
Comparable newValue = (Comparable)expressionValue;
if (value != null && !variable.isInitialized() && (newValue == null || value.compareTo(newValue) > 0))
newValue = value;
return newValue;
}
public Object initialValue() {
return null;
}
}

View File

@@ -0,0 +1,23 @@
package net.sf.jasperreports.engine.fill;
public class JRComparableIncrementerFactory extends JRAbstractExtendedIncrementerFactory {
private static JRComparableIncrementerFactory mainInstance = new JRComparableIncrementerFactory();
public static JRComparableIncrementerFactory getInstance() {
return mainInstance;
}
public JRExtendedIncrementer getExtendedIncrementer(byte calculation) {
JRExtendedIncrementer incrementer = null;
switch (calculation) {
case 4:
incrementer = JRComparableLowestIncrementer.getInstance();
return incrementer;
case 5:
incrementer = JRComparableHighestIncrementer.getInstance();
return incrementer;
}
incrementer = JRDefaultIncrementerFactory.getInstance().getExtendedIncrementer(calculation);
return incrementer;
}
}

View File

@@ -0,0 +1,21 @@
package net.sf.jasperreports.engine.fill;
class JRComparableLowestIncrementer extends JRAbstractExtendedIncrementer {
private static JRComparableLowestIncrementer mainInstance = new JRComparableLowestIncrementer();
public static JRComparableLowestIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Comparable value = (Comparable)variable.getIncrementedValue();
Comparable newValue = (Comparable)expressionValue;
if (value != null && !variable.isInitialized() && (newValue == null || value.compareTo(newValue) < 0))
newValue = value;
return newValue;
}
public Object initialValue() {
return null;
}
}

View File

@@ -0,0 +1,27 @@
package net.sf.jasperreports.engine.fill;
class JRDefaultFirstIncrementer extends JRAbstractExtendedIncrementer {
private static final JRDefaultFirstIncrementer instance = new JRDefaultFirstIncrementer();
public static JRDefaultFirstIncrementer getInstance() {
return instance;
}
public Object initialValue() {
return null;
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
if (!calculable.isInitialized())
return calculable.getValue();
if (!calculableValue.isInitialized())
return calculableValue.getValue();
return null;
}
public Object increment(JRCalculable calculable, Object expressionValue, AbstractValueProvider valueProvider) {
if (calculable.isInitialized())
return expressionValue;
return calculable.getIncrementedValue();
}
}

View File

@@ -0,0 +1,49 @@
package net.sf.jasperreports.engine.fill;
import java.math.BigDecimal;
public class JRDefaultIncrementerFactory extends JRAbstractExtendedIncrementerFactory {
private static JRDefaultIncrementerFactory mainInstance = new JRDefaultIncrementerFactory();
public static JRDefaultIncrementerFactory getInstance() {
return mainInstance;
}
public JRExtendedIncrementer getExtendedIncrementer(byte calculation) {
JRExtendedIncrementer incrementer = null;
switch (calculation) {
case 8:
incrementer = JRDefaultSystemIncrementer.getInstance();
return incrementer;
case 9:
incrementer = JRDefaultFirstIncrementer.getInstance();
return incrementer;
}
incrementer = JRDefaultNothingIncrementer.getInstance();
return incrementer;
}
public static JRExtendedIncrementerFactory getFactory(Class valueClass) {
JRExtendedIncrementerFactory factory;
if (BigDecimal.class.equals(valueClass)) {
factory = JRBigDecimalIncrementerFactory.getInstance();
} else if (Number.class.equals(valueClass) || Double.class.equals(valueClass)) {
factory = JRDoubleIncrementerFactory.getInstance();
} else if (Float.class.equals(valueClass)) {
factory = JRFloatIncrementerFactory.getInstance();
} else if (Long.class.equals(valueClass)) {
factory = JRLongIncrementerFactory.getInstance();
} else if (Integer.class.equals(valueClass)) {
factory = JRIntegerIncrementerFactory.getInstance();
} else if (Short.class.equals(valueClass)) {
factory = JRShortIncrementerFactory.getInstance();
} else if (Byte.class.equals(valueClass)) {
factory = JRByteIncrementerFactory.getInstance();
} else if (Comparable.class.isAssignableFrom(valueClass)) {
factory = JRComparableIncrementerFactory.getInstance();
} else {
factory = getInstance();
}
return factory;
}
}

View File

@@ -0,0 +1,25 @@
package net.sf.jasperreports.engine.fill;
class JRDefaultNothingIncrementer extends JRAbstractExtendedIncrementer {
private static JRDefaultNothingIncrementer mainInstance = new JRDefaultNothingIncrementer();
public static JRDefaultNothingIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
return expressionValue;
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
if (!calculableValue.isInitialized())
return calculableValue.getValue();
if (!calculable.isInitialized())
return calculable.getValue();
return null;
}
public Object initialValue() {
return null;
}
}

View File

@@ -0,0 +1,21 @@
package net.sf.jasperreports.engine.fill;
class JRDefaultSystemIncrementer extends JRAbstractExtendedIncrementer {
private static JRDefaultSystemIncrementer mainInstance = new JRDefaultSystemIncrementer();
public static JRDefaultSystemIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
return variable.getValue();
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
return calculable.getValue();
}
public Object initialValue() {
return null;
}
}

View File

@@ -0,0 +1,40 @@
package net.sf.jasperreports.engine.fill;
import java.util.HashSet;
import java.util.Set;
class JRDistinctCountExtendedIncrementer extends JRAbstractExtendedIncrementer {
private DistinctCountHolder lastHolder = new DistinctCountHolder();
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
DistinctCountHolder holder = (DistinctCountHolder)variable.getIncrementedValue();
if (holder == null) {
holder = this.lastHolder;
} else {
this.lastHolder = holder;
}
holder.addLastValue();
return new DistinctCountHolder(holder, expressionValue);
}
public Object combine(JRCalculable calculable1, JRCalculable calculable2, AbstractValueProvider valueProvider) {
Set distinctValues = new HashSet();
DistinctCountHolder holder1 = (DistinctCountHolder)calculable1.getValue();
if (holder1 != null) {
distinctValues.addAll(holder1.getDistinctValues());
if (holder1.getLastValue() != null)
distinctValues.add(holder1.getLastValue());
}
DistinctCountHolder holder2 = (DistinctCountHolder)calculable2.getValue();
if (holder2 != null) {
distinctValues.addAll(holder2.getDistinctValues());
if (holder2.getLastValue() != null)
distinctValues.add(holder2.getLastValue());
}
return new DistinctCountHolder(distinctValues);
}
public Object initialValue() {
return null;
}
}

View File

@@ -0,0 +1,17 @@
package net.sf.jasperreports.engine.fill;
public class JRDistinctCountExtendedIncrementerFactory extends JRAbstractExtendedIncrementerFactory {
private static JRDistinctCountExtendedIncrementerFactory mainInstance = new JRDistinctCountExtendedIncrementerFactory();
public static JRDistinctCountExtendedIncrementerFactory getInstance() {
return mainInstance;
}
public JRExtendedIncrementer getExtendedIncrementer(byte calculation) {
return new JRDistinctCountExtendedIncrementer();
}
public static JRExtendedIncrementerFactory getFactory(Class valueClass) {
return getInstance();
}
}

View File

@@ -0,0 +1,24 @@
package net.sf.jasperreports.engine.fill;
class JRDoubleAverageIncrementer extends JRAbstractExtendedIncrementer {
private static JRDoubleAverageIncrementer mainInstance = new JRDoubleAverageIncrementer();
public static JRDoubleAverageIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
if (expressionValue == null) {
if (variable.isInitialized())
return null;
return variable.getValue();
}
Number countValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)0));
Number sumValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)1));
return new Double(sumValue.doubleValue() / countValue.doubleValue());
}
public Object initialValue() {
return JRDoubleIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,32 @@
package net.sf.jasperreports.engine.fill;
class JRDoubleCountIncrementer extends JRAbstractExtendedIncrementer {
private static JRDoubleCountIncrementer mainInstance = new JRDoubleCountIncrementer();
public static JRDoubleCountIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Number value = (Number)variable.getIncrementedValue();
if (value == null || variable.isInitialized())
value = JRDoubleIncrementerFactory.ZERO;
if (expressionValue == null)
return value;
return new Double(value.doubleValue() + 1.0D);
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
Number value = (Number)calculable.getIncrementedValue();
Number combineValue = (Number)calculableValue.getValue();
if (value == null || calculable.isInitialized())
value = JRDoubleIncrementerFactory.ZERO;
if (combineValue == null)
return value;
return new Double(value.doubleValue() + combineValue.doubleValue());
}
public Object initialValue() {
return JRDoubleIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,25 @@
package net.sf.jasperreports.engine.fill;
class JRDoubleDistinctCountIncrementer extends JRAbstractExtendedIncrementer {
private static JRDoubleDistinctCountIncrementer mainInstance = new JRDoubleDistinctCountIncrementer();
public static JRDoubleDistinctCountIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
DistinctCountHolder holder = (DistinctCountHolder)valueProvider.getValue(variable.getHelperVariable((byte)0));
if (variable.isInitialized())
holder.init();
return new Double(holder.getCount());
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
DistinctCountHolder holder = (DistinctCountHolder)valueProvider.getValue(calculable.getHelperVariable((byte)0));
return new Double(holder.getCount());
}
public Object initialValue() {
return JRDoubleIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,41 @@
package net.sf.jasperreports.engine.fill;
public class JRDoubleIncrementerFactory extends JRAbstractExtendedIncrementerFactory {
protected static final Double ZERO = new Double(0.0D);
private static JRDoubleIncrementerFactory mainInstance = new JRDoubleIncrementerFactory();
public static JRDoubleIncrementerFactory getInstance() {
return mainInstance;
}
public JRExtendedIncrementer getExtendedIncrementer(byte calculation) {
JRExtendedIncrementer incrementer = null;
switch (calculation) {
case 1:
incrementer = JRDoubleCountIncrementer.getInstance();
return incrementer;
case 2:
incrementer = JRDoubleSumIncrementer.getInstance();
return incrementer;
case 3:
incrementer = JRDoubleAverageIncrementer.getInstance();
return incrementer;
case 4:
case 5:
incrementer = JRComparableIncrementerFactory.getInstance().getExtendedIncrementer(calculation);
return incrementer;
case 6:
incrementer = JRDoubleStandardDeviationIncrementer.getInstance();
return incrementer;
case 7:
incrementer = JRDoubleVarianceIncrementer.getInstance();
return incrementer;
case 10:
incrementer = JRDoubleDistinctCountIncrementer.getInstance();
return incrementer;
}
incrementer = JRDefaultIncrementerFactory.getInstance().getExtendedIncrementer(calculation);
return incrementer;
}
}

View File

@@ -0,0 +1,23 @@
package net.sf.jasperreports.engine.fill;
class JRDoubleStandardDeviationIncrementer extends JRAbstractExtendedIncrementer {
private static JRDoubleStandardDeviationIncrementer mainInstance = new JRDoubleStandardDeviationIncrementer();
public static JRDoubleStandardDeviationIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
if (expressionValue == null) {
if (variable.isInitialized())
return null;
return variable.getValue();
}
Number varianceValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)2));
return new Double(Math.sqrt(varianceValue.doubleValue()));
}
public Object initialValue() {
return JRDoubleIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,26 @@
package net.sf.jasperreports.engine.fill;
class JRDoubleSumIncrementer extends JRAbstractExtendedIncrementer {
private static JRDoubleSumIncrementer mainInstance = new JRDoubleSumIncrementer();
public static JRDoubleSumIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Number value = (Number)variable.getIncrementedValue();
Number newValue = (Number)expressionValue;
if (newValue == null) {
if (variable.isInitialized())
return null;
return value;
}
if (value == null || variable.isInitialized())
value = JRDoubleIncrementerFactory.ZERO;
return new Double(value.doubleValue() + newValue.doubleValue());
}
public Object initialValue() {
return JRDoubleIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,49 @@
package net.sf.jasperreports.engine.fill;
class JRDoubleVarianceIncrementer extends JRAbstractExtendedIncrementer {
private static JRDoubleVarianceIncrementer mainInstance = new JRDoubleVarianceIncrementer();
public static JRDoubleVarianceIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Number value = (Number)variable.getIncrementedValue();
Number newValue = (Number)expressionValue;
if (newValue == null) {
if (variable.isInitialized())
return null;
return value;
}
if (value == null || variable.isInitialized())
return JRDoubleIncrementerFactory.ZERO;
Number countValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)0));
Number sumValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)1));
return new Double((countValue.doubleValue() - 1.0D) * value.doubleValue() / countValue.doubleValue() + (sumValue.doubleValue() / countValue.doubleValue() - newValue.doubleValue()) * (sumValue.doubleValue() / countValue.doubleValue() - newValue.doubleValue()) / (countValue.doubleValue() - 1.0D));
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
Number value = (Number)calculable.getIncrementedValue();
if (calculableValue.getValue() == null) {
if (calculable.isInitialized())
return null;
return value;
}
if (value == null || calculable.isInitialized())
return new Double(((Number)calculableValue.getIncrementedValue()).doubleValue());
double v1 = value.doubleValue();
double c1 = ((Number)valueProvider.getValue(calculable.getHelperVariable((byte)0))).doubleValue();
double s1 = ((Number)valueProvider.getValue(calculable.getHelperVariable((byte)1))).doubleValue();
double v2 = ((Number)calculableValue.getIncrementedValue()).doubleValue();
double c2 = ((Number)valueProvider.getValue(calculableValue.getHelperVariable((byte)0))).doubleValue();
double s2 = ((Number)valueProvider.getValue(calculableValue.getHelperVariable((byte)1))).doubleValue();
c1 -= c2;
s1 -= s2;
double c = c1 + c2;
return new Double(c1 / c * v1 + c2 / c * v2 + c2 / c1 * s1 / c * s1 / c + c1 / c2 * s2 / c * s2 / c - 2.0D * s1 / c * s2 / c);
}
public Object initialValue() {
return JRDoubleIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,89 @@
package net.sf.jasperreports.engine.fill;
import java.io.Serializable;
import net.sf.jasperreports.engine.JRGroup;
public class JREvaluationTime implements Serializable {
private static final long serialVersionUID = 10200L;
public static final JREvaluationTime EVALUATION_TIME_REPORT = new JREvaluationTime((byte)2, null, null);
public static final JREvaluationTime EVALUATION_TIME_PAGE = new JREvaluationTime((byte)3, null, null);
public static final JREvaluationTime EVALUATION_TIME_COLUMN = new JREvaluationTime((byte)4, null, null);
public static final JREvaluationTime EVALUATION_TIME_NOW = new JREvaluationTime((byte)1, null, null);
private final byte type;
private final String groupName;
private final int bandId;
private final int hash;
public static JREvaluationTime getGroupEvaluationTime(String groupName) {
return new JREvaluationTime((byte)5, groupName, null);
}
public static JREvaluationTime getBandEvaluationTime(JRFillBand band) {
return new JREvaluationTime((byte)6, null, band);
}
public static JREvaluationTime getEvaluationTime(byte type, JRGroup group, JRFillBand band) {
switch (type) {
case 2:
evaluationTime = EVALUATION_TIME_REPORT;
return evaluationTime;
case 3:
evaluationTime = EVALUATION_TIME_PAGE;
return evaluationTime;
case 4:
evaluationTime = EVALUATION_TIME_COLUMN;
return evaluationTime;
case 5:
evaluationTime = getGroupEvaluationTime(group.getName());
return evaluationTime;
case 6:
evaluationTime = getBandEvaluationTime(band);
return evaluationTime;
}
JREvaluationTime evaluationTime = null;
return evaluationTime;
}
private JREvaluationTime(byte type, String groupName, JRFillBand band) {
this.type = type;
this.groupName = groupName;
this.bandId = (band == null) ? 0 : band.getId();
this.hash = computeHash();
}
private int computeHash() {
int hashCode = this.type;
hashCode = 31 * hashCode + ((this.groupName == null) ? 0 : this.groupName.hashCode());
hashCode = 31 * hashCode + this.bandId;
return hashCode;
}
public boolean equals(Object obj) {
if (obj == this)
return true;
JREvaluationTime e = (JREvaluationTime)obj;
boolean eq = (e.type == this.type);
if (eq)
switch (this.type) {
case 5:
eq = this.groupName.equals(e.groupName);
break;
case 6:
eq = (this.bandId == e.bandId);
break;
}
return eq;
}
public int hashCode() {
return this.hash;
}
}

View File

@@ -0,0 +1,129 @@
package net.sf.jasperreports.engine.fill;
import java.text.FieldPosition;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRRuntimeException;
public abstract class JREvaluator {
private JRFillParameter resourceBundle = null;
private byte whenResourceMissingType;
private JRFillParameter locale;
public void init(Map parametersMap, Map fieldsMap, Map variablesMap, byte resourceMissingType) throws JRException {
this.whenResourceMissingType = resourceMissingType;
this.resourceBundle = (JRFillParameter)parametersMap.get("REPORT_RESOURCE_BUNDLE");
this.locale = (JRFillParameter)parametersMap.get("REPORT_LOCALE");
customizedInit(parametersMap, fieldsMap, variablesMap);
}
public String msg(String pattern, Object arg0) {
return getMessageFormat(pattern).format(new Object[] { arg0 }, new StringBuffer(), (FieldPosition)null).toString();
}
public String msg(String pattern, Object arg0, Object arg1) {
return getMessageFormat(pattern).format(new Object[] { arg0, arg1 }, new StringBuffer(), (FieldPosition)null).toString();
}
public String msg(String pattern, Object arg0, Object arg1, Object arg2) {
return getMessageFormat(pattern).format(new Object[] { arg0, arg1, arg2 }, new StringBuffer(), (FieldPosition)null).toString();
}
public String msg(String pattern, Object[] args) {
return getMessageFormat(pattern).format(args, new StringBuffer(), (FieldPosition)null).toString();
}
public String str(String key) {
String str = null;
try {
str = ((ResourceBundle)this.resourceBundle.getValue()).getString(key);
} catch (NullPointerException e) {
str = handleMissingResource(key, e);
} catch (MissingResourceException e) {
str = handleMissingResource(key, e);
}
return str;
}
public Object evaluate(JRExpression expression) throws JRExpressionEvalException {
Object value = null;
if (expression != null)
try {
value = evaluate(expression.getId());
} catch (NullPointerException e) {
} catch (OutOfMemoryError e) {
throw e;
} catch (Throwable e) {
throw new JRExpressionEvalException(expression, e);
}
return value;
}
public Object evaluateOld(JRExpression expression) throws JRExpressionEvalException {
Object value = null;
if (expression != null)
try {
value = evaluateOld(expression.getId());
} catch (NullPointerException e) {
} catch (OutOfMemoryError e) {
throw e;
} catch (Throwable e) {
throw new JRExpressionEvalException(expression, e);
}
return value;
}
public Object evaluateEstimated(JRExpression expression) throws JRExpressionEvalException {
Object value = null;
if (expression != null)
try {
value = evaluateEstimated(expression.getId());
} catch (NullPointerException e) {
} catch (OutOfMemoryError e) {
throw e;
} catch (Throwable e) {
throw new JRExpressionEvalException(expression, e);
}
return value;
}
protected String handleMissingResource(String key, Exception e) throws JRRuntimeException {
switch (this.whenResourceMissingType) {
case 2:
str = "";
return str;
case 3:
str = key;
return str;
case 4:
throw new JRRuntimeException("Resource not found for key \"" + key + "\".", e);
}
String str = null;
return str;
}
protected abstract void customizedInit(Map paramMap1, Map paramMap2, Map paramMap3) throws JRException;
protected abstract Object evaluate(int paramInt) throws Throwable;
protected abstract Object evaluateOld(int paramInt) throws Throwable;
protected abstract Object evaluateEstimated(int paramInt) throws Throwable;
private MessageFormat getMessageFormat(String pattern) {
MessageFormat messageFormat = new MessageFormat("");
messageFormat.setLocale((Locale)this.locale.getValue());
messageFormat.applyPattern(pattern);
return messageFormat;
}
}

View File

@@ -0,0 +1,19 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
public class JRExpressionEvalException extends JRException {
private static final long serialVersionUID = 10200L;
private JRExpression expression = null;
public JRExpressionEvalException(JRExpression expr, Throwable throwable) {
super("Error evaluating expression : \n\tSource text : " + expr.getText(), throwable);
this.expression = expr;
}
public JRExpression getExpression() {
return this.expression;
}
}

View File

@@ -0,0 +1,11 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRException;
public interface JRExtendedIncrementer extends JRIncrementer {
Object increment(JRCalculable paramJRCalculable, Object paramObject, AbstractValueProvider paramAbstractValueProvider) throws JRException;
Object initialValue();
Object combine(JRCalculable paramJRCalculable1, JRCalculable paramJRCalculable2, AbstractValueProvider paramAbstractValueProvider) throws JRException;
}

View File

@@ -0,0 +1,5 @@
package net.sf.jasperreports.engine.fill;
public interface JRExtendedIncrementerFactory extends JRIncrementerFactory {
JRExtendedIncrementer getExtendedIncrementer(byte paramByte);
}

View File

@@ -0,0 +1,231 @@
package net.sf.jasperreports.engine.fill;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import net.sf.jasperreports.engine.JRBand;
import net.sf.jasperreports.engine.JRElementGroup;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRGroup;
import net.sf.jasperreports.engine.JROrigin;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class JRFillBand extends JRFillElementContainer implements JRBand {
private static final Log log = LogFactory.getLog(JRFillBand.class);
private JRBand parent = null;
private boolean isPrintWhenTrue = true;
private boolean isNewPageColumn = false;
private boolean isFirstWholeOnPageColumn = false;
private Map isNewGroupMap = new HashMap();
private Set nowEvaluationTimes;
private Map savedVariableValues = new HashMap();
protected JROrigin origin = null;
protected JRFillBand(JRBaseFiller filler, JRBand band, JRFillObjectFactory factory) {
super(filler, (JRElementGroup)band, factory);
this.parent = band;
if (this.deepElements.length > 0)
for (int i = 0; i < this.deepElements.length; i++)
this.deepElements[i].setBand(this);
initElements();
initConditionalStyles();
this.nowEvaluationTimes = new HashSet();
}
protected JROrigin getOrigin() {
return this.origin;
}
protected void setOrigin(JROrigin origin) {
this.origin = origin;
this.filler.getJasperPrint().addOrigin(origin);
}
protected void setNewPageColumn(boolean isNew) {
this.isNewPageColumn = isNew;
}
protected boolean isNewPageColumn() {
return this.isNewPageColumn;
}
protected boolean isFirstWholeOnPageColumn() {
return this.isFirstWholeOnPageColumn;
}
protected void setNewGroup(JRGroup group, boolean isNew) {
this.isNewGroupMap.put(group, isNew ? Boolean.TRUE : Boolean.FALSE);
}
protected boolean isNewGroup(JRGroup group) {
Boolean value = (Boolean)this.isNewGroupMap.get(group);
if (value == null)
value = Boolean.FALSE;
return value.booleanValue();
}
public int getHeight() {
return (this.parent != null) ? this.parent.getHeight() : 0;
}
public boolean isSplitAllowed() {
return this.parent.isSplitAllowed();
}
public void setSplitAllowed(boolean isSplitAllowed) {}
public JRExpression getPrintWhenExpression() {
return (this.parent != null) ? this.parent.getPrintWhenExpression() : null;
}
protected boolean isPrintWhenExpressionNull() {
return (getPrintWhenExpression() == null);
}
protected boolean isPrintWhenTrue() {
return this.isPrintWhenTrue;
}
protected void setPrintWhenTrue(boolean isPrintWhenTrue) {
this.isPrintWhenTrue = isPrintWhenTrue;
}
protected boolean isToPrint() {
return (isPrintWhenExpressionNull() || (!isPrintWhenExpressionNull() && isPrintWhenTrue()));
}
protected void evaluatePrintWhenExpression(byte evaluation) throws JRException {
boolean isPrintTrue = false;
JRExpression expression = getPrintWhenExpression();
if (expression != null) {
Boolean printWhenExpressionValue = (Boolean)this.filler.evaluateExpression(expression, evaluation);
if (printWhenExpressionValue == null) {
isPrintTrue = false;
} else {
isPrintTrue = printWhenExpressionValue.booleanValue();
}
}
setPrintWhenTrue(isPrintTrue);
}
protected JRPrintBand refill(int availableStretchHeight) throws JRException {
rewind();
restoreSavedVariables();
return fill(availableStretchHeight);
}
protected JRPrintBand fill() throws JRException {
return fill(0, false);
}
protected JRPrintBand fill(int availableStretchHeight) throws JRException {
return fill(availableStretchHeight, true);
}
protected JRPrintBand fill(int availableStretchHeight, boolean isOverflowAllowed) throws JRException {
this.filler.fillContext.ensureMasterPageAvailable();
if (Thread.currentThread().isInterrupted() || this.filler.isInterrupted()) {
if (log.isDebugEnabled())
log.debug("Fill " + this.filler.fillerId + ": interrupted");
this.filler.setInterrupted(true);
throw new JRFillInterruptedException();
}
this.filler.setBandOverFlowAllowed(isOverflowAllowed);
initFill();
if (this.isNewPageColumn && !this.isOverflow)
this.isFirstWholeOnPageColumn = true;
resetElements();
prepareElements(availableStretchHeight, isOverflowAllowed);
stretchElements();
moveBandBottomElements();
removeBlankElements();
this.isFirstWholeOnPageColumn = (this.isNewPageColumn && this.isOverflow);
this.isNewPageColumn = false;
this.isNewGroupMap = new HashMap();
JRPrintBand printBand = new JRPrintBand();
fillElements(printBand);
return printBand;
}
protected int getContainerHeight() {
return getHeight();
}
protected boolean isVariableUsedInSubreportReturns(String variableName) {
boolean used = false;
if (this.deepElements != null)
for (int i = 0; i < this.deepElements.length; i++) {
JRFillElement element = this.deepElements[i];
if (element instanceof JRFillSubreport) {
JRFillSubreport subreport = (JRFillSubreport)element;
if (subreport.usesForReturnValue(variableName)) {
used = true;
break;
}
}
}
return used;
}
protected void addNowEvaluationTime(JREvaluationTime evaluationTime) {
this.nowEvaluationTimes.add(evaluationTime);
}
protected void addNowEvaluationTimes(JREvaluationTime[] evaluationTimes) {
for (int i = 0; i < evaluationTimes.length; i++)
this.nowEvaluationTimes.add(evaluationTimes[i]);
}
protected boolean isNowEvaluationTime(JREvaluationTime evaluationTime) {
return this.nowEvaluationTimes.contains(evaluationTime);
}
protected int getId() {
return System.identityHashCode(this);
}
protected void evaluate(byte evaluation) throws JRException {
resetSavedVariables();
evaluateConditionalStyles(evaluation);
super.evaluate(evaluation);
}
protected void resetSavedVariables() {
this.savedVariableValues.clear();
}
protected void saveVariable(String variableName) {
if (!this.savedVariableValues.containsKey(variableName)) {
Object value = this.filler.getVariableValue(variableName);
this.savedVariableValues.put(variableName, value);
}
}
protected void restoreSavedVariables() {
for (Iterator it = this.savedVariableValues.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = it.next();
String variableName = (String)entry.getKey();
Object value = entry.getValue();
JRFillVariable variable = this.filler.getVariable(variableName);
variable.setOldValue(value);
variable.setValue(value);
variable.setIncrementedValue(value);
}
}
protected boolean isEmpty() {
return (this == this.filler.missingFillBand || (getHeight() == 0 && (getElements() == null || (getElements()).length == 0) && getPrintWhenExpression() == null));
}
}

View File

@@ -0,0 +1,83 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRBreak;
import net.sf.jasperreports.engine.JRElement;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRVisitor;
public class JRFillBreak extends JRFillElement implements JRBreak {
protected JRFillBreak(JRBaseFiller filler, JRBreak breakElement, JRFillObjectFactory factory) {
super(filler, (JRElement)breakElement, factory);
}
protected JRFillBreak(JRFillBreak breakElement, JRFillCloneFactory factory) {
super(breakElement, factory);
}
public int getWidth() {
switch (getType()) {
case 1:
width = this.filler.pageWidth - this.filler.leftMargin - this.filler.rightMargin;
return width;
}
int width = this.filler.columnWidth;
return width;
}
public byte getType() {
return ((JRBreak)this.parent).getType();
}
public void setType(byte type) {}
protected void evaluate(byte evaluation) throws JRException {
reset();
evaluatePrintWhenExpression(evaluation);
evaluateProperties(evaluation);
setValueRepeating(true);
}
protected JRPrintElement fill() {
return null;
}
public void collectExpressions(JRExpressionCollector collector) {
collector.collect(this);
}
public void visit(JRVisitor visitor) {
visitor.visitBreak(this);
}
protected void resolveElement(JRPrintElement element, byte evaluation) {}
public JRFillCloneable createClone(JRFillCloneFactory factory) {
return new JRFillBreak(this, factory);
}
public void rewind() {}
protected boolean prepare(int availableStretchHeight, boolean isOverflow) throws JRException {
super.prepare(availableStretchHeight, isOverflow);
if (!isToPrint())
return false;
boolean isToPrint = true;
if (isOverflow && isAlreadyPrinted())
isToPrint = false;
if (isToPrint && availableStretchHeight < getRelativeY() - getY() - getBandBottomY())
isToPrint = false;
if (isToPrint)
if (getType() == 2) {
if (!this.filler.isFirstColumnBand || this.band.firstYElement != null)
setStretchHeight(getHeight() + availableStretchHeight - getRelativeY() + getY() + getBandBottomY());
} else if (!this.filler.isFirstPageBand || this.band.firstYElement != null) {
setStretchHeight(getHeight() + availableStretchHeight - getRelativeY() + getY() + getBandBottomY());
this.filler.columnIndex = this.filler.columnCount - 1;
}
setToPrint(isToPrint);
setReprinted(false);
return false;
}
}

View File

@@ -0,0 +1,459 @@
package net.sf.jasperreports.engine.fill;
import java.awt.Color;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.sf.jasperreports.crosstabs.JRCellContents;
import net.sf.jasperreports.engine.JRBox;
import net.sf.jasperreports.engine.JRBoxContainer;
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
import net.sf.jasperreports.engine.JRElement;
import net.sf.jasperreports.engine.JRElementGroup;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRFrame;
import net.sf.jasperreports.engine.JRLineBox;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRPrintFrame;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRStyleContainer;
import net.sf.jasperreports.engine.JRStyleSetter;
import net.sf.jasperreports.engine.util.LineBoxWrapper;
import org.apache.commons.collections.ReferenceMap;
public class JRFillCellContents extends JRFillElementContainer implements JRCellContents, JRFillCloneable, JRStyleSetter {
private final Map transformedContentsCache;
private final Map boxContentsCache;
private final JRClonePool clonePool;
private JRFillCellContents original;
private final JRCellContents parentCell;
private JRLineBox lineBox;
private int height;
private int width;
private int x;
private int y;
private int verticalSpan;
private byte verticalPositionType = 1;
private Map templateFrames;
private JRDefaultStyleProvider defaultStyleProvider;
private JRStyle initStyle;
public JRFillCellContents(JRBaseFiller filler, JRCellContents cell, JRFillObjectFactory factory) {
super(filler, (JRElementGroup)cell, factory);
this.defaultStyleProvider = factory.getDefaultStyleProvider();
this.parentCell = cell;
this.lineBox = cell.getLineBox();
this.width = cell.getWidth();
this.height = cell.getHeight();
factory.registerDelayedStyleSetter(this, (JRStyleContainer)this.parentCell);
initElements();
initConditionalStyles();
initTemplatesMap();
this.transformedContentsCache = (Map)new ReferenceMap();
this.boxContentsCache = new HashMap();
this.clonePool = new JRClonePool(this, true, true);
}
private void initTemplatesMap() {
this.templateFrames = new HashMap();
}
protected JRFillCellContents(JRFillCellContents cellContents, JRFillCloneFactory factory) {
super(cellContents, factory);
this.defaultStyleProvider = cellContents.defaultStyleProvider;
this.parentCell = cellContents.parentCell;
this.lineBox = cellContents.lineBox;
this.width = cellContents.width;
this.height = cellContents.height;
this.initStyle = cellContents.initStyle;
initElements();
initConditionalStyles();
this.templateFrames = cellContents.templateFrames;
this.transformedContentsCache = (Map)new ReferenceMap();
this.boxContentsCache = new HashMap();
this.clonePool = new JRClonePool(this, true, true);
this.verticalPositionType = cellContents.verticalPositionType;
}
public Color getBackcolor() {
return this.parentCell.getBackcolor();
}
public JRBox getBox() {
return (JRBox)new LineBoxWrapper(getLineBox());
}
public JRLineBox getLineBox() {
return this.lineBox;
}
protected void setBox(JRLineBox box) {
this.lineBox = box;
initTemplatesMap();
}
public int getHeight() {
return this.height;
}
public int getWidth() {
return this.width;
}
protected void setHeight(int height) {
this.height = height;
}
protected void setWidth(int width) {
this.width = width;
}
public JRFillCellContents getBoxContents(boolean left, boolean right, boolean top) {
if (this.lineBox == null)
return this;
boolean copyLeft = (left && this.lineBox.getLeftPen().getLineWidth().floatValue() <= 0.0F && this.lineBox.getRightPen().getLineWidth().floatValue() > 0.0F);
boolean copyRight = (right && this.lineBox.getRightPen().getLineWidth().floatValue() <= 0.0F && this.lineBox.getLeftPen().getLineWidth().floatValue() > 0.0F);
boolean copyTop = (top && this.lineBox.getTopPen().getLineWidth().floatValue() <= 0.0F && this.lineBox.getBottomPen().getLineWidth().floatValue() > 0.0F);
if (!copyLeft && !copyRight && !copyTop)
return this;
Object key = new BoxContents(copyLeft, copyRight, copyTop);
JRFillCellContents boxContents = (JRFillCellContents)this.boxContentsCache.get(key);
if (boxContents == null) {
boxContents = (JRFillCellContents)createClone();
JRLineBox newBox = this.lineBox.clone((JRBoxContainer)this.parentCell);
if (copyLeft)
newBox.copyLeftPen(this.lineBox.getRightPen());
if (copyRight)
newBox.copyRightPen(this.lineBox.getLeftPen());
if (copyTop)
newBox.copyTopPen(this.lineBox.getBottomPen());
boxContents.setBox(newBox);
this.boxContentsCache.put(key, boxContents);
}
return boxContents;
}
public JRFillCellContents getTransformedContents(int newWidth, int newHeight, byte xPosition, byte yPosition) throws JRException {
if (getHeight() == newHeight && getWidth() == newWidth)
return this;
if (newHeight < getHeight() || newWidth < getWidth())
throw new JRException("Cannot shrink cell contents.");
Object key = new StretchedContents(newWidth, newHeight, xPosition, yPosition);
JRFillCellContents transformedCell = (JRFillCellContents)this.transformedContentsCache.get(key);
if (transformedCell == null) {
transformedCell = (JRFillCellContents)createClone();
transformedCell.transform(newWidth, newHeight, xPosition, yPosition);
transformedCell.setElementsBandBottomY();
this.transformedContentsCache.put(key, transformedCell);
}
return transformedCell;
}
private void transform(int newWidth, int newHeight, byte xPosition, byte yPosition) {
transformElements(newWidth, newHeight, xPosition, yPosition);
this.width = newWidth;
this.height = newHeight;
}
private void transformElements(int newWidth, int newHeight, byte xPosition, byte yPosition) {
if ((this.height == newHeight || yPosition == 1) && (this.width == newWidth || xPosition == 1))
return;
double scaleX = -1.0D;
int offsetX = 0;
switch (xPosition) {
case 2:
offsetX = (newWidth - this.width) / 2;
break;
case 3:
offsetX = newWidth - this.width;
break;
case 4:
scaleX = newWidth / this.width;
break;
}
double scaleY = -1.0D;
int offsetY = 0;
switch (yPosition) {
case 2:
offsetY = (newHeight - this.height) / 2;
break;
case 3:
offsetY = newHeight - this.height;
break;
case 4:
scaleY = newHeight / this.height;
break;
}
transformElements(getElements(), scaleX, offsetX, scaleY, offsetY);
}
private static void transformElements(JRElement[] elements, double scaleX, int offsetX, double scaleY, int offsetY) {
if (elements != null)
for (int i = 0; i < elements.length; i++) {
JRFillElement element = (JRFillElement)elements[i];
if (scaleX != -1.0D) {
element.setX((int)(element.getX() * scaleX));
element.setWidth((int)(element.getWidth() * scaleX));
}
if (offsetX != 0)
element.setX(element.getX() + offsetX);
if (scaleY != -1.0D) {
element.setY((int)(element.getY() * scaleY));
element.setHeight((int)(element.getHeight() * scaleY));
}
if (offsetY != 0)
element.setY(element.getY() + offsetY);
if (element instanceof JRFrame) {
JRElement[] frameElements = ((JRFrame)element).getElements();
transformElements(frameElements, scaleX, offsetX, scaleY, offsetY);
}
}
}
protected void prepare(int availableStretchHeight) throws JRException {
initFill();
resetElements();
prepareElements(availableStretchHeight, true);
}
protected JRPrintFrame fill() throws JRException {
stretchElements();
moveBandBottomElements();
removeBlankElements();
JRTemplatePrintFrame printCell = new JRTemplatePrintFrame(getTemplateFrame());
printCell.setX(this.x);
printCell.setY(this.y);
printCell.setWidth(this.width);
fillElements(printCell);
verticallyPositionElements(printCell);
printCell.setHeight(getPrintHeight());
return printCell;
}
private JRTemplateFrame getTemplateFrame() {
JRStyle style = getStyle();
JRTemplateFrame template = (JRTemplateFrame)this.templateFrames.get(style);
if (template == null) {
template = new JRTemplateFrame(null, this.filler.getJasperPrint().getDefaultStyleProvider(), this);
this.templateFrames.put(style, template);
}
return template;
}
protected void verticallyPositionElements(JRTemplatePrintFrame printCell) {
int positionOffset;
switch (this.verticalPositionType) {
case 2:
positionOffset = (getStretchHeight() - getContainerHeight()) / 2;
break;
case 3:
positionOffset = getStretchHeight() - getContainerHeight();
break;
default:
positionOffset = 0;
break;
}
if (positionOffset != 0) {
List printElements = printCell.getElements();
int positionY = getStretchHeight() - positionOffset;
boolean outside = false;
for (Iterator it = printElements.iterator(); !outside && it.hasNext(); ) {
JRPrintElement element = it.next();
outside = (element.getY() > positionY);
}
if (!outside)
for (Iterator iterator = printElements.iterator(); iterator.hasNext(); ) {
JRPrintElement element = iterator.next();
element.setY(element.getY() + positionOffset);
}
}
}
protected int getPrintHeight() {
return getStretchHeight() + getTopPadding() + getBottomPadding();
}
protected void stretchTo(int stretchHeight) {
setStretchHeight(stretchHeight - getTopPadding() - getBottomPadding());
}
protected static class BoxContents {
final boolean left;
final boolean right;
final boolean top;
final int hashCode;
public BoxContents(boolean left, boolean right, boolean top) {
this.left = left;
this.right = right;
this.top = top;
int hash = left ? 1231 : 1237;
hash = 31 * hash + (right ? 1231 : 1237);
hash = 31 * hash + (top ? 1231 : 1237);
this.hashCode = hash;
}
public boolean equals(Object obj) {
if (obj == this)
return true;
BoxContents b = (BoxContents)obj;
return (b.left == this.left && b.right == this.right && b.top == this.top);
}
public int hashCode() {
return this.hashCode;
}
}
protected static class StretchedContents {
final int newHeight;
final int newWidth;
final int hashCode;
final byte xPosition;
final byte yPosition;
StretchedContents(int newWidth, int newHeight, byte xPosition, byte yPosition) {
this.newHeight = newHeight;
this.newWidth = newWidth;
this.xPosition = xPosition;
this.yPosition = yPosition;
int hash = newHeight;
hash = 31 * hash + newWidth;
hash = 31 * hash + xPosition;
hash = 31 * hash + yPosition;
this.hashCode = hash;
}
public boolean equals(Object o) {
if (o == this)
return true;
StretchedContents s = (StretchedContents)o;
return (s.newHeight == this.newHeight && s.newWidth == this.newWidth && s.xPosition == this.xPosition && s.yPosition == this.yPosition);
}
public int hashCode() {
return this.hashCode;
}
}
protected int getContainerHeight() {
return getHeight() - getTopPadding() - getBottomPadding();
}
protected int getTopPadding() {
return (this.lineBox == null) ? 0 : this.lineBox.getTopPadding().intValue();
}
protected int getBottomPadding() {
return (this.lineBox == null) ? 0 : this.lineBox.getBottomPadding().intValue();
}
public JRFillCloneable createClone() {
JRFillCloneFactory factory = new JRFillCloneFactory();
return createClone(factory);
}
public JRFillCloneable createClone(JRFillCloneFactory factory) {
return new JRFillCellContents(this, factory);
}
public JRFillCellContents getWorkingClone() {
JRFillCellContents clone = (JRFillCellContents)this.clonePool.getClone();
clone.original = this;
return clone;
}
public void releaseWorkingClone() {
this.original.clonePool.releaseClone(this);
}
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
public int getVerticalSpan() {
return this.verticalSpan;
}
public void setVerticalSpan(int span) {
this.verticalSpan = span;
}
public void setVerticalPositionType(byte positionType) {
this.verticalPositionType = positionType;
}
protected void evaluate(byte evaluation) throws JRException {
evaluateConditionalStyles(evaluation);
super.evaluate(evaluation);
}
public JRDefaultStyleProvider getDefaultStyleProvider() {
return this.defaultStyleProvider;
}
public JRStyle getStyle() {
JRStyle crtStyle = this.initStyle;
boolean isUsingDefaultStyle = false;
if (crtStyle == null) {
crtStyle = this.filler.getDefaultStyle();
isUsingDefaultStyle = true;
}
JRStyle evalStyle = getEvaluatedConditionalStyle(crtStyle);
if (isUsingDefaultStyle && evalStyle == crtStyle)
evalStyle = null;
return evalStyle;
}
protected void initConditionalStyles() {
super.initConditionalStyles();
collectConditionalStyle(this.initStyle);
}
public Byte getMode() {
return this.parentCell.getMode();
}
public String getStyleNameReference() {
return null;
}
public void setStyle(JRStyle style) {
this.initStyle = style;
collectConditionalStyle(style);
}
public void setStyleNameReference(String name) {
throw new UnsupportedOperationException("Style name references not allowed at fill time");
}
public Color getDefaultLineColor() {
return this.parentCell.getDefaultLineColor();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRChartDataset;
import net.sf.jasperreports.engine.JRElementDataset;
import org.jfree.data.general.Dataset;
public abstract class JRFillChartDataset extends JRFillElementDataset implements JRChartDataset {
protected JRFillChartDataset(JRChartDataset dataset, JRFillObjectFactory factory) {
super((JRElementDataset)dataset, factory);
}
public Dataset getDataset() {
increment();
return getCustomDataset();
}
public abstract Dataset getCustomDataset();
}

View File

@@ -0,0 +1,77 @@
package net.sf.jasperreports.engine.fill;
import java.awt.Color;
import java.util.Collection;
import java.util.SortedSet;
import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRChartPlot;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRVisitable;
import net.sf.jasperreports.engine.util.JRStyleResolver;
import org.jfree.chart.plot.PlotOrientation;
public class JRFillChartPlot implements JRChartPlot {
protected JRChartPlot parent = null;
protected JRChart chart = null;
protected JRFillChartPlot(JRChartPlot plot, JRFillObjectFactory factory) {
factory.put(plot, this);
this.parent = plot;
this.chart = (JRChart)factory.getVisitResult((JRVisitable)plot.getChart());
}
public JRChart getChart() {
return this.chart;
}
public Color getBackcolor() {
return JRStyleResolver.getBackcolor(this);
}
public Color getOwnBackcolor() {
return this.parent.getOwnBackcolor();
}
public void setBackcolor(Color backcolor) {}
public PlotOrientation getOrientation() {
return this.parent.getOrientation();
}
public void setOrientation(PlotOrientation orientation) {}
public float getBackgroundAlpha() {
return this.parent.getBackgroundAlpha();
}
public void setBackgroundAlpha(float BackgroundAlpha) {}
public float getForegroundAlpha() {
return this.parent.getForegroundAlpha();
}
public void setForegroundAlpha(float foregroundAlpha) {}
public double getLabelRotation() {
return this.parent.getLabelRotation();
}
public void setLabelRotation(double labelRotation) {}
public SortedSet getSeriesColors() {
return this.parent.getSeriesColors();
}
public void clearSeriesColors() {}
public void addSeriesColor(JRChartPlot.JRSeriesColor seriesColor) {}
public void setSeriesColors(Collection colors) {}
public void collectExpressions(JRExpressionCollector collector) {}
public Object clone(JRChart parentChart) {
return null;
}
}

View File

@@ -0,0 +1,28 @@
package net.sf.jasperreports.engine.fill;
import java.util.HashMap;
import java.util.Map;
public class JRFillCloneFactory {
private Map cloneMap = new HashMap();
protected JRFillCloneable getCached(JRFillCloneable original) {
return (JRFillCloneable)this.cloneMap.get(original);
}
public void put(JRFillCloneable original, JRFillCloneable clone) {
this.cloneMap.put(original, clone);
}
public JRFillCloneable getClone(JRFillCloneable original) {
JRFillCloneable clone;
if (original == null) {
clone = null;
} else {
clone = getCached(original);
if (clone == null)
clone = original.createClone(this);
}
return clone;
}
}

View File

@@ -0,0 +1,5 @@
package net.sf.jasperreports.engine.fill;
public interface JRFillCloneable {
JRFillCloneable createClone(JRFillCloneFactory paramJRFillCloneFactory);
}

View File

@@ -0,0 +1,164 @@
package net.sf.jasperreports.engine.fill;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRPrintImage;
import net.sf.jasperreports.engine.JRPrintPage;
import net.sf.jasperreports.engine.JRTemplate;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.query.JRQueryExecuter;
import net.sf.jasperreports.engine.util.FormatFactory;
public class JRFillContext {
private Map loadedImages;
private Map loadedSubreports;
private Map loadedTemplates;
private boolean usingVirtualizer = false;
private boolean perPageBoundElements = false;
private JRPrintPage printPage = null;
private boolean ignorePagination = false;
private JRQueryExecuter queryExecuter;
private JRVirtualizationContext virtualizationContext;
private FormatFactory masterFormatFactory;
private Locale masterLocale;
private TimeZone masterTimeZone;
public JRFillContext() {
this.loadedImages = new HashMap();
this.loadedSubreports = new HashMap();
this.loadedTemplates = new HashMap();
}
public boolean hasLoadedImage(Object source) {
return this.loadedImages.containsKey(source);
}
public JRPrintImage getLoadedImage(Object source) {
return (JRPrintImage)this.loadedImages.get(source);
}
public void registerLoadedImage(Object source, JRPrintImage image) {
this.loadedImages.put(source, image);
if (this.usingVirtualizer)
this.virtualizationContext.cacheRenderer(image);
}
public boolean hasLoadedSubreport(Object source) {
return this.loadedSubreports.containsKey(source);
}
public JasperReport getLoadedSubreport(Object source) {
return (JasperReport)this.loadedSubreports.get(source);
}
public void registerLoadedSubreport(Object source, JasperReport subreport) {
this.loadedSubreports.put(source, subreport);
}
public void setUsingVirtualizer(boolean usingVirtualizer) {
this.usingVirtualizer = usingVirtualizer;
if (usingVirtualizer && this.virtualizationContext == null)
this.virtualizationContext = new JRVirtualizationContext();
}
public boolean isUsingVirtualizer() {
return this.usingVirtualizer;
}
public void setPerPageBoundElements(boolean perPageBoundElements) {
this.perPageBoundElements = perPageBoundElements;
}
public boolean isPerPageBoundElements() {
return this.perPageBoundElements;
}
public void setPrintPage(JRPrintPage page) {
this.printPage = page;
}
public JRPrintPage getPrintPage() {
return this.printPage;
}
public void setIgnorePagination(boolean ignorePagination) {
this.ignorePagination = ignorePagination;
}
public boolean isIgnorePagination() {
return this.ignorePagination;
}
public synchronized void setRunningQueryExecuter(JRQueryExecuter queryExecuter) {
this.queryExecuter = queryExecuter;
}
public synchronized void clearRunningQueryExecuter() {
this.queryExecuter = null;
}
public synchronized boolean cancelRunningQuery() throws JRException {
if (this.queryExecuter != null)
return this.queryExecuter.cancelQuery();
return false;
}
public void ensureMasterPageAvailable() {
if (this.usingVirtualizer)
this.printPage.getElements();
}
public JRVirtualizationContext getVirtualizationContext() {
return this.virtualizationContext;
}
public FormatFactory getMasterFormatFactory() {
return this.masterFormatFactory;
}
public void setMasterFormatFactory(FormatFactory masterFormatFactory) {
this.masterFormatFactory = masterFormatFactory;
}
public Locale getMasterLocale() {
return this.masterLocale;
}
public void setMasterLocale(Locale masterLocale) {
this.masterLocale = masterLocale;
}
public TimeZone getMasterTimeZone() {
return this.masterTimeZone;
}
public void setMasterTimeZone(TimeZone masterTimeZone) {
this.masterTimeZone = masterTimeZone;
}
public boolean hasLoadedTemplate(Object source) {
return this.loadedTemplates.containsKey(source);
}
public JRTemplate getLoadedTemplate(Object source) {
return (JRTemplate)this.loadedTemplates.get(source);
}
public void registerLoadedTemplate(Object source, JRTemplate template) {
this.loadedTemplates.put(source, template);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,653 @@
package net.sf.jasperreports.engine.fill;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.TimeZone;
import net.sf.jasperreports.engine.JRAbstractScriptlet;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRDataset;
import net.sf.jasperreports.engine.JRDefaultScriptlet;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.JRGroup;
import net.sf.jasperreports.engine.JRParameter;
import net.sf.jasperreports.engine.JRPropertiesHolder;
import net.sf.jasperreports.engine.JRPropertiesMap;
import net.sf.jasperreports.engine.JRQuery;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.JRSortField;
import net.sf.jasperreports.engine.JRVariable;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRSortableDataSource;
import net.sf.jasperreports.engine.design.JRDesignVariable;
import net.sf.jasperreports.engine.query.JRQueryExecuter;
import net.sf.jasperreports.engine.query.JRQueryExecuterFactory;
import net.sf.jasperreports.engine.util.JRClassLoader;
import net.sf.jasperreports.engine.util.JRQueryExecuterUtils;
import net.sf.jasperreports.engine.util.JRResourcesUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class JRFillDataset implements JRDataset {
private static final Log log = LogFactory.getLog(JRFillDataset.class);
private final JRBaseFiller filler;
private final JRDataset parent;
private final boolean isMain;
protected JRQuery query = null;
private boolean useDatasourceParamValue = false;
private boolean useConnectionParamValue = false;
protected JRFillParameter[] parameters = null;
protected Map parametersMap = null;
protected JRFillField[] fields = null;
protected Map fieldsMap = null;
protected JRFillVariable[] variables = null;
protected Map variablesMap = null;
protected Set variableCalculationReqs;
protected JRFillElementDataset[] elementDatasets;
protected JRFillElementDataset[] origElementDatasets;
protected JRFillGroup[] groups = null;
protected String resourceBundleBaseName = null;
protected byte whenResourceMissingType;
protected String scriptletClassName = null;
protected JRDataSource dataSource = null;
protected Locale locale = null;
protected ResourceBundle resourceBundle = null;
protected TimeZone timeZone = null;
protected int reportCount = 0;
protected JRCalculator calculator = null;
protected JRAbstractScriptlet scriptlet = null;
protected Integer reportMaxCount = null;
private JRQueryExecuter queryExecuter;
protected JRFillDataset(JRBaseFiller filler, JRDataset dataset, JRFillObjectFactory factory) {
factory.put(dataset, this);
this.filler = filler;
this.parent = dataset;
this.isMain = dataset.isMainDataset();
this.scriptletClassName = dataset.getScriptletClass();
this.resourceBundleBaseName = dataset.getResourceBundle();
this.whenResourceMissingType = dataset.getWhenResourceMissingType();
this.query = dataset.getQuery();
setParameters(dataset, factory);
setFields(dataset, factory);
setVariables(dataset, factory);
setGroups(dataset, factory);
}
private void setParameters(JRDataset dataset, JRFillObjectFactory factory) {
JRParameter[] jrParameters = dataset.getParameters();
if (jrParameters != null && jrParameters.length > 0) {
this.parameters = new JRFillParameter[jrParameters.length];
this.parametersMap = new HashMap();
for (int i = 0; i < this.parameters.length; i++) {
this.parameters[i] = factory.getParameter(jrParameters[i]);
this.parametersMap.put(this.parameters[i].getName(), this.parameters[i]);
}
}
}
private void setGroups(JRDataset dataset, JRFillObjectFactory factory) {
JRGroup[] jrGroups = dataset.getGroups();
if (jrGroups != null && jrGroups.length > 0) {
this.groups = new JRFillGroup[jrGroups.length];
for (int i = 0; i < this.groups.length; i++)
this.groups[i] = factory.getGroup(jrGroups[i]);
}
}
private void setVariables(JRDataset dataset, JRFillObjectFactory factory) {
JRVariable[] jrVariables = dataset.getVariables();
if (jrVariables != null && jrVariables.length > 0) {
List variableList = new ArrayList(jrVariables.length * 3);
this.variablesMap = new HashMap();
for (int i = 0; i < jrVariables.length; i++)
addVariable(jrVariables[i], variableList, factory);
setVariables(variableList);
}
}
private JRFillVariable addVariable(JRVariable parentVariable, List variableList, JRFillObjectFactory factory) {
JRVariable jRVariable1, varianceVar, countVar;
JRFillVariable jRFillVariable1, fillVarianceVar, fillCountVar;
JRVariable sumVar;
JRFillVariable fillSumVar, variable = factory.getVariable(parentVariable);
byte calculation = variable.getCalculation();
switch (calculation) {
case 3:
case 7:
jRVariable1 = createHelperVariable(parentVariable, "_COUNT", (byte)1);
jRFillVariable1 = addVariable(jRVariable1, variableList, factory);
variable.setHelperVariable(jRFillVariable1, (byte)0);
sumVar = createHelperVariable(parentVariable, "_SUM", (byte)2);
fillSumVar = addVariable(sumVar, variableList, factory);
variable.setHelperVariable(fillSumVar, (byte)1);
break;
case 6:
varianceVar = createHelperVariable(parentVariable, "_VARIANCE", (byte)7);
fillVarianceVar = addVariable(varianceVar, variableList, factory);
variable.setHelperVariable(fillVarianceVar, (byte)2);
break;
case 10:
countVar = createDistinctCountHelperVariable(parentVariable);
fillCountVar = addVariable(countVar, variableList, factory);
variable.setHelperVariable(fillCountVar, (byte)0);
break;
}
variableList.add(variable);
return variable;
}
private JRVariable createHelperVariable(JRVariable variable, String nameSuffix, byte calculation) {
JRDesignVariable helper = new JRDesignVariable();
helper.setName(variable.getName() + nameSuffix);
helper.setValueClassName(variable.getValueClassName());
helper.setIncrementerFactoryClassName(variable.getIncrementerFactoryClassName());
helper.setResetType(variable.getResetType());
helper.setResetGroup(variable.getResetGroup());
helper.setIncrementType(variable.getIncrementType());
helper.setIncrementGroup(variable.getIncrementGroup());
helper.setCalculation(calculation);
helper.setSystemDefined(true);
helper.setExpression(variable.getExpression());
return (JRVariable)helper;
}
private JRVariable createDistinctCountHelperVariable(JRVariable variable) {
JRDesignVariable helper = new JRDesignVariable();
helper.setName(variable.getName() + "_DISTINCT_COUNT");
helper.setValueClassName(variable.getValueClassName());
helper.setIncrementerFactoryClassName(JRDistinctCountIncrementerFactory.class.getName());
helper.setResetType((byte)1);
if (variable.getIncrementType() != 5)
helper.setResetType(variable.getIncrementType());
helper.setResetGroup(variable.getIncrementGroup());
helper.setCalculation((byte)0);
helper.setSystemDefined(true);
helper.setExpression(variable.getExpression());
return (JRVariable)helper;
}
private void setVariables(List variableList) {
this.variables = new JRFillVariable[variableList.size()];
this.variables = (JRFillVariable[])variableList.toArray((Object[])this.variables);
for (int i = 0; i < this.variables.length; i++)
this.variablesMap.put(this.variables[i].getName(), this.variables[i]);
}
private void setFields(JRDataset dataset, JRFillObjectFactory factory) {
JRField[] jrFields = dataset.getFields();
if (jrFields != null && jrFields.length > 0) {
this.fields = new JRFillField[jrFields.length];
this.fieldsMap = new HashMap();
for (int i = 0; i < this.fields.length; i++) {
this.fields[i] = factory.getField(jrFields[i]);
this.fieldsMap.put(this.fields[i].getName(), this.fields[i]);
}
}
}
protected void createCalculator(JasperReport jasperReport) throws JRException {
setCalculator(createCalculator(jasperReport, this));
}
protected void setCalculator(JRCalculator calculator) {
this.calculator = calculator;
}
protected static JRCalculator createCalculator(JasperReport jasperReport, JRDataset dataset) throws JRException {
JREvaluator evaluator = JasperCompileManager.loadEvaluator(jasperReport, dataset);
return new JRCalculator(evaluator);
}
protected void initCalculator() throws JRException {
this.calculator.init(this);
}
protected void inheritFromMain() {
if (this.resourceBundleBaseName == null && !this.isMain) {
this.resourceBundleBaseName = this.filler.mainDataset.resourceBundleBaseName;
this.whenResourceMissingType = this.filler.mainDataset.whenResourceMissingType;
}
}
protected JRAbstractScriptlet createScriptlet() throws JRException {
JRDefaultScriptlet jRDefaultScriptlet;
JRAbstractScriptlet tmpScriptlet = null;
if (this.scriptletClassName != null) {
try {
Class scriptletClass = JRClassLoader.loadClassForName(this.scriptletClassName);
tmpScriptlet = scriptletClass.newInstance();
} catch (ClassNotFoundException e) {
throw new JRException("Error loading scriptlet class : " + this.scriptletClassName, e);
} catch (Exception e) {
throw new JRException("Error creating scriptlet class instance : " + this.scriptletClassName, e);
}
} else {
jRDefaultScriptlet = new JRDefaultScriptlet();
}
return (JRAbstractScriptlet)jRDefaultScriptlet;
}
protected void initElementDatasets(JRFillObjectFactory factory) {
this.elementDatasets = factory.getElementDatasets(this);
}
protected void filterElementDatasets(JRFillElementDataset elementDataset) {
this.origElementDatasets = this.elementDatasets;
this.elementDatasets = new JRFillElementDataset[] { elementDataset };
}
protected void restoreElementDatasets() {
if (this.origElementDatasets != null) {
this.elementDatasets = this.origElementDatasets;
this.origElementDatasets = null;
}
}
protected ResourceBundle loadResourceBundle() {
ResourceBundle loadedBundle;
if (this.resourceBundleBaseName == null) {
loadedBundle = null;
} else {
loadedBundle = JRResourcesUtil.loadResourceBundle(this.resourceBundleBaseName, this.locale);
}
return loadedBundle;
}
protected void setParameterValues(Map parameterValues) throws JRException {
parameterValues.put("REPORT_PARAMETERS_MAP", parameterValues);
this.reportMaxCount = (Integer)parameterValues.get("REPORT_MAX_COUNT");
this.locale = (Locale)parameterValues.get("REPORT_LOCALE");
if (this.locale == null) {
this.locale = Locale.getDefault();
parameterValues.put("REPORT_LOCALE", this.locale);
}
this.resourceBundle = (ResourceBundle)parameterValues.get("REPORT_RESOURCE_BUNDLE");
if (this.resourceBundle == null) {
this.resourceBundle = loadResourceBundle();
if (this.resourceBundle != null)
parameterValues.put("REPORT_RESOURCE_BUNDLE", this.resourceBundle);
}
this.timeZone = (TimeZone)parameterValues.get("REPORT_TIME_ZONE");
if (this.timeZone == null) {
this.timeZone = TimeZone.getDefault();
parameterValues.put("REPORT_TIME_ZONE", this.timeZone);
}
this.scriptlet = (JRAbstractScriptlet)parameterValues.get("REPORT_SCRIPTLET");
if (this.scriptlet == null) {
this.scriptlet = createScriptlet();
parameterValues.put("REPORT_SCRIPTLET", this.scriptlet);
}
this.scriptlet.setData(this.parametersMap, this.fieldsMap, this.variablesMap, this.groups);
setFillParameterValues(parameterValues);
}
protected void initDatasource() throws JRException {
this.queryExecuter = null;
this.dataSource = (JRDataSource)getParameterValue("REPORT_DATA_SOURCE");
if (!this.useDatasourceParamValue && (this.useConnectionParamValue || this.dataSource == null)) {
this.dataSource = createQueryDatasource();
setParameter("REPORT_DATA_SOURCE", this.dataSource);
}
JRSortField[] sortFields = getSortFields();
if (sortFields != null && sortFields.length > 0) {
this.dataSource = (JRDataSource)new JRSortableDataSource(this.dataSource, (JRField[])this.fields, sortFields, this.locale);
setParameter("REPORT_DATA_SOURCE", this.dataSource);
}
}
private void setFillParameterValues(Map parameterValues) throws JRException {
if (this.parameters != null && this.parameters.length > 0)
for (int i = 0; i < this.parameters.length; i++) {
Object value = null;
if (parameterValues.containsKey(this.parameters[i].getName())) {
value = parameterValues.get(this.parameters[i].getName());
} else if (!this.parameters[i].isSystemDefined()) {
value = this.calculator.evaluate(this.parameters[i].getDefaultValueExpression(), (byte)3);
if (value != null)
parameterValues.put(this.parameters[i].getName(), value);
}
setParameter(this.parameters[i], value);
}
}
private JRDataSource createQueryDatasource() throws JRException {
if (this.query == null)
return null;
try {
if (log.isDebugEnabled())
log.debug("Fill " + this.filler.fillerId + ": Creating " + this.query.getLanguage() + " query executer");
JRQueryExecuterFactory queryExecuterFactory = JRQueryExecuterUtils.getQueryExecuterFactory(this.query.getLanguage());
this.queryExecuter = queryExecuterFactory.createQueryExecuter(this.parent, this.parametersMap);
this.filler.fillContext.setRunningQueryExecuter(this.queryExecuter);
return this.queryExecuter.createDatasource();
} finally {
this.filler.fillContext.clearRunningQueryExecuter();
}
}
protected void reset() {
this.useDatasourceParamValue = false;
this.useConnectionParamValue = false;
}
protected void setDatasourceParameterValue(Map parameterValues, JRDataSource ds) {
this.useDatasourceParamValue = true;
if (ds != null)
parameterValues.put("REPORT_DATA_SOURCE", ds);
}
protected void setConnectionParameterValue(Map parameterValues, Connection conn) {
this.useConnectionParamValue = true;
if (conn != null)
parameterValues.put("REPORT_CONNECTION", conn);
}
protected void closeDatasource() {
if (this.queryExecuter != null) {
if (log.isDebugEnabled())
log.debug("Fill " + this.filler.fillerId + ": closing query executer");
this.queryExecuter.close();
this.queryExecuter = null;
}
reset();
}
protected void start() {
this.reportCount = 0;
}
protected boolean next() throws JRException {
boolean hasNext = false;
if (this.dataSource != null) {
boolean includeRow = true;
JRExpression filterExpression = getFilterExpression();
do {
hasNext = advanceDataSource();
if (!hasNext)
continue;
setOldValues();
this.calculator.estimateVariables();
if (filterExpression != null) {
Boolean filterExprResult = (Boolean)this.calculator.evaluate(filterExpression, (byte)2);
includeRow = (filterExprResult != null && filterExprResult.booleanValue());
}
if (includeRow)
continue;
revertToOldValues();
} while (hasNext && !includeRow);
if (hasNext)
this.reportCount++;
}
return hasNext;
}
protected void setOldValues() throws JRException {
if (this.fields != null && this.fields.length > 0)
for (int i = 0; i < this.fields.length; i++) {
JRFillField field = this.fields[i];
field.setPreviousOldValue(field.getOldValue());
field.setOldValue(field.getValue());
field.setValue(this.dataSource.getFieldValue(field));
}
if (this.variables != null && this.variables.length > 0)
for (int i = 0; i < this.variables.length; i++) {
JRFillVariable variable = this.variables[i];
variable.setPreviousOldValue(variable.getOldValue());
variable.setOldValue(variable.getValue());
}
}
protected void revertToOldValues() {
if (this.fields != null && this.fields.length > 0)
for (int i = 0; i < this.fields.length; i++) {
JRFillField field = this.fields[i];
field.setValue(field.getOldValue());
field.setOldValue(field.getPreviousOldValue());
}
if (this.variables != null && this.variables.length > 0)
for (int i = 0; i < this.variables.length; i++) {
JRFillVariable variable = this.variables[i];
variable.setValue(variable.getOldValue());
variable.setOldValue(variable.getPreviousOldValue());
}
}
protected boolean advanceDataSource() throws JRException {
boolean hasNext = ((this.reportMaxCount == null || this.reportMaxCount.intValue() > this.reportCount) && this.dataSource.next());
return hasNext;
}
protected void setParameter(String parameterName, Object value) throws JRException {
JRFillParameter parameter = (JRFillParameter)this.parametersMap.get(parameterName);
if (parameter != null)
setParameter(parameter, value);
}
protected void setParameter(JRFillParameter parameter, Object value) throws JRException {
if (value != null) {
if (parameter.getValueClass().isInstance(value)) {
parameter.setValue(value);
} else {
throw new JRException("Incompatible " + value.getClass().getName() + " value assigned to parameter " + parameter.getName() + " in the " + getName() + " dataset.");
}
} else {
parameter.setValue(value);
}
}
public Object getVariableValue(String variableName) {
JRFillVariable var = (JRFillVariable)this.variablesMap.get(variableName);
if (var == null)
throw new JRRuntimeException("No such variable " + variableName);
return var.getValue();
}
public Object getParameterValue(String parameterName) {
return getParameterValue(parameterName, false);
}
public Object getParameterValue(String parameterName, boolean ignoreMissing) {
Object value;
JRFillParameter param = (JRFillParameter)this.parametersMap.get(parameterName);
if (param == null) {
if (!ignoreMissing)
throw new JRRuntimeException("No such parameter " + parameterName);
value = null;
} else {
value = param.getValue();
}
return value;
}
public Object getFieldValue(String fieldName) {
JRFillField var = (JRFillField)this.fieldsMap.get(fieldName);
if (var == null)
throw new JRRuntimeException("No such field " + fieldName);
return var.getValue();
}
protected static class VariableCalculationReq {
String variableName;
byte calculation;
VariableCalculationReq(String variableName, byte calculation) {
this.variableName = variableName;
this.calculation = calculation;
}
public boolean equals(Object o) {
if (o == null || !(o instanceof VariableCalculationReq))
return false;
VariableCalculationReq r = (VariableCalculationReq)o;
return (this.variableName.equals(r.variableName) && this.calculation == r.calculation);
}
public int hashCode() {
return 31 * this.calculation + this.variableName.hashCode();
}
}
protected void addVariableCalculationReq(String variableName, byte calculation) {
if (this.variableCalculationReqs == null)
this.variableCalculationReqs = new HashSet();
this.variableCalculationReqs.add(new VariableCalculationReq(variableName, calculation));
}
protected void checkVariableCalculationReqs(JRFillObjectFactory factory) {
if (this.variableCalculationReqs != null && !this.variableCalculationReqs.isEmpty()) {
List variableList = new ArrayList(this.variables.length * 2);
for (int i = 0; i < this.variables.length; i++) {
JRFillVariable variable = this.variables[i];
checkVariableCalculationReq(variable, variableList, factory);
}
setVariables(variableList);
}
}
private void checkVariableCalculationReq(JRFillVariable variable, List variableList, JRFillObjectFactory factory) {
if (hasVariableCalculationReq(variable, (byte)3) || hasVariableCalculationReq(variable, (byte)7)) {
if (variable.getHelperVariable((byte)0) == null) {
JRVariable countVar = createHelperVariable(variable, "_COUNT", (byte)1);
JRFillVariable fillCountVar = factory.getVariable(countVar);
checkVariableCalculationReq(fillCountVar, variableList, factory);
variable.setHelperVariable(fillCountVar, (byte)0);
}
if (variable.getHelperVariable((byte)1) == null) {
JRVariable sumVar = createHelperVariable(variable, "_SUM", (byte)2);
JRFillVariable fillSumVar = factory.getVariable(sumVar);
checkVariableCalculationReq(fillSumVar, variableList, factory);
variable.setHelperVariable(fillSumVar, (byte)1);
}
}
if (hasVariableCalculationReq(variable, (byte)6))
if (variable.getHelperVariable((byte)2) == null) {
JRVariable varianceVar = createHelperVariable(variable, "_VARIANCE", (byte)7);
JRFillVariable fillVarianceVar = factory.getVariable(varianceVar);
checkVariableCalculationReq(fillVarianceVar, variableList, factory);
variable.setHelperVariable(fillVarianceVar, (byte)2);
}
if (hasVariableCalculationReq(variable, (byte)10))
if (variable.getHelperVariable((byte)0) == null) {
JRVariable countVar = createDistinctCountHelperVariable(variable);
JRFillVariable fillCountVar = factory.getVariable(countVar);
checkVariableCalculationReq(fillCountVar, variableList, factory);
variable.setHelperVariable(fillCountVar, (byte)0);
}
variableList.add(variable);
}
private boolean hasVariableCalculationReq(JRVariable var, byte calculation) {
return this.variableCalculationReqs.contains(new VariableCalculationReq(var.getName(), calculation));
}
public String getName() {
return this.parent.getName();
}
public String getScriptletClass() {
return this.parent.getScriptletClass();
}
public JRParameter[] getParameters() {
return (JRParameter[])this.parameters;
}
public Map getParametersMap() {
return this.parametersMap;
}
public JRQuery getQuery() {
return this.query;
}
public JRField[] getFields() {
return (JRField[])this.fields;
}
public JRSortField[] getSortFields() {
return this.parent.getSortFields();
}
public JRVariable[] getVariables() {
return (JRVariable[])this.variables;
}
public JRGroup[] getGroups() {
return (JRGroup[])this.groups;
}
public boolean isMainDataset() {
return this.isMain;
}
public String getResourceBundle() {
return this.parent.getResourceBundle();
}
public byte getWhenResourceMissingType() {
return this.whenResourceMissingType;
}
public void setWhenResourceMissingType(byte whenResourceMissingType) {
this.whenResourceMissingType = whenResourceMissingType;
}
public boolean hasProperties() {
return this.parent.hasProperties();
}
public JRPropertiesMap getPropertiesMap() {
return this.parent.getPropertiesMap();
}
public JRPropertiesHolder getParentProperties() {
return null;
}
public JRExpression getFilterExpression() {
return this.parent.getFilterExpression();
}
public Object clone() {
return null;
}
}

View File

@@ -0,0 +1,142 @@
package net.sf.jasperreports.engine.fill;
import java.sql.Connection;
import java.util.Map;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRDatasetParameter;
import net.sf.jasperreports.engine.JRDatasetRun;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRQuery;
import net.sf.jasperreports.engine.JRScriptletException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class JRFillDatasetRun implements JRDatasetRun {
private static final Log log = LogFactory.getLog(JRFillDatasetRun.class);
private final JRBaseFiller filler;
private final JRFillDataset dataset;
private JRExpression parametersMapExpression;
private JRDatasetParameter[] parameters;
private JRExpression connectionExpression;
private JRExpression dataSourceExpression;
public JRFillDatasetRun(JRBaseFiller filler, JRDatasetRun datasetRun, JRFillObjectFactory factory) {
factory.put(datasetRun, this);
this.filler = filler;
this.dataset = (JRFillDataset)filler.datasetMap.get(datasetRun.getDatasetName());
this.parametersMapExpression = datasetRun.getParametersMapExpression();
this.parameters = datasetRun.getParameters();
this.connectionExpression = datasetRun.getConnectionExpression();
this.dataSourceExpression = datasetRun.getDataSourceExpression();
}
public void evaluate(JRFillElementDataset elementDataset, byte evaluation) throws JRException {
Map parameterValues = JRFillSubreport.getParameterValues(this.filler, this.parametersMapExpression, this.parameters, evaluation, false, (this.dataset.getResourceBundle() != null), false);
try {
if (this.dataSourceExpression != null) {
JRDataSource dataSource = (JRDataSource)this.filler.evaluateExpression(this.dataSourceExpression, evaluation);
this.dataset.setDatasourceParameterValue(parameterValues, dataSource);
} else if (this.connectionExpression != null) {
Connection connection = (Connection)this.filler.evaluateExpression(this.connectionExpression, evaluation);
this.dataset.setConnectionParameterValue(parameterValues, connection);
}
copyConnectionParameter(parameterValues);
this.dataset.setParameterValues(parameterValues);
this.dataset.initDatasource();
this.dataset.filterElementDatasets(elementDataset);
this.dataset.initCalculator();
iterate();
} finally {
this.dataset.closeDatasource();
this.dataset.restoreElementDatasets();
}
}
protected void copyConnectionParameter(Map parameterValues) {
JRQuery query = this.dataset.getQuery();
if (query != null) {
String language = query.getLanguage();
if (this.connectionExpression == null && (language.equals("sql") || language.equals("SQL")) && !parameterValues.containsKey("REPORT_CONNECTION")) {
JRFillParameter connParam = (JRFillParameter)this.filler.getParametersMap().get("REPORT_CONNECTION");
Connection connection = (Connection)connParam.getValue();
parameterValues.put("REPORT_CONNECTION", connection);
}
}
}
protected void iterate() throws JRException {
this.dataset.start();
init();
if (this.dataset.next()) {
detail();
while (this.dataset.next()) {
checkInterrupted();
group();
detail();
}
}
}
protected void checkInterrupted() {
if (Thread.currentThread().isInterrupted() || this.filler.isInterrupted()) {
if (log.isDebugEnabled())
log.debug("Fill " + this.filler.fillerId + ": interrupting");
this.filler.setInterrupted(true);
throw new JRFillInterruptedException();
}
}
protected void group() throws JRException, JRScriptletException {
this.dataset.calculator.estimateGroupRuptures();
this.dataset.scriptlet.callBeforeGroupInit();
this.dataset.calculator.initializeVariables((byte)4);
this.dataset.scriptlet.callAfterGroupInit();
}
protected void init() throws JRScriptletException, JRException {
this.dataset.scriptlet.callBeforeReportInit();
this.dataset.calculator.initializeVariables((byte)1);
this.dataset.scriptlet.callAfterReportInit();
}
protected void detail() throws JRScriptletException, JRException {
this.dataset.scriptlet.callBeforeDetailEval();
this.dataset.calculator.calculateVariables();
this.dataset.scriptlet.callAfterDetailEval();
}
public String getDatasetName() {
return this.dataset.getName();
}
public JRExpression getParametersMapExpression() {
return this.parametersMapExpression;
}
public JRDatasetParameter[] getParameters() {
return this.parameters;
}
public JRExpression getConnectionExpression() {
return this.connectionExpression;
}
public JRExpression getDataSourceExpression() {
return this.dataSourceExpression;
}
protected JRFillDataset getDataset() {
return this.dataset;
}
public Object clone() {
return null;
}
}

View File

@@ -0,0 +1,717 @@
package net.sf.jasperreports.engine.fill;
import java.awt.Color;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import net.sf.jasperreports.engine.JRCommonElement;
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
import net.sf.jasperreports.engine.JRElement;
import net.sf.jasperreports.engine.JRElementGroup;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRExpressionChunk;
import net.sf.jasperreports.engine.JRGroup;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRPropertiesHolder;
import net.sf.jasperreports.engine.JRPropertiesMap;
import net.sf.jasperreports.engine.JRPropertyExpression;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRStyleContainer;
import net.sf.jasperreports.engine.JRStyleSetter;
import net.sf.jasperreports.engine.JRVisitable;
import net.sf.jasperreports.engine.util.JRProperties;
import net.sf.jasperreports.engine.util.JRStyleResolver;
public abstract class JRFillElement implements JRElement, JRFillCloneable, JRStyleSetter {
protected JRElement parent = null;
protected Map templates = new HashMap();
protected JRBaseFiller filler = null;
protected JRFillExpressionEvaluator expressionEvaluator = null;
protected JRDefaultStyleProvider defaultStyleProvider;
protected JRGroup printWhenGroupChanges = null;
protected JRFillElementGroup elementGroup = null;
protected JRFillBand band = null;
private boolean isPrintWhenExpressionNull = true;
private boolean isPrintWhenTrue = true;
private boolean isToPrint = true;
private boolean isReprinted = false;
private boolean isAlreadyPrinted = false;
private Collection dependantElements = new ArrayList();
private int relativeY = 0;
private int stretchHeight = 0;
private int bandBottomY = 0;
private int x;
private int y;
private int width;
private int height;
private boolean isValueRepeating = false;
protected byte currentEvaluation;
protected Map delayedEvaluationsMap;
protected JRFillElementContainer conditionalStylesContainer;
protected JRStyle initStyle;
private boolean shrinkable;
protected JRPropertiesMap staticProperties;
protected JRPropertiesMap dynamicProperties;
protected JRPropertiesMap mergedProperties;
protected JRFillElement(JRBaseFiller filler, JRElement element, JRFillObjectFactory factory) {
factory.put(element, this);
this.parent = element;
this.filler = filler;
this.expressionEvaluator = factory.getExpressionEvaluator();
this.defaultStyleProvider = factory.getDefaultStyleProvider();
this.printWhenGroupChanges = factory.getGroup(element.getPrintWhenGroupChanges());
this.elementGroup = (JRFillElementGroup)factory.getVisitResult((JRVisitable)element.getElementGroup());
this.x = element.getX();
this.y = element.getY();
this.width = element.getWidth();
this.height = element.getHeight();
this.staticProperties = element.hasProperties() ? element.getPropertiesMap().cloneProperties() : null;
this.mergedProperties = this.staticProperties;
factory.registerDelayedStyleSetter(this, (JRStyleContainer)this.parent);
}
protected JRFillElement(JRFillElement element, JRFillCloneFactory factory) {
factory.put(element, this);
this.parent = element.parent;
this.filler = element.filler;
this.expressionEvaluator = element.expressionEvaluator;
this.defaultStyleProvider = element.defaultStyleProvider;
this.printWhenGroupChanges = element.printWhenGroupChanges;
this.elementGroup = (JRFillElementGroup)factory.getClone((JRFillElementGroup)element.getElementGroup());
this.x = element.getX();
this.y = element.getY();
this.width = element.getWidth();
this.height = element.getHeight();
this.templates = element.templates;
this.initStyle = element.initStyle;
this.shrinkable = element.shrinkable;
this.staticProperties = (element.staticProperties == null) ? null : element.staticProperties.cloneProperties();
this.mergedProperties = this.staticProperties;
}
public JRDefaultStyleProvider getDefaultStyleProvider() {
return this.defaultStyleProvider;
}
public String getKey() {
return this.parent.getKey();
}
public byte getPositionType() {
return this.parent.getPositionType();
}
public void setPositionType(byte positionType) {}
public byte getStretchType() {
return this.parent.getStretchType();
}
public void setStretchType(byte stretchType) {}
public boolean isPrintRepeatedValues() {
return this.parent.isPrintRepeatedValues();
}
public void setPrintRepeatedValues(boolean isPrintRepeatedValues) {}
public byte getMode() {
return JRStyleResolver.getMode((JRCommonElement)this, (byte)1);
}
public Byte getOwnMode() {
return this.parent.getOwnMode();
}
public void setMode(byte mode) {}
public void setMode(Byte mode) {}
public int getX() {
return this.x;
}
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
public int getY() {
return this.y;
}
public int getWidth() {
return this.width;
}
public void setWidth(int width) {
this.width = width;
}
public void setHeight(int height) {
this.height = height;
}
public int getHeight() {
return this.height;
}
public boolean isRemoveLineWhenBlank() {
return this.parent.isRemoveLineWhenBlank();
}
public void setRemoveLineWhenBlank(boolean isRemoveLine) {}
public boolean isPrintInFirstWholeBand() {
return this.parent.isPrintInFirstWholeBand();
}
public void setPrintInFirstWholeBand(boolean isPrint) {}
public boolean isPrintWhenDetailOverflows() {
return this.parent.isPrintWhenDetailOverflows();
}
public void setPrintWhenDetailOverflows(boolean isPrint) {}
public Color getForecolor() {
return JRStyleResolver.getForecolor((JRCommonElement)this);
}
public Color getOwnForecolor() {
return this.parent.getOwnForecolor();
}
public void setForecolor(Color forecolor) {}
public Color getBackcolor() {
return JRStyleResolver.getBackcolor((JRCommonElement)this);
}
public Color getOwnBackcolor() {
return this.parent.getOwnBackcolor();
}
public void setBackcolor(Color backcolor) {}
public JRExpression getPrintWhenExpression() {
return this.parent.getPrintWhenExpression();
}
public JRGroup getPrintWhenGroupChanges() {
return this.printWhenGroupChanges;
}
public JRElementGroup getElementGroup() {
return this.elementGroup;
}
protected boolean isPrintWhenExpressionNull() {
return this.isPrintWhenExpressionNull;
}
protected void setPrintWhenExpressionNull(boolean isPrintWhenExpressionNull) {
this.isPrintWhenExpressionNull = isPrintWhenExpressionNull;
}
protected boolean isPrintWhenTrue() {
return this.isPrintWhenTrue;
}
protected void setPrintWhenTrue(boolean isPrintWhenTrue) {
this.isPrintWhenTrue = isPrintWhenTrue;
}
protected boolean isToPrint() {
return this.isToPrint;
}
protected void setToPrint(boolean isToPrint) {
this.isToPrint = isToPrint;
}
protected boolean isReprinted() {
return this.isReprinted;
}
protected void setReprinted(boolean isReprinted) {
this.isReprinted = isReprinted;
}
protected boolean isAlreadyPrinted() {
return this.isAlreadyPrinted;
}
protected void setAlreadyPrinted(boolean isAlreadyPrinted) {
this.isAlreadyPrinted = isAlreadyPrinted;
}
protected JRElement[] getGroupElements() {
JRElement[] groupElements = null;
if (this.elementGroup != null)
groupElements = this.elementGroup.getElements();
return groupElements;
}
protected Collection getDependantElements() {
return this.dependantElements;
}
protected void addDependantElement(JRElement element) {
this.dependantElements.add(element);
}
protected int getRelativeY() {
return this.relativeY;
}
protected void setRelativeY(int relativeY) {
this.relativeY = relativeY;
}
protected int getStretchHeight() {
return this.stretchHeight;
}
protected void setStretchHeight(int stretchHeight) {
if (stretchHeight > getHeight() || (this.shrinkable && isRemoveLineWhenBlank())) {
this.stretchHeight = stretchHeight;
} else {
this.stretchHeight = getHeight();
}
}
protected int getBandBottomY() {
return this.bandBottomY;
}
protected void setBandBottomY(int bandBottomY) {
this.bandBottomY = bandBottomY;
}
protected JRFillBand getBand() {
return this.band;
}
protected void setBand(JRFillBand band) {
this.band = band;
}
protected void reset() {
this.relativeY = this.y;
this.stretchHeight = this.height;
if (this.elementGroup != null)
this.elementGroup.reset();
}
protected void setCurrentEvaluation(byte evaluation) {
this.currentEvaluation = evaluation;
}
protected abstract void evaluate(byte paramByte) throws JRException;
protected void evaluatePrintWhenExpression(byte evaluation) throws JRException {
boolean isExprNull = true;
boolean isExprTrue = false;
JRExpression expression = getPrintWhenExpression();
if (expression != null) {
isExprNull = false;
Boolean printWhenExpressionValue = (Boolean)evaluateExpression(expression, evaluation);
if (printWhenExpressionValue == null) {
isExprTrue = false;
} else {
isExprTrue = printWhenExpressionValue.booleanValue();
}
}
setPrintWhenExpressionNull(isExprNull);
setPrintWhenTrue(isExprTrue);
}
protected abstract void rewind() throws JRException;
protected abstract JRPrintElement fill() throws JRException;
protected boolean prepare(int availableStretchHeight, boolean isOverflow) throws JRException {
if (isPrintWhenExpressionNull() || (!isPrintWhenExpressionNull() && isPrintWhenTrue())) {
setToPrint(true);
} else {
setToPrint(false);
}
setReprinted(false);
return false;
}
protected void stretchElement(int bandStretch) {
switch (getStretchType()) {
case 2:
setStretchHeight(getHeight() + bandStretch);
break;
case 1:
if (this.elementGroup != null)
setStretchHeight(getHeight() + this.elementGroup.getStretchHeightDiff());
break;
}
}
protected void moveDependantElements() {
Collection elements = getDependantElements();
if (elements != null && elements.size() > 0) {
JRFillElement element = null;
int diffY = 0;
for (Iterator it = elements.iterator(); it.hasNext(); ) {
element = it.next();
diffY = element.getY() - getY() - getHeight() - element.getRelativeY() - getRelativeY() - getStretchHeight();
if (diffY < 0)
diffY = 0;
element.setRelativeY(element.getRelativeY() + diffY);
}
}
}
protected abstract void resolveElement(JRPrintElement paramJRPrintElement, byte paramByte) throws JRException;
protected final Object evaluateExpression(JRExpression expression, byte evaluation) throws JRException {
return this.expressionEvaluator.evaluate(expression, evaluation);
}
protected boolean isValueRepeating() {
return this.isValueRepeating;
}
protected void setValueRepeating(boolean isValueRepeating) {
this.isValueRepeating = isValueRepeating;
}
protected JRFillVariable getVariable(String variableName) {
return this.filler.getVariable(variableName);
}
protected JRFillField getField(String fieldName) {
return this.filler.getField(fieldName);
}
protected byte getEvaluationTime() {
return 1;
}
protected void resolveElement(JRPrintElement element, byte evaluation, JREvaluationTime evaluationTime) throws JRException {
byte evaluationTimeType = getEvaluationTime();
switch (evaluationTimeType) {
case 1:
return;
case 7:
delayedEvaluate((JRRecordedValuesPrintElement)element, evaluationTime, evaluation);
}
resolveElement(element, evaluation);
}
private static class DelayedEvaluations implements Serializable {
private static final long serialVersionUID = 10200L;
final Set fields = new HashSet();
final Set variables = new HashSet();
}
protected void initDelayedEvaluations() {
if (getEvaluationTime() == 7 && this.delayedEvaluationsMap == null) {
this.delayedEvaluationsMap = new HashMap();
collectDelayedEvaluations();
}
}
protected void collectDelayedEvaluations() {}
protected void collectDelayedEvaluations(JRExpression expression) {
if (expression != null) {
JRExpressionChunk[] chunks = expression.getChunks();
if (chunks != null)
for (int i = 0; i < chunks.length; i++) {
DelayedEvaluations delayedEvaluations;
JREvaluationTime time;
DelayedEvaluations delayedEvaluations1;
JRExpressionChunk chunk = chunks[i];
switch (chunk.getType()) {
case 3:
delayedEvaluations = getDelayedEvaluations(JREvaluationTime.EVALUATION_TIME_NOW);
delayedEvaluations.fields.add(chunk.getText());
break;
case 4:
time = autogetVariableEvaluationTime(chunk.getText());
delayedEvaluations1 = getDelayedEvaluations(time);
delayedEvaluations1.variables.add(chunk.getText());
break;
}
}
}
}
private DelayedEvaluations getDelayedEvaluations(JREvaluationTime time) {
DelayedEvaluations delayedEvaluations = (DelayedEvaluations)this.delayedEvaluationsMap.get(time);
if (delayedEvaluations == null) {
delayedEvaluations = new DelayedEvaluations();
this.delayedEvaluationsMap.put(time, delayedEvaluations);
}
return delayedEvaluations;
}
private JREvaluationTime autogetVariableEvaluationTime(String variableName) {
JREvaluationTime evaluationTime;
JRFillVariable variable = getVariable(variableName);
switch (variable.getResetType()) {
case 1:
evaluationTime = JREvaluationTime.EVALUATION_TIME_REPORT;
break;
case 2:
evaluationTime = JREvaluationTime.EVALUATION_TIME_PAGE;
break;
case 3:
evaluationTime = JREvaluationTime.EVALUATION_TIME_COLUMN;
break;
case 4:
evaluationTime = JREvaluationTime.getGroupEvaluationTime(variable.getResetGroup().getName());
break;
default:
evaluationTime = JREvaluationTime.EVALUATION_TIME_NOW;
break;
}
if (!evaluationTime.equals(JREvaluationTime.EVALUATION_TIME_NOW) && this.band.isNowEvaluationTime(evaluationTime))
evaluationTime = JREvaluationTime.EVALUATION_TIME_NOW;
if (variable.getCalculation() == 8 && evaluationTime.equals(JREvaluationTime.EVALUATION_TIME_NOW) && this.band.isVariableUsedInSubreportReturns(variableName))
evaluationTime = JREvaluationTime.getBandEvaluationTime(this.band);
return evaluationTime;
}
protected void initDelayedEvaluationPrint(JRRecordedValuesPrintElement printElement) throws JRException {
for (Iterator it = this.delayedEvaluationsMap.keySet().iterator(); it.hasNext(); ) {
JREvaluationTime evaluationTime = it.next();
if (!evaluationTime.equals(JREvaluationTime.EVALUATION_TIME_NOW))
this.filler.addBoundElement(this, printElement, evaluationTime);
}
printElement.initRecordedValues(this.delayedEvaluationsMap.keySet());
if (this.delayedEvaluationsMap.containsKey(JREvaluationTime.EVALUATION_TIME_NOW))
delayedEvaluate(printElement, JREvaluationTime.EVALUATION_TIME_NOW, this.currentEvaluation);
}
protected void delayedEvaluate(JRRecordedValuesPrintElement printElement, JREvaluationTime evaluationTime, byte evaluation) throws JRException {
JRRecordedValues recordedValues = printElement.getRecordedValues();
if (!recordedValues.lastEvaluationTime()) {
DelayedEvaluations delayedEvaluations = (DelayedEvaluations)this.delayedEvaluationsMap.get(evaluationTime);
for (Iterator iterator1 = delayedEvaluations.fields.iterator(); iterator1.hasNext(); ) {
String fieldName = iterator1.next();
JRFillField field = getField(fieldName);
recordedValues.recordFieldValue(fieldName, field.getValue(evaluation));
}
for (Iterator it = delayedEvaluations.variables.iterator(); it.hasNext(); ) {
String variableName = it.next();
JRFillVariable variable = getVariable(variableName);
recordedValues.recordVariableValue(variableName, variable.getValue(evaluation));
}
}
recordedValues.doneEvaluation(evaluationTime);
if (recordedValues.finishedEvaluations()) {
overwriteWithRecordedValues(recordedValues, evaluation);
resolveElement(printElement, evaluation);
restoreValues(recordedValues, evaluation);
printElement.deleteRecordedValues();
}
}
private void overwriteWithRecordedValues(JRRecordedValues recordedValues, byte evaluation) {
Map fieldValues = recordedValues.getRecordedFieldValues();
if (fieldValues != null)
for (Iterator it = fieldValues.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = it.next();
String fieldName = (String)entry.getKey();
Object fieldValue = entry.getValue();
JRFillField field = getField(fieldName);
field.overwriteValue(fieldValue, evaluation);
}
Map variableValues = recordedValues.getRecordedVariableValues();
if (variableValues != null)
for (Iterator it = variableValues.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = it.next();
String variableName = (String)entry.getKey();
Object variableValue = entry.getValue();
JRFillVariable variable = getVariable(variableName);
variable.overwriteValue(variableValue, evaluation);
}
}
private void restoreValues(JRRecordedValues recordedValues, byte evaluation) {
Map fieldValues = recordedValues.getRecordedFieldValues();
if (fieldValues != null)
for (Iterator it = fieldValues.keySet().iterator(); it.hasNext(); ) {
String fieldName = it.next();
JRFillField field = getField(fieldName);
field.restoreValue(evaluation);
}
Map variableValues = recordedValues.getRecordedVariableValues();
if (variableValues != null)
for (Iterator it = variableValues.keySet().iterator(); it.hasNext(); ) {
String variableName = it.next();
JRFillVariable variable = getVariable(variableName);
variable.restoreValue(evaluation);
}
}
protected void setConditionalStylesContainer(JRFillElementContainer conditionalStylesContainer) {
this.conditionalStylesContainer = conditionalStylesContainer;
}
public JRStyle getStyle() {
JRStyle crtStyle = this.initStyle;
boolean isUsingDefaultStyle = false;
if (crtStyle == null) {
crtStyle = this.filler.getDefaultStyle();
isUsingDefaultStyle = true;
}
JRStyle evalStyle = crtStyle;
if (this.conditionalStylesContainer != null)
evalStyle = this.conditionalStylesContainer.getEvaluatedConditionalStyle(crtStyle);
if (isUsingDefaultStyle && evalStyle == crtStyle)
evalStyle = null;
return evalStyle;
}
protected JRTemplateElement getTemplate(JRStyle style) {
return (JRTemplateElement)this.templates.get(style);
}
protected void registerTemplate(JRStyle style, JRTemplateElement template) {
this.templates.put(style, template);
}
protected final void setShrinkable(boolean shrinkable) {
this.shrinkable = shrinkable;
}
protected void stretchHeightFinal() {}
protected boolean isEvaluateNow() {
switch (getEvaluationTime()) {
case 1:
evaluateNow = true;
return evaluateNow;
case 7:
evaluateNow = isAutoEvaluateNow();
return evaluateNow;
}
boolean evaluateNow = false;
return evaluateNow;
}
protected boolean isAutoEvaluateNow() {
return (this.delayedEvaluationsMap == null || this.delayedEvaluationsMap.isEmpty() || (this.delayedEvaluationsMap.size() == 1 && this.delayedEvaluationsMap.containsKey(JREvaluationTime.EVALUATION_TIME_NOW)));
}
protected boolean isEvaluateAuto() {
return (getEvaluationTime() == 7 && !isAutoEvaluateNow());
}
public String getStyleNameReference() {
return null;
}
public void setStyle(JRStyle style) {
this.initStyle = style;
this.conditionalStylesContainer.collectConditionalStyle(style);
}
public void setStyleNameReference(String name) {
throw new UnsupportedOperationException("Style name references not allowed at fill time");
}
public Object clone() {
return null;
}
public Object clone(JRElementGroup parentGroup) {
return null;
}
public boolean hasProperties() {
return (this.mergedProperties != null && this.mergedProperties.hasProperties());
}
public JRPropertiesMap getPropertiesMap() {
return this.mergedProperties;
}
public JRPropertiesHolder getParentProperties() {
return (JRPropertiesHolder)this.filler.getJasperReport();
}
public JRPropertyExpression[] getPropertyExpressions() {
return this.parent.getPropertyExpressions();
}
protected void transferProperties(JRTemplateElement template) {
JRProperties.transferProperties((JRPropertiesHolder)this.parent, template, "net.sf.jasperreports.print.transfer.");
}
protected void transferProperties(JRPrintElement element) {
JRProperties.transferProperties(this.dynamicProperties, (JRPropertiesHolder)element, "net.sf.jasperreports.print.transfer.");
}
protected JRPropertiesMap getEvaluatedProperties() {
return this.mergedProperties;
}
protected void evaluateProperties(byte evaluation) throws JRException {
JRPropertyExpression[] propExprs = getPropertyExpressions();
if (propExprs == null || propExprs.length == 0) {
this.dynamicProperties = null;
this.mergedProperties = this.staticProperties;
} else {
this.dynamicProperties = new JRPropertiesMap();
for (int i = 0; i < propExprs.length; i++) {
JRPropertyExpression prop = propExprs[i];
String value = (String)evaluateExpression(prop.getValueExpression(), evaluation);
if (value != null)
this.dynamicProperties.setProperty(prop.getName(), value);
}
this.mergedProperties = this.dynamicProperties.cloneProperties();
this.mergedProperties.setBaseProperties(this.staticProperties);
}
}
}

View File

@@ -0,0 +1,434 @@
package net.sf.jasperreports.engine.fill;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sf.jasperreports.engine.JRConditionalStyle;
import net.sf.jasperreports.engine.JRElement;
import net.sf.jasperreports.engine.JRElementGroup;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRFrame;
import net.sf.jasperreports.engine.JROrigin;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRPrintElementContainer;
import net.sf.jasperreports.engine.JRReportFont;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.base.JRBaseStyle;
import net.sf.jasperreports.engine.util.JRStyleResolver;
public abstract class JRFillElementContainer extends JRFillElementGroup {
protected JRBaseFiller filler;
private JRFillElement[] ySortedElements = null;
private JRFillElement[] stretchElements = null;
private JRFillElement[] bandBottomElements = null;
private JRFillElement[] removableElements = null;
private boolean willOverflow = false;
protected boolean isOverflow = false;
private int stretchHeight = 0;
private int firstY = 0;
protected JRFillElement firstYElement = null;
protected final JRFillExpressionEvaluator expressionEvaluator;
protected JRFillElement[] deepElements;
protected Set stylesToEvaluate = new HashSet();
protected Map evaluatedStyles = new HashMap();
protected boolean hasPrintWhenOverflowElement;
protected JRFillElementContainer(JRBaseFiller filler, JRElementGroup container, JRFillObjectFactory factory) {
super(container, factory);
this.expressionEvaluator = factory.getExpressionEvaluator();
initDeepElements();
this.filler = filler;
}
protected JRFillElementContainer(JRFillElementContainer container, JRFillCloneFactory factory) {
super(container, factory);
this.expressionEvaluator = container.expressionEvaluator;
initDeepElements();
this.filler = container.filler;
}
private void initDeepElements() {
if (this.elements == null) {
this.deepElements = new JRFillElement[0];
} else {
List deepElementsList = new ArrayList(this.elements.length);
collectDeepElements((JRElement[])this.elements, deepElementsList);
this.deepElements = new JRFillElement[deepElementsList.size()];
deepElementsList.toArray((Object[])this.deepElements);
}
}
private static void collectDeepElements(JRElement[] elements, List deepElementsList) {
for (int i = 0; i < elements.length; i++) {
JRElement element = elements[i];
deepElementsList.add(element);
if (element instanceof JRFillFrame) {
JRFrame frame = (JRFrame)element;
collectDeepElements(frame.getElements(), deepElementsList);
}
}
}
protected final void initElements() {
this.hasPrintWhenOverflowElement = false;
if (this.elements != null && this.elements.length > 0) {
List sortedElemsList = new ArrayList();
List stretchElemsList = new ArrayList();
List bandBottomElemsList = new ArrayList();
List removableElemsList = new ArrayList();
for (int i = 0; i < this.elements.length; i++) {
JRFillElement element = this.elements[i];
sortedElemsList.add(element);
if (element.getPositionType() == 3)
bandBottomElemsList.add(element);
if (element.getStretchType() != 0)
stretchElemsList.add(element);
if (element.isRemoveLineWhenBlank())
removableElemsList.add(element);
if (element.isPrintWhenDetailOverflows())
this.hasPrintWhenOverflowElement = true;
}
Collections.sort(sortedElemsList, new JRYComparator());
this.ySortedElements = new JRFillElement[this.elements.length];
sortedElemsList.toArray(this.ySortedElements);
this.stretchElements = new JRFillElement[stretchElemsList.size()];
stretchElemsList.toArray(this.stretchElements);
this.bandBottomElements = new JRFillElement[bandBottomElemsList.size()];
bandBottomElemsList.toArray(this.bandBottomElements);
this.removableElements = new JRFillElement[removableElemsList.size()];
removableElemsList.toArray(this.removableElements);
}
setDependentElements();
setElementsBandBottomY();
}
protected final void setElementsBandBottomY() {
if (this.elements != null && this.elements.length > 0)
for (int i = 0; i < this.elements.length; i++)
this.elements[i].setBandBottomY(getContainerHeight() - this.elements[i].getY() - this.elements[i].getHeight());
}
private void setDependentElements() {
if (this.ySortedElements != null && this.ySortedElements.length > 0)
for (int i = 0; i < this.ySortedElements.length - 1; i++) {
JRFillElement iElem = this.ySortedElements[i];
boolean isBreakElem = iElem instanceof JRFillBreak;
for (int j = i + 1; j < this.ySortedElements.length; j++) {
JRFillElement jElem = this.ySortedElements[j];
int left = Math.min(iElem.getX(), jElem.getX());
int right = Math.max(iElem.getX() + iElem.getWidth(), jElem.getX() + jElem.getWidth());
if (((isBreakElem && jElem.getPositionType() == 2) || jElem.getPositionType() == 1) && iElem.getY() + iElem.getHeight() <= jElem.getY() && iElem.getWidth() + jElem.getWidth() > right - left)
iElem.addDependantElement(jElem);
}
}
}
protected void evaluate(byte evaluation) throws JRException {
JRElement[] allElements = getElements();
if (allElements != null && allElements.length > 0)
for (int i = 0; i < allElements.length; i++) {
JRFillElement element = (JRFillElement)allElements[i];
element.setCurrentEvaluation(evaluation);
element.evaluate(evaluation);
}
}
protected void resetElements() {
if (this.ySortedElements != null && this.ySortedElements.length > 0)
for (int i = 0; i < this.ySortedElements.length; i++) {
JRFillElement element = this.ySortedElements[i];
element.reset();
if (!this.isOverflow)
element.setAlreadyPrinted(false);
}
}
protected boolean willOverflow() {
return this.willOverflow;
}
protected void initFill() {
this.isOverflow = this.willOverflow;
this.firstY = 0;
this.firstYElement = null;
}
protected void prepareElements(int availableStretchHeight, boolean isOverflowAllowed) throws JRException {
boolean tmpWillOverflow = false;
int maxBandStretch = 0;
int bandStretch = 0;
this.firstY = this.isOverflow ? getContainerHeight() : 0;
this.firstYElement = null;
boolean isFirstYFound = false;
if (this.ySortedElements != null && this.ySortedElements.length > 0)
for (int i = 0; i < this.ySortedElements.length; i++) {
JRFillElement element = this.ySortedElements[i];
tmpWillOverflow = (element.prepare(availableStretchHeight + getElementFirstY(element), this.isOverflow) || tmpWillOverflow);
element.moveDependantElements();
if (element.isToPrint()) {
if (this.isOverflow) {
if (element.isReprinted()) {
this.firstY = 0;
} else if (!isFirstYFound) {
this.firstY = element.getY();
}
isFirstYFound = true;
}
this.firstYElement = element;
bandStretch = element.getRelativeY() + element.getStretchHeight() - getContainerHeight() + element.getBandBottomY();
if (bandStretch > maxBandStretch)
maxBandStretch = bandStretch;
}
}
if (maxBandStretch > availableStretchHeight + this.firstY)
tmpWillOverflow = true;
if (tmpWillOverflow) {
this.stretchHeight = getContainerHeight() + availableStretchHeight;
} else {
this.stretchHeight = getContainerHeight() + maxBandStretch;
}
this.willOverflow = (tmpWillOverflow && isOverflowAllowed);
}
private int getElementFirstY(JRFillElement element) {
int elemFirstY;
if (!this.isOverflow || this.hasPrintWhenOverflowElement) {
elemFirstY = 0;
} else if (element.getY() >= this.firstY) {
elemFirstY = this.firstY;
} else {
elemFirstY = element.getY();
}
return elemFirstY;
}
protected void setStretchHeight(int stretchHeight) {
if (stretchHeight > this.stretchHeight)
this.stretchHeight = stretchHeight;
}
protected void stretchElements() {
if (this.stretchElements != null && this.stretchElements.length > 0)
for (int i = 0; i < this.stretchElements.length; i++) {
JRFillElement element = this.stretchElements[i];
element.stretchElement(this.stretchHeight - getContainerHeight());
element.moveDependantElements();
}
if (this.ySortedElements != null && this.ySortedElements.length > 0)
for (int i = 0; i < this.ySortedElements.length; i++) {
JRFillElement element = this.ySortedElements[i];
element.stretchHeightFinal();
}
}
protected int getStretchHeight() {
return this.stretchHeight;
}
protected void moveBandBottomElements() {
if (this.bandBottomElements != null && this.bandBottomElements.length > 0)
for (int i = 0; i < this.bandBottomElements.length; i++) {
JRFillElement element = this.bandBottomElements[i];
element.setRelativeY(element.getY() + this.stretchHeight - getContainerHeight());
element.setToPrint((element.isToPrint() && !this.willOverflow));
}
}
protected void removeBlankElements() {
JRFillElement[] arrayOfJRFillElement = this.removableElements;
if (arrayOfJRFillElement != null && arrayOfJRFillElement.length > 0) {
JRFillElement[] arrayOfJRFillElement1 = this.ySortedElements;
for (int i = 0; i < arrayOfJRFillElement.length; i++) {
int blankHeight;
JRFillElement iElem = arrayOfJRFillElement[i];
if (iElem.isToPrint()) {
blankHeight = iElem.getHeight() - iElem.getStretchHeight();
} else {
blankHeight = iElem.getHeight();
}
if (blankHeight > 0 && iElem.getRelativeY() + iElem.getStretchHeight() <= this.stretchHeight && iElem.getRelativeY() >= this.firstY) {
int blankY = iElem.getRelativeY() + iElem.getHeight() - blankHeight;
boolean isToRemove = true;
int j;
for (j = 0; j < arrayOfJRFillElement1.length; j++) {
JRFillElement jElem = arrayOfJRFillElement1[j];
if (iElem != jElem && jElem.isToPrint()) {
int top = Math.min(blankY, jElem.getRelativeY());
int bottom = Math.max(blankY + blankHeight, jElem.getRelativeY() + jElem.getStretchHeight());
if (blankHeight + jElem.getStretchHeight() > bottom - top) {
isToRemove = false;
break;
}
}
}
if (isToRemove) {
for (j = 0; j < arrayOfJRFillElement1.length; j++) {
JRFillElement jElem = arrayOfJRFillElement1[j];
if (jElem.getRelativeY() >= blankY + blankHeight)
jElem.setRelativeY(jElem.getRelativeY() - blankHeight);
}
this.stretchHeight -= blankHeight;
}
}
}
}
}
protected void fillElements(JRPrintElementContainer printContainer) throws JRException {
JRElement[] allElements = getElements();
if (allElements != null && allElements.length > 0)
for (int i = 0; i < allElements.length; i++) {
JRFillElement element = (JRFillElement)allElements[i];
element.setRelativeY(element.getRelativeY() - this.firstY);
if (element.getRelativeY() + element.getStretchHeight() > this.stretchHeight)
element.setToPrint(false);
element.setAlreadyPrinted((element.isToPrint() || element.isAlreadyPrinted()));
if (element.isToPrint()) {
JRPrintElement printElement = element.fill();
if (printElement != null) {
printContainer.addElement(printElement);
if (element instanceof JRFillSubreport) {
JRFillSubreport subreport = (JRFillSubreport)element;
List fonts = subreport.subreportFiller.getJasperPrint().getFontsList();
for (int j = 0; j < fonts.size(); j++)
this.filler.getJasperPrint().addFont(fonts.get(j), true);
List styles = subreport.subreportFiller.getJasperPrint().getStylesList();
for (int k = 0; k < styles.size(); k++)
this.filler.addPrintStyle(styles.get(k));
List origins = subreport.subreportFiller.getJasperPrint().getOriginsList();
for (int m = 0; m < origins.size(); m++)
this.filler.getJasperPrint().addOrigin(origins.get(m));
Collection printElements = subreport.getPrintElements();
addSubElements(printContainer, element, printElements);
} else if (element instanceof JRFillCrosstab) {
List printElements = ((JRFillCrosstab)element).getPrintElements();
addSubElements(printContainer, element, printElements);
}
}
}
}
printContainer.setHeight(this.stretchHeight - this.firstY);
}
protected void addSubElements(JRPrintElementContainer printContainer, JRFillElement element, Collection printElements) {
if (printElements != null && printElements.size() > 0)
for (Iterator it = printElements.iterator(); it.hasNext(); ) {
JRPrintElement printElement = it.next();
printElement.setX(element.getX() + printElement.getX());
printElement.setY(element.getRelativeY() + printElement.getY());
printContainer.addElement(printElement);
}
}
protected void rewind() throws JRException {
if (this.ySortedElements != null && this.ySortedElements.length > 0)
for (int i = 0; i < this.ySortedElements.length; i++) {
JRFillElement element = this.ySortedElements[i];
element.rewind();
element.setAlreadyPrinted(false);
}
this.willOverflow = false;
}
protected int getFirstY() {
return this.firstY;
}
protected abstract int getContainerHeight();
protected void initConditionalStyles() {
this.filler.addDefaultStyleListener(new JRBaseFiller.DefaultStyleListener() {
private final JRFillElementContainer this$0;
public void defaultStyleSet(JRStyle style) {
JRFillElementContainer.this.collectConditionalStyle(style);
}
});
int i;
for (i = 0; i < this.deepElements.length; i++) {
JRStyle style = (this.deepElements[i]).initStyle;
collectConditionalStyle(style);
}
if (this.deepElements.length > 0)
for (i = 0; i < this.deepElements.length; i++)
this.deepElements[i].setConditionalStylesContainer(this);
}
protected void collectConditionalStyle(JRStyle style) {
if (style != null)
this.stylesToEvaluate.add(style);
}
protected void evaluateConditionalStyles(byte evaluation) throws JRException {
for (Iterator it = this.stylesToEvaluate.iterator(); it.hasNext();)
evaluateConditionalStyle(it.next(), evaluation);
}
protected JRStyle evaluateConditionalStyle(JRStyle initialStyle, byte evaluation) throws JRException {
JRBaseStyle jRBaseStyle;
JRStyle consolidatedStyle = initialStyle;
StringBuffer code = new StringBuffer();
List condStylesToApply = new ArrayList();
boolean anyTrue = buildConsolidatedStyle(initialStyle, evaluation, code, condStylesToApply);
if (anyTrue) {
String consolidatedStyleName = initialStyle.getName() + code.toString();
consolidatedStyle = (JRStyle)this.filler.getJasperPrint().getStylesMap().get(consolidatedStyleName);
if (consolidatedStyle == null) {
jRBaseStyle = new JRBaseStyle(consolidatedStyleName);
for (int j = condStylesToApply.size() - 1; j >= 0; j--)
JRStyleResolver.appendStyle((JRStyle)jRBaseStyle, condStylesToApply.get(j));
this.filler.addPrintStyle((JRStyle)jRBaseStyle);
}
}
this.evaluatedStyles.put(initialStyle, jRBaseStyle);
return (JRStyle)jRBaseStyle;
}
protected boolean buildConsolidatedStyle(JRStyle style, byte evaluation, StringBuffer code, List condStylesToApply) throws JRException {
boolean anyTrue = false;
JRConditionalStyle[] conditionalStyles = style.getConditionalStyles();
if (conditionalStyles != null && conditionalStyles.length > 0)
for (int j = 0; j < conditionalStyles.length; j++) {
boolean condition;
JRConditionalStyle conditionalStyle = conditionalStyles[j];
Boolean expressionValue = (Boolean)this.expressionEvaluator.evaluate(conditionalStyle.getConditionExpression(), evaluation);
if (expressionValue == null) {
condition = false;
} else {
condition = expressionValue.booleanValue();
}
code.append(condition ? 49 : 48);
anyTrue |= condition;
if (condition)
condStylesToApply.add(conditionalStyle);
}
condStylesToApply.add(style);
if (style.getStyle() != null)
anyTrue |= buildConsolidatedStyle(style.getStyle(), evaluation, code, condStylesToApply);
return anyTrue;
}
public JRStyle getEvaluatedConditionalStyle(JRStyle parentStyle) {
return (JRStyle)this.evaluatedStyles.get(parentStyle);
}
}

View File

@@ -0,0 +1,115 @@
package net.sf.jasperreports.engine.fill;
import java.util.TimeZone;
import net.sf.jasperreports.engine.JRDatasetRun;
import net.sf.jasperreports.engine.JRElementDataset;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRGroup;
public abstract class JRFillElementDataset implements JRElementDataset {
protected JRElementDataset parent = null;
private final JRBaseFiller filler;
protected JRGroup resetGroup = null;
protected JRGroup incrementGroup = null;
private boolean isIncremented = true;
protected JRFillDatasetRun datasetRun;
private boolean increment = false;
protected JRFillElementDataset(JRElementDataset dataset, JRFillObjectFactory factory) {
factory.put(dataset, this);
this.parent = dataset;
this.filler = factory.getFiller();
this.resetGroup = factory.getGroup(dataset.getResetGroup());
this.incrementGroup = factory.getGroup(dataset.getIncrementGroup());
this.datasetRun = factory.getDatasetRun(dataset.getDatasetRun());
}
public byte getResetType() {
return this.parent.getResetType();
}
public byte getIncrementType() {
return this.parent.getIncrementType();
}
public JRGroup getResetGroup() {
return this.resetGroup;
}
public JRGroup getIncrementGroup() {
return this.incrementGroup;
}
protected TimeZone getTimeZone() {
return this.filler.getTimeZone();
}
protected void initialize() {
customInitialize();
this.isIncremented = false;
this.increment = false;
}
protected void evaluate(JRCalculator calculator) throws JRExpressionEvalException {
evaluateIncrementWhenExpression(calculator);
if (this.increment)
customEvaluate(calculator);
this.isIncremented = false;
}
protected void evaluateIncrementWhenExpression(JRCalculator calculator) throws JRExpressionEvalException {
JRExpression incrementWhenExpression = getIncrementWhenExpression();
if (incrementWhenExpression == null) {
this.increment = true;
} else {
Boolean evaluated = (Boolean)calculator.evaluate(incrementWhenExpression);
this.increment = (evaluated != null && evaluated.booleanValue());
}
}
protected void increment() {
if (!this.isIncremented && this.increment)
customIncrement();
this.isIncremented = true;
}
protected abstract void customInitialize();
protected abstract void customEvaluate(JRCalculator paramJRCalculator) throws JRExpressionEvalException;
protected abstract void customIncrement();
public JRDatasetRun getDatasetRun() {
return this.datasetRun;
}
public void evaluateDatasetRun(byte evaluation) throws JRException {
if (this.datasetRun != null)
this.datasetRun.evaluate(this, evaluation);
}
public JRFillDataset getInputDataset() {
JRFillDataset inputDataset;
if (this.datasetRun != null) {
inputDataset = this.datasetRun.getDataset();
} else {
inputDataset = this.filler.mainDataset;
}
return inputDataset;
}
public JRExpression getIncrementWhenExpression() {
return this.parent.getIncrementWhenExpression();
}
public Object clone() {
return null;
}
}

View File

@@ -0,0 +1,143 @@
package net.sf.jasperreports.engine.fill;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.sf.jasperreports.engine.JRChild;
import net.sf.jasperreports.engine.JRElement;
import net.sf.jasperreports.engine.JRElementGroup;
import net.sf.jasperreports.engine.JRVisitable;
import net.sf.jasperreports.engine.JRVisitor;
public class JRFillElementGroup implements JRElementGroup, JRFillCloneable {
protected List children = new ArrayList();
protected JRElementGroup elementGroup = null;
protected JRFillElement[] elements = null;
private JRElement topElementInGroup = null;
private JRElement bottomElementInGroup = null;
private int stretchHeightDiff = 0;
protected JRFillElementGroup(JRElementGroup elementGrp, JRFillObjectFactory factory) {
factory.put(elementGrp, this);
if (elementGrp != null) {
List list = elementGrp.getChildren();
if (list != null && list.size() > 0)
for (int i = 0; i < list.size(); i++) {
JRChild child = list.get(i);
child = (JRChild)factory.getVisitResult((JRVisitable)child);
this.children.add(child);
}
getElements();
this.elementGroup = (JRElementGroup)factory.getVisitResult((JRVisitable)elementGrp.getElementGroup());
}
}
protected JRFillElementGroup(JRFillElementGroup elementGrp, JRFillCloneFactory factory) {
factory.put(elementGrp, this);
List list = elementGrp.getChildren();
if (list != null)
for (int i = 0; i < list.size(); i++) {
JRFillCloneable child = list.get(i);
JRFillCloneable clone = child.createClone(factory);
this.children.add(clone);
}
getElements();
this.elementGroup = (JRFillElementGroup)factory.getClone((JRFillElementGroup)elementGrp.getElementGroup());
}
public List getChildren() {
return this.children;
}
public JRElementGroup getElementGroup() {
return this.elementGroup;
}
public JRElement[] getElements() {
if (this.elements == null)
if (this.children != null) {
List allElements = new ArrayList();
Object child = null;
JRElement[] childElementArray = null;
for (int i = 0; i < this.children.size(); i++) {
child = this.children.get(i);
if (child instanceof JRFillElement) {
allElements.add(child);
} else if (child instanceof JRFillElementGroup) {
childElementArray = ((JRFillElementGroup)child).getElements();
if (childElementArray != null)
allElements.addAll(Arrays.asList((Object[])childElementArray));
}
}
this.elements = new JRFillElement[allElements.size()];
allElements.toArray(this.elements);
}
return (JRElement[])this.elements;
}
public JRElement getElementByKey(String key) {
return null;
}
protected void reset() {
this.topElementInGroup = null;
}
protected int getStretchHeightDiff() {
if (this.topElementInGroup == null) {
this.stretchHeightDiff = 0;
setTopBottomElements();
JRElement[] allElements = getElements();
if (allElements != null && allElements.length > 0) {
JRFillElement topElem = null;
JRFillElement bottomElem = null;
for (int i = 0; i < allElements.length; i++) {
JRFillElement element = (JRFillElement)allElements[i];
if (element.isToPrint()) {
if (topElem == null || (topElem != null && element.getRelativeY() + element.getStretchHeight() < topElem.getRelativeY() + topElem.getStretchHeight()))
topElem = element;
if (bottomElem == null || (bottomElem != null && element.getRelativeY() + element.getStretchHeight() > bottomElem.getRelativeY() + bottomElem.getStretchHeight()))
bottomElem = element;
}
}
if (topElem != null)
this.stretchHeightDiff = bottomElem.getRelativeY() + bottomElem.getStretchHeight() - topElem.getRelativeY() - this.bottomElementInGroup.getY() + this.bottomElementInGroup.getHeight() - this.topElementInGroup.getY();
if (this.stretchHeightDiff < 0)
this.stretchHeightDiff = 0;
}
}
return this.stretchHeightDiff;
}
private void setTopBottomElements() {
JRElement[] allElements = getElements();
if (allElements != null && allElements.length > 0)
for (int i = 0; i < allElements.length; i++) {
if (this.topElementInGroup == null || (this.topElementInGroup != null && allElements[i].getY() + allElements[i].getHeight() < this.topElementInGroup.getY() + this.topElementInGroup.getHeight()))
this.topElementInGroup = allElements[i];
if (this.bottomElementInGroup == null || (this.bottomElementInGroup != null && allElements[i].getY() + allElements[i].getHeight() > this.bottomElementInGroup.getY() + this.bottomElementInGroup.getHeight()))
this.bottomElementInGroup = allElements[i];
}
}
public void visit(JRVisitor visitor) {
visitor.visitElementGroup(this);
}
public JRFillCloneable createClone(JRFillCloneFactory factory) {
return new JRFillElementGroup(this, factory);
}
public Object clone() {
return null;
}
public Object clone(JRElementGroup parentGroup) {
return null;
}
}

View File

@@ -0,0 +1,61 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JREllipse;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRGraphicElement;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRVisitor;
public class JRFillEllipse extends JRFillGraphicElement implements JREllipse {
protected JRFillEllipse(JRBaseFiller filler, JREllipse ellipse, JRFillObjectFactory factory) {
super(filler, (JRGraphicElement)ellipse, factory);
}
protected JRFillEllipse(JRFillEllipse ellipse, JRFillCloneFactory factory) {
super(ellipse, factory);
}
protected JRTemplateEllipse getJRTemplateEllipse() {
JRStyle style = getStyle();
JRTemplateEllipse template = (JRTemplateEllipse)getTemplate(style);
if (template == null) {
template = new JRTemplateEllipse((this.band == null) ? null : this.band.getOrigin(), this.filler.getJasperPrint().getDefaultStyleProvider(), this);
transferProperties(template);
registerTemplate(style, template);
}
return template;
}
protected void evaluate(byte evaluation) throws JRException {
reset();
evaluatePrintWhenExpression(evaluation);
evaluateProperties(evaluation);
setValueRepeating(true);
}
protected JRPrintElement fill() {
JRTemplatePrintEllipse printEllipse = new JRTemplatePrintEllipse(getJRTemplateEllipse());
printEllipse.setX(getX());
printEllipse.setY(getRelativeY());
printEllipse.setWidth(getWidth());
printEllipse.setHeight(getStretchHeight());
transferProperties(printEllipse);
return printEllipse;
}
public void collectExpressions(JRExpressionCollector collector) {
collector.collect(this);
}
public void visit(JRVisitor visitor) {
visitor.visitEllipse(this);
}
protected void resolveElement(JRPrintElement element, byte evaluation) {}
public JRFillCloneable createClone(JRFillCloneFactory factory) {
return new JRFillEllipse(this, factory);
}
}

View File

@@ -0,0 +1,8 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
public interface JRFillExpressionEvaluator {
Object evaluate(JRExpression paramJRExpression, byte paramByte) throws JRException;
}

View File

@@ -0,0 +1,113 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.JRPropertiesHolder;
import net.sf.jasperreports.engine.JRPropertiesMap;
public class JRFillField implements JRField {
protected JRField parent = null;
private Object previousOldValue = null;
private Object oldValue = null;
private Object value = null;
private Object savedValue;
protected JRFillField(JRField field, JRFillObjectFactory factory) {
factory.put(field, this);
this.parent = field;
}
public String getName() {
return this.parent.getName();
}
public String getDescription() {
return this.parent.getDescription();
}
public void setDescription(String description) {}
public Class getValueClass() {
return this.parent.getValueClass();
}
public String getValueClassName() {
return this.parent.getValueClassName();
}
public Object getOldValue() {
return this.oldValue;
}
public void setOldValue(Object oldValue) {
this.oldValue = oldValue;
}
public Object getValue() {
return this.value;
}
public void setValue(Object value) {
this.value = value;
}
public Object getValue(byte evaluation) {
switch (evaluation) {
case 1:
returnValue = this.oldValue;
return returnValue;
}
Object returnValue = this.value;
return returnValue;
}
public void overwriteValue(Object newValue, byte evaluation) {
switch (evaluation) {
case 1:
this.savedValue = this.oldValue;
this.oldValue = newValue;
return;
}
this.savedValue = this.value;
this.value = newValue;
}
public void restoreValue(byte evaluation) {
switch (evaluation) {
case 1:
this.oldValue = this.savedValue;
break;
default:
this.value = this.savedValue;
break;
}
this.savedValue = null;
}
public Object getPreviousOldValue() {
return this.previousOldValue;
}
public void setPreviousOldValue(Object previousOldValue) {
this.previousOldValue = previousOldValue;
}
public boolean hasProperties() {
return this.parent.hasProperties();
}
public JRPropertiesMap getPropertiesMap() {
return this.parent.getPropertiesMap();
}
public JRPropertiesHolder getParentProperties() {
return null;
}
public Object clone() {
return null;
}
}

View File

@@ -0,0 +1,463 @@
package net.sf.jasperreports.engine.fill;
import java.awt.Color;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.jasperreports.engine.JRBoxContainer;
import net.sf.jasperreports.engine.JRCommonElement;
import net.sf.jasperreports.engine.JRElement;
import net.sf.jasperreports.engine.JRElementGroup;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRFrame;
import net.sf.jasperreports.engine.JRLineBox;
import net.sf.jasperreports.engine.JRPen;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRVisitor;
import net.sf.jasperreports.engine.base.JRBaseElementGroup;
import net.sf.jasperreports.engine.util.JRBoxUtil;
import net.sf.jasperreports.engine.util.JRPenUtil;
import net.sf.jasperreports.engine.util.JRStyleResolver;
public class JRFillFrame extends JRFillElement implements JRFrame {
protected final JRFrame parentFrame;
private JRFillFrameElements frameContainer;
private Map bottomTemplateFrames;
private Map topTemplateFrames;
private Map topBottomTemplateFrames;
private boolean first;
private boolean fillBottomBorder;
private boolean filling;
public JRFillFrame(JRBaseFiller filler, JRFrame frame, JRFillObjectFactory factory) {
super(filler, (JRElement)frame, factory);
this.parentFrame = frame;
this.frameContainer = new JRFillFrameElements(factory);
this.bottomTemplateFrames = new HashMap();
this.topTemplateFrames = new HashMap();
this.topBottomTemplateFrames = new HashMap();
setShrinkable(true);
}
protected JRFillFrame(JRFillFrame frame, JRFillCloneFactory factory) {
super(frame, factory);
this.parentFrame = frame.parentFrame;
this.frameContainer = new JRFillFrameElements(frame.frameContainer, factory);
this.bottomTemplateFrames = frame.bottomTemplateFrames;
this.topTemplateFrames = frame.topTemplateFrames;
this.topBottomTemplateFrames = frame.topBottomTemplateFrames;
}
public byte getMode() {
return JRStyleResolver.getMode((JRCommonElement)this, (byte)2);
}
public Color getDefaultLineColor() {
return getForecolor();
}
protected void evaluate(byte evaluation) throws JRException {
reset();
evaluatePrintWhenExpression(evaluation);
evaluateProperties(evaluation);
if (isPrintWhenExpressionNull() || isPrintWhenTrue()) {
this.frameContainer.evaluate(evaluation);
boolean repeating = true;
JRFillElement[] elements = (JRFillElement[])getElements();
for (int i = 0; repeating && i < elements.length; i++)
repeating &= elements[i].isValueRepeating();
setValueRepeating(repeating);
}
this.filling = false;
}
protected void rewind() throws JRException {
this.frameContainer.rewind();
this.filling = false;
}
protected boolean prepare(int availableStretchHeight, boolean isOverflow) throws JRException {
super.prepare(availableStretchHeight, isOverflow);
if (!isToPrint())
return false;
this.first = (!isOverflow || !this.filling);
int topPadding = this.first ? getLineBox().getTopPadding().intValue() : 0;
int bottomPadding = getLineBox().getBottomPadding().intValue();
if (availableStretchHeight < getRelativeY() - getY() - getBandBottomY() - topPadding) {
setToPrint(false);
return true;
}
if (!this.filling && !isPrintRepeatedValues() && isValueRepeating() && (!isPrintInFirstWholeBand() || !getBand().isFirstWholeOnPageColumn()) && (getPrintWhenGroupChanges() == null || !getBand().isNewGroup(getPrintWhenGroupChanges())) && (!isOverflow || !isPrintWhenDetailOverflows())) {
setToPrint(false);
return false;
}
if (!this.filling && isOverflow && isAlreadyPrinted())
if (isPrintWhenDetailOverflows()) {
rewind();
setReprinted(true);
} else {
setToPrint(false);
return false;
}
int stretchHeight = availableStretchHeight - getRelativeY() + getY() + getBandBottomY();
this.frameContainer.initFill();
this.frameContainer.resetElements();
int frameElemsAvailableHeight = stretchHeight + bottomPadding + getLineBox().getTopPadding().intValue() - topPadding;
this.frameContainer.prepareElements(frameElemsAvailableHeight, true);
boolean willOverflow = this.frameContainer.willOverflow();
if (willOverflow) {
this.fillBottomBorder = false;
setStretchHeight(getHeight() + stretchHeight);
} else {
int neededStretch = this.frameContainer.getStretchHeight() - this.frameContainer.getFirstY() + topPadding + bottomPadding;
if (neededStretch <= getHeight() + stretchHeight) {
this.fillBottomBorder = true;
setStretchHeight(neededStretch);
} else {
this.fillBottomBorder = false;
setStretchHeight(getHeight() + stretchHeight);
}
}
this.filling = willOverflow;
return willOverflow;
}
protected void setStretchHeight(int stretchHeight) {
super.setStretchHeight(stretchHeight);
int topPadding = this.first ? getLineBox().getTopPadding().intValue() : 0;
int bottomPadding = this.fillBottomBorder ? getLineBox().getBottomPadding().intValue() : 0;
this.frameContainer.setStretchHeight(stretchHeight + this.frameContainer.getFirstY() - topPadding - bottomPadding);
}
protected void stretchHeightFinal() {
this.frameContainer.stretchElements();
this.frameContainer.moveBandBottomElements();
this.frameContainer.removeBlankElements();
int topPadding = this.first ? getLineBox().getTopPadding().intValue() : 0;
int bottomPadding = this.fillBottomBorder ? getLineBox().getBottomPadding().intValue() : 0;
super.setStretchHeight(this.frameContainer.getStretchHeight() - this.frameContainer.getFirstY() + topPadding + bottomPadding);
}
protected JRPrintElement fill() throws JRException {
JRTemplatePrintFrame printFrame = new JRTemplatePrintFrame(getTemplate());
printFrame.setX(getX());
printFrame.setY(getRelativeY());
printFrame.setWidth(getWidth());
this.frameContainer.fillElements(printFrame);
printFrame.setHeight(getStretchHeight());
transferProperties(printFrame);
return printFrame;
}
protected JRTemplateFrame getTemplate() {
Map templatesMap;
JRStyle style = getStyle();
if (this.first) {
if (this.fillBottomBorder) {
templatesMap = this.templates;
} else {
templatesMap = this.bottomTemplateFrames;
}
} else if (this.fillBottomBorder) {
templatesMap = this.topTemplateFrames;
} else {
templatesMap = this.topBottomTemplateFrames;
}
JRTemplateFrame boxTemplate = (JRTemplateFrame)templatesMap.get(style);
if (boxTemplate == null) {
boxTemplate = new JRTemplateFrame((this.band == null) ? null : this.band.getOrigin(), this.filler.getJasperPrint().getDefaultStyleProvider(), this);
transferProperties(boxTemplate);
if (this.first) {
if (!this.fillBottomBorder) {
boxTemplate.copyBox(getLineBox());
JRBoxUtil.reset(boxTemplate.getLineBox(), false, false, false, true);
}
} else if (this.fillBottomBorder) {
boxTemplate.copyBox(getLineBox());
JRBoxUtil.reset(boxTemplate.getLineBox(), false, false, true, false);
} else {
boxTemplate.copyBox(getLineBox());
JRBoxUtil.reset(boxTemplate.getLineBox(), false, false, true, true);
}
templatesMap.put(style, boxTemplate);
}
return boxTemplate;
}
protected void resolveElement(JRPrintElement element, byte evaluation) {}
public JRElement[] getElements() {
return this.frameContainer.getElements();
}
public List getChildren() {
return this.frameContainer.getChildren();
}
public void collectExpressions(JRExpressionCollector collector) {
collector.collect(this);
}
public JRLineBox getLineBox() {
return ((JRBoxContainer)this.parent).getLineBox();
}
public byte getBorder() {
return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getPen());
}
public Byte getOwnBorder() {
return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getPen());
}
public void setBorder(byte border) {
JRPenUtil.setLinePenFromPen(border, (JRPen)getLineBox().getPen());
}
public void setBorder(Byte border) {
JRPenUtil.setLinePenFromPen(border, (JRPen)getLineBox().getPen());
}
public Color getBorderColor() {
return getLineBox().getPen().getLineColor();
}
public Color getOwnBorderColor() {
return getLineBox().getPen().getOwnLineColor();
}
public void setBorderColor(Color borderColor) {
getLineBox().getPen().setLineColor(borderColor);
}
public int getPadding() {
return getLineBox().getPadding().intValue();
}
public Integer getOwnPadding() {
return getLineBox().getOwnPadding();
}
public void setPadding(int padding) {
getLineBox().setPadding(padding);
}
public void setPadding(Integer padding) {
getLineBox().setPadding(padding);
}
public byte getTopBorder() {
return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getTopPen());
}
public Byte getOwnTopBorder() {
return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getTopPen());
}
public void setTopBorder(byte topBorder) {
JRPenUtil.setLinePenFromPen(topBorder, (JRPen)getLineBox().getTopPen());
}
public void setTopBorder(Byte topBorder) {
JRPenUtil.setLinePenFromPen(topBorder, (JRPen)getLineBox().getTopPen());
}
public Color getTopBorderColor() {
return getLineBox().getTopPen().getLineColor();
}
public Color getOwnTopBorderColor() {
return getLineBox().getTopPen().getOwnLineColor();
}
public void setTopBorderColor(Color topBorderColor) {
getLineBox().getTopPen().setLineColor(topBorderColor);
}
public int getTopPadding() {
return getLineBox().getTopPadding().intValue();
}
public Integer getOwnTopPadding() {
return getLineBox().getOwnTopPadding();
}
public void setTopPadding(int topPadding) {
getLineBox().setTopPadding(topPadding);
}
public void setTopPadding(Integer topPadding) {
getLineBox().setTopPadding(topPadding);
}
public byte getLeftBorder() {
return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getLeftPen());
}
public Byte getOwnLeftBorder() {
return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getLeftPen());
}
public void setLeftBorder(byte leftBorder) {
JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)getLineBox().getLeftPen());
}
public void setLeftBorder(Byte leftBorder) {
JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)getLineBox().getLeftPen());
}
public Color getLeftBorderColor() {
return getLineBox().getLeftPen().getLineColor();
}
public Color getOwnLeftBorderColor() {
return getLineBox().getLeftPen().getOwnLineColor();
}
public void setLeftBorderColor(Color leftBorderColor) {
getLineBox().getLeftPen().setLineColor(leftBorderColor);
}
public int getLeftPadding() {
return getLineBox().getLeftPadding().intValue();
}
public Integer getOwnLeftPadding() {
return getLineBox().getOwnLeftPadding();
}
public void setLeftPadding(int leftPadding) {
getLineBox().setLeftPadding(leftPadding);
}
public void setLeftPadding(Integer leftPadding) {
getLineBox().setLeftPadding(leftPadding);
}
public byte getBottomBorder() {
return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getBottomPen());
}
public Byte getOwnBottomBorder() {
return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getBottomPen());
}
public void setBottomBorder(byte bottomBorder) {
JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)getLineBox().getBottomPen());
}
public void setBottomBorder(Byte bottomBorder) {
JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)getLineBox().getBottomPen());
}
public Color getBottomBorderColor() {
return getLineBox().getBottomPen().getLineColor();
}
public Color getOwnBottomBorderColor() {
return getLineBox().getBottomPen().getOwnLineColor();
}
public void setBottomBorderColor(Color bottomBorderColor) {
getLineBox().getBottomPen().setLineColor(bottomBorderColor);
}
public int getBottomPadding() {
return getLineBox().getBottomPadding().intValue();
}
public Integer getOwnBottomPadding() {
return getLineBox().getOwnBottomPadding();
}
public void setBottomPadding(int bottomPadding) {
getLineBox().setBottomPadding(bottomPadding);
}
public void setBottomPadding(Integer bottomPadding) {
getLineBox().setBottomPadding(bottomPadding);
}
public byte getRightBorder() {
return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getRightPen());
}
public Byte getOwnRightBorder() {
return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getRightPen());
}
public void setRightBorder(byte rightBorder) {
JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)getLineBox().getRightPen());
}
public void setRightBorder(Byte rightBorder) {
JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)getLineBox().getRightPen());
}
public Color getRightBorderColor() {
return getLineBox().getRightPen().getLineColor();
}
public Color getOwnRightBorderColor() {
return getLineBox().getRightPen().getOwnLineColor();
}
public void setRightBorderColor(Color rightBorderColor) {
getLineBox().getRightPen().setLineColor(rightBorderColor);
}
public int getRightPadding() {
return getLineBox().getRightPadding().intValue();
}
public Integer getOwnRightPadding() {
return getLineBox().getOwnRightPadding();
}
public void setRightPadding(int rightPadding) {
getLineBox().setRightPadding(rightPadding);
}
public void setRightPadding(Integer rightPadding) {
getLineBox().setRightPadding(rightPadding);
}
public void visit(JRVisitor visitor) {
visitor.visitFrame(this);
}
public JRElement getElementByKey(String key) {
return JRBaseElementGroup.getElementByKey(getElements(), key);
}
public JRFillCloneable createClone(JRFillCloneFactory factory) {
return new JRFillFrame(this, factory);
}
protected class JRFillFrameElements extends JRFillElementContainer {
private final JRFillFrame this$0;
JRFillFrameElements(JRFillObjectFactory factory) {
super(JRFillFrame.this.filler, (JRElementGroup)JRFillFrame.this.parentFrame, factory);
initElements();
}
JRFillFrameElements(JRFillFrameElements frameElements, JRFillCloneFactory factory) {
super(frameElements, factory);
initElements();
}
protected int getContainerHeight() {
return JRFillFrame.this.getHeight() - JRFillFrame.this.getLineBox().getTopPadding().intValue() - JRFillFrame.this.getLineBox().getBottomPadding().intValue();
}
}
}

View File

@@ -0,0 +1,81 @@
package net.sf.jasperreports.engine.fill;
import java.awt.Color;
import net.sf.jasperreports.engine.JRCommonGraphicElement;
import net.sf.jasperreports.engine.JRElement;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRGraphicElement;
import net.sf.jasperreports.engine.JRPen;
import net.sf.jasperreports.engine.util.JRPenUtil;
import net.sf.jasperreports.engine.util.JRStyleResolver;
public abstract class JRFillGraphicElement extends JRFillElement implements JRGraphicElement {
protected JRFillGraphicElement(JRBaseFiller filler, JRGraphicElement graphicElement, JRFillObjectFactory factory) {
super(filler, (JRElement)graphicElement, factory);
}
protected JRFillGraphicElement(JRFillGraphicElement graphicElement, JRFillCloneFactory factory) {
super(graphicElement, factory);
}
public JRPen getLinePen() {
return ((JRGraphicElement)this.parent).getLinePen();
}
public byte getPen() {
return JRPenUtil.getPenFromLinePen(getLinePen());
}
public Byte getOwnPen() {
return JRPenUtil.getOwnPenFromLinePen(getLinePen());
}
public void setPen(byte pen) {}
public void setPen(Byte pen) {}
public byte getFill() {
return JRStyleResolver.getFill((JRCommonGraphicElement)this);
}
public Byte getOwnFill() {
return ((JRGraphicElement)this.parent).getOwnFill();
}
public void setFill(byte fill) {}
public void setFill(Byte fill) {}
public Float getDefaultLineWidth() {
return ((JRGraphicElement)this.parent).getDefaultLineWidth();
}
public Color getDefaultLineColor() {
return getForecolor();
}
public void rewind() {}
protected boolean prepare(int availableStretchHeight, boolean isOverflow) throws JRException {
boolean willOverflow = false;
super.prepare(availableStretchHeight, isOverflow);
if (!isToPrint())
return willOverflow;
boolean isToPrint = true;
boolean isReprinted = false;
if (isOverflow && isAlreadyPrinted() && !isPrintWhenDetailOverflows())
isToPrint = false;
if (isToPrint && isPrintWhenExpressionNull() && !isPrintRepeatedValues())
if ((!isPrintInFirstWholeBand() || !getBand().isFirstWholeOnPageColumn()) && (getPrintWhenGroupChanges() == null || !getBand().isNewGroup(getPrintWhenGroupChanges())) && (!isOverflow || !isPrintWhenDetailOverflows()))
isToPrint = false;
if (isToPrint && availableStretchHeight < getRelativeY() - getY() - getBandBottomY()) {
isToPrint = false;
willOverflow = true;
}
if (isToPrint && isOverflow && isPrintWhenDetailOverflows() && (isAlreadyPrinted() || (!isAlreadyPrinted() && !isPrintRepeatedValues())))
isReprinted = true;
setToPrint(isToPrint);
setReprinted(isReprinted);
return willOverflow;
}
}

View File

@@ -0,0 +1,130 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRBand;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRGroup;
import net.sf.jasperreports.engine.JROrigin;
import net.sf.jasperreports.engine.JRVariable;
public class JRFillGroup implements JRGroup {
protected JRGroup parent = null;
private JRFillBand groupHeader = null;
private JRFillBand groupFooter = null;
private JRVariable countVariable = null;
private boolean hasChanged = true;
private boolean isTopLevelChange = false;
private boolean isHeaderPrinted = false;
private boolean isFooterPrinted = true;
public JRFillGroup(JRGroup group, JRFillObjectFactory factory) {
factory.put(group, this);
this.parent = group;
String reportName = factory.getFiller().isSubreport() ? factory.getFiller().getJasperReport().getName() : null;
this.groupHeader = factory.getBand(group.getGroupHeader());
if (this.groupHeader != (factory.getFiller()).missingFillBand)
this.groupHeader.setOrigin(new JROrigin(reportName, group.getName(), (byte)5));
this.groupFooter = factory.getBand(group.getGroupFooter());
if (this.groupFooter != (factory.getFiller()).missingFillBand)
this.groupFooter.setOrigin(new JROrigin(reportName, group.getName(), (byte)7));
this.countVariable = factory.getVariable(group.getCountVariable());
}
public String getName() {
return this.parent.getName();
}
public JRExpression getExpression() {
return this.parent.getExpression();
}
public boolean isStartNewColumn() {
return this.parent.isStartNewColumn();
}
public void setStartNewColumn(boolean isStart) {
this.parent.setStartNewColumn(isStart);
}
public boolean isStartNewPage() {
return this.parent.isStartNewPage();
}
public void setStartNewPage(boolean isStart) {
this.parent.setStartNewPage(isStart);
}
public boolean isResetPageNumber() {
return this.parent.isResetPageNumber();
}
public void setResetPageNumber(boolean isReset) {
this.parent.setResetPageNumber(isReset);
}
public boolean isReprintHeaderOnEachPage() {
return this.parent.isReprintHeaderOnEachPage();
}
public void setReprintHeaderOnEachPage(boolean isReprint) {}
public int getMinHeightToStartNewPage() {
return this.parent.getMinHeightToStartNewPage();
}
public void setMinHeightToStartNewPage(int minHeight) {}
public JRBand getGroupHeader() {
return this.groupHeader;
}
public JRBand getGroupFooter() {
return this.groupFooter;
}
public JRVariable getCountVariable() {
return this.countVariable;
}
public boolean hasChanged() {
return this.hasChanged;
}
public void setHasChanged(boolean hasChanged) {
this.hasChanged = hasChanged;
}
public boolean isTopLevelChange() {
return this.isTopLevelChange;
}
public void setTopLevelChange(boolean isTopLevelChange) {
this.isTopLevelChange = isTopLevelChange;
}
public boolean isHeaderPrinted() {
return this.isHeaderPrinted;
}
public void setHeaderPrinted(boolean isHeaderPrinted) {
this.isHeaderPrinted = isHeaderPrinted;
}
public boolean isFooterPrinted() {
return this.isFooterPrinted;
}
public void setFooterPrinted(boolean isFooterPrinted) {
this.isFooterPrinted = isFooterPrinted;
}
public Object clone() {
return null;
}
}

View File

@@ -0,0 +1,50 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRHyperlink;
import net.sf.jasperreports.engine.JRHyperlinkParameter;
import net.sf.jasperreports.engine.JRPrintHyperlink;
import net.sf.jasperreports.engine.JRPrintHyperlinkParameter;
import net.sf.jasperreports.engine.JRPrintHyperlinkParameters;
import net.sf.jasperreports.engine.base.JRBasePrintHyperlink;
public class JRFillHyperlinkHelper {
public static JRPrintHyperlinkParameters evaluateHyperlinkParameters(JRHyperlink hyperlink, JRFillExpressionEvaluator expressionEvaluator, byte evaluationType) throws JRException {
JRPrintHyperlinkParameters printParameters;
JRHyperlinkParameter[] hyperlinkParameters = hyperlink.getHyperlinkParameters();
if (hyperlinkParameters == null) {
printParameters = null;
} else {
printParameters = new JRPrintHyperlinkParameters();
for (int i = 0; i < hyperlinkParameters.length; i++) {
Class valueClass;
Object value;
JRHyperlinkParameter hyperlinkParameter = hyperlinkParameters[i];
JRExpression valueExpression = hyperlinkParameter.getValueExpression();
if (valueExpression == null) {
value = null;
valueClass = Object.class;
} else {
value = expressionEvaluator.evaluate(valueExpression, evaluationType);
valueClass = valueExpression.getValueClass();
}
JRPrintHyperlinkParameter printParam = new JRPrintHyperlinkParameter(hyperlinkParameter.getName(), valueClass.getName(), value);
printParameters.addParameter(printParam);
}
}
return printParameters;
}
public static JRPrintHyperlink evaluateHyperlink(JRHyperlink hyperlink, JRFillExpressionEvaluator expressionEvaluator, byte evaluationType) throws JRException {
JRBasePrintHyperlink printHyperlink = new JRBasePrintHyperlink();
printHyperlink.setLinkType(hyperlink.getLinkType());
printHyperlink.setHyperlinkTarget(hyperlink.getHyperlinkTarget());
printHyperlink.setHyperlinkReference((String)expressionEvaluator.evaluate(hyperlink.getHyperlinkReferenceExpression(), evaluationType));
printHyperlink.setHyperlinkAnchor((String)expressionEvaluator.evaluate(hyperlink.getHyperlinkAnchorExpression(), evaluationType));
printHyperlink.setHyperlinkPage((Integer)expressionEvaluator.evaluate(hyperlink.getHyperlinkPageExpression(), evaluationType));
printHyperlink.setHyperlinkTooltip((String)expressionEvaluator.evaluate(hyperlink.getHyperlinkTooltipExpression(), evaluationType));
printHyperlink.setHyperlinkParameters(evaluateHyperlinkParameters(hyperlink, expressionEvaluator, evaluationType));
return (JRPrintHyperlink)printHyperlink;
}
}

View File

@@ -0,0 +1,590 @@
package net.sf.jasperreports.engine.fill;
import java.awt.Color;
import java.awt.Image;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import net.sf.jasperreports.engine.JRAlignment;
import net.sf.jasperreports.engine.JRBox;
import net.sf.jasperreports.engine.JRCommonElement;
import net.sf.jasperreports.engine.JRCommonImage;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRGraphicElement;
import net.sf.jasperreports.engine.JRGroup;
import net.sf.jasperreports.engine.JRHyperlink;
import net.sf.jasperreports.engine.JRHyperlinkParameter;
import net.sf.jasperreports.engine.JRImage;
import net.sf.jasperreports.engine.JRImageRenderer;
import net.sf.jasperreports.engine.JRLineBox;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRPrintHyperlinkParameters;
import net.sf.jasperreports.engine.JRPrintImage;
import net.sf.jasperreports.engine.JRRenderable;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRVisitor;
import net.sf.jasperreports.engine.util.JRStyleResolver;
import net.sf.jasperreports.engine.util.LineBoxWrapper;
public class JRFillImage extends JRFillGraphicElement implements JRImage {
private JRGroup evaluationGroup = null;
private JRRenderable renderer = null;
private String anchorName = null;
private String hyperlinkReference = null;
private String hyperlinkAnchor = null;
private Integer hyperlinkPage = null;
private String hyperlinkTooltip;
private JRPrintHyperlinkParameters hyperlinkParameters;
protected JRFillImage(JRBaseFiller filler, JRImage image, JRFillObjectFactory factory) {
super(filler, (JRGraphicElement)image, factory);
this.evaluationGroup = factory.getGroup(image.getEvaluationGroup());
}
protected JRFillImage(JRFillImage image, JRFillCloneFactory factory) {
super(image, factory);
this.evaluationGroup = image.evaluationGroup;
}
public byte getMode() {
return JRStyleResolver.getMode((JRCommonElement)this, (byte)2);
}
public byte getScaleImage() {
return JRStyleResolver.getScaleImage((JRCommonImage)this);
}
public Byte getOwnScaleImage() {
return ((JRImage)this.parent).getOwnScaleImage();
}
public void setScaleImage(byte scaleImage) {}
public void setScaleImage(Byte scaleImage) {}
public byte getHorizontalAlignment() {
return JRStyleResolver.getHorizontalAlignment((JRAlignment)this);
}
public Byte getOwnHorizontalAlignment() {
return ((JRImage)this.parent).getOwnHorizontalAlignment();
}
public void setHorizontalAlignment(byte horizontalAlignment) {}
public void setHorizontalAlignment(Byte horizontalAlignment) {}
public byte getVerticalAlignment() {
return JRStyleResolver.getVerticalAlignment((JRAlignment)this);
}
public Byte getOwnVerticalAlignment() {
return ((JRImage)this.parent).getOwnVerticalAlignment();
}
public void setVerticalAlignment(byte verticalAlignment) {}
public void setVerticalAlignment(Byte verticalAlignment) {}
public boolean isUsingCache() {
return ((JRImage)this.parent).isUsingCache();
}
public Boolean isOwnUsingCache() {
return ((JRImage)this.parent).isOwnUsingCache();
}
public void setUsingCache(boolean isUsingCache) {}
public void setUsingCache(Boolean isUsingCache) {}
public boolean isLazy() {
return ((JRImage)this.parent).isLazy();
}
public void setLazy(boolean isLazy) {}
public byte getOnErrorType() {
return ((JRImage)this.parent).getOnErrorType();
}
public void setOnErrorType(byte onErrorType) {}
public byte getEvaluationTime() {
return ((JRImage)this.parent).getEvaluationTime();
}
public JRGroup getEvaluationGroup() {
return this.evaluationGroup;
}
public JRBox getBox() {
return (JRBox)new LineBoxWrapper(getLineBox());
}
public JRLineBox getLineBox() {
return ((JRImage)this.parent).getLineBox();
}
public byte getBorder() {
return getBox().getBorder();
}
public Byte getOwnBorder() {
return getBox().getOwnBorder();
}
public void setBorder(byte border) {
getBox().setBorder(border);
}
public void setBorder(Byte border) {
getBox().setBorder(border);
}
public Color getBorderColor() {
return getBox().getBorderColor();
}
public Color getOwnBorderColor() {
return getBox().getOwnBorderColor();
}
public void setBorderColor(Color borderColor) {
getBox().setBorderColor(borderColor);
}
public int getPadding() {
return getBox().getPadding();
}
public Integer getOwnPadding() {
return getBox().getOwnPadding();
}
public void setPadding(int padding) {
getBox().setPadding(padding);
}
public void setPadding(Integer padding) {
getBox().setPadding(padding);
}
public byte getTopBorder() {
return getBox().getTopBorder();
}
public Byte getOwnTopBorder() {
return getBox().getOwnTopBorder();
}
public void setTopBorder(byte topBorder) {
getBox().setTopBorder(topBorder);
}
public void setTopBorder(Byte topBorder) {
getBox().setTopBorder(topBorder);
}
public Color getTopBorderColor() {
return getBox().getTopBorderColor();
}
public Color getOwnTopBorderColor() {
return getBox().getOwnTopBorderColor();
}
public void setTopBorderColor(Color topBorderColor) {
getBox().setTopBorderColor(topBorderColor);
}
public int getTopPadding() {
return getBox().getTopPadding();
}
public Integer getOwnTopPadding() {
return getBox().getOwnTopPadding();
}
public void setTopPadding(int topPadding) {
getBox().setTopPadding(topPadding);
}
public void setTopPadding(Integer topPadding) {
getBox().setTopPadding(topPadding);
}
public byte getLeftBorder() {
return getBox().getLeftBorder();
}
public Byte getOwnLeftBorder() {
return getBox().getOwnLeftBorder();
}
public void setLeftBorder(byte leftBorder) {
getBox().setLeftBorder(leftBorder);
}
public void setLeftBorder(Byte leftBorder) {
getBox().setLeftBorder(leftBorder);
}
public Color getLeftBorderColor() {
return getBox().getLeftBorderColor();
}
public Color getOwnLeftBorderColor() {
return getBox().getOwnLeftBorderColor();
}
public void setLeftBorderColor(Color leftBorderColor) {
getBox().setLeftBorderColor(leftBorderColor);
}
public int getLeftPadding() {
return getBox().getLeftPadding();
}
public Integer getOwnLeftPadding() {
return getBox().getOwnLeftPadding();
}
public void setLeftPadding(int leftPadding) {
getBox().setLeftPadding(leftPadding);
}
public void setLeftPadding(Integer leftPadding) {
getBox().setLeftPadding(leftPadding);
}
public byte getBottomBorder() {
return getBox().getBottomBorder();
}
public Byte getOwnBottomBorder() {
return getBox().getOwnBottomBorder();
}
public void setBottomBorder(byte bottomBorder) {
getBox().setBottomBorder(bottomBorder);
}
public void setBottomBorder(Byte bottomBorder) {
getBox().setBottomBorder(bottomBorder);
}
public Color getBottomBorderColor() {
return getBox().getBottomBorderColor();
}
public Color getOwnBottomBorderColor() {
return getBox().getOwnBottomBorderColor();
}
public void setBottomBorderColor(Color bottomBorderColor) {
getBox().setBottomBorderColor(bottomBorderColor);
}
public int getBottomPadding() {
return getBox().getBottomPadding();
}
public Integer getOwnBottomPadding() {
return getBox().getOwnBottomPadding();
}
public void setBottomPadding(int bottomPadding) {
getBox().setBottomPadding(bottomPadding);
}
public void setBottomPadding(Integer bottomPadding) {
getBox().setBottomPadding(bottomPadding);
}
public byte getRightBorder() {
return getBox().getRightBorder();
}
public Byte getOwnRightBorder() {
return getBox().getOwnRightBorder();
}
public void setRightBorder(byte rightBorder) {
getBox().setRightBorder(rightBorder);
}
public void setRightBorder(Byte rightBorder) {
getBox().setRightBorder(rightBorder);
}
public Color getRightBorderColor() {
return getBox().getRightBorderColor();
}
public Color getOwnRightBorderColor() {
return getBox().getOwnRightBorderColor();
}
public void setRightBorderColor(Color rightBorderColor) {
getBox().setRightBorderColor(rightBorderColor);
}
public int getRightPadding() {
return getBox().getRightPadding();
}
public Integer getOwnRightPadding() {
return getBox().getOwnRightPadding();
}
public void setRightPadding(int rightPadding) {
getBox().setRightPadding(rightPadding);
}
public void setRightPadding(Integer rightPadding) {
getBox().setRightPadding(rightPadding);
}
public byte getHyperlinkType() {
return ((JRImage)this.parent).getHyperlinkType();
}
public byte getHyperlinkTarget() {
return ((JRImage)this.parent).getHyperlinkTarget();
}
public JRExpression getExpression() {
return ((JRImage)this.parent).getExpression();
}
public JRExpression getAnchorNameExpression() {
return ((JRImage)this.parent).getAnchorNameExpression();
}
public JRExpression getHyperlinkReferenceExpression() {
return ((JRImage)this.parent).getHyperlinkReferenceExpression();
}
public JRExpression getHyperlinkAnchorExpression() {
return ((JRImage)this.parent).getHyperlinkAnchorExpression();
}
public JRExpression getHyperlinkPageExpression() {
return ((JRImage)this.parent).getHyperlinkPageExpression();
}
protected JRRenderable getRenderer() {
return this.renderer;
}
protected String getAnchorName() {
return this.anchorName;
}
protected String getHyperlinkReference() {
return this.hyperlinkReference;
}
protected String getHyperlinkAnchor() {
return this.hyperlinkAnchor;
}
protected Integer getHyperlinkPage() {
return this.hyperlinkPage;
}
protected String getHyperlinkTooltip() {
return this.hyperlinkTooltip;
}
protected JRTemplateImage getJRTemplateImage() {
JRStyle style = getStyle();
JRTemplateImage template = (JRTemplateImage)getTemplate(style);
if (template == null) {
template = new JRTemplateImage((this.band == null) ? null : this.band.getOrigin(), this.filler.getJasperPrint().getDefaultStyleProvider(), this);
transferProperties(template);
registerTemplate(style, template);
}
return template;
}
protected void evaluate(byte evaluation) throws JRException {
initDelayedEvaluations();
reset();
evaluatePrintWhenExpression(evaluation);
if (isPrintWhenExpressionNull() || (!isPrintWhenExpressionNull() && isPrintWhenTrue()))
if (isEvaluateNow())
evaluateImage(evaluation);
}
protected void evaluateImage(byte evaluation) throws JRException {
evaluateProperties(evaluation);
JRExpression expression = getExpression();
JRRenderable newRenderer = null;
Object source = evaluateExpression(expression, evaluation);
if (source != null)
if (isUsingCache() && this.filler.fillContext.hasLoadedImage(source)) {
newRenderer = this.filler.fillContext.getLoadedImage(source).getRenderer();
} else {
Class expressionClass = expression.getValueClass();
if (Image.class.getName().equals(expressionClass.getName())) {
Image img = (Image)source;
newRenderer = JRImageRenderer.getInstance(img, getOnErrorType());
} else if (InputStream.class.getName().equals(expressionClass.getName())) {
InputStream is = (InputStream)source;
newRenderer = JRImageRenderer.getInstance(is, getOnErrorType());
} else if (URL.class.getName().equals(expressionClass.getName())) {
URL url = (URL)source;
newRenderer = JRImageRenderer.getInstance(url, getOnErrorType());
} else if (File.class.getName().equals(expressionClass.getName())) {
File file = (File)source;
newRenderer = JRImageRenderer.getInstance(file, getOnErrorType());
} else if (String.class.getName().equals(expressionClass.getName())) {
String location = (String)source;
newRenderer = JRImageRenderer.getInstance(location, getOnErrorType(), isLazy(), this.filler.reportClassLoader, this.filler.urlHandlerFactory, this.filler.fileResolver);
} else if (JRRenderable.class.getName().equals(expressionClass.getName())) {
newRenderer = (JRRenderable)source;
}
if (isUsingCache()) {
JRPrintImage img = new JRTemplatePrintImage(getJRTemplateImage());
img.setRenderer(newRenderer);
this.filler.fillContext.registerLoadedImage(source, img);
}
}
setValueRepeating((this.renderer == newRenderer));
this.renderer = newRenderer;
this.anchorName = (String)evaluateExpression(getAnchorNameExpression(), evaluation);
this.hyperlinkReference = (String)evaluateExpression(getHyperlinkReferenceExpression(), evaluation);
this.hyperlinkAnchor = (String)evaluateExpression(getHyperlinkAnchorExpression(), evaluation);
this.hyperlinkPage = (Integer)evaluateExpression(getHyperlinkPageExpression(), evaluation);
this.hyperlinkTooltip = (String)evaluateExpression(getHyperlinkTooltipExpression(), evaluation);
this.hyperlinkParameters = JRFillHyperlinkHelper.evaluateHyperlinkParameters((JRHyperlink)this, this.expressionEvaluator, evaluation);
}
protected boolean prepare(int availableStretchHeight, boolean isOverflow) {
boolean willOverflow = false;
if (isPrintWhenExpressionNull() || (!isPrintWhenExpressionNull() && isPrintWhenTrue())) {
setToPrint(true);
} else {
setToPrint(false);
}
if (!isToPrint())
return willOverflow;
boolean isToPrint = true;
boolean isReprinted = false;
if (isEvaluateNow()) {
if (isOverflow && isAlreadyPrinted() && !isPrintWhenDetailOverflows())
isToPrint = false;
if (isToPrint && isPrintWhenExpressionNull() && !isPrintRepeatedValues() && isValueRepeating())
if ((!isPrintInFirstWholeBand() || !getBand().isFirstWholeOnPageColumn()) && (getPrintWhenGroupChanges() == null || !getBand().isNewGroup(getPrintWhenGroupChanges())) && (!isOverflow || !isPrintWhenDetailOverflows()))
isToPrint = false;
if (isToPrint && availableStretchHeight < getRelativeY() - getY() - getBandBottomY()) {
isToPrint = false;
willOverflow = true;
}
if (isToPrint && isOverflow && isPrintWhenDetailOverflows() && (isAlreadyPrinted() || (!isAlreadyPrinted() && !isPrintRepeatedValues())))
isReprinted = true;
if (isToPrint && isRemoveLineWhenBlank() && getRenderer() == null)
isToPrint = false;
} else {
if (isOverflow && isAlreadyPrinted() && !isPrintWhenDetailOverflows())
isToPrint = false;
if (isToPrint && availableStretchHeight < getRelativeY() - getY() - getBandBottomY()) {
isToPrint = false;
willOverflow = true;
}
if (isToPrint && isOverflow && isPrintWhenDetailOverflows() && (isAlreadyPrinted() || (!isAlreadyPrinted() && !isPrintRepeatedValues())))
isReprinted = true;
}
setToPrint(isToPrint);
setReprinted(isReprinted);
return willOverflow;
}
protected JRPrintElement fill() throws JRException {
JRTemplatePrintImage printImage;
JRRecordedValuesPrintImage recordedValuesImage;
byte evaluationType = getEvaluationTime();
if (isEvaluateAuto()) {
printImage = recordedValuesImage = new JRRecordedValuesPrintImage(getJRTemplateImage());
} else {
printImage = new JRTemplatePrintImage(getJRTemplateImage());
recordedValuesImage = null;
}
printImage.setX(getX());
printImage.setY(getRelativeY());
printImage.setWidth(getWidth());
printImage.setHeight(getStretchHeight());
if (isEvaluateNow()) {
copy(printImage);
} else if (isEvaluateAuto()) {
initDelayedEvaluationPrint(recordedValuesImage);
} else {
this.filler.addBoundElement(this, printImage, evaluationType, getEvaluationGroup(), this.band);
}
return printImage;
}
protected void copy(JRPrintImage printImage) {
printImage.setRenderer(getRenderer());
printImage.setAnchorName(getAnchorName());
printImage.setHyperlinkReference(getHyperlinkReference());
printImage.setHyperlinkAnchor(getHyperlinkAnchor());
printImage.setHyperlinkPage(getHyperlinkPage());
printImage.setHyperlinkTooltip(getHyperlinkTooltip());
printImage.setBookmarkLevel(getBookmarkLevel());
printImage.setHyperlinkParameters(this.hyperlinkParameters);
transferProperties((JRPrintElement)printImage);
}
public void collectExpressions(JRExpressionCollector collector) {
collector.collect(this);
}
public void visit(JRVisitor visitor) {
visitor.visitImage(this);
}
protected void resolveElement(JRPrintElement element, byte evaluation) throws JRException {
evaluateImage(evaluation);
copy((JRPrintImage)element);
}
public int getBookmarkLevel() {
return ((JRImage)this.parent).getBookmarkLevel();
}
public JRFillCloneable createClone(JRFillCloneFactory factory) {
return new JRFillImage(this, factory);
}
protected void collectDelayedEvaluations() {
collectDelayedEvaluations(getExpression());
collectDelayedEvaluations(getAnchorNameExpression());
collectDelayedEvaluations(getHyperlinkReferenceExpression());
collectDelayedEvaluations(getHyperlinkAnchorExpression());
collectDelayedEvaluations(getHyperlinkPageExpression());
}
public JRHyperlinkParameter[] getHyperlinkParameters() {
return ((JRImage)this.parent).getHyperlinkParameters();
}
public String getLinkType() {
return ((JRImage)this.parent).getLinkType();
}
public JRExpression getHyperlinkTooltipExpression() {
return ((JRImage)this.parent).getHyperlinkTooltipExpression();
}
}

View File

@@ -0,0 +1,5 @@
package net.sf.jasperreports.engine.fill;
public class JRFillInterruptedException extends RuntimeException {
private static final long serialVersionUID = 10200L;
}

View File

@@ -0,0 +1,67 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRGraphicElement;
import net.sf.jasperreports.engine.JRLine;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRVisitor;
public class JRFillLine extends JRFillGraphicElement implements JRLine {
protected JRFillLine(JRBaseFiller filler, JRLine line, JRFillObjectFactory factory) {
super(filler, (JRGraphicElement)line, factory);
}
protected JRFillLine(JRFillLine line, JRFillCloneFactory factory) {
super(line, factory);
}
public byte getDirection() {
return ((JRLine)this.parent).getDirection();
}
public void setDirection(byte direction) {}
protected JRTemplateLine getJRTemplateLine() {
JRStyle style = getStyle();
JRTemplateLine template = (JRTemplateLine)getTemplate(style);
if (template == null) {
template = new JRTemplateLine((this.band == null) ? null : this.band.getOrigin(), this.filler.getJasperPrint().getDefaultStyleProvider(), this);
transferProperties(template);
registerTemplate(style, template);
}
return template;
}
protected void evaluate(byte evaluation) throws JRException {
reset();
evaluatePrintWhenExpression(evaluation);
evaluateProperties(evaluation);
setValueRepeating(true);
}
protected JRPrintElement fill() {
JRTemplatePrintLine printLine = new JRTemplatePrintLine(getJRTemplateLine());
printLine.setX(getX());
printLine.setY(getRelativeY());
printLine.setWidth(getWidth());
printLine.setHeight(getStretchHeight());
transferProperties(printLine);
return printLine;
}
public void collectExpressions(JRExpressionCollector collector) {
collector.collect(this);
}
public void visit(JRVisitor visitor) {
visitor.visitLine(this);
}
protected void resolveElement(JRPrintElement element, byte evaluation) {}
public JRFillCloneable createClone(JRFillCloneFactory factory) {
return new JRFillLine(this, factory);
}
}

View File

@@ -0,0 +1,965 @@
package net.sf.jasperreports.engine.fill;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sf.jasperreports.charts.JRAreaPlot;
import net.sf.jasperreports.charts.JRBar3DPlot;
import net.sf.jasperreports.charts.JRBarPlot;
import net.sf.jasperreports.charts.JRBubblePlot;
import net.sf.jasperreports.charts.JRCandlestickPlot;
import net.sf.jasperreports.charts.JRCategoryDataset;
import net.sf.jasperreports.charts.JRCategorySeries;
import net.sf.jasperreports.charts.JRChartAxis;
import net.sf.jasperreports.charts.JRHighLowDataset;
import net.sf.jasperreports.charts.JRHighLowPlot;
import net.sf.jasperreports.charts.JRLinePlot;
import net.sf.jasperreports.charts.JRMeterPlot;
import net.sf.jasperreports.charts.JRMultiAxisPlot;
import net.sf.jasperreports.charts.JRPie3DPlot;
import net.sf.jasperreports.charts.JRPieDataset;
import net.sf.jasperreports.charts.JRPiePlot;
import net.sf.jasperreports.charts.JRScatterPlot;
import net.sf.jasperreports.charts.JRThermometerPlot;
import net.sf.jasperreports.charts.JRTimePeriodDataset;
import net.sf.jasperreports.charts.JRTimePeriodSeries;
import net.sf.jasperreports.charts.JRTimeSeries;
import net.sf.jasperreports.charts.JRTimeSeriesDataset;
import net.sf.jasperreports.charts.JRTimeSeriesPlot;
import net.sf.jasperreports.charts.JRValueDataset;
import net.sf.jasperreports.charts.JRXyDataset;
import net.sf.jasperreports.charts.JRXySeries;
import net.sf.jasperreports.charts.JRXyzDataset;
import net.sf.jasperreports.charts.JRXyzSeries;
import net.sf.jasperreports.charts.fill.JRFillAreaPlot;
import net.sf.jasperreports.charts.fill.JRFillBar3DPlot;
import net.sf.jasperreports.charts.fill.JRFillBarPlot;
import net.sf.jasperreports.charts.fill.JRFillBubblePlot;
import net.sf.jasperreports.charts.fill.JRFillCandlestickPlot;
import net.sf.jasperreports.charts.fill.JRFillCategoryDataset;
import net.sf.jasperreports.charts.fill.JRFillCategorySeries;
import net.sf.jasperreports.charts.fill.JRFillChartAxis;
import net.sf.jasperreports.charts.fill.JRFillHighLowDataset;
import net.sf.jasperreports.charts.fill.JRFillHighLowPlot;
import net.sf.jasperreports.charts.fill.JRFillLinePlot;
import net.sf.jasperreports.charts.fill.JRFillMeterPlot;
import net.sf.jasperreports.charts.fill.JRFillMultiAxisPlot;
import net.sf.jasperreports.charts.fill.JRFillPie3DPlot;
import net.sf.jasperreports.charts.fill.JRFillPieDataset;
import net.sf.jasperreports.charts.fill.JRFillPiePlot;
import net.sf.jasperreports.charts.fill.JRFillScatterPlot;
import net.sf.jasperreports.charts.fill.JRFillThermometerPlot;
import net.sf.jasperreports.charts.fill.JRFillTimePeriodDataset;
import net.sf.jasperreports.charts.fill.JRFillTimePeriodSeries;
import net.sf.jasperreports.charts.fill.JRFillTimeSeries;
import net.sf.jasperreports.charts.fill.JRFillTimeSeriesDataset;
import net.sf.jasperreports.charts.fill.JRFillTimeSeriesPlot;
import net.sf.jasperreports.charts.fill.JRFillValueDataset;
import net.sf.jasperreports.charts.fill.JRFillXyDataset;
import net.sf.jasperreports.charts.fill.JRFillXySeries;
import net.sf.jasperreports.charts.fill.JRFillXyzDataset;
import net.sf.jasperreports.charts.fill.JRFillXyzSeries;
import net.sf.jasperreports.crosstabs.JRCellContents;
import net.sf.jasperreports.crosstabs.JRCrosstab;
import net.sf.jasperreports.crosstabs.JRCrosstabCell;
import net.sf.jasperreports.crosstabs.JRCrosstabColumnGroup;
import net.sf.jasperreports.crosstabs.JRCrosstabDataset;
import net.sf.jasperreports.crosstabs.JRCrosstabMeasure;
import net.sf.jasperreports.crosstabs.JRCrosstabParameter;
import net.sf.jasperreports.crosstabs.JRCrosstabRowGroup;
import net.sf.jasperreports.crosstabs.fill.JRFillCrosstabCell;
import net.sf.jasperreports.crosstabs.fill.JRFillCrosstabColumnGroup;
import net.sf.jasperreports.crosstabs.fill.JRFillCrosstabMeasure;
import net.sf.jasperreports.crosstabs.fill.JRFillCrosstabParameter;
import net.sf.jasperreports.crosstabs.fill.JRFillCrosstabRowGroup;
import net.sf.jasperreports.engine.JRAbstractObjectFactory;
import net.sf.jasperreports.engine.JRBand;
import net.sf.jasperreports.engine.JRBreak;
import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRConditionalStyle;
import net.sf.jasperreports.engine.JRDataset;
import net.sf.jasperreports.engine.JRDatasetRun;
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
import net.sf.jasperreports.engine.JRElementGroup;
import net.sf.jasperreports.engine.JREllipse;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.JRFrame;
import net.sf.jasperreports.engine.JRGroup;
import net.sf.jasperreports.engine.JRImage;
import net.sf.jasperreports.engine.JRLine;
import net.sf.jasperreports.engine.JRParameter;
import net.sf.jasperreports.engine.JRRectangle;
import net.sf.jasperreports.engine.JRReportFont;
import net.sf.jasperreports.engine.JRReportTemplate;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.JRStaticText;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRStyleContainer;
import net.sf.jasperreports.engine.JRStyleSetter;
import net.sf.jasperreports.engine.JRSubreport;
import net.sf.jasperreports.engine.JRSubreportReturnValue;
import net.sf.jasperreports.engine.JRTextField;
import net.sf.jasperreports.engine.JRVariable;
import net.sf.jasperreports.engine.base.JRBaseConditionalStyle;
import net.sf.jasperreports.engine.base.JRBaseReportFont;
import net.sf.jasperreports.engine.base.JRBaseStyle;
import org.apache.commons.collections.SequencedHashMap;
public class JRFillObjectFactory extends JRAbstractObjectFactory {
private JRBaseFiller filler = null;
private JRFillExpressionEvaluator evaluator;
private JRFillObjectFactory parentFiller;
private List elementDatasets = new ArrayList();
private Map elementDatasetMap = new HashMap();
private Map delayedStyleSettersByName = new HashMap();
private Set originalStyleList;
protected static class StylesList {
private final List styles = new ArrayList();
private final Map stylesIdx = new HashMap();
public boolean containsStyle(String name) {
return this.stylesIdx.containsKey(name);
}
public JRStyle getStyle(String name) {
Integer idx = (Integer)this.stylesIdx.get(name);
return (idx == null) ? null : this.styles.get(idx.intValue());
}
public void addStyle(JRStyle style) {
this.styles.add(style);
this.stylesIdx.put(style.getName(), new Integer(this.styles.size() - 1));
}
public void renamed(String oldName, String newName) {
Integer idx = (Integer)this.stylesIdx.remove(oldName);
this.stylesIdx.put(newName, idx);
}
}
private StylesList stylesMap = new StylesList();
protected JRFillObjectFactory(JRBaseFiller filler) {
this.filler = filler;
this.evaluator = filler.calculator;
}
public JRFillObjectFactory(JRBaseFiller filler, JRFillExpressionEvaluator expressionEvaluator) {
this.filler = filler;
this.evaluator = expressionEvaluator;
}
public JRFillObjectFactory(JRFillObjectFactory parent, JRFillExpressionEvaluator expressionEvaluator) {
this.parentFiller = parent;
this.filler = parent.filler;
this.evaluator = expressionEvaluator;
}
protected JRFillExpressionEvaluator getExpressionEvaluator() {
return this.evaluator;
}
protected JRFillChartDataset[] getDatasets() {
return (JRFillChartDataset[])this.elementDatasets.toArray((Object[])new JRFillChartDataset[this.elementDatasets.size()]);
}
protected JRFillElementDataset[] getElementDatasets(JRDataset dataset) {
JRFillElementDataset[] elementDatasetsArray;
List elementDatasetsList;
if (dataset.isMainDataset()) {
elementDatasetsList = this.elementDatasets;
} else {
elementDatasetsList = (List)this.elementDatasetMap.get(dataset.getName());
}
if (elementDatasetsList == null || elementDatasetsList.size() == 0) {
elementDatasetsArray = new JRFillElementDataset[0];
} else {
elementDatasetsArray = new JRFillElementDataset[elementDatasetsList.size()];
elementDatasetsList.toArray((Object[])elementDatasetsArray);
}
return elementDatasetsArray;
}
public JRReportFont getReportFont(JRReportFont font) {
JRBaseReportFont fillFont = null;
if (font != null) {
fillFont = (JRBaseReportFont)get(font);
if (fillFont == null) {
fillFont = new JRBaseReportFont(font);
put(font, fillFont);
}
}
return (JRReportFont)fillFont;
}
protected void registerDelayedStyleSetter(JRStyleSetter delayedSetter, String styleName) {
if (this.parentFiller == null) {
List setters = (List)this.delayedStyleSettersByName.get(styleName);
if (setters == null) {
setters = new ArrayList();
this.delayedStyleSettersByName.put(styleName, setters);
}
setters.add(delayedSetter);
} else {
this.parentFiller.registerDelayedStyleSetter(delayedSetter, styleName);
}
}
public void registerDelayedStyleSetter(JRStyleSetter delayedSetter, JRStyleContainer styleContainer) {
JRStyle style = styleContainer.getStyle();
String nameReference = styleContainer.getStyleNameReference();
if (style != null) {
registerDelayedStyleSetter(delayedSetter, style.getName());
} else if (nameReference != null) {
registerDelayedStyleSetter(delayedSetter, nameReference);
}
}
public JRStyle getStyle(JRStyle style) {
JRBaseStyle fillStyle = null;
if (style != null) {
fillStyle = (JRBaseStyle)get(style);
if (fillStyle == null) {
fillStyle = new JRBaseStyle(style, this);
put(style, fillStyle);
if (this.originalStyleList != null && this.originalStyleList.contains(style)) {
renameExistingStyle(style.getName());
this.stylesMap.addStyle(style);
}
}
}
return (JRStyle)fillStyle;
}
protected void renameExistingStyle(String name) {
JRStyle originalStyle = this.stylesMap.getStyle(name);
if (originalStyle != null) {
String newName;
JRBaseStyle style = (JRBaseStyle)get(originalStyle);
int suf = 1;
do {
newName = name + suf;
suf++;
} while (this.stylesMap.containsStyle(newName));
style.rename(newName);
this.stylesMap.renamed(name, newName);
}
}
public void setStyle(JRStyleSetter setter, JRStyleContainer styleContainer) {
JRStyle style = styleContainer.getStyle();
String nameReference = styleContainer.getStyleNameReference();
if (style != null) {
JRStyle newStyle = getStyle(style);
setter.setStyle(newStyle);
} else if (nameReference != null) {
JRStyle originalStyle = this.stylesMap.getStyle(nameReference);
if (originalStyle == null)
throw new JRRuntimeException("Style " + nameReference + " not found");
JRStyle externalStyle = (JRStyle)get(originalStyle);
setter.setStyle(externalStyle);
}
}
protected JRFillParameter getParameter(JRParameter parameter) {
JRFillParameter fillParameter = null;
if (parameter != null) {
fillParameter = (JRFillParameter)get(parameter);
if (fillParameter == null)
fillParameter = new JRFillParameter(parameter, this);
}
return fillParameter;
}
protected JRFillField getField(JRField field) {
JRFillField fillField = null;
if (field != null) {
fillField = (JRFillField)get(field);
if (fillField == null)
fillField = new JRFillField(field, this);
}
return fillField;
}
public JRFillVariable getVariable(JRVariable variable) {
JRFillVariable fillVariable = null;
if (variable != null) {
fillVariable = (JRFillVariable)get(variable);
if (fillVariable == null)
fillVariable = new JRFillVariable(variable, this);
}
return fillVariable;
}
protected JRFillGroup getGroup(JRGroup group) {
JRFillGroup fillGroup = null;
if (group != null) {
fillGroup = (JRFillGroup)get(group);
if (fillGroup == null)
fillGroup = new JRFillGroup(group, this);
}
return fillGroup;
}
protected JRFillBand getBand(JRBand band) {
JRFillBand fillBand = null;
fillBand = (JRFillBand)get(band);
if (fillBand == null)
fillBand = new JRFillBand(this.filler, band, this);
return fillBand;
}
public void visitElementGroup(JRElementGroup elementGroup) {
JRFillElementGroup fillElementGroup = null;
if (elementGroup != null) {
fillElementGroup = (JRFillElementGroup)get(elementGroup);
if (fillElementGroup == null)
fillElementGroup = new JRFillElementGroup(elementGroup, this);
}
setVisitResult(fillElementGroup);
}
public void visitBreak(JRBreak breakElement) {
JRFillBreak fillBreak = null;
if (breakElement != null) {
fillBreak = (JRFillBreak)get(breakElement);
if (fillBreak == null)
fillBreak = new JRFillBreak(this.filler, breakElement, this);
}
setVisitResult(fillBreak);
}
public void visitLine(JRLine line) {
JRFillLine fillLine = null;
if (line != null) {
fillLine = (JRFillLine)get(line);
if (fillLine == null)
fillLine = new JRFillLine(this.filler, line, this);
}
setVisitResult(fillLine);
}
public void visitRectangle(JRRectangle rectangle) {
JRFillRectangle fillRectangle = null;
if (rectangle != null) {
fillRectangle = (JRFillRectangle)get(rectangle);
if (fillRectangle == null)
fillRectangle = new JRFillRectangle(this.filler, rectangle, this);
}
setVisitResult(fillRectangle);
}
public void visitEllipse(JREllipse ellipse) {
JRFillEllipse fillEllipse = null;
if (ellipse != null) {
fillEllipse = (JRFillEllipse)get(ellipse);
if (fillEllipse == null)
fillEllipse = new JRFillEllipse(this.filler, ellipse, this);
}
setVisitResult(fillEllipse);
}
public void visitImage(JRImage image) {
JRFillImage fillImage = null;
if (image != null) {
fillImage = (JRFillImage)get(image);
if (fillImage == null)
fillImage = new JRFillImage(this.filler, image, this);
}
setVisitResult(fillImage);
}
public void visitStaticText(JRStaticText staticText) {
JRFillStaticText fillStaticText = null;
if (staticText != null) {
fillStaticText = (JRFillStaticText)get(staticText);
if (fillStaticText == null)
fillStaticText = new JRFillStaticText(this.filler, staticText, this);
}
setVisitResult(fillStaticText);
}
public void visitTextField(JRTextField textField) {
JRFillTextField fillTextField = null;
if (textField != null) {
fillTextField = (JRFillTextField)get(textField);
if (fillTextField == null)
fillTextField = new JRFillTextField(this.filler, textField, this);
}
setVisitResult(fillTextField);
}
public void visitSubreport(JRSubreport subreport) {
JRFillSubreport fillSubreport = null;
if (subreport != null) {
fillSubreport = (JRFillSubreport)get(subreport);
if (fillSubreport == null)
fillSubreport = new JRFillSubreport(this.filler, subreport, this);
}
setVisitResult(fillSubreport);
}
public void visitChart(JRChart chart) {
JRFillChart fillChart = null;
if (chart != null) {
fillChart = (JRFillChart)get(chart);
if (fillChart == null)
fillChart = new JRFillChart(this.filler, chart, this);
}
setVisitResult(fillChart);
}
public JRPieDataset getPieDataset(JRPieDataset pieDataset) {
JRFillPieDataset fillPieDataset = null;
if (pieDataset != null) {
fillPieDataset = (JRFillPieDataset)get(pieDataset);
if (fillPieDataset == null) {
fillPieDataset = new JRFillPieDataset(pieDataset, this);
addChartDataset((JRFillElementDataset)fillPieDataset);
}
}
return (JRPieDataset)fillPieDataset;
}
public JRPiePlot getPiePlot(JRPiePlot piePlot) {
JRFillPiePlot fillPiePlot = null;
if (piePlot != null) {
fillPiePlot = (JRFillPiePlot)get(piePlot);
if (fillPiePlot == null)
fillPiePlot = new JRFillPiePlot(piePlot, this);
}
return (JRPiePlot)fillPiePlot;
}
public JRPie3DPlot getPie3DPlot(JRPie3DPlot pie3DPlot) {
JRFillPie3DPlot fillPie3DPlot = null;
if (pie3DPlot != null) {
fillPie3DPlot = (JRFillPie3DPlot)get(pie3DPlot);
if (fillPie3DPlot == null)
fillPie3DPlot = new JRFillPie3DPlot(pie3DPlot, this);
}
return (JRPie3DPlot)fillPie3DPlot;
}
public JRCategoryDataset getCategoryDataset(JRCategoryDataset categoryDataset) {
JRFillCategoryDataset fillCategoryDataset = null;
if (categoryDataset != null) {
fillCategoryDataset = (JRFillCategoryDataset)get(categoryDataset);
if (fillCategoryDataset == null) {
fillCategoryDataset = new JRFillCategoryDataset(categoryDataset, this);
addChartDataset((JRFillElementDataset)fillCategoryDataset);
}
}
return (JRCategoryDataset)fillCategoryDataset;
}
public JRXyzDataset getXyzDataset(JRXyzDataset xyzDataset) {
JRFillXyzDataset fillXyzDataset = null;
if (xyzDataset != null) {
fillXyzDataset = (JRFillXyzDataset)get(xyzDataset);
if (fillXyzDataset == null) {
fillXyzDataset = new JRFillXyzDataset(xyzDataset, this);
addChartDataset((JRFillElementDataset)fillXyzDataset);
}
}
return (JRXyzDataset)fillXyzDataset;
}
public JRXyDataset getXyDataset(JRXyDataset xyDataset) {
JRFillXyDataset fillXyDataset = null;
if (xyDataset != null) {
fillXyDataset = (JRFillXyDataset)get(xyDataset);
if (fillXyDataset == null) {
fillXyDataset = new JRFillXyDataset(xyDataset, this);
addChartDataset((JRFillElementDataset)fillXyDataset);
}
}
return (JRXyDataset)fillXyDataset;
}
public JRTimeSeriesDataset getTimeSeriesDataset(JRTimeSeriesDataset timeSeriesDataset) {
JRFillTimeSeriesDataset fillTimeSeriesDataset = null;
if (timeSeriesDataset != null) {
fillTimeSeriesDataset = (JRFillTimeSeriesDataset)get(timeSeriesDataset);
if (fillTimeSeriesDataset == null) {
fillTimeSeriesDataset = new JRFillTimeSeriesDataset(timeSeriesDataset, this);
addChartDataset((JRFillElementDataset)fillTimeSeriesDataset);
}
}
return (JRTimeSeriesDataset)fillTimeSeriesDataset;
}
public JRTimePeriodDataset getTimePeriodDataset(JRTimePeriodDataset timePeriodDataset) {
JRFillTimePeriodDataset fillTimePeriodDataset = null;
if (timePeriodDataset != null) {
fillTimePeriodDataset = (JRFillTimePeriodDataset)get(timePeriodDataset);
if (fillTimePeriodDataset == null) {
fillTimePeriodDataset = new JRFillTimePeriodDataset(timePeriodDataset, this);
addChartDataset((JRFillElementDataset)fillTimePeriodDataset);
}
}
return (JRTimePeriodDataset)fillTimePeriodDataset;
}
public JRCategorySeries getCategorySeries(JRCategorySeries categorySeries) {
JRFillCategorySeries fillCategorySeries = null;
if (categorySeries != null) {
fillCategorySeries = (JRFillCategorySeries)get(categorySeries);
if (fillCategorySeries == null)
fillCategorySeries = new JRFillCategorySeries(categorySeries, this);
}
return (JRCategorySeries)fillCategorySeries;
}
public JRXyzSeries getXyzSeries(JRXyzSeries xyzSeries) {
JRFillXyzSeries fillXyzSeries = null;
if (xyzSeries != null) {
fillXyzSeries = (JRFillXyzSeries)get(xyzSeries);
if (fillXyzSeries == null)
fillXyzSeries = new JRFillXyzSeries(xyzSeries, this);
}
return (JRXyzSeries)fillXyzSeries;
}
public JRXySeries getXySeries(JRXySeries xySeries) {
JRFillXySeries fillXySeries = null;
if (xySeries != null) {
fillXySeries = (JRFillXySeries)get(xySeries);
if (fillXySeries == null)
fillXySeries = new JRFillXySeries(xySeries, this);
}
return (JRXySeries)fillXySeries;
}
public JRBarPlot getBarPlot(JRBarPlot barPlot) {
JRFillBarPlot fillBarPlot = null;
if (barPlot != null) {
fillBarPlot = (JRFillBarPlot)get(barPlot);
if (fillBarPlot == null)
fillBarPlot = new JRFillBarPlot(barPlot, this);
}
return (JRBarPlot)fillBarPlot;
}
public JRTimeSeries getTimeSeries(JRTimeSeries timeSeries) {
JRFillTimeSeries fillTimeSeries = null;
if (timeSeries != null) {
fillTimeSeries = (JRFillTimeSeries)get(timeSeries);
if (fillTimeSeries == null)
fillTimeSeries = new JRFillTimeSeries(timeSeries, this);
}
return (JRTimeSeries)fillTimeSeries;
}
public JRTimePeriodSeries getTimePeriodSeries(JRTimePeriodSeries timePeriodSeries) {
JRFillTimePeriodSeries fillTimePeriodSeries = null;
if (timePeriodSeries != null) {
fillTimePeriodSeries = (JRFillTimePeriodSeries)get(timePeriodSeries);
if (fillTimePeriodSeries == null)
fillTimePeriodSeries = new JRFillTimePeriodSeries(timePeriodSeries, this);
}
return (JRTimePeriodSeries)fillTimePeriodSeries;
}
public JRBar3DPlot getBar3DPlot(JRBar3DPlot barPlot) {
JRFillBar3DPlot fillBarPlot = null;
if (barPlot != null) {
fillBarPlot = (JRFillBar3DPlot)get(barPlot);
if (fillBarPlot == null)
fillBarPlot = new JRFillBar3DPlot(barPlot, this);
}
return (JRBar3DPlot)fillBarPlot;
}
public JRLinePlot getLinePlot(JRLinePlot linePlot) {
JRFillLinePlot fillLinePlot = null;
if (linePlot != null) {
fillLinePlot = (JRFillLinePlot)get(linePlot);
if (fillLinePlot == null)
fillLinePlot = new JRFillLinePlot(linePlot, this);
}
return (JRLinePlot)fillLinePlot;
}
public JRScatterPlot getScatterPlot(JRScatterPlot scatterPlot) {
JRFillScatterPlot fillScatterPlot = null;
if (scatterPlot != null) {
fillScatterPlot = (JRFillScatterPlot)get(scatterPlot);
if (fillScatterPlot == null)
fillScatterPlot = new JRFillScatterPlot(scatterPlot, this);
}
return (JRScatterPlot)fillScatterPlot;
}
public JRAreaPlot getAreaPlot(JRAreaPlot areaPlot) {
JRFillAreaPlot fillAreaPlot = null;
if (areaPlot != null) {
fillAreaPlot = (JRFillAreaPlot)get(areaPlot);
if (fillAreaPlot == null)
fillAreaPlot = new JRFillAreaPlot(areaPlot, this);
}
return (JRAreaPlot)fillAreaPlot;
}
public JRBubblePlot getBubblePlot(JRBubblePlot bubblePlot) {
JRFillBubblePlot fillBubblePlot = null;
if (bubblePlot != null) {
fillBubblePlot = (JRFillBubblePlot)get(bubblePlot);
if (fillBubblePlot == null)
fillBubblePlot = new JRFillBubblePlot(bubblePlot, this);
}
return (JRBubblePlot)fillBubblePlot;
}
public JRHighLowDataset getHighLowDataset(JRHighLowDataset highLowDataset) {
JRFillHighLowDataset fillHighLowDataset = null;
if (highLowDataset != null) {
fillHighLowDataset = (JRFillHighLowDataset)get(highLowDataset);
if (fillHighLowDataset == null) {
fillHighLowDataset = new JRFillHighLowDataset(highLowDataset, this);
addChartDataset((JRFillElementDataset)fillHighLowDataset);
}
}
return (JRHighLowDataset)fillHighLowDataset;
}
public JRHighLowPlot getHighLowPlot(JRHighLowPlot highLowPlot) {
JRFillHighLowPlot fillHighLowPlot = null;
if (highLowPlot != null) {
fillHighLowPlot = (JRFillHighLowPlot)get(highLowPlot);
if (fillHighLowPlot == null)
fillHighLowPlot = new JRFillHighLowPlot(highLowPlot, this);
}
return (JRHighLowPlot)fillHighLowPlot;
}
public JRCandlestickPlot getCandlestickPlot(JRCandlestickPlot candlestickPlot) {
JRFillCandlestickPlot fillCandlestickPlot = null;
if (candlestickPlot != null) {
fillCandlestickPlot = (JRFillCandlestickPlot)get(candlestickPlot);
if (fillCandlestickPlot == null)
fillCandlestickPlot = new JRFillCandlestickPlot(candlestickPlot, this);
}
return (JRCandlestickPlot)fillCandlestickPlot;
}
public JRTimeSeriesPlot getTimeSeriesPlot(JRTimeSeriesPlot plot) {
JRFillTimeSeriesPlot fillPlot = null;
if (plot != null) {
fillPlot = (JRFillTimeSeriesPlot)get(plot);
if (fillPlot == null)
fillPlot = new JRFillTimeSeriesPlot(plot, this);
}
return (JRTimeSeriesPlot)fillPlot;
}
public JRValueDataset getValueDataset(JRValueDataset valueDataset) {
JRFillValueDataset fillValueDataset = null;
if (valueDataset != null) {
fillValueDataset = (JRFillValueDataset)get(valueDataset);
if (fillValueDataset == null) {
fillValueDataset = new JRFillValueDataset(valueDataset, this);
addChartDataset((JRFillElementDataset)fillValueDataset);
}
}
return (JRValueDataset)fillValueDataset;
}
public JRMeterPlot getMeterPlot(JRMeterPlot meterPlot) {
JRFillMeterPlot fillMeterPlot = null;
if (meterPlot != null) {
fillMeterPlot = (JRFillMeterPlot)get(meterPlot);
if (fillMeterPlot == null)
fillMeterPlot = new JRFillMeterPlot(meterPlot, this);
}
return (JRMeterPlot)fillMeterPlot;
}
public JRThermometerPlot getThermometerPlot(JRThermometerPlot thermometerPlot) {
JRFillThermometerPlot fillThermometerPlot = null;
if (thermometerPlot != null) {
fillThermometerPlot = (JRFillThermometerPlot)get(thermometerPlot);
if (fillThermometerPlot == null)
fillThermometerPlot = new JRFillThermometerPlot(thermometerPlot, this);
}
return (JRThermometerPlot)fillThermometerPlot;
}
public JRMultiAxisPlot getMultiAxisPlot(JRMultiAxisPlot multiAxisPlot) {
JRFillMultiAxisPlot fillMultiAxisPlot = null;
if (multiAxisPlot != null) {
fillMultiAxisPlot = (JRFillMultiAxisPlot)get(multiAxisPlot);
if (fillMultiAxisPlot == null)
fillMultiAxisPlot = new JRFillMultiAxisPlot(multiAxisPlot, this);
}
return (JRMultiAxisPlot)fillMultiAxisPlot;
}
protected JRFillSubreportReturnValue getSubreportReturnValue(JRSubreportReturnValue returnValue) {
JRFillSubreportReturnValue fillReturnValue = null;
if (returnValue != null) {
fillReturnValue = (JRFillSubreportReturnValue)get(returnValue);
if (fillReturnValue == null)
fillReturnValue = new JRFillSubreportReturnValue(returnValue, this, this.filler);
}
return fillReturnValue;
}
public void visitCrosstab(JRCrosstab crosstabElement) {
JRFillCrosstab fillCrosstab = null;
if (crosstabElement != null) {
fillCrosstab = (JRFillCrosstab)get(crosstabElement);
if (fillCrosstab == null)
fillCrosstab = new JRFillCrosstab(this.filler, crosstabElement, this);
}
setVisitResult(fillCrosstab);
}
public JRFillCrosstab.JRFillCrosstabDataset getCrosstabDataset(JRCrosstabDataset dataset, JRFillCrosstab fillCrosstab) {
JRFillCrosstab.JRFillCrosstabDataset fillDataset = null;
if (dataset != null) {
fillDataset = (JRFillCrosstab.JRFillCrosstabDataset)get(dataset);
if (fillDataset == null) {
fillCrosstab.getClass();
fillDataset = new JRFillCrosstab.JRFillCrosstabDataset(fillCrosstab, dataset, this);
addChartDataset(fillDataset);
}
}
return fillDataset;
}
public JRFillDataset getDataset(JRDataset dataset) {
JRFillDataset fillDataset = null;
if (dataset != null) {
fillDataset = (JRFillDataset)get(dataset);
if (fillDataset == null)
fillDataset = new JRFillDataset(this.filler, dataset, this);
}
return fillDataset;
}
private void addChartDataset(JRFillElementDataset elementDataset) {
List elementDatasetsList;
JRDatasetRun datasetRun = elementDataset.getDatasetRun();
if (datasetRun == null) {
elementDatasetsList = this.elementDatasets;
} else {
String datasetName = datasetRun.getDatasetName();
elementDatasetsList = (List)this.elementDatasetMap.get(datasetName);
if (elementDatasetsList == null) {
elementDatasetsList = new ArrayList();
this.elementDatasetMap.put(datasetName, elementDatasetsList);
}
}
elementDatasetsList.add(elementDataset);
}
public JRFillDatasetRun getDatasetRun(JRDatasetRun datasetRun) {
JRFillDatasetRun fillDatasetRun = null;
if (datasetRun != null) {
fillDatasetRun = (JRFillDatasetRun)get(datasetRun);
if (fillDatasetRun == null)
fillDatasetRun = new JRFillDatasetRun(this.filler, datasetRun, this);
}
return fillDatasetRun;
}
public JRFillCrosstabParameter getCrosstabParameter(JRCrosstabParameter parameter) {
JRFillCrosstabParameter fillParameter = null;
if (parameter != null) {
fillParameter = (JRFillCrosstabParameter)get(parameter);
if (fillParameter == null)
fillParameter = new JRFillCrosstabParameter(parameter, this);
}
return fillParameter;
}
public JRFillCellContents getCell(JRCellContents cell) {
JRFillCellContents fillCell = null;
if (cell != null) {
fillCell = (JRFillCellContents)get(cell);
if (fillCell == null)
fillCell = new JRFillCellContents(this.filler, cell, this);
}
return fillCell;
}
public JRFillCrosstabRowGroup getCrosstabRowGroup(JRCrosstabRowGroup group) {
JRFillCrosstabRowGroup fillGroup = null;
if (group != null) {
fillGroup = (JRFillCrosstabRowGroup)get(group);
if (fillGroup == null)
fillGroup = new JRFillCrosstabRowGroup(group, this);
}
return fillGroup;
}
public JRFillCrosstabColumnGroup getCrosstabColumnGroup(JRCrosstabColumnGroup group) {
JRFillCrosstabColumnGroup fillGroup = null;
if (group != null) {
fillGroup = (JRFillCrosstabColumnGroup)get(group);
if (fillGroup == null)
fillGroup = new JRFillCrosstabColumnGroup(group, this);
}
return fillGroup;
}
public JRFillCrosstabCell getCrosstabCell(JRCrosstabCell cell) {
JRFillCrosstabCell fillCell = null;
if (cell != null) {
fillCell = (JRFillCrosstabCell)get(cell);
if (fillCell == null)
fillCell = new JRFillCrosstabCell(cell, this);
}
return fillCell;
}
public JRFillCrosstabMeasure getCrosstabMeasure(JRCrosstabMeasure measure) {
JRFillCrosstabMeasure fillMeasure = null;
if (measure != null) {
fillMeasure = (JRFillCrosstabMeasure)get(measure);
if (fillMeasure == null)
fillMeasure = new JRFillCrosstabMeasure(measure, this);
}
return fillMeasure;
}
public void visitFrame(JRFrame frame) {
Object fillFrame = null;
if (frame != null) {
fillFrame = get(frame);
if (fillFrame == null)
fillFrame = new JRFillFrame(this.filler, frame, this);
}
setVisitResult(fillFrame);
}
protected JRBaseFiller getFiller() {
return this.filler;
}
public JRConditionalStyle getConditionalStyle(JRConditionalStyle conditionalStyle, JRStyle style) {
JRBaseConditionalStyle baseConditionalStyle = null;
if (conditionalStyle != null) {
baseConditionalStyle = (JRBaseConditionalStyle)get(conditionalStyle);
if (baseConditionalStyle == null) {
baseConditionalStyle = new JRBaseConditionalStyle(conditionalStyle, style, this);
put(conditionalStyle, baseConditionalStyle);
}
}
return (JRConditionalStyle)baseConditionalStyle;
}
public JRExpression getExpression(JRExpression expression, boolean assignNotUsedId) {
return expression;
}
public JRChartAxis getChartAxis(JRChartAxis axis) {
JRFillChartAxis fillAxis = null;
if (axis != null) {
fillAxis = (JRFillChartAxis)get(axis);
if (fillAxis == null)
fillAxis = new JRFillChartAxis(axis, this);
}
return (JRChartAxis)fillAxis;
}
public JRFillReportTemplate getReportTemplate(JRReportTemplate template) {
JRFillReportTemplate fillTemplate = null;
if (template != null) {
fillTemplate = (JRFillReportTemplate)get(template);
if (fillTemplate == null)
fillTemplate = new JRFillReportTemplate(template, this.filler, this);
}
return fillTemplate;
}
public List setStyles(List styles) {
this.originalStyleList = new HashSet(styles);
Set requestedStyles = collectRequestedStyles(styles);
SequencedHashMap sequencedHashMap = new SequencedHashMap();
Map allStylesMap = new HashMap();
for (Iterator it = styles.iterator(); it.hasNext(); ) {
JRStyle style = (JRStyle)it.next();
if (requestedStyles.contains(style))
collectUsedStyles(style, (Map)sequencedHashMap, allStylesMap);
allStylesMap.put(style.getName(), style);
}
List includedStyles = new ArrayList();
for (Iterator iterator = sequencedHashMap.keySet().iterator(); iterator.hasNext(); ) {
JRStyle style = iterator.next();
JRStyle newStyle = getStyle(style);
includedStyles.add(newStyle);
if (requestedStyles.contains(style))
useDelayedStyle(newStyle);
}
checkUnresolvedReferences();
return includedStyles;
}
protected Set collectRequestedStyles(List externalStyles) {
Map requestedStylesMap = new HashMap();
for (Iterator it = externalStyles.iterator(); it.hasNext(); ) {
JRStyle style = it.next();
String name = style.getName();
if (this.delayedStyleSettersByName.containsKey(name))
requestedStylesMap.put(name, style);
}
return new HashSet(requestedStylesMap.values());
}
protected void collectUsedStyles(JRStyle style, Map usedStylesMap, Map allStylesMap) {
if (!usedStylesMap.containsKey(style) && this.originalStyleList.contains(style)) {
JRStyle parent = style.getStyle();
if (parent == null) {
String parentName = style.getStyleNameReference();
if (parentName != null) {
parent = (JRStyle)allStylesMap.get(parentName);
if (parent == null)
throw new JRRuntimeException("Style " + parentName + " not found");
}
}
if (parent != null)
collectUsedStyles(parent, usedStylesMap, allStylesMap);
usedStylesMap.put(style, null);
}
}
protected void useDelayedStyle(JRStyle style) {
List delayedSetters = (List)this.delayedStyleSettersByName.remove(style.getName());
if (delayedSetters != null)
for (Iterator it = delayedSetters.iterator(); it.hasNext(); ) {
JRStyleSetter setter = it.next();
setter.setStyle(style);
}
}
protected void checkUnresolvedReferences() {
if (!this.delayedStyleSettersByName.isEmpty()) {
StringBuffer errorMsg = new StringBuffer("Could not resolved style(s): ");
for (Iterator it = this.delayedStyleSettersByName.keySet().iterator(); it.hasNext(); ) {
String name = it.next();
errorMsg.append(name);
errorMsg.append(", ");
}
throw new JRRuntimeException(errorMsg.substring(0, errorMsg.length() - 2));
}
}
public JRDefaultStyleProvider getDefaultStyleProvider() {
return this.filler.getJasperPrint().getDefaultStyleProvider();
}
}

View File

@@ -0,0 +1,72 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRParameter;
import net.sf.jasperreports.engine.JRPropertiesHolder;
import net.sf.jasperreports.engine.JRPropertiesMap;
import net.sf.jasperreports.engine.JRValueParameter;
public class JRFillParameter implements JRValueParameter {
protected JRParameter parent = null;
private Object value = null;
protected JRFillParameter(JRParameter parameter, JRFillObjectFactory factory) {
factory.put(parameter, this);
this.parent = parameter;
}
public String getName() {
return this.parent.getName();
}
public String getDescription() {
return this.parent.getDescription();
}
public void setDescription(String description) {}
public Class getValueClass() {
return this.parent.getValueClass();
}
public String getValueClassName() {
return this.parent.getValueClassName();
}
public boolean isSystemDefined() {
return this.parent.isSystemDefined();
}
public boolean isForPrompting() {
return this.parent.isForPrompting();
}
public JRExpression getDefaultValueExpression() {
return this.parent.getDefaultValueExpression();
}
public Object getValue() {
return this.value;
}
public void setValue(Object value) {
this.value = value;
}
public boolean hasProperties() {
return this.parent.hasProperties();
}
public JRPropertiesMap getPropertiesMap() {
return this.parent.getPropertiesMap();
}
public JRPropertiesHolder getParentProperties() {
return null;
}
public Object clone() {
return null;
}
}

View File

@@ -0,0 +1,77 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRCommonRectangle;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRGraphicElement;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRPrintRectangle;
import net.sf.jasperreports.engine.JRRectangle;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRVisitor;
import net.sf.jasperreports.engine.util.JRStyleResolver;
public class JRFillRectangle extends JRFillGraphicElement implements JRRectangle {
protected JRFillRectangle(JRBaseFiller filler, JRRectangle rectangle, JRFillObjectFactory factory) {
super(filler, (JRGraphicElement)rectangle, factory);
}
protected JRFillRectangle(JRFillRectangle rectangle, JRFillCloneFactory factory) {
super(rectangle, factory);
}
public int getRadius() {
return JRStyleResolver.getRadius((JRCommonRectangle)this);
}
public Integer getOwnRadius() {
return ((JRRectangle)this.parent).getOwnRadius();
}
public void setRadius(int radius) {}
public void setRadius(Integer radius) {}
protected JRTemplateRectangle getJRTemplateRectangle() {
JRStyle style = getStyle();
JRTemplateRectangle template = (JRTemplateRectangle)getTemplate(style);
if (template == null) {
template = new JRTemplateRectangle((this.band == null) ? null : this.band.getOrigin(), this.filler.getJasperPrint().getDefaultStyleProvider(), this);
transferProperties(template);
registerTemplate(style, template);
}
return template;
}
protected void evaluate(byte evaluation) throws JRException {
reset();
evaluatePrintWhenExpression(evaluation);
evaluateProperties(evaluation);
setValueRepeating(true);
}
protected JRPrintElement fill() {
JRPrintRectangle printRectangle = null;
printRectangle = new JRTemplatePrintRectangle(getJRTemplateRectangle());
printRectangle.setX(getX());
printRectangle.setY(getRelativeY());
printRectangle.setWidth(getWidth());
printRectangle.setHeight(getStretchHeight());
transferProperties((JRPrintElement)printRectangle);
return (JRPrintElement)printRectangle;
}
public void collectExpressions(JRExpressionCollector collector) {
collector.collect(this);
}
public void visit(JRVisitor visitor) {
visitor.visitRectangle(this);
}
protected void resolveElement(JRPrintElement element, byte evaluation) {}
public JRFillCloneable createClone(JRFillCloneFactory factory) {
return new JRFillRectangle(this, factory);
}
}

View File

@@ -0,0 +1,65 @@
package net.sf.jasperreports.engine.fill;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRReportTemplate;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.JRTemplate;
import net.sf.jasperreports.engine.xml.JRXmlTemplateLoader;
public class JRFillReportTemplate implements JRReportTemplate {
private final JRReportTemplate parent;
private final JRBaseFiller filler;
public JRFillReportTemplate(JRReportTemplate template, JRBaseFiller filler, JRFillObjectFactory factory) {
factory.put(template, this);
this.parent = template;
this.filler = filler;
}
public JRExpression getSourceExpression() {
return this.parent.getSourceExpression();
}
public JRTemplate evaluate() throws JRException {
JRTemplate template;
JRExpression sourceExpression = getSourceExpression();
Object source = this.filler.evaluateExpression(sourceExpression, (byte)3);
if (source == null) {
template = null;
} else {
Class sourceType = sourceExpression.getValueClass();
if (JRTemplate.class.isAssignableFrom(sourceType)) {
template = (JRTemplate)source;
} else {
template = loadTemplate(source, sourceType, this.filler.fillContext);
}
}
return template;
}
protected static JRTemplate loadTemplate(Object source, Class sourceType, JRFillContext fillContext) throws JRException {
JRTemplate template;
if (fillContext.hasLoadedTemplate(source)) {
template = fillContext.getLoadedTemplate(source);
} else {
if (String.class.equals(sourceType)) {
template = JRXmlTemplateLoader.load((String)source);
} else if (File.class.isAssignableFrom(sourceType)) {
template = JRXmlTemplateLoader.load((File)source);
} else if (URL.class.isAssignableFrom(sourceType)) {
template = JRXmlTemplateLoader.load((URL)source);
} else if (InputStream.class.isAssignableFrom(sourceType)) {
template = JRXmlTemplateLoader.load((InputStream)source);
} else {
throw new JRRuntimeException("Unknown template source class " + sourceType.getName());
}
fillContext.registerLoadedTemplate(source, template);
}
return template;
}
}

View File

@@ -0,0 +1,113 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRStaticText;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRTextElement;
import net.sf.jasperreports.engine.JRVisitor;
public class JRFillStaticText extends JRFillTextElement implements JRStaticText {
protected JRFillStaticText(JRBaseFiller filler, JRStaticText staticText, JRFillObjectFactory factory) {
super(filler, (JRTextElement)staticText, factory);
String text = processMarkupText(staticText.getText());
if (text == null)
text = "";
setRawText(text);
}
protected JRFillStaticText(JRFillStaticText staticText, JRFillCloneFactory factory) {
super(staticText, factory);
String text = processMarkupText(staticText.getText());
if (text == null)
text = "";
setRawText(text);
}
public void setText(String text) {}
protected JRTemplateText getJRTemplateText() {
JRStyle style = getStyle();
JRTemplateText template = (JRTemplateText)getTemplate(style);
if (template == null) {
template = new JRTemplateText((this.band == null) ? null : this.band.getOrigin(), this.filler.getJasperPrint().getDefaultStyleProvider(), this);
transferProperties(template);
registerTemplate(style, template);
}
return template;
}
protected void evaluate(byte evaluation) throws JRException {
reset();
evaluatePrintWhenExpression(evaluation);
evaluateProperties(evaluation);
setTextStart(0);
setTextEnd(0);
setValueRepeating(true);
}
protected boolean prepare(int availableStretchHeight, boolean isOverflow) throws JRException {
boolean willOverflow = false;
super.prepare(availableStretchHeight, isOverflow);
if (!isToPrint())
return willOverflow;
boolean isToPrint = true;
boolean isReprinted = false;
if (isOverflow && isAlreadyPrinted() && !isPrintWhenDetailOverflows())
isToPrint = false;
if (isToPrint && isPrintWhenExpressionNull() && !isPrintRepeatedValues())
if ((!isPrintInFirstWholeBand() || !getBand().isFirstWholeOnPageColumn()) && (getPrintWhenGroupChanges() == null || !getBand().isNewGroup(getPrintWhenGroupChanges())) && (!isOverflow || !isPrintWhenDetailOverflows()))
isToPrint = false;
if (isToPrint && availableStretchHeight < getRelativeY() - getY() - getBandBottomY()) {
isToPrint = false;
willOverflow = true;
}
if (isToPrint && isOverflow && isPrintWhenDetailOverflows() && (isAlreadyPrinted() || (!isAlreadyPrinted() && !isPrintRepeatedValues())))
isReprinted = true;
setTextStart(0);
setTextEnd(0);
if (isToPrint)
chopTextElement(0);
setToPrint(isToPrint);
setReprinted(isReprinted);
return willOverflow;
}
protected JRPrintElement fill() {
JRTemplatePrintText text = new JRTemplatePrintText(getJRTemplateText());
text.setX(getX());
text.setY(getRelativeY());
text.setWidth(getWidth());
if (getRotation() == 0) {
text.setHeight(getStretchHeight());
} else {
text.setHeight(getHeight());
}
text.setRunDirection(getRunDirection());
text.setLineSpacingFactor(getLineSpacingFactor());
text.setLeadingOffset(getLeadingOffset());
text.setTextHeight(getTextHeight());
transferProperties(text);
setPrintText(text);
return text;
}
public void collectExpressions(JRExpressionCollector collector) {
collector.collect(this);
}
public void visit(JRVisitor visitor) {
visitor.visitStaticText(this);
}
protected void resolveElement(JRPrintElement element, byte evaluation) {}
public JRFillCloneable createClone(JRFillCloneFactory factory) {
return new JRFillStaticText(this, factory);
}
protected boolean canOverflow() {
return false;
}
}

View File

@@ -0,0 +1,491 @@
package net.sf.jasperreports.engine.fill;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sf.jasperreports.engine.JRCommonElement;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRDatasetParameter;
import net.sf.jasperreports.engine.JRElement;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRPrintPage;
import net.sf.jasperreports.engine.JRPrintRectangle;
import net.sf.jasperreports.engine.JRRewindableDataSource;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRSubreport;
import net.sf.jasperreports.engine.JRSubreportParameter;
import net.sf.jasperreports.engine.JRSubreportReturnValue;
import net.sf.jasperreports.engine.JRVariable;
import net.sf.jasperreports.engine.JRVisitor;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JRDesignSubreportReturnValue;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.engine.util.JRProperties;
import net.sf.jasperreports.engine.util.JRSingletonCache;
import net.sf.jasperreports.engine.util.JRStyleResolver;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class JRFillSubreport extends JRFillElement implements JRSubreport {
private static final Log log = LogFactory.getLog(JRFillSubreport.class);
private static final JRSingletonCache runnerFactoryCache = new JRSingletonCache(JRSubreportRunnerFactory.class);
private Map parameterValues = null;
private JRSubreportParameter[] parameters = null;
private Connection connection = null;
private JRDataSource dataSource = null;
private JasperReport jasperReport = null;
private Map loadedEvaluators = null;
private JRFillSubreportReturnValue[] returnValues = null;
protected JRBaseFiller subreportFiller = null;
private JRPrintPage printPage = null;
private JRSubreportRunner runner;
private Set checkedReports;
protected JRFillSubreport(JRBaseFiller filler, JRSubreport subreport, JRFillObjectFactory factory) {
super(filler, (JRElement)subreport, factory);
this.parameters = subreport.getParameters();
JRSubreportReturnValue[] subrepReturnValues = subreport.getReturnValues();
if (subrepReturnValues != null) {
List returnValuesList = new ArrayList(subrepReturnValues.length * 2);
this.returnValues = new JRFillSubreportReturnValue[subrepReturnValues.length];
for (int i = 0; i < subrepReturnValues.length; i++)
addReturnValue(subrepReturnValues[i], returnValuesList, factory);
this.returnValues = new JRFillSubreportReturnValue[returnValuesList.size()];
returnValuesList.toArray((Object[])this.returnValues);
}
this.loadedEvaluators = new HashMap();
this.checkedReports = new HashSet();
}
public byte getMode() {
return JRStyleResolver.getMode((JRCommonElement)this, (byte)2);
}
public boolean isUsingCache() {
return ((JRSubreport)this.parent).isUsingCache();
}
public void setUsingCache(boolean isUsingCache) {}
public JRExpression getParametersMapExpression() {
return ((JRSubreport)this.parent).getParametersMapExpression();
}
public JRSubreportParameter[] getParameters() {
return this.parameters;
}
public JRExpression getConnectionExpression() {
return ((JRSubreport)this.parent).getConnectionExpression();
}
public JRExpression getDataSourceExpression() {
return ((JRSubreport)this.parent).getDataSourceExpression();
}
public JRExpression getExpression() {
return ((JRSubreport)this.parent).getExpression();
}
protected JRTemplateRectangle getJRTemplateRectangle() {
JRStyle style = getStyle();
JRTemplateRectangle template = (JRTemplateRectangle)getTemplate(style);
if (template == null) {
template = new JRTemplateRectangle(this.band.getOrigin(), this.filler.getJasperPrint().getDefaultStyleProvider(), this);
transferProperties(template);
registerTemplate(style, template);
}
return template;
}
protected Collection getPrintElements() {
Collection printElements = null;
if (this.printPage != null)
printElements = this.printPage.getElements();
return printElements;
}
protected void evaluate(byte evaluation) throws JRException {
reset();
evaluatePrintWhenExpression(evaluation);
evaluateProperties(evaluation);
if (isPrintWhenExpressionNull() || (!isPrintWhenExpressionNull() && isPrintWhenTrue()))
evaluateSubreport(evaluation);
}
protected void evaluateSubreport(byte evaluation) throws JRException {
JRExpression expression = getExpression();
Object source = evaluateExpression(expression, evaluation);
if (source != null) {
JREvaluator evaluator = null;
if (isUsingCache() && this.filler.fillContext.hasLoadedSubreport(source)) {
this.jasperReport = this.filler.fillContext.getLoadedSubreport(source);
evaluator = (JREvaluator)this.loadedEvaluators.get(this.jasperReport);
if (evaluator == null) {
evaluator = JasperCompileManager.loadEvaluator(this.jasperReport);
this.loadedEvaluators.put(this.jasperReport, evaluator);
}
} else {
Class expressionClass = expression.getValueClass();
if (expressionClass.equals(JasperReport.class)) {
this.jasperReport = (JasperReport)source;
} else if (expressionClass.equals(InputStream.class)) {
this.jasperReport = (JasperReport)JRLoader.loadObject((InputStream)source);
} else if (expressionClass.equals(URL.class)) {
this.jasperReport = (JasperReport)JRLoader.loadObject((URL)source);
} else if (expressionClass.equals(File.class)) {
this.jasperReport = (JasperReport)JRLoader.loadObject((File)source);
} else if (expressionClass.equals(String.class)) {
this.jasperReport = (JasperReport)JRLoader.loadObjectFromLocation((String)source, this.filler.reportClassLoader, this.filler.urlHandlerFactory, this.filler.fileResolver);
}
if (this.jasperReport != null)
evaluator = JasperCompileManager.loadEvaluator(this.jasperReport);
if (isUsingCache()) {
this.filler.fillContext.registerLoadedSubreport(source, this.jasperReport);
this.loadedEvaluators.put(this.jasperReport, evaluator);
}
}
if (this.jasperReport != null) {
expression = getConnectionExpression();
this.connection = (Connection)evaluateExpression(expression, evaluation);
expression = getDataSourceExpression();
this.dataSource = (JRDataSource)evaluateExpression(expression, evaluation);
this.parameterValues = getParameterValues(this.filler, getParametersMapExpression(), (JRDatasetParameter[])getParameters(), evaluation, false, (this.jasperReport.getResourceBundle() != null), (this.jasperReport.getFormatFactoryClass() != null));
if (this.subreportFiller != null)
this.filler.unregisterSubfiller(this.subreportFiller);
initSubreportFiller(evaluator);
checkReturnValues();
saveReturnVariables();
}
}
}
protected void initSubreportFiller(JREvaluator evaluator) throws JRException {
if (log.isDebugEnabled())
log.debug("Fill " + this.filler.fillerId + ": creating subreport filler");
switch (this.jasperReport.getPrintOrder()) {
case 2:
this.subreportFiller = new JRHorizontalFiller(this.jasperReport, evaluator, this.filler);
break;
case 1:
this.subreportFiller = new JRVerticalFiller(this.jasperReport, evaluator, this.filler);
break;
default:
throw new JRRuntimeException("Unkown print order " + this.jasperReport.getPrintOrder() + ".");
}
this.runner = getRunnerFactory().createSubreportRunner(this, this.subreportFiller);
this.subreportFiller.setSubreportRunner(this.runner);
}
protected void saveReturnVariables() {
if (this.returnValues != null)
for (int i = 0; i < this.returnValues.length; i++) {
String varName = this.returnValues[i].getToVariable();
this.band.saveVariable(varName);
}
}
public static Map getParameterValues(JRBaseFiller filler, JRExpression parametersMapExpression, JRDatasetParameter[] subreportParameters, byte evaluation, boolean ignoreNullExpressions, boolean removeResourceBundle, boolean removeFormatFactory) throws JRException {
Map parameterValues = null;
if (parametersMapExpression != null)
parameterValues = (Map)filler.evaluateExpression(parametersMapExpression, evaluation);
if (parameterValues != null) {
if (removeResourceBundle)
parameterValues.remove("REPORT_RESOURCE_BUNDLE");
if (removeFormatFactory)
parameterValues.remove("REPORT_FORMAT_FACTORY");
parameterValues.remove("REPORT_CONNECTION");
parameterValues.remove("REPORT_MAX_COUNT");
parameterValues.remove("REPORT_DATA_SOURCE");
parameterValues.remove("REPORT_SCRIPTLET");
parameterValues.remove("REPORT_VIRTUALIZER");
parameterValues.remove("IS_IGNORE_PAGINATION");
parameterValues.remove("REPORT_PARAMETERS_MAP");
}
if (parameterValues == null)
parameterValues = new HashMap();
if (subreportParameters != null && subreportParameters.length > 0) {
Object parameterValue = null;
for (int i = 0; i < subreportParameters.length; i++) {
JRExpression expression = subreportParameters[i].getExpression();
if (expression != null || !ignoreNullExpressions) {
parameterValue = filler.evaluateExpression(expression, evaluation);
if (parameterValue == null) {
parameterValues.remove(subreportParameters[i].getName());
} else {
parameterValues.put(subreportParameters[i].getName(), parameterValue);
}
}
}
}
if (!parameterValues.containsKey("REPORT_LOCALE"))
parameterValues.put("REPORT_LOCALE", filler.getLocale());
if (!parameterValues.containsKey("REPORT_TIME_ZONE"))
parameterValues.put("REPORT_TIME_ZONE", filler.getTimeZone());
if (!parameterValues.containsKey("REPORT_FORMAT_FACTORY") && !removeFormatFactory)
parameterValues.put("REPORT_FORMAT_FACTORY", filler.getFormatFactory());
if (!parameterValues.containsKey("REPORT_CLASS_LOADER") && filler.reportClassLoader != null)
parameterValues.put("REPORT_CLASS_LOADER", filler.reportClassLoader);
if (!parameterValues.containsKey("REPORT_URL_HANDLER_FACTORY") && filler.urlHandlerFactory != null)
parameterValues.put("REPORT_URL_HANDLER_FACTORY", filler.urlHandlerFactory);
if (!parameterValues.containsKey("REPORT_FILE_RESOLVER") && filler.fileResolver != null)
parameterValues.put("REPORT_FILE_RESOLVER", filler.fileResolver);
return parameterValues;
}
protected void fillSubreport() throws JRException {
if (getConnectionExpression() != null) {
this.subreportFiller.fill(this.parameterValues, this.connection);
} else if (getDataSourceExpression() != null) {
this.subreportFiller.fill(this.parameterValues, this.dataSource);
} else {
this.subreportFiller.fill(this.parameterValues);
}
}
protected boolean prepare(int availableStretchHeight, boolean isOverflow) throws JRException {
boolean willOverflow = false;
super.prepare(availableStretchHeight, isOverflow);
if (this.subreportFiller == null)
setToPrint(false);
if (!isToPrint())
return willOverflow;
if (availableStretchHeight < getRelativeY() - getY() - getBandBottomY()) {
setToPrint(false);
return true;
}
boolean filling = this.runner.isFilling();
boolean toPrint = (!isOverflow || isPrintWhenDetailOverflows() || !isAlreadyPrinted());
boolean reprinted = (isOverflow && isPrintWhenDetailOverflows());
if (!filling && toPrint && reprinted)
rewind();
int availableHeight = getHeight() + availableStretchHeight - getRelativeY() + getY() + getBandBottomY();
this.subreportFiller.setPageHeight(availableHeight);
synchronized (this.subreportFiller) {
JRSubreportRunResult result;
if (filling) {
if (log.isDebugEnabled())
log.debug("Fill " + this.filler.fillerId + ": resuming " + this.subreportFiller.fillerId);
result = this.runner.resume();
} else if (toPrint) {
setReprinted(reprinted);
if (log.isDebugEnabled())
log.debug("Fill " + this.filler.fillerId + ": starting " + this.subreportFiller.fillerId);
result = this.runner.start();
} else {
this.printPage = null;
setStretchHeight(getHeight());
setToPrint(false);
return willOverflow;
}
if (result.getException() != null) {
Throwable error = result.getException();
if (log.isErrorEnabled())
log.error("Fill " + this.filler.fillerId + ": exception", error);
if (error instanceof RuntimeException)
throw (RuntimeException)error;
throw new JRRuntimeException(error);
}
if (result.hasFinished()) {
if (log.isDebugEnabled())
log.debug("Fill " + this.filler.fillerId + ": subreport " + this.subreportFiller.fillerId + " finished");
copyValues();
} else if (log.isDebugEnabled()) {
log.debug("Fill " + this.filler.fillerId + ": subreport " + this.subreportFiller.fillerId + " to continue");
}
this.printPage = this.subreportFiller.getCurrentPage();
setStretchHeight(result.hasFinished() ? this.subreportFiller.getCurrentPageStretchHeight() : availableHeight);
willOverflow = !result.hasFinished();
if (!willOverflow)
this.runner.reset();
}
Collection printElements = getPrintElements();
if ((printElements == null || printElements.size() == 0) && isRemoveLineWhenBlank())
setToPrint(false);
return willOverflow;
}
public void rewind() throws JRException {
if (this.subreportFiller == null)
return;
if (log.isDebugEnabled())
log.debug("Fill " + this.filler.fillerId + ": cancelling " + this.subreportFiller.fillerId);
this.subreportFiller.setInterrupted(true);
synchronized (this.subreportFiller) {
this.runner.cancel();
this.runner.reset();
}
this.filler.unregisterSubfiller(this.subreportFiller);
initSubreportFiller((JREvaluator)null);
if (getConnectionExpression() == null && this.dataSource != null)
if (this.dataSource instanceof JRRewindableDataSource) {
((JRRewindableDataSource)this.dataSource).moveFirst();
} else {
throw new JRException("The subreport is placed on a non-splitting band, but it does not have a rewindable data source.");
}
}
protected JRPrintElement fill() {
JRPrintRectangle printRectangle = new JRTemplatePrintRectangle(getJRTemplateRectangle());
printRectangle.setX(getX());
printRectangle.setY(getRelativeY());
printRectangle.setWidth(getWidth());
printRectangle.setHeight(getStretchHeight());
return (JRPrintElement)printRectangle;
}
public void collectExpressions(JRExpressionCollector collector) {
collector.collect(this);
}
public void visit(JRVisitor visitor) {
visitor.visitSubreport(this);
}
private JRFillSubreportReturnValue addReturnValue(JRSubreportReturnValue parentReturnValue, List returnValueList, JRFillObjectFactory factory) {
JRSubreportReturnValue jRSubreportReturnValue1, varianceVal, countVal, sumVal;
JRFillSubreportReturnValue returnValue = factory.getSubreportReturnValue(parentReturnValue);
byte calculation = returnValue.getCalculation();
switch (calculation) {
case 3:
case 7:
jRSubreportReturnValue1 = createHelperReturnValue(parentReturnValue, "_COUNT", (byte)1);
addReturnValue(jRSubreportReturnValue1, returnValueList, factory);
sumVal = createHelperReturnValue(parentReturnValue, "_SUM", (byte)2);
addReturnValue(sumVal, returnValueList, factory);
this.filler.addVariableCalculationReq(returnValue.getToVariable(), calculation);
break;
case 6:
varianceVal = createHelperReturnValue(parentReturnValue, "_VARIANCE", (byte)7);
addReturnValue(varianceVal, returnValueList, factory);
this.filler.addVariableCalculationReq(returnValue.getToVariable(), calculation);
break;
case 10:
countVal = createDistinctCountHelperReturnValue(parentReturnValue);
addReturnValue(countVal, returnValueList, factory);
this.filler.addVariableCalculationReq(returnValue.getToVariable(), calculation);
break;
}
returnValueList.add(returnValue);
return returnValue;
}
protected JRSubreportReturnValue createHelperReturnValue(JRSubreportReturnValue returnValue, String nameSuffix, byte calculation) {
JRDesignSubreportReturnValue helper = new JRDesignSubreportReturnValue();
helper.setToVariable(returnValue.getToVariable() + nameSuffix);
helper.setSubreportVariable(returnValue.getSubreportVariable());
helper.setCalculation(calculation);
helper.setIncrementerFactoryClassName(helper.getIncrementerFactoryClassName());
return (JRSubreportReturnValue)helper;
}
protected JRSubreportReturnValue createDistinctCountHelperReturnValue(JRSubreportReturnValue returnValue) {
JRDesignSubreportReturnValue helper = new JRDesignSubreportReturnValue();
helper.setToVariable(returnValue.getToVariable() + "_DISTINCT_COUNT");
helper.setSubreportVariable(returnValue.getSubreportVariable());
helper.setCalculation((byte)0);
helper.setIncrementerFactoryClassName(helper.getIncrementerFactoryClassName());
return (JRSubreportReturnValue)helper;
}
public JRSubreportReturnValue[] getReturnValues() {
return (JRSubreportReturnValue[])this.returnValues;
}
public boolean usesForReturnValue(String variableName) {
boolean used = false;
if (this.returnValues != null)
for (int j = 0; j < this.returnValues.length; j++) {
JRSubreportReturnValue returnValue = this.returnValues[j];
if (returnValue.getToVariable().equals(variableName)) {
used = true;
break;
}
}
return used;
}
protected void copyValues() {
if (this.returnValues != null && this.returnValues.length > 0)
for (int i = 0; i < this.returnValues.length; i++)
copyValue(this.returnValues[i]);
}
protected void copyValue(JRFillSubreportReturnValue returnValue) {
try {
JRFillVariable variable = this.filler.getVariable(returnValue.getToVariable());
Object value = this.subreportFiller.getVariableValue(returnValue.getSubreportVariable());
Object newValue = returnValue.getIncrementer().increment(variable, value, AbstractValueProvider.getCurrentValueProvider());
variable.setOldValue(newValue);
variable.setValue(newValue);
variable.setIncrementedValue(newValue);
} catch (JRException e) {
throw new JRRuntimeException(e);
}
}
private void checkReturnValues() throws JRException {
if (this.returnValues != null && this.returnValues.length > 0 && !this.checkedReports.contains(this.jasperReport)) {
for (int i = 0; i < this.returnValues.length; i++) {
JRSubreportReturnValue returnValue = this.returnValues[i];
String subreportVariableName = returnValue.getSubreportVariable();
JRVariable subrepVariable = this.subreportFiller.getVariable(subreportVariableName);
if (subrepVariable == null)
throw new JRException("Subreport variable " + subreportVariableName + " not found.");
JRVariable variable = this.filler.getVariable(returnValue.getToVariable());
if (returnValue.getCalculation() == 1 || returnValue.getCalculation() == 10) {
if (!Number.class.isAssignableFrom(variable.getValueClass()))
throw new JRException("Variable " + returnValue.getToVariable() + " must have a numeric type.");
} else if (!variable.getValueClass().isAssignableFrom(subrepVariable.getValueClass()) && (!Number.class.isAssignableFrom(variable.getValueClass()) || !Number.class.isAssignableFrom(subrepVariable.getValueClass()))) {
throw new JRException("Variable " + returnValue.getToVariable() + " is not assignable from subreport variable " + subreportVariableName);
}
}
if (isUsingCache())
this.checkedReports.add(this.jasperReport);
}
}
protected void resolveElement(JRPrintElement element, byte evaluation) {}
public Boolean isOwnUsingCache() {
return ((JRSubreport)this.parent).isOwnUsingCache();
}
public void setUsingCache(Boolean isUsingCache) {}
public JRFillCloneable createClone(JRFillCloneFactory factory) {
return null;
}
protected static JRSubreportRunnerFactory getRunnerFactory() throws JRException {
String factoryClassName = JRProperties.getProperty("net.sf.jasperreports.subreport.runner.factory");
if (factoryClassName == null)
throw new JRException("Property \"net.sf.jasperreports.subreport.runner.factory\" must be set");
return (JRSubreportRunnerFactory)runnerFactoryCache.getCachedInstance(factoryClassName);
}
}

View File

@@ -0,0 +1,60 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.JRSubreportReturnValue;
import net.sf.jasperreports.engine.JRVariable;
import net.sf.jasperreports.engine.util.JRClassLoader;
public class JRFillSubreportReturnValue implements JRSubreportReturnValue {
protected final JRSubreportReturnValue parent;
protected JRIncrementer incrementer = null;
protected final JRBaseFiller filler;
protected JRFillSubreportReturnValue(JRSubreportReturnValue returnValue, JRFillObjectFactory factory, JRBaseFiller filler) {
factory.put(returnValue, this);
this.parent = returnValue;
this.filler = filler;
}
public String getSubreportVariable() {
return this.parent.getSubreportVariable();
}
public String getToVariable() {
return this.parent.getToVariable();
}
public String getIncrementerFactoryClassName() {
return this.parent.getIncrementerFactoryClassName();
}
public byte getCalculation() {
return this.parent.getCalculation();
}
public JRIncrementer getIncrementer() {
if (this.incrementer == null) {
JRIncrementerFactory incrementerFactory;
String incrementerFactoryClassName = getIncrementerFactoryClassName();
if (incrementerFactoryClassName == null) {
JRVariable toVariable = this.filler.getVariable(getToVariable());
incrementerFactory = JRDefaultIncrementerFactory.getFactory(toVariable.getValueClass());
} else {
try {
Class incrementerFactoryClass = JRClassLoader.loadClassForName(incrementerFactoryClassName);
incrementerFactory = JRIncrementerFactoryCache.getInstance(incrementerFactoryClass);
} catch (ClassNotFoundException e) {
throw new JRRuntimeException("Increment class " + incrementerFactoryClassName + " not found.", e);
}
}
this.incrementer = incrementerFactory.getIncrementer(getCalculation());
}
return this.incrementer;
}
public Object clone() {
return null;
}
}

View File

@@ -0,0 +1,716 @@
package net.sf.jasperreports.engine.fill;
import java.awt.Color;
import java.awt.font.TextAttribute;
import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.JRAlignment;
import net.sf.jasperreports.engine.JRBox;
import net.sf.jasperreports.engine.JRBoxContainer;
import net.sf.jasperreports.engine.JRCommonElement;
import net.sf.jasperreports.engine.JRCommonText;
import net.sf.jasperreports.engine.JRElement;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRFont;
import net.sf.jasperreports.engine.JRLineBox;
import net.sf.jasperreports.engine.JRPen;
import net.sf.jasperreports.engine.JRPrintText;
import net.sf.jasperreports.engine.JRPropertiesHolder;
import net.sf.jasperreports.engine.JRReportFont;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRTextElement;
import net.sf.jasperreports.engine.util.JRFontUtil;
import net.sf.jasperreports.engine.util.JRPenUtil;
import net.sf.jasperreports.engine.util.JRProperties;
import net.sf.jasperreports.engine.util.JRSingletonCache;
import net.sf.jasperreports.engine.util.JRStringUtil;
import net.sf.jasperreports.engine.util.JRStyleResolver;
import net.sf.jasperreports.engine.util.JRStyledText;
import net.sf.jasperreports.engine.util.JRTextMeasurerUtil;
import net.sf.jasperreports.engine.util.LineBoxWrapper;
import net.sf.jasperreports.engine.util.MarkupProcessor;
import net.sf.jasperreports.engine.util.MarkupProcessorFactory;
public abstract class JRFillTextElement extends JRFillElement implements JRTextElement {
private static final JRSingletonCache markupProcessorFactoryCache = new JRSingletonCache(MarkupProcessorFactory.class);
private static final Map markupProcessors = new HashMap();
private boolean isLeftToRight = true;
private JRTextMeasurer textMeasurer = null;
private float lineSpacingFactor = 0.0F;
private float leadingOffset = 0.0F;
private float textHeight = 0.0F;
private int textStart = 0;
private int textEnd = 0;
private String textTruncateSuffix;
private String rawText = null;
private JRStyledText styledText = null;
private Map styledTextAttributesMap = new HashMap();
protected final JRReportFont reportFont;
protected JRFillTextElement(JRBaseFiller filler, JRTextElement textElement, JRFillObjectFactory factory) {
super(filler, (JRElement)textElement, factory);
this.reportFont = factory.getReportFont(textElement.getReportFont());
}
protected JRFillTextElement(JRFillTextElement textElement, JRFillCloneFactory factory) {
super(textElement, factory);
this.reportFont = textElement.reportFont;
}
private void createTextMeasurer() {
this.textMeasurer = JRTextMeasurerUtil.createTextMeasurer((JRCommonText)this);
}
protected void ensureTextMeasurer() {
if (this.textMeasurer == null)
createTextMeasurer();
}
public byte getMode() {
return JRStyleResolver.getMode((JRCommonElement)this, (byte)2);
}
public byte getTextAlignment() {
return JRStyleResolver.getHorizontalAlignment((JRAlignment)this);
}
public void setTextAlignment(byte horizontalAlignment) {}
public byte getHorizontalAlignment() {
return JRStyleResolver.getHorizontalAlignment((JRAlignment)this);
}
public Byte getOwnHorizontalAlignment() {
return ((JRTextElement)this.parent).getOwnHorizontalAlignment();
}
public void setHorizontalAlignment(byte horizontalAlignment) {}
public void setHorizontalAlignment(Byte horizontalAlignment) {}
public byte getVerticalAlignment() {
return JRStyleResolver.getVerticalAlignment((JRAlignment)this);
}
public Byte getOwnVerticalAlignment() {
return ((JRTextElement)this.parent).getOwnVerticalAlignment();
}
public void setVerticalAlignment(byte verticalAlignment) {}
public void setVerticalAlignment(Byte verticalAlignment) {}
public byte getRotation() {
return JRStyleResolver.getRotation((JRCommonText)this);
}
public Byte getOwnRotation() {
return ((JRTextElement)this.parent).getOwnRotation();
}
public void setRotation(byte rotation) {}
public void setRotation(Byte rotation) {}
public byte getLineSpacing() {
return JRStyleResolver.getLineSpacing((JRCommonText)this);
}
public Byte getOwnLineSpacing() {
return ((JRTextElement)this.parent).getOwnLineSpacing();
}
public void setLineSpacing(byte lineSpacing) {}
public void setLineSpacing(Byte lineSpacing) {}
public boolean isStyledText() {
return "styled".equals(getMarkup());
}
public Boolean isOwnStyledText() {
String mkp = getOwnMarkup();
return "styled".equals(mkp) ? Boolean.TRUE : ((mkp == null) ? null : Boolean.FALSE);
}
public void setStyledText(boolean isStyledText) {}
public void setStyledText(Boolean isStyledText) {}
public String getMarkup() {
return JRStyleResolver.getMarkup((JRCommonText)this);
}
public String getOwnMarkup() {
return ((JRTextElement)this.parent).getOwnMarkup();
}
public void setMarkup(String markup) {}
public JRBox getBox() {
return (JRBox)new LineBoxWrapper(getLineBox());
}
public JRLineBox getLineBox() {
return ((JRBoxContainer)this.parent).getLineBox();
}
public byte getBorder() {
return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getPen());
}
public Byte getOwnBorder() {
return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getPen());
}
public void setBorder(byte border) {
JRPenUtil.setLinePenFromPen(border, (JRPen)getLineBox().getPen());
}
public void setBorder(Byte border) {
JRPenUtil.setLinePenFromPen(border, (JRPen)getLineBox().getPen());
}
public Color getBorderColor() {
return getLineBox().getPen().getLineColor();
}
public Color getOwnBorderColor() {
return getLineBox().getPen().getOwnLineColor();
}
public void setBorderColor(Color borderColor) {
getLineBox().getPen().setLineColor(borderColor);
}
public int getPadding() {
return getLineBox().getPadding().intValue();
}
public Integer getOwnPadding() {
return getLineBox().getOwnPadding();
}
public void setPadding(int padding) {
getLineBox().setPadding(padding);
}
public void setPadding(Integer padding) {
getLineBox().setPadding(padding);
}
public byte getTopBorder() {
return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getTopPen());
}
public Byte getOwnTopBorder() {
return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getTopPen());
}
public void setTopBorder(byte topBorder) {
JRPenUtil.setLinePenFromPen(topBorder, (JRPen)getLineBox().getTopPen());
}
public void setTopBorder(Byte topBorder) {
JRPenUtil.setLinePenFromPen(topBorder, (JRPen)getLineBox().getTopPen());
}
public Color getTopBorderColor() {
return getLineBox().getTopPen().getLineColor();
}
public Color getOwnTopBorderColor() {
return getLineBox().getTopPen().getOwnLineColor();
}
public void setTopBorderColor(Color topBorderColor) {
getLineBox().getTopPen().setLineColor(topBorderColor);
}
public int getTopPadding() {
return getLineBox().getTopPadding().intValue();
}
public Integer getOwnTopPadding() {
return getLineBox().getOwnTopPadding();
}
public void setTopPadding(int topPadding) {
getLineBox().setTopPadding(topPadding);
}
public void setTopPadding(Integer topPadding) {
getLineBox().setTopPadding(topPadding);
}
public byte getLeftBorder() {
return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getLeftPen());
}
public Byte getOwnLeftBorder() {
return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getLeftPen());
}
public void setLeftBorder(byte leftBorder) {
JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)getLineBox().getLeftPen());
}
public void setLeftBorder(Byte leftBorder) {
JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)getLineBox().getLeftPen());
}
public Color getLeftBorderColor() {
return getLineBox().getLeftPen().getLineColor();
}
public Color getOwnLeftBorderColor() {
return getLineBox().getLeftPen().getOwnLineColor();
}
public void setLeftBorderColor(Color leftBorderColor) {
getLineBox().getLeftPen().setLineColor(leftBorderColor);
}
public int getLeftPadding() {
return getLineBox().getLeftPadding().intValue();
}
public Integer getOwnLeftPadding() {
return getLineBox().getOwnLeftPadding();
}
public void setLeftPadding(int leftPadding) {
getLineBox().setLeftPadding(leftPadding);
}
public void setLeftPadding(Integer leftPadding) {
getLineBox().setLeftPadding(leftPadding);
}
public byte getBottomBorder() {
return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getBottomPen());
}
public Byte getOwnBottomBorder() {
return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getBottomPen());
}
public void setBottomBorder(byte bottomBorder) {
JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)getLineBox().getBottomPen());
}
public void setBottomBorder(Byte bottomBorder) {
JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)getLineBox().getBottomPen());
}
public Color getBottomBorderColor() {
return getLineBox().getBottomPen().getLineColor();
}
public Color getOwnBottomBorderColor() {
return getLineBox().getBottomPen().getOwnLineColor();
}
public void setBottomBorderColor(Color bottomBorderColor) {
getLineBox().getBottomPen().setLineColor(bottomBorderColor);
}
public int getBottomPadding() {
return getLineBox().getBottomPadding().intValue();
}
public Integer getOwnBottomPadding() {
return getLineBox().getOwnBottomPadding();
}
public void setBottomPadding(int bottomPadding) {
getLineBox().setBottomPadding(bottomPadding);
}
public void setBottomPadding(Integer bottomPadding) {
getLineBox().setBottomPadding(bottomPadding);
}
public byte getRightBorder() {
return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getRightPen());
}
public Byte getOwnRightBorder() {
return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getRightPen());
}
public void setRightBorder(byte rightBorder) {
JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)getLineBox().getRightPen());
}
public void setRightBorder(Byte rightBorder) {
JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)getLineBox().getRightPen());
}
public Color getRightBorderColor() {
return getLineBox().getRightPen().getLineColor();
}
public Color getOwnRightBorderColor() {
return getLineBox().getRightPen().getOwnLineColor();
}
public void setRightBorderColor(Color rightBorderColor) {
getLineBox().getRightPen().setLineColor(rightBorderColor);
}
public int getRightPadding() {
return getLineBox().getRightPadding().intValue();
}
public Integer getOwnRightPadding() {
return getLineBox().getOwnRightPadding();
}
public void setRightPadding(int rightPadding) {
getLineBox().setRightPadding(rightPadding);
}
public void setRightPadding(Integer rightPadding) {
getLineBox().setRightPadding(rightPadding);
}
public JRFont getFont() {
return (JRFont)this;
}
protected Map getStyledTextAttributes() {
JRStyle style = getStyle();
Map styledTextAttributes = (Map)this.styledTextAttributesMap.get(style);
if (styledTextAttributes == null) {
styledTextAttributes = new HashMap();
JRFontUtil.setAttributes(styledTextAttributes, (JRFont)this);
styledTextAttributes.put(TextAttribute.FOREGROUND, getForecolor());
if (getMode() == 1)
styledTextAttributes.put(TextAttribute.BACKGROUND, getBackcolor());
this.styledTextAttributesMap.put(style, styledTextAttributes);
}
return styledTextAttributes;
}
protected float getLineSpacingFactor() {
return this.lineSpacingFactor;
}
protected void setLineSpacingFactor(float lineSpacingFactor) {
this.lineSpacingFactor = lineSpacingFactor;
}
protected float getLeadingOffset() {
return this.leadingOffset;
}
protected void setLeadingOffset(float leadingOffset) {
this.leadingOffset = leadingOffset;
}
protected byte getRunDirection() {
return this.isLeftToRight ? 0 : 1;
}
protected float getTextHeight() {
return this.textHeight;
}
protected void setTextHeight(float textHeight) {
this.textHeight = textHeight;
}
protected int getTextStart() {
return this.textStart;
}
protected void setTextStart(int textStart) {
this.textStart = textStart;
}
protected int getTextEnd() {
return this.textEnd;
}
protected void setTextEnd(int textEnd) {
this.textEnd = textEnd;
}
protected String getRawText() {
return this.rawText;
}
protected void setRawText(String rawText) {
this.rawText = rawText;
this.styledText = null;
}
protected void reset() {
super.reset();
this.isLeftToRight = true;
this.lineSpacingFactor = 0.0F;
this.leadingOffset = 0.0F;
this.textHeight = 0.0F;
}
protected void rewind() {
this.textStart = 0;
this.textEnd = 0;
}
protected JRStyledText getStyledText() {
if (this.styledText == null) {
String text = getRawText();
if (text != null)
this.styledText = this.filler.getStyledTextParser().getStyledText(getStyledTextAttributes(), text, !"none".equals(getMarkup()));
}
return this.styledText;
}
public String getText() {
JRStyledText tmpStyledText = getStyledText();
if (tmpStyledText == null)
return null;
return tmpStyledText.getText();
}
protected void chopTextElement(int availableStretchHeight) {
ensureTextMeasurer();
JRStyledText tmpStyledText = getStyledText();
if (tmpStyledText == null)
return;
if (getTextEnd() == tmpStyledText.getText().length())
return;
JRMeasuredText measuredText = this.textMeasurer.measure(tmpStyledText, getTextEnd(), availableStretchHeight, canOverflow());
this.isLeftToRight = measuredText.isLeftToRight();
setTextHeight(measuredText.getTextHeight());
if (getRotation() == 0) {
setStretchHeight((int)getTextHeight() + getLineBox().getTopPadding().intValue() + getLineBox().getBottomPadding().intValue());
} else {
setStretchHeight(getHeight());
}
setTextStart(getTextEnd());
setTextEnd(measuredText.getTextOffset());
setTextTruncateSuffix(measuredText.getTextSuffix());
setLineSpacingFactor(measuredText.getLineSpacingFactor());
setLeadingOffset(measuredText.getLeadingOffset());
}
public JRReportFont getReportFont() {
return this.reportFont;
}
public void setReportFont(JRReportFont reportFont) {}
public String getFontName() {
return JRStyleResolver.getFontName((JRFont)this);
}
public String getOwnFontName() {
return ((JRFont)this.parent).getOwnFontName();
}
public void setFontName(String fontName) {}
public boolean isBold() {
return JRStyleResolver.isBold((JRFont)this);
}
public Boolean isOwnBold() {
return ((JRFont)this.parent).isOwnBold();
}
public void setBold(boolean isBold) {}
public void setBold(Boolean isBold) {}
public boolean isItalic() {
return JRStyleResolver.isItalic((JRFont)this);
}
public Boolean isOwnItalic() {
return ((JRFont)this.parent).isOwnItalic();
}
public void setItalic(boolean isItalic) {}
public void setItalic(Boolean isItalic) {}
public boolean isUnderline() {
return JRStyleResolver.isUnderline((JRFont)this);
}
public Boolean isOwnUnderline() {
return ((JRFont)this.parent).isOwnUnderline();
}
public void setUnderline(boolean isUnderline) {}
public void setUnderline(Boolean isUnderline) {}
public boolean isStrikeThrough() {
return JRStyleResolver.isStrikeThrough((JRFont)this);
}
public Boolean isOwnStrikeThrough() {
return ((JRFont)this.parent).isOwnStrikeThrough();
}
public void setStrikeThrough(boolean isStrikeThrough) {}
public void setStrikeThrough(Boolean isStrikeThrough) {}
public int getFontSize() {
return JRStyleResolver.getFontSize((JRFont)this);
}
public Integer getOwnFontSize() {
return ((JRFont)this.parent).getOwnFontSize();
}
public void setFontSize(int size) {}
public void setFontSize(Integer size) {}
public int getSize() {
return getFontSize();
}
public Integer getOwnSize() {
return getOwnFontSize();
}
public void setSize(int size) {}
public void setSize(Integer size) {}
public String getPdfFontName() {
return JRStyleResolver.getPdfFontName((JRFont)this);
}
public String getOwnPdfFontName() {
return ((JRFont)this.parent).getOwnPdfFontName();
}
public void setPdfFontName(String pdfFontName) {}
public String getPdfEncoding() {
return JRStyleResolver.getPdfEncoding((JRFont)this);
}
public String getOwnPdfEncoding() {
return ((JRFont)this.parent).getOwnPdfEncoding();
}
public void setPdfEncoding(String pdfEncoding) {}
public boolean isPdfEmbedded() {
return JRStyleResolver.isPdfEmbedded((JRFont)this);
}
public Boolean isOwnPdfEmbedded() {
return ((JRFont)this.parent).isOwnPdfEmbedded();
}
public void setPdfEmbedded(boolean isPdfEmbedded) {
setPdfEmbedded(isPdfEmbedded ? Boolean.TRUE : Boolean.FALSE);
}
public void setPdfEmbedded(Boolean isPdfEmbedded) {}
public Color getDefaultLineColor() {
return getForecolor();
}
public void setHeight(int height) {
super.setHeight(height);
createTextMeasurer();
}
public void setWidth(int width) {
super.setWidth(width);
createTextMeasurer();
}
protected String processMarkupText(String text) {
text = JRStringUtil.replaceCRwithLF(text);
if (text != null) {
String markup = getMarkup();
if (!"none".equals(markup) && !"styled".equals(markup))
text = getMarkupProcessor(markup).convert(text);
}
return text;
}
protected static MarkupProcessor getMarkupProcessor(String markup) {
MarkupProcessor markupProcessor = (MarkupProcessor)markupProcessors.get(markup);
if (markupProcessor == null) {
String factoryClass = JRProperties.getProperty("net.sf.jasperreports.markup.processor.factory." + markup);
if (factoryClass == null)
throw new JRRuntimeException("No markup processor factory specifyed for '" + markup + "' markup.");
MarkupProcessorFactory factory = null;
try {
factory = (MarkupProcessorFactory)markupProcessorFactoryCache.getCachedInstance(factoryClass);
} catch (JRException e) {
throw new JRRuntimeException(e);
}
markupProcessor = factory.createMarkupProcessor();
markupProcessors.put(markup, markupProcessor);
}
return markupProcessor;
}
protected void setPrintText(JRPrintText printText) {
int startIndex = getTextStart();
int endIndex = getTextEnd();
JRStyledText fullStyledText = getStyledText();
String fullText = fullStyledText.getText();
boolean keepAllText = (!canOverflow() && JRProperties.getBooleanProperty((JRPropertiesHolder)this, "net.sf.jasperreports.print.keep.full.text", false));
if (keepAllText) {
if (startIndex != 0)
throw new JRRuntimeException("Text start index != 0 on keep all text.");
if (!"none".equals(getMarkup())) {
String styledText = this.filler.getStyledTextParser().write(fullStyledText);
printText.setText(styledText);
} else {
printText.setText(fullText);
}
if (endIndex < fullText.length())
printText.setTextTruncateIndex(new Integer(endIndex));
} else {
String printedText;
if (!"none".equals(getMarkup())) {
printedText = this.filler.getStyledTextParser().write(fullStyledText, startIndex, endIndex);
} else {
printedText = fullText.substring(startIndex, endIndex);
}
printText.setText(printedText);
}
printText.setTextTruncateSuffix(getTextTruncateSuffix());
}
protected String getTextTruncateSuffix() {
return this.textTruncateSuffix;
}
protected void setTextTruncateSuffix(String textTruncateSuffix) {
this.textTruncateSuffix = textTruncateSuffix;
}
protected abstract boolean canOverflow();
}

View File

@@ -0,0 +1,383 @@
package net.sf.jasperreports.engine.fill;
import java.text.DecimalFormat;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRGroup;
import net.sf.jasperreports.engine.JRHyperlink;
import net.sf.jasperreports.engine.JRHyperlinkParameter;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRPrintHyperlinkParameters;
import net.sf.jasperreports.engine.JRPrintText;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRTextElement;
import net.sf.jasperreports.engine.JRTextField;
import net.sf.jasperreports.engine.JRVisitor;
import net.sf.jasperreports.engine.util.JRDataUtils;
import net.sf.jasperreports.engine.util.JRStyleResolver;
public class JRFillTextField extends JRFillTextElement implements JRTextField {
private JRGroup evaluationGroup = null;
private String anchorName = null;
private String hyperlinkReference = null;
private String hyperlinkAnchor = null;
private Integer hyperlinkPage = null;
private String hyperlinkTooltip;
private JRPrintHyperlinkParameters hyperlinkParameters;
protected JRFillTextField(JRBaseFiller filler, JRTextField textField, JRFillObjectFactory factory) {
super(filler, (JRTextElement)textField, factory);
this.evaluationGroup = factory.getGroup(textField.getEvaluationGroup());
}
protected JRFillTextField(JRFillTextField textField, JRFillCloneFactory factory) {
super(textField, factory);
this.evaluationGroup = textField.evaluationGroup;
}
public boolean isStretchWithOverflow() {
return ((JRTextField)this.parent).isStretchWithOverflow();
}
public void setStretchWithOverflow(boolean isStretchWithOverflow) {}
public byte getEvaluationTime() {
return ((JRTextField)this.parent).getEvaluationTime();
}
public String getPattern() {
return JRStyleResolver.getPattern(this);
}
public String getOwnPattern() {
return ((JRTextField)this.parent).getOwnPattern();
}
public void setPattern(String pattern) {}
public boolean isBlankWhenNull() {
return JRStyleResolver.isBlankWhenNull(this);
}
public Boolean isOwnBlankWhenNull() {
return ((JRTextField)this.parent).isOwnBlankWhenNull();
}
public void setBlankWhenNull(boolean isBlank) {}
public void setBlankWhenNull(Boolean isBlank) {}
public byte getHyperlinkType() {
return ((JRTextField)this.parent).getHyperlinkType();
}
public byte getHyperlinkTarget() {
return ((JRTextField)this.parent).getHyperlinkTarget();
}
public JRGroup getEvaluationGroup() {
return this.evaluationGroup;
}
public JRExpression getExpression() {
return ((JRTextField)this.parent).getExpression();
}
public JRExpression getAnchorNameExpression() {
return ((JRTextField)this.parent).getAnchorNameExpression();
}
public JRExpression getHyperlinkReferenceExpression() {
return ((JRTextField)this.parent).getHyperlinkReferenceExpression();
}
public JRExpression getHyperlinkAnchorExpression() {
return ((JRTextField)this.parent).getHyperlinkAnchorExpression();
}
public JRExpression getHyperlinkPageExpression() {
return ((JRTextField)this.parent).getHyperlinkPageExpression();
}
protected String getAnchorName() {
return this.anchorName;
}
protected String getHyperlinkReference() {
return this.hyperlinkReference;
}
protected String getHyperlinkAnchor() {
return this.hyperlinkAnchor;
}
protected Integer getHyperlinkPage() {
return this.hyperlinkPage;
}
protected String getHyperlinkTooltip() {
return this.hyperlinkTooltip;
}
protected JRTemplateText getJRTemplateText() {
JRStyle style = getStyle();
JRTemplateText template = (JRTemplateText)getTemplate(style);
if (template == null) {
template = new JRTemplateText((this.band == null) ? null : this.band.getOrigin(), this.filler.getJasperPrint().getDefaultStyleProvider(), this);
transferProperties(template);
setTemplatePattern(template);
registerTemplate(style, template);
}
return template;
}
protected void setTemplatePattern(JRTemplateText template) {
if (getExpression() != null) {
Class valueClass = getExpression().getValueClass();
if (!String.class.equals(valueClass)) {
template.setValueClassName(valueClass.getName());
String pattern = getTemplatePattern();
if (pattern != null)
template.setPattern(pattern);
if (!this.filler.hasMasterFormatFactory())
template.setFormatFactoryClass(this.filler.getFormatFactory().getClass().getName());
if (!this.filler.hasMasterLocale())
template.setLocaleCode(JRDataUtils.getLocaleCode(this.filler.getLocale()));
if (!this.filler.hasMasterTimeZone() && Date.class.isAssignableFrom(valueClass))
template.setTimeZoneId(JRDataUtils.getTimeZoneId(this.filler.getTimeZone()));
}
}
}
protected void evaluate(byte evaluation) throws JRException {
initDelayedEvaluations();
reset();
evaluatePrintWhenExpression(evaluation);
if (isPrintWhenExpressionNull() || (!isPrintWhenExpressionNull() && isPrintWhenTrue()))
if (isEvaluateNow())
evaluateText(evaluation);
}
protected void evaluateText(byte evaluation) throws JRException {
evaluateProperties(evaluation);
Object textFieldValue = evaluateExpression(getExpression(), evaluation);
if (textFieldValue == null) {
if (isBlankWhenNull())
textFieldValue = "";
} else {
Format format = getFormat();
if (format != null)
textFieldValue = format.format(textFieldValue);
}
String oldRawText = getRawText();
String newRawText = processMarkupText(String.valueOf(textFieldValue));
setRawText(newRawText);
setTextStart(0);
setTextEnd(0);
setValueRepeating(((oldRawText == null && newRawText == null) || (oldRawText != null && oldRawText.equals(newRawText))));
this.anchorName = (String)evaluateExpression(getAnchorNameExpression(), evaluation);
this.hyperlinkReference = (String)evaluateExpression(getHyperlinkReferenceExpression(), evaluation);
this.hyperlinkAnchor = (String)evaluateExpression(getHyperlinkAnchorExpression(), evaluation);
this.hyperlinkPage = (Integer)evaluateExpression(getHyperlinkPageExpression(), evaluation);
this.hyperlinkTooltip = (String)evaluateExpression(getHyperlinkTooltipExpression(), evaluation);
this.hyperlinkParameters = JRFillHyperlinkHelper.evaluateHyperlinkParameters((JRHyperlink)this, this.expressionEvaluator, evaluation);
}
protected boolean prepare(int availableStretchHeight, boolean isOverflow) throws JRException {
boolean willOverflow = false;
super.prepare(availableStretchHeight, isOverflow);
if (!isToPrint())
return willOverflow;
boolean isToPrint = true;
boolean isReprinted = false;
if (isEvaluateNow()) {
if (isOverflow) {
if (getPositionType() == 3) {
setTextStart(0);
setTextEnd(0);
}
if (getTextEnd() >= getText().length() || !isStretchWithOverflow() || getRotation() != 0)
if (isAlreadyPrinted())
if (isPrintWhenDetailOverflows()) {
setTextStart(0);
setTextEnd(0);
isReprinted = true;
} else {
isToPrint = false;
}
if (isToPrint && isPrintWhenExpressionNull() && !isPrintRepeatedValues() && isValueRepeating())
isToPrint = false;
} else if (isPrintWhenExpressionNull() && !isPrintRepeatedValues() && isValueRepeating()) {
if ((!isPrintInFirstWholeBand() || !getBand().isFirstWholeOnPageColumn()) && (getPrintWhenGroupChanges() == null || !getBand().isNewGroup(getPrintWhenGroupChanges())))
isToPrint = false;
}
if (isToPrint)
if (availableStretchHeight >= getRelativeY() - getY() - getBandBottomY()) {
if (getTextEnd() < getText().length() || getTextEnd() == 0) {
if (isStretchWithOverflow() && getRotation() == 0) {
chopTextElement(availableStretchHeight - getRelativeY() + getY() + getBandBottomY());
if (getTextEnd() < getText().length())
willOverflow = true;
} else {
chopTextElement(0);
}
} else {
isToPrint = false;
}
} else {
isToPrint = false;
willOverflow = true;
}
if (isToPrint && isRemoveLineWhenBlank() && getText().substring(getTextStart(), getTextEnd()).trim().length() == 0)
isToPrint = false;
} else {
if (isOverflow && isAlreadyPrinted())
if (isPrintWhenDetailOverflows()) {
isReprinted = true;
} else {
isToPrint = false;
}
if (isToPrint && availableStretchHeight < getRelativeY() - getY() - getBandBottomY()) {
isToPrint = false;
willOverflow = true;
}
}
setToPrint(isToPrint);
setReprinted(isReprinted);
return willOverflow;
}
protected JRPrintElement fill() throws JRException {
JRTemplatePrintText text;
JRRecordedValuesPrintText recordedValuesText;
byte evaluationType = getEvaluationTime();
if (isEvaluateAuto()) {
text = recordedValuesText = new JRRecordedValuesPrintText(getJRTemplateText());
} else {
text = new JRTemplatePrintText(getJRTemplateText());
recordedValuesText = null;
}
text.setX(getX());
text.setY(getRelativeY());
text.setWidth(getWidth());
if (getRotation() == 0) {
text.setHeight(getStretchHeight());
} else {
text.setHeight(getHeight());
}
text.setRunDirection(getRunDirection());
if (isEvaluateNow()) {
copy(text);
} else if (isEvaluateAuto()) {
initDelayedEvaluationPrint(recordedValuesText);
} else {
this.filler.addBoundElement(this, text, evaluationType, getEvaluationGroup(), this.band);
}
return text;
}
protected void copy(JRPrintText text) {
text.setLineSpacingFactor(getLineSpacingFactor());
text.setLeadingOffset(getLeadingOffset());
text.setTextHeight(getTextHeight());
setPrintText(text);
text.setAnchorName(getAnchorName());
text.setHyperlinkReference(getHyperlinkReference());
text.setHyperlinkAnchor(getHyperlinkAnchor());
text.setHyperlinkPage(getHyperlinkPage());
text.setHyperlinkTooltip(getHyperlinkTooltip());
text.setBookmarkLevel(getBookmarkLevel());
text.setHyperlinkParameters(this.hyperlinkParameters);
transferProperties((JRPrintElement)text);
}
protected Format getFormat() {
Format format = null;
JRExpression valueExpression = getExpression();
if (valueExpression != null) {
Class valueClass = valueExpression.getValueClass();
if (Date.class.isAssignableFrom(valueClass)) {
format = this.filler.getDateFormat(getPattern());
} else if (Number.class.isAssignableFrom(valueClass)) {
format = this.filler.getNumberFormat(getPattern());
}
}
return format;
}
protected String getTemplatePattern() {
String pattern = null;
String originalPattern = getPattern();
Format format = getFormat();
JRExpression valueExpression = getExpression();
if (format != null && valueExpression != null) {
Class valueClass = valueExpression.getValueClass();
if (Date.class.isAssignableFrom(valueClass)) {
if (format instanceof SimpleDateFormat)
pattern = ((SimpleDateFormat)format).toPattern();
} else if (Number.class.isAssignableFrom(valueClass)) {
if (format instanceof DecimalFormat)
pattern = ((DecimalFormat)format).toPattern();
}
}
if (pattern == null)
pattern = originalPattern;
return pattern;
}
public void collectExpressions(JRExpressionCollector collector) {
collector.collect(this);
}
public void visit(JRVisitor visitor) {
visitor.visitTextField(this);
}
protected void resolveElement(JRPrintElement element, byte evaluation) throws JRException {
evaluateText(evaluation);
chopTextElement(0);
copy((JRPrintText)element);
}
public int getBookmarkLevel() {
return ((JRTextField)this.parent).getBookmarkLevel();
}
public JRFillCloneable createClone(JRFillCloneFactory factory) {
return new JRFillTextField(this, factory);
}
protected void collectDelayedEvaluations() {
collectDelayedEvaluations(getExpression());
collectDelayedEvaluations(getAnchorNameExpression());
collectDelayedEvaluations(getHyperlinkReferenceExpression());
collectDelayedEvaluations(getHyperlinkAnchorExpression());
collectDelayedEvaluations(getHyperlinkPageExpression());
}
public JRHyperlinkParameter[] getHyperlinkParameters() {
return ((JRTextField)this.parent).getHyperlinkParameters();
}
public String getLinkType() {
return ((JRTextField)this.parent).getLinkType();
}
public JRExpression getHyperlinkTooltipExpression() {
return ((JRTextField)this.parent).getHyperlinkTooltipExpression();
}
protected boolean canOverflow() {
return (isStretchWithOverflow() && getRotation() == 0 && isEvaluateNow() && this.filler.isBandOverFlowAllowed());
}
}

View File

@@ -0,0 +1,210 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRGroup;
import net.sf.jasperreports.engine.JRVariable;
public class JRFillVariable implements JRVariable, JRCalculable {
protected JRVariable parent = null;
private JRGroup resetGroup = null;
private JRGroup incrementGroup = null;
private Object previousOldValue = null;
private Object oldValue = null;
private Object estimatedValue = null;
private Object incrementedValue = null;
private Object value = null;
private boolean isInitialized = false;
private Object savedValue;
private JRFillVariable[] helperVariables;
private JRIncrementer incrementer = null;
protected JRFillVariable(JRVariable variable, JRFillObjectFactory factory) {
factory.put(variable, this);
this.parent = variable;
this.resetGroup = factory.getGroup(variable.getResetGroup());
this.incrementGroup = factory.getGroup(variable.getIncrementGroup());
this.helperVariables = new JRFillVariable[3];
}
public String getName() {
return this.parent.getName();
}
public Class getValueClass() {
return this.parent.getValueClass();
}
public String getValueClassName() {
return this.parent.getValueClassName();
}
public Class getIncrementerFactoryClass() {
return this.parent.getIncrementerFactoryClass();
}
public String getIncrementerFactoryClassName() {
return this.parent.getIncrementerFactoryClassName();
}
public JRExpression getExpression() {
return this.parent.getExpression();
}
public JRExpression getInitialValueExpression() {
return this.parent.getInitialValueExpression();
}
public byte getResetType() {
return this.parent.getResetType();
}
public byte getIncrementType() {
return this.parent.getIncrementType();
}
public byte getCalculation() {
return this.parent.getCalculation();
}
public boolean isSystemDefined() {
return this.parent.isSystemDefined();
}
public JRGroup getResetGroup() {
return this.resetGroup;
}
public JRGroup getIncrementGroup() {
return this.incrementGroup;
}
public Object getOldValue() {
return this.oldValue;
}
public void setOldValue(Object oldValue) {
this.oldValue = oldValue;
}
public Object getEstimatedValue() {
return this.estimatedValue;
}
public void setEstimatedValue(Object estimatedValue) {
this.estimatedValue = estimatedValue;
}
public Object getIncrementedValue() {
return this.incrementedValue;
}
public void setIncrementedValue(Object incrementedValue) {
this.incrementedValue = incrementedValue;
}
public Object getValue() {
return this.value;
}
public void setValue(Object value) {
this.value = value;
}
public boolean isInitialized() {
return this.isInitialized;
}
public void setInitialized(boolean isInitialized) {
this.isInitialized = isInitialized;
}
public JRIncrementer getIncrementer() {
if (this.incrementer == null) {
JRIncrementerFactory incrementerFactory;
Class incrementerFactoryClass = getIncrementerFactoryClass();
if (incrementerFactoryClass == null) {
incrementerFactory = JRDefaultIncrementerFactory.getFactory(getValueClass());
} else {
incrementerFactory = JRIncrementerFactoryCache.getInstance(incrementerFactoryClass);
}
this.incrementer = incrementerFactory.getIncrementer(getCalculation());
}
return this.incrementer;
}
public JRFillVariable setHelperVariable(JRFillVariable helperVariable, byte type) {
JRFillVariable old = this.helperVariables[type];
this.helperVariables[type] = helperVariable;
return old;
}
public JRCalculable getHelperVariable(byte type) {
return this.helperVariables[type];
}
public Object getValue(byte evaluation) {
switch (evaluation) {
case 1:
returnValue = this.oldValue;
return returnValue;
case 2:
returnValue = this.estimatedValue;
return returnValue;
}
Object returnValue = this.value;
return returnValue;
}
public void overwriteValue(Object newValue, byte evaluation) {
switch (evaluation) {
case 1:
this.savedValue = this.oldValue;
this.oldValue = newValue;
return;
case 2:
this.savedValue = this.estimatedValue;
this.estimatedValue = newValue;
return;
}
this.savedValue = this.value;
this.value = newValue;
}
public void restoreValue(byte evaluation) {
switch (evaluation) {
case 1:
this.oldValue = this.savedValue;
break;
case 2:
this.estimatedValue = this.savedValue;
break;
default:
this.value = this.savedValue;
break;
}
this.savedValue = null;
}
public Object getPreviousOldValue() {
return this.previousOldValue;
}
public void setPreviousOldValue(Object previousOldValue) {
this.previousOldValue = previousOldValue;
}
public Object clone() {
return null;
}
}

View File

@@ -0,0 +1,55 @@
package net.sf.jasperreports.engine.fill;
import java.sql.Connection;
import java.util.Map;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
public abstract class JRFiller {
public static JasperPrint fillReport(JasperReport jasperReport, Map parameters, Connection conn) throws JRException {
JRBaseFiller filler = createFiller(jasperReport);
JasperPrint jasperPrint = null;
try {
jasperPrint = filler.fill(parameters, conn);
} catch (JRFillInterruptedException e) {
throw new JRException("The report filling thread was interrupted.");
}
return jasperPrint;
}
public static JasperPrint fillReport(JasperReport jasperReport, Map parameters, JRDataSource dataSource) throws JRException {
JRBaseFiller filler = createFiller(jasperReport);
JasperPrint jasperPrint = null;
try {
jasperPrint = filler.fill(parameters, dataSource);
} catch (JRFillInterruptedException e) {
throw new JRException("The report filling thread was interrupted.");
}
return jasperPrint;
}
public static JasperPrint fillReport(JasperReport jasperReport, Map parameters) throws JRException {
JRBaseFiller filler = createFiller(jasperReport);
try {
JasperPrint jasperPrint = filler.fill(parameters);
return jasperPrint;
} catch (JRFillInterruptedException e) {
throw new JRException("The report filling thread was interrupted.");
}
}
public static JRBaseFiller createFiller(JasperReport jasperReport) throws JRException {
JRBaseFiller filler = null;
switch (jasperReport.getPrintOrder()) {
case 2:
filler = new JRHorizontalFiller(jasperReport);
break;
case 1:
filler = new JRVerticalFiller(jasperReport);
break;
}
return filler;
}
}

View File

@@ -0,0 +1,24 @@
package net.sf.jasperreports.engine.fill;
class JRFloatAverageIncrementer extends JRAbstractExtendedIncrementer {
private static JRFloatAverageIncrementer mainInstance = new JRFloatAverageIncrementer();
public static JRFloatAverageIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
if (expressionValue == null) {
if (variable.isInitialized())
return null;
return variable.getValue();
}
Number countValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)0));
Number sumValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)1));
return new Float(sumValue.floatValue() / countValue.floatValue());
}
public Object initialValue() {
return JRFloatIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,32 @@
package net.sf.jasperreports.engine.fill;
class JRFloatCountIncrementer extends JRAbstractExtendedIncrementer {
private static JRFloatCountIncrementer mainInstance = new JRFloatCountIncrementer();
public static JRFloatCountIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Number value = (Number)variable.getIncrementedValue();
if (value == null || variable.isInitialized())
value = JRFloatIncrementerFactory.ZERO;
if (expressionValue == null)
return value;
return new Float(value.floatValue() + 1.0F);
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
Number value = (Number)calculable.getIncrementedValue();
Number combineValue = (Number)calculableValue.getValue();
if (value == null || calculable.isInitialized())
value = JRFloatIncrementerFactory.ZERO;
if (combineValue == null)
return value;
return new Float(value.floatValue() + combineValue.floatValue());
}
public Object initialValue() {
return JRFloatIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,25 @@
package net.sf.jasperreports.engine.fill;
class JRFloatDistinctCountIncrementer extends JRAbstractExtendedIncrementer {
private static JRFloatDistinctCountIncrementer mainInstance = new JRFloatDistinctCountIncrementer();
public static JRFloatDistinctCountIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
DistinctCountHolder holder = (DistinctCountHolder)valueProvider.getValue(variable.getHelperVariable((byte)0));
if (variable.isInitialized())
holder.init();
return new Float((float)holder.getCount());
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
DistinctCountHolder holder = (DistinctCountHolder)valueProvider.getValue(calculable.getHelperVariable((byte)0));
return new Float((float)holder.getCount());
}
public Object initialValue() {
return JRFloatIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,41 @@
package net.sf.jasperreports.engine.fill;
public class JRFloatIncrementerFactory extends JRAbstractExtendedIncrementerFactory {
protected static final Float ZERO = new Float(0.0F);
private static JRFloatIncrementerFactory mainInstance = new JRFloatIncrementerFactory();
public static JRFloatIncrementerFactory getInstance() {
return mainInstance;
}
public JRExtendedIncrementer getExtendedIncrementer(byte calculation) {
JRExtendedIncrementer incrementer = null;
switch (calculation) {
case 1:
incrementer = JRFloatCountIncrementer.getInstance();
return incrementer;
case 2:
incrementer = JRFloatSumIncrementer.getInstance();
return incrementer;
case 3:
incrementer = JRFloatAverageIncrementer.getInstance();
return incrementer;
case 4:
case 5:
incrementer = JRComparableIncrementerFactory.getInstance().getExtendedIncrementer(calculation);
return incrementer;
case 6:
incrementer = JRFloatStandardDeviationIncrementer.getInstance();
return incrementer;
case 7:
incrementer = JRFloatVarianceIncrementer.getInstance();
return incrementer;
case 10:
incrementer = JRFloatDistinctCountIncrementer.getInstance();
return incrementer;
}
incrementer = JRDefaultIncrementerFactory.getInstance().getExtendedIncrementer(calculation);
return incrementer;
}
}

View File

@@ -0,0 +1,23 @@
package net.sf.jasperreports.engine.fill;
class JRFloatStandardDeviationIncrementer extends JRAbstractExtendedIncrementer {
private static JRFloatStandardDeviationIncrementer mainInstance = new JRFloatStandardDeviationIncrementer();
public static JRFloatStandardDeviationIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
if (expressionValue == null) {
if (variable.isInitialized())
return null;
return variable.getValue();
}
Number varianceValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)2));
return new Float(Math.sqrt(varianceValue.doubleValue()));
}
public Object initialValue() {
return JRFloatIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,26 @@
package net.sf.jasperreports.engine.fill;
class JRFloatSumIncrementer extends JRAbstractExtendedIncrementer {
private static JRFloatSumIncrementer mainInstance = new JRFloatSumIncrementer();
public static JRFloatSumIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Number value = (Number)variable.getIncrementedValue();
Number newValue = (Number)expressionValue;
if (newValue == null) {
if (variable.isInitialized())
return null;
return value;
}
if (value == null || variable.isInitialized())
value = JRFloatIncrementerFactory.ZERO;
return new Float(value.floatValue() + newValue.floatValue());
}
public Object initialValue() {
return JRFloatIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,49 @@
package net.sf.jasperreports.engine.fill;
class JRFloatVarianceIncrementer extends JRAbstractExtendedIncrementer {
private static JRFloatVarianceIncrementer mainInstance = new JRFloatVarianceIncrementer();
public static JRFloatVarianceIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Number value = (Number)variable.getIncrementedValue();
Number newValue = (Number)expressionValue;
if (newValue == null) {
if (variable.isInitialized())
return null;
return value;
}
if (value == null || variable.isInitialized())
return JRFloatIncrementerFactory.ZERO;
Number countValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)0));
Number sumValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)1));
return new Float((countValue.floatValue() - 1.0F) * value.floatValue() / countValue.floatValue() + (sumValue.floatValue() / countValue.floatValue() - newValue.floatValue()) * (sumValue.floatValue() / countValue.floatValue() - newValue.floatValue()) / (countValue.floatValue() - 1.0F));
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
Number value = (Number)calculable.getIncrementedValue();
if (calculableValue.getValue() == null) {
if (calculable.isInitialized())
return null;
return value;
}
if (value == null || calculable.isInitialized())
return new Float(((Number)calculableValue.getIncrementedValue()).floatValue());
float v1 = value.floatValue();
float c1 = ((Number)valueProvider.getValue(calculable.getHelperVariable((byte)0))).floatValue();
float s1 = ((Number)valueProvider.getValue(calculable.getHelperVariable((byte)1))).floatValue();
float v2 = ((Number)calculableValue.getIncrementedValue()).floatValue();
float c2 = ((Number)valueProvider.getValue(calculableValue.getHelperVariable((byte)0))).floatValue();
float s2 = ((Number)valueProvider.getValue(calculableValue.getHelperVariable((byte)1))).floatValue();
c1 -= c2;
s1 -= s2;
float c = c1 + c2;
return new Float(c1 / c * v1 + c2 / c * v2 + c2 / c1 * s1 / c * s1 / c + c1 / c2 * s2 / c * s2 / c - 2.0F * s1 / c * s2 / c);
}
public Object initialValue() {
return JRFloatIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,818 @@
package net.sf.jasperreports.engine.fill;
import java.util.Iterator;
import java.util.List;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRGroup;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.JasperReport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class JRHorizontalFiller extends JRBaseFiller {
private static final Log log = LogFactory.getLog(JRHorizontalFiller.class);
private int lastDetailOffsetX = -1;
private int lastDetailOffsetY = -1;
protected JRHorizontalFiller(JasperReport jasperReport) throws JRException {
this(jasperReport, (JREvaluator)null, (JRBaseFiller)null);
}
protected JRHorizontalFiller(JasperReport jasperReport, JRBaseFiller parentFiller) throws JRException {
super(jasperReport, null, parentFiller);
setPageHeight(this.pageHeight);
}
protected JRHorizontalFiller(JasperReport jasperReport, JREvaluator evaluator, JRBaseFiller parentFiller) throws JRException {
super(jasperReport, evaluator, parentFiller);
setPageHeight(this.pageHeight);
}
protected void setPageHeight(int pageHeight) {
this.pageHeight = pageHeight;
this.columnFooterOffsetY = pageHeight - this.bottomMargin;
if (this.pageFooter != null)
this.columnFooterOffsetY -= this.pageFooter.getHeight();
if (this.columnFooter != null)
this.columnFooterOffsetY -= this.columnFooter.getHeight();
this.lastPageColumnFooterOffsetY = pageHeight - this.bottomMargin;
if (this.lastPageFooter != null)
this.lastPageColumnFooterOffsetY -= this.lastPageFooter.getHeight();
if (this.columnFooter != null)
this.lastPageColumnFooterOffsetY -= this.columnFooter.getHeight();
}
protected synchronized void fillReport() throws JRException {
setLastPageFooter(false);
if (next()) {
fillReportStart();
while (next())
fillReportContent();
fillReportEnd();
} else {
if (log.isDebugEnabled())
log.debug("Fill " + this.fillerId + ": no data");
switch (this.whenNoDataType) {
case 3:
if (log.isDebugEnabled())
log.debug("Fill " + this.fillerId + ": all sections");
this.scriptlet.callBeforeReportInit();
this.calculator.initializeVariables((byte)1);
this.scriptlet.callAfterReportInit();
this.printPage = newPage();
addPage(this.printPage);
setFirstColumn();
this.offsetY = this.topMargin;
fillBackground();
fillTitle();
fillPageHeader((byte)3);
fillColumnHeaders((byte)3);
fillGroupHeaders(true);
fillGroupFooters(true);
fillSummary();
break;
case 2:
if (log.isDebugEnabled())
log.debug("Fill " + this.fillerId + ": blank page");
this.printPage = newPage();
addPage(this.printPage);
break;
case 4:
if (log.isDebugEnabled())
log.debug("Fill " + this.fillerId + ": NoData section");
this.scriptlet.callBeforeReportInit();
this.calculator.initializeVariables((byte)1);
this.scriptlet.callAfterReportInit();
this.printPage = newPage();
addPage(this.printPage);
setFirstColumn();
this.offsetY = this.topMargin;
fillBackground();
fillNoData();
break;
default:
if (log.isDebugEnabled())
log.debug("Fill " + this.fillerId + ": no pages");
break;
}
}
if (isSubreport()) {
this.printPageStretchHeight = this.offsetY + this.bottomMargin;
if (this.fillContext.isUsingVirtualizer())
removePageIdentityDataProvider();
}
if (this.fillContext.isIgnorePagination())
this.jasperPrint.setPageHeight(this.offsetY + this.bottomMargin);
}
private void fillReportStart() throws JRException {
this.scriptlet.callBeforeReportInit();
this.calculator.initializeVariables((byte)1);
this.scriptlet.callAfterReportInit();
this.printPage = newPage();
addPage(this.printPage);
setFirstColumn();
this.offsetY = this.topMargin;
fillBackground();
fillTitle();
fillPageHeader((byte)3);
fillColumnHeaders((byte)3);
fillGroupHeaders(true);
fillDetail();
}
private void setFirstColumn() {
this.columnIndex = 0;
this.offsetX = this.leftMargin;
setColumnNumberVariable();
}
private void fillReportContent() throws JRException {
this.calculator.estimateGroupRuptures();
fillGroupFooters(false);
resolveGroupBoundElements((byte)1, false);
this.scriptlet.callBeforeGroupInit();
this.calculator.initializeVariables((byte)4);
this.scriptlet.callAfterGroupInit();
fillGroupHeaders(false);
fillDetail();
}
private void fillReportEnd() throws JRException {
fillGroupFooters(true);
fillSummary();
}
private void fillTitle() throws JRException {
if (log.isDebugEnabled() && !this.title.isEmpty())
log.debug("Fill " + this.fillerId + ": title");
this.title.evaluatePrintWhenExpression((byte)3);
if (this.title.isToPrint()) {
while (this.title.getHeight() > this.pageHeight - this.bottomMargin - this.offsetY)
addPage(false);
this.title.evaluate((byte)3);
JRPrintBand printBand = this.title.fill(this.pageHeight - this.bottomMargin - this.offsetY - this.title.getHeight());
if (this.title.willOverflow() && !this.title.isSplitAllowed() && isSubreport()) {
resolveGroupBoundElements((byte)3, false);
resolveColumnBoundElements((byte)3);
resolvePageBoundElements((byte)3);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
printBand = this.title.refill(this.pageHeight - this.bottomMargin - this.offsetY - this.title.getHeight());
}
fillBand(printBand);
this.offsetY += printBand.getHeight();
while (this.title.willOverflow()) {
resolveGroupBoundElements((byte)3, false);
resolveColumnBoundElements((byte)3);
resolvePageBoundElements((byte)3);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
printBand = this.title.fill(this.pageHeight - this.bottomMargin - this.offsetY - this.title.getHeight());
fillBand(printBand);
this.offsetY += printBand.getHeight();
}
resolveBandBoundElements(this.title, (byte)3);
if (this.isTitleNewPage) {
resolveGroupBoundElements((byte)3, false);
resolveColumnBoundElements((byte)3);
resolvePageBoundElements((byte)3);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
}
}
}
private void fillPageHeader(byte evaluation) throws JRException {
if (log.isDebugEnabled() && !this.pageHeader.isEmpty())
log.debug("Fill " + this.fillerId + ": page header");
setNewPageColumnInBands();
this.pageHeader.evaluatePrintWhenExpression((byte)3);
if (this.pageHeader.isToPrint()) {
int reattempts = getMasterColumnCount();
if (this.isCreatingNewPage)
reattempts--;
boolean filled = fillBandNoOverflow(this.pageHeader, evaluation);
for (int i = 0; !filled && i < reattempts; i++) {
resolveGroupBoundElements(evaluation, false);
resolveColumnBoundElements(evaluation);
resolvePageBoundElements(evaluation);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
filled = fillBandNoOverflow(this.pageHeader, evaluation);
}
if (!filled)
throw new JRRuntimeException("Infinite loop creating new page due to page header overflow.");
}
this.columnHeaderOffsetY = this.offsetY;
this.isNewPage = true;
this.isFirstPageBand = true;
}
private boolean fillBandNoOverflow(JRFillBand band, byte evaluation) throws JRException {
int availableStretch = this.columnFooterOffsetY - this.offsetY - band.getHeight();
boolean overflow = (availableStretch < 0);
if (!overflow) {
band.evaluate(evaluation);
JRPrintBand printBand = band.fill(availableStretch);
overflow = band.willOverflow();
if (overflow) {
band.rewind();
} else {
fillBand(printBand);
this.offsetY += printBand.getHeight();
resolveBandBoundElements(band, evaluation);
}
}
return !overflow;
}
private void fillColumnHeaders(byte evaluation) throws JRException {
if (log.isDebugEnabled() && !this.columnHeader.isEmpty())
log.debug("Fill " + this.fillerId + ": column headers");
setNewPageColumnInBands();
for (this.columnIndex = 0; this.columnIndex < this.columnCount; this.columnIndex++) {
setColumnNumberVariable();
this.columnHeader.evaluatePrintWhenExpression(evaluation);
if (this.columnHeader.isToPrint()) {
int reattempts = getMasterColumnCount();
if (this.isCreatingNewPage)
reattempts--;
boolean fits = (this.columnHeader.getHeight() <= this.columnFooterOffsetY - this.offsetY);
for (int i = 0; !fits && i < reattempts; i++) {
fillPageFooter(evaluation);
resolveGroupBoundElements(evaluation, false);
resolveColumnBoundElements(evaluation);
resolvePageBoundElements(evaluation);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
fillPageHeader(evaluation);
fits = (this.columnHeader.getHeight() <= this.columnFooterOffsetY - this.offsetY);
}
if (!fits)
throw new JRRuntimeException("Infinite loop creating new page due to column header size.");
this.offsetX = this.leftMargin + this.columnIndex * (this.columnSpacing + this.columnWidth);
this.offsetY = this.columnHeaderOffsetY;
fillFixedBand(this.columnHeader, evaluation, false);
}
}
setFirstColumn();
this.isNewColumn = true;
this.isFirstColumnBand = true;
}
private void fillGroupHeaders(boolean isFillAll) throws JRException {
if (this.groups != null && this.groups.length > 0)
for (int i = 0; i < this.groups.length; i++) {
if (isFillAll) {
fillGroupHeader(this.groups[i]);
} else if (this.groups[i].hasChanged()) {
fillGroupHeader(this.groups[i]);
}
}
}
private void fillGroupHeader(JRFillGroup group) throws JRException {
JRFillBand groupHeader = (JRFillBand)group.getGroupHeader();
if (log.isDebugEnabled() && !groupHeader.isEmpty())
log.debug("Fill " + this.fillerId + ": " + group.getName() + " header");
byte evalPrevPage = group.isTopLevelChange() ? 1 : 3;
if (((group.isStartNewPage() || group.isResetPageNumber()) && !this.isNewPage) || (group.isStartNewColumn() && !this.isNewColumn))
fillPageBreak(group.isResetPageNumber(), evalPrevPage, (byte)3, true);
groupHeader.evaluatePrintWhenExpression((byte)3);
if (groupHeader.isToPrint())
while (groupHeader.getHeight() > this.columnFooterOffsetY - this.offsetY || group.getMinHeightToStartNewPage() > this.columnFooterOffsetY - this.offsetY)
fillPageBreak(false, evalPrevPage, (byte)3, true);
setNewGroupInBands(group);
group.setFooterPrinted(false);
if (groupHeader.isToPrint()) {
setFirstColumn();
fillColumnBand(groupHeader, (byte)3);
}
group.setHeaderPrinted(true);
this.isNewGroup = true;
this.isFirstPageBand = false;
}
private void fillGroupHeadersReprint(byte evaluation) throws JRException {
if (this.groups != null && this.groups.length > 0)
for (int i = 0; i < this.groups.length; i++)
fillGroupHeaderReprint(this.groups[i], evaluation);
}
private void fillGroupHeaderReprint(JRFillGroup group, byte evaluation) throws JRException {
if (group.isReprintHeaderOnEachPage() && (!group.hasChanged() || (group.hasChanged() && group.isHeaderPrinted()))) {
JRFillBand groupHeader = (JRFillBand)group.getGroupHeader();
groupHeader.evaluatePrintWhenExpression(evaluation);
if (groupHeader.isToPrint()) {
setFirstColumn();
while (groupHeader.getHeight() > this.columnFooterOffsetY - this.offsetY || group.getMinHeightToStartNewPage() > this.columnFooterOffsetY - this.offsetY)
fillPageBreak(false, evaluation, evaluation, true);
fillColumnBand(groupHeader, evaluation);
}
this.isFirstPageBand = false;
}
}
private void fillDetail() throws JRException {
if (log.isDebugEnabled() && !this.detail.isEmpty())
log.debug("Fill " + this.fillerId + ": detail");
if (!this.detail.isPrintWhenExpressionNull()) {
this.calculator.estimateVariables();
this.detail.evaluatePrintWhenExpression((byte)2);
}
if (this.detail.isToPrint())
while ((this.columnIndex == this.columnCount - 1 || this.isNewGroup) && this.detail.getHeight() > this.columnFooterOffsetY - this.offsetY) {
byte evalPrevPage = this.isNewGroup ? 3 : 1;
fillPageBreak(false, evalPrevPage, (byte)3, true);
}
this.scriptlet.callBeforeDetailEval();
this.calculator.calculateVariables();
this.scriptlet.callAfterDetailEval();
if (!this.detail.isPrintWhenExpressionNull())
this.detail.evaluatePrintWhenExpression((byte)3);
if (this.detail.isToPrint()) {
if (this.offsetX == this.lastDetailOffsetX && this.offsetY == this.lastDetailOffsetY)
if (this.columnIndex == this.columnCount - 1) {
setFirstColumn();
} else {
this.columnIndex++;
this.offsetX += this.columnWidth + this.columnSpacing;
this.offsetY -= this.detail.getHeight();
setColumnNumberVariable();
}
fillFixedBand(this.detail, (byte)3, false);
this.lastDetailOffsetX = this.offsetX;
this.lastDetailOffsetY = this.offsetY;
}
this.isNewPage = false;
this.isNewColumn = false;
this.isNewGroup = false;
this.isFirstPageBand = false;
this.isFirstColumnBand = false;
}
private void fillGroupFooters(boolean isFillAll) throws JRException {
if (this.groups != null && this.groups.length > 0) {
byte evaluation = isFillAll ? 3 : 1;
for (int i = this.groups.length - 1; i >= 0; i--) {
if (isFillAll) {
fillGroupFooter(this.groups[i], evaluation);
} else if (this.groups[i].hasChanged()) {
fillGroupFooter(this.groups[i], evaluation);
}
}
}
}
private void fillGroupFooter(JRFillGroup group, byte evaluation) throws JRException {
JRFillBand groupFooter = (JRFillBand)group.getGroupFooter();
if (log.isDebugEnabled() && !groupFooter.isEmpty())
log.debug("Fill " + this.fillerId + ": " + group.getName() + " footer");
groupFooter.evaluatePrintWhenExpression(evaluation);
if (groupFooter.isToPrint()) {
setFirstColumn();
if (groupFooter.getHeight() > this.columnFooterOffsetY - this.offsetY)
fillPageBreak(false, evaluation, evaluation, true);
fillColumnBand(groupFooter, evaluation);
}
this.isNewPage = false;
this.isNewColumn = false;
this.isFirstPageBand = false;
this.isFirstColumnBand = false;
group.setHeaderPrinted(false);
group.setFooterPrinted(true);
}
private void fillColumnFooters(byte evaluation) throws JRException {
if (log.isDebugEnabled() && !this.columnFooter.isEmpty())
log.debug("Fill " + this.fillerId + ": column footers");
if (isSubreport())
this.columnFooterOffsetY = this.offsetY;
int tmpColumnFooterOffsetY = this.columnFooterOffsetY;
if (this.isFloatColumnFooter || this.fillContext.isIgnorePagination())
tmpColumnFooterOffsetY = this.offsetY;
for (this.columnIndex = 0; this.columnIndex < this.columnCount; this.columnIndex++) {
setColumnNumberVariable();
this.offsetX = this.leftMargin + this.columnIndex * (this.columnSpacing + this.columnWidth);
this.offsetY = tmpColumnFooterOffsetY;
this.columnFooter.evaluatePrintWhenExpression(evaluation);
if (this.columnFooter.isToPrint())
fillFixedBand(this.columnFooter, evaluation, false);
}
}
private void fillPageFooter(byte evaluation) throws JRException {
JRFillBand crtPageFooter = getCurrentPageFooter();
if (log.isDebugEnabled() && !crtPageFooter.isEmpty())
log.debug("Fill " + this.fillerId + ": " + (this.isLastPageFooter ? "last " : "") + "page footer");
this.offsetX = this.leftMargin;
if (!isSubreport() && !this.fillContext.isIgnorePagination())
this.offsetY = this.pageHeight - crtPageFooter.getHeight() - this.bottomMargin;
crtPageFooter.evaluatePrintWhenExpression(evaluation);
if (crtPageFooter.isToPrint())
fillFixedBand(crtPageFooter, evaluation);
}
private void fillSummary() throws JRException {
if (log.isDebugEnabled() && !this.summary.isEmpty())
log.debug("Fill " + this.fillerId + ": summary");
this.offsetX = this.leftMargin;
if (this.lastPageFooter == this.missingFillBand) {
if (!this.isSummaryNewPage && this.summary.getHeight() <= this.columnFooterOffsetY - this.offsetY) {
fillSummarySamePage();
} else {
fillSummaryNewPage();
}
} else if (!this.isSummaryNewPage && this.summary.getHeight() <= this.lastPageColumnFooterOffsetY - this.offsetY) {
setLastPageFooter(true);
fillSummarySamePage();
} else if (!this.isSummaryNewPage && this.summary.getHeight() <= this.columnFooterOffsetY - this.offsetY) {
fillSummarySamePageMixedFooters();
} else if (this.offsetY <= this.lastPageColumnFooterOffsetY) {
setLastPageFooter(true);
fillSummaryNewPage();
} else {
fillPageBreak(false, (byte)3, (byte)3, false);
setLastPageFooter(true);
if (this.isSummaryNewPage) {
fillSummaryNewPage();
} else {
fillSummarySamePage();
}
}
resolveGroupBoundElements((byte)3, true);
resolveColumnBoundElements((byte)3);
resolvePageBoundElements((byte)3);
resolveReportBoundElements();
}
private void fillSummarySamePage() throws JRException {
this.summary.evaluatePrintWhenExpression((byte)3);
if (this.summary != this.missingFillBand && this.summary.isToPrint()) {
this.summary.evaluate((byte)3);
JRPrintBand printBand = this.summary.fill(this.columnFooterOffsetY - this.offsetY - this.summary.getHeight());
if (this.summary.willOverflow() && !this.summary.isSplitAllowed()) {
fillColumnFooters((byte)3);
fillPageFooter((byte)3);
resolveGroupBoundElements((byte)3, true);
resolveColumnBoundElements((byte)3);
resolvePageBoundElements((byte)3);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
printBand = this.summary.refill(this.pageHeight - this.bottomMargin - this.offsetY - this.summary.getHeight());
fillBand(printBand);
this.offsetY += printBand.getHeight();
} else {
fillBand(printBand);
this.offsetY += printBand.getHeight();
fillColumnFooters((byte)3);
fillPageFooter((byte)3);
}
while (this.summary.willOverflow()) {
resolveGroupBoundElements((byte)3, true);
resolveColumnBoundElements((byte)3);
resolvePageBoundElements((byte)3);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
printBand = this.summary.fill(this.pageHeight - this.bottomMargin - this.offsetY - this.summary.getHeight());
fillBand(printBand);
this.offsetY += printBand.getHeight();
}
resolveBandBoundElements(this.summary, (byte)3);
} else {
fillColumnFooters((byte)3);
fillPageFooter((byte)3);
}
}
private void fillSummarySamePageMixedFooters() throws JRException {
this.summary.evaluatePrintWhenExpression((byte)3);
if (this.summary != this.missingFillBand && this.summary.isToPrint()) {
this.summary.evaluate((byte)3);
JRPrintBand printBand = this.summary.fill(this.columnFooterOffsetY - this.offsetY - this.summary.getHeight());
if (this.summary.willOverflow() && !this.summary.isSplitAllowed()) {
if (this.offsetY <= this.lastPageColumnFooterOffsetY) {
setLastPageFooter(true);
fillColumnFooters((byte)3);
fillPageFooter((byte)3);
resolveGroupBoundElements((byte)3, true);
resolveColumnBoundElements((byte)3);
resolvePageBoundElements((byte)3);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
printBand = this.summary.refill(this.pageHeight - this.bottomMargin - this.offsetY - this.summary.getHeight());
fillBand(printBand);
this.offsetY += printBand.getHeight();
} else {
fillPageBreak(false, (byte)3, (byte)3, false);
setLastPageFooter(true);
printBand = this.summary.refill(this.lastPageColumnFooterOffsetY - this.offsetY - this.summary.getHeight());
fillBand(printBand);
this.offsetY += printBand.getHeight();
fillColumnFooters((byte)3);
fillPageFooter((byte)3);
}
} else {
fillBand(printBand);
this.offsetY += printBand.getHeight();
fillPageBreak(false, (byte)3, (byte)3, false);
setLastPageFooter(true);
if (this.summary.willOverflow()) {
printBand = this.summary.fill(this.lastPageColumnFooterOffsetY - this.offsetY - this.summary.getHeight());
fillBand(printBand);
this.offsetY += printBand.getHeight();
}
fillColumnFooters((byte)3);
fillPageFooter((byte)3);
}
while (this.summary.willOverflow()) {
resolveGroupBoundElements((byte)3, true);
resolveColumnBoundElements((byte)3);
resolvePageBoundElements((byte)3);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
printBand = this.summary.fill(this.pageHeight - this.bottomMargin - this.offsetY - this.summary.getHeight());
fillBand(printBand);
this.offsetY += printBand.getHeight();
}
resolveBandBoundElements(this.summary, (byte)3);
} else {
if (this.offsetY > this.lastPageColumnFooterOffsetY)
fillPageBreak(false, (byte)3, (byte)3, false);
setLastPageFooter(true);
fillColumnFooters((byte)3);
fillPageFooter((byte)3);
}
}
private void fillSummaryNewPage() throws JRException {
fillColumnFooters((byte)3);
fillPageFooter((byte)3);
this.summary.evaluatePrintWhenExpression((byte)3);
if (this.summary != this.missingFillBand && this.summary.isToPrint()) {
resolveGroupBoundElements((byte)3, true);
resolveColumnBoundElements((byte)3);
resolvePageBoundElements((byte)3);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
this.columnIndex = -1;
this.summary.evaluate((byte)3);
JRPrintBand printBand = this.summary.fill(this.pageHeight - this.bottomMargin - this.offsetY - this.summary.getHeight());
if (this.summary.willOverflow() && !this.summary.isSplitAllowed() && isSubreport()) {
resolveGroupBoundElements((byte)3, true);
resolveColumnBoundElements((byte)3);
resolvePageBoundElements((byte)3);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
printBand = this.summary.refill(this.pageHeight - this.bottomMargin - this.offsetY - this.summary.getHeight());
}
fillBand(printBand);
this.offsetY += printBand.getHeight();
while (this.summary.willOverflow()) {
resolveGroupBoundElements((byte)3, true);
resolveColumnBoundElements((byte)3);
resolvePageBoundElements((byte)3);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
printBand = this.summary.fill(this.pageHeight - this.bottomMargin - this.offsetY - this.summary.getHeight());
fillBand(printBand);
this.offsetY += printBand.getHeight();
}
resolveBandBoundElements(this.summary, (byte)3);
}
}
private void fillBackground() throws JRException {
if (log.isDebugEnabled() && !this.background.isEmpty())
log.debug("Fill " + this.fillerId + ": background");
if (this.background.getHeight() <= this.pageHeight - this.bottomMargin - this.offsetY) {
this.background.evaluatePrintWhenExpression((byte)3);
if (this.background.isToPrint()) {
this.background.evaluate((byte)3);
JRPrintBand printBand = this.background.fill(this.pageHeight - this.bottomMargin - this.offsetY - this.background.getHeight());
fillBand(printBand);
}
}
}
private void addPage(boolean isResetPageNumber) throws JRException {
if (isSubreport()) {
if (!this.parentFiller.isBandOverFlowAllowed())
throw new JRRuntimeException("Subreport overflowed on a band that does not support overflow.");
this.printPageStretchHeight = this.offsetY + this.bottomMargin;
if (this.fillContext.isUsingVirtualizer())
removePageIdentityDataProvider();
suspendSubreportRunner();
}
this.printPage = newPage();
if (isSubreport() && this.fillContext.isUsingVirtualizer())
addPageIdentityDataProvider();
if (isResetPageNumber) {
this.calculator.getPageNumber().setValue(new Integer(1));
} else {
this.calculator.getPageNumber().setValue(new Integer(((Number)this.calculator.getPageNumber().getValue()).intValue() + 1));
}
this.calculator.getPageNumber().setOldValue(this.calculator.getPageNumber().getValue());
addPage(this.printPage);
setFirstColumn();
this.offsetY = this.topMargin;
this.lastDetailOffsetX = -1;
this.lastDetailOffsetY = -1;
fillBackground();
}
private void setColumnNumberVariable() {
JRFillVariable columnNumberVar = this.calculator.getColumnNumber();
columnNumberVar.setValue(new Integer(this.columnIndex + 1));
columnNumberVar.setOldValue(columnNumberVar.getValue());
}
private void fillPageBreak(boolean isResetPageNumber, byte evalPrevPage, byte evalNextPage, boolean isReprintGroupHeaders) throws JRException {
if (this.isCreatingNewPage)
throw new JRException("Infinite loop creating new page.");
this.isCreatingNewPage = true;
fillColumnFooters(evalPrevPage);
fillPageFooter(evalPrevPage);
resolveGroupBoundElements(evalPrevPage, false);
resolveColumnBoundElements(evalPrevPage);
resolvePageBoundElements(evalPrevPage);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(isResetPageNumber);
fillPageHeader(evalNextPage);
fillColumnHeaders(evalNextPage);
if (isReprintGroupHeaders)
fillGroupHeadersReprint(evalNextPage);
this.isCreatingNewPage = false;
}
protected void fillPageBand(JRFillBand band, byte evaluation) throws JRException {
band.evaluate(evaluation);
JRPrintBand printBand = band.fill(this.columnFooterOffsetY - this.offsetY - band.getHeight());
if (band.willOverflow() && !band.isSplitAllowed()) {
fillPageBreak(false, evaluation, evaluation, true);
printBand = band.refill(this.columnFooterOffsetY - this.offsetY - band.getHeight());
}
fillBand(printBand);
this.offsetY += printBand.getHeight();
while (band.willOverflow()) {
fillPageBreak(false, evaluation, evaluation, true);
printBand = band.fill(this.columnFooterOffsetY - this.offsetY - band.getHeight());
fillBand(printBand);
this.offsetY += printBand.getHeight();
}
resolveBandBoundElements(band, evaluation);
}
protected void fillColumnBand(JRFillBand band, byte evaluation) throws JRException {
band.evaluate(evaluation);
JRPrintBand printBand = band.fill(this.columnFooterOffsetY - this.offsetY - band.getHeight());
if (band.willOverflow() && !band.isSplitAllowed()) {
fillPageBreak(false, evaluation, evaluation, true);
printBand = band.refill(this.columnFooterOffsetY - this.offsetY - band.getHeight());
}
fillBand(printBand);
this.offsetY += printBand.getHeight();
while (band.willOverflow()) {
fillPageBreak(false, evaluation, evaluation, true);
printBand = band.fill(this.columnFooterOffsetY - this.offsetY - band.getHeight());
fillBand(printBand);
this.offsetY += printBand.getHeight();
}
resolveBandBoundElements(band, evaluation);
}
protected void fillFixedBand(JRFillBand band, byte evaluation) throws JRException {
fillFixedBand(band, evaluation, true);
}
protected void fillFixedBand(JRFillBand band, byte evaluation, boolean allowShrinking) throws JRException {
band.evaluate(evaluation);
JRPrintBand printBand = band.fill();
fillBand(printBand);
this.offsetY += allowShrinking ? printBand.getHeight() : band.getHeight();
resolveBandBoundElements(band, evaluation);
}
protected void fillBand(JRPrintBand band) {
List elements = band.getElements();
if (elements != null && elements.size() > 0) {
JRPrintElement element = null;
for (Iterator it = elements.iterator(); it.hasNext(); ) {
element = it.next();
element.setX(element.getX() + this.offsetX);
element.setY(element.getY() + this.offsetY);
this.printPage.addElement(element);
}
}
}
private void setNewPageColumnInBands() {
this.title.setNewPageColumn(true);
this.pageHeader.setNewPageColumn(true);
this.columnHeader.setNewPageColumn(true);
this.detail.setNewPageColumn(true);
this.columnFooter.setNewPageColumn(true);
this.pageFooter.setNewPageColumn(true);
this.lastPageFooter.setNewPageColumn(true);
this.summary.setNewPageColumn(true);
this.noData.setNewPageColumn(true);
if (this.groups != null && this.groups.length > 0)
for (int i = 0; i < this.groups.length; i++) {
((JRFillBand)this.groups[i].getGroupHeader()).setNewPageColumn(true);
((JRFillBand)this.groups[i].getGroupFooter()).setNewPageColumn(true);
}
}
private void setNewGroupInBands(JRGroup group) {
this.title.setNewGroup(group, true);
this.pageHeader.setNewGroup(group, true);
this.columnHeader.setNewGroup(group, true);
this.detail.setNewGroup(group, true);
this.columnFooter.setNewGroup(group, true);
this.pageFooter.setNewGroup(group, true);
this.lastPageFooter.setNewGroup(group, true);
this.summary.setNewGroup(group, true);
if (this.groups != null && this.groups.length > 0)
for (int i = 0; i < this.groups.length; i++) {
((JRFillBand)this.groups[i].getGroupHeader()).setNewGroup(group, true);
((JRFillBand)this.groups[i].getGroupFooter()).setNewGroup(group, true);
}
}
private JRFillBand getCurrentPageFooter() {
return this.isLastPageFooter ? this.lastPageFooter : this.pageFooter;
}
private void setLastPageFooter(boolean isLastPageFooter) {
this.isLastPageFooter = isLastPageFooter;
if (isLastPageFooter)
this.columnFooterOffsetY = this.lastPageColumnFooterOffsetY;
}
private void fillNoData() throws JRException {
if (log.isDebugEnabled() && !this.noData.isEmpty())
log.debug("Fill " + this.fillerId + ": noData");
this.noData.evaluatePrintWhenExpression((byte)3);
if (this.noData.isToPrint()) {
while (this.noData.getHeight() > this.pageHeight - this.bottomMargin - this.offsetY)
addPage(false);
this.noData.evaluate((byte)3);
JRPrintBand printBand = this.noData.fill(this.pageHeight - this.bottomMargin - this.offsetY - this.noData.getHeight());
if (this.noData.willOverflow() && !this.noData.isSplitAllowed() && isSubreport()) {
resolveGroupBoundElements((byte)3, false);
resolveColumnBoundElements((byte)3);
resolvePageBoundElements((byte)3);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
printBand = this.noData.refill(this.pageHeight - this.bottomMargin - this.offsetY - this.noData.getHeight());
}
fillBand(printBand);
this.offsetY += printBand.getHeight();
while (this.noData.willOverflow()) {
resolveGroupBoundElements((byte)3, false);
resolveColumnBoundElements((byte)3);
resolvePageBoundElements((byte)3);
this.scriptlet.callBeforePageInit();
this.calculator.initializeVariables((byte)2);
this.scriptlet.callAfterPageInit();
addPage(false);
printBand = this.noData.fill(this.pageHeight - this.bottomMargin - this.offsetY - this.noData.getHeight());
fillBand(printBand);
this.offsetY += printBand.getHeight();
}
resolveBandBoundElements(this.noData, (byte)3);
}
}
}

View File

@@ -0,0 +1,7 @@
package net.sf.jasperreports.engine.fill;
import net.sf.jasperreports.engine.JRException;
public interface JRIncrementer {
Object increment(JRFillVariable paramJRFillVariable, Object paramObject, AbstractValueProvider paramAbstractValueProvider) throws JRException;
}

View File

@@ -0,0 +1,5 @@
package net.sf.jasperreports.engine.fill;
public interface JRIncrementerFactory {
JRIncrementer getIncrementer(byte paramByte);
}

View File

@@ -0,0 +1,26 @@
package net.sf.jasperreports.engine.fill;
import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.JRRuntimeException;
public class JRIncrementerFactoryCache {
private static Map factoriesMap = null;
public static synchronized JRIncrementerFactory getInstance(Class factoryClass) {
if (factoriesMap == null)
factoriesMap = new HashMap();
JRIncrementerFactory incrementerFactory = (JRIncrementerFactory)factoriesMap.get(factoryClass.getName());
if (incrementerFactory == null) {
try {
incrementerFactory = factoryClass.newInstance();
} catch (InstantiationException e) {
throw new JRRuntimeException(e);
} catch (IllegalAccessException e) {
throw new JRRuntimeException(e);
}
factoriesMap.put(factoryClass.getName(), incrementerFactory);
}
return incrementerFactory;
}
}

View File

@@ -0,0 +1,24 @@
package net.sf.jasperreports.engine.fill;
class JRIntegerAverageIncrementer extends JRAbstractExtendedIncrementer {
private static JRIntegerAverageIncrementer mainInstance = new JRIntegerAverageIncrementer();
public static JRIntegerAverageIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
if (expressionValue == null) {
if (variable.isInitialized())
return null;
return variable.getValue();
}
Number countValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)0));
Number sumValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)1));
return new Integer(sumValue.intValue() / countValue.intValue());
}
public Object initialValue() {
return JRIntegerIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,32 @@
package net.sf.jasperreports.engine.fill;
class JRIntegerCountIncrementer extends JRAbstractExtendedIncrementer {
private static JRIntegerCountIncrementer mainInstance = new JRIntegerCountIncrementer();
public static JRIntegerCountIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Number value = (Number)variable.getIncrementedValue();
if (value == null || variable.isInitialized())
value = JRIntegerIncrementerFactory.ZERO;
if (expressionValue == null)
return value;
return new Integer(value.intValue() + 1);
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
Number value = (Number)calculable.getIncrementedValue();
Number combineValue = (Number)calculableValue.getValue();
if (value == null || calculable.isInitialized())
value = JRIntegerIncrementerFactory.ZERO;
if (combineValue == null)
return value;
return new Integer(value.intValue() + combineValue.intValue());
}
public Object initialValue() {
return JRIntegerIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,25 @@
package net.sf.jasperreports.engine.fill;
class JRIntegerDistinctCountIncrementer extends JRAbstractExtendedIncrementer {
private static JRIntegerDistinctCountIncrementer mainInstance = new JRIntegerDistinctCountIncrementer();
public static JRIntegerDistinctCountIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
DistinctCountHolder holder = (DistinctCountHolder)valueProvider.getValue(variable.getHelperVariable((byte)0));
if (variable.isInitialized())
holder.init();
return new Integer((int)holder.getCount());
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
DistinctCountHolder holder = (DistinctCountHolder)valueProvider.getValue(calculable.getHelperVariable((byte)0));
return new Integer((int)holder.getCount());
}
public Object initialValue() {
return JRIntegerIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,41 @@
package net.sf.jasperreports.engine.fill;
public class JRIntegerIncrementerFactory extends JRAbstractExtendedIncrementerFactory {
protected static final Integer ZERO = new Integer(0);
private static JRIntegerIncrementerFactory mainInstance = new JRIntegerIncrementerFactory();
public static JRIntegerIncrementerFactory getInstance() {
return mainInstance;
}
public JRExtendedIncrementer getExtendedIncrementer(byte calculation) {
JRExtendedIncrementer incrementer = null;
switch (calculation) {
case 1:
incrementer = JRIntegerCountIncrementer.getInstance();
return incrementer;
case 2:
incrementer = JRIntegerSumIncrementer.getInstance();
return incrementer;
case 3:
incrementer = JRIntegerAverageIncrementer.getInstance();
return incrementer;
case 4:
case 5:
incrementer = JRComparableIncrementerFactory.getInstance().getExtendedIncrementer(calculation);
return incrementer;
case 6:
incrementer = JRIntegerStandardDeviationIncrementer.getInstance();
return incrementer;
case 7:
incrementer = JRIntegerVarianceIncrementer.getInstance();
return incrementer;
case 10:
incrementer = JRIntegerDistinctCountIncrementer.getInstance();
return incrementer;
}
incrementer = JRDefaultIncrementerFactory.getInstance().getExtendedIncrementer(calculation);
return incrementer;
}
}

View File

@@ -0,0 +1,23 @@
package net.sf.jasperreports.engine.fill;
class JRIntegerStandardDeviationIncrementer extends JRAbstractExtendedIncrementer {
private static JRIntegerStandardDeviationIncrementer mainInstance = new JRIntegerStandardDeviationIncrementer();
public static JRIntegerStandardDeviationIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
if (expressionValue == null) {
if (variable.isInitialized())
return null;
return variable.getValue();
}
Number varianceValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)2));
return new Integer((int)Math.sqrt(varianceValue.doubleValue()));
}
public Object initialValue() {
return JRIntegerIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,26 @@
package net.sf.jasperreports.engine.fill;
class JRIntegerSumIncrementer extends JRAbstractExtendedIncrementer {
private static JRIntegerSumIncrementer mainInstance = new JRIntegerSumIncrementer();
public static JRIntegerSumIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Number value = (Number)variable.getIncrementedValue();
Number newValue = (Number)expressionValue;
if (newValue == null) {
if (variable.isInitialized())
return null;
return value;
}
if (value == null || variable.isInitialized())
value = JRIntegerIncrementerFactory.ZERO;
return new Integer(value.intValue() + newValue.intValue());
}
public Object initialValue() {
return JRIntegerIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,49 @@
package net.sf.jasperreports.engine.fill;
class JRIntegerVarianceIncrementer extends JRAbstractExtendedIncrementer {
private static JRIntegerVarianceIncrementer mainInstance = new JRIntegerVarianceIncrementer();
public static JRIntegerVarianceIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Number value = (Number)variable.getIncrementedValue();
Number newValue = (Number)expressionValue;
if (newValue == null) {
if (variable.isInitialized())
return null;
return value;
}
if (value == null || variable.isInitialized())
return JRIntegerIncrementerFactory.ZERO;
Number countValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)0));
Number sumValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)1));
return new Integer((countValue.intValue() - 1) * value.intValue() / countValue.intValue() + (sumValue.intValue() / countValue.intValue() - newValue.intValue()) * (sumValue.intValue() / countValue.intValue() - newValue.intValue()) / (countValue.intValue() - 1));
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
Number value = (Number)calculable.getIncrementedValue();
if (calculableValue.getValue() == null) {
if (calculable.isInitialized())
return null;
return value;
}
if (value == null || calculable.isInitialized())
return new Integer(((Number)calculableValue.getIncrementedValue()).intValue());
double v1 = value.doubleValue();
double c1 = ((Number)valueProvider.getValue(calculable.getHelperVariable((byte)0))).doubleValue();
double s1 = ((Number)valueProvider.getValue(calculable.getHelperVariable((byte)1))).doubleValue();
double v2 = ((Number)calculableValue.getIncrementedValue()).doubleValue();
double c2 = ((Number)valueProvider.getValue(calculableValue.getHelperVariable((byte)0))).doubleValue();
double s2 = ((Number)valueProvider.getValue(calculableValue.getHelperVariable((byte)1))).doubleValue();
c1 -= c2;
s1 -= s2;
double c = c1 + c2;
return new Integer((int)(c1 / c * v1 + c2 / c * v2 + c2 / c1 * s1 / c * s1 / c + c1 / c2 * s2 / c * s2 / c - 2.0D * s1 / c * s2 / c));
}
public Object initialValue() {
return JRIntegerIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,24 @@
package net.sf.jasperreports.engine.fill;
class JRLongAverageIncrementer extends JRAbstractExtendedIncrementer {
private static JRLongAverageIncrementer mainInstance = new JRLongAverageIncrementer();
public static JRLongAverageIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
if (expressionValue == null) {
if (variable.isInitialized())
return null;
return variable.getValue();
}
Number countValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)0));
Number sumValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)1));
return new Long(sumValue.longValue() / countValue.longValue());
}
public Object initialValue() {
return JRLongIncrementerFactory.ZERO;
}
}

View File

@@ -0,0 +1,32 @@
package net.sf.jasperreports.engine.fill;
class JRLongCountIncrementer extends JRAbstractExtendedIncrementer {
private static JRLongCountIncrementer mainInstance = new JRLongCountIncrementer();
public static JRLongCountIncrementer getInstance() {
return mainInstance;
}
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
Number value = (Number)variable.getIncrementedValue();
if (value == null || variable.isInitialized())
value = JRLongIncrementerFactory.ZERO;
if (expressionValue == null)
return value;
return new Long(value.longValue() + 1L);
}
public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
Number value = (Number)calculable.getIncrementedValue();
Number combineValue = (Number)calculableValue.getValue();
if (value == null || calculable.isInitialized())
value = JRLongIncrementerFactory.ZERO;
if (combineValue == null)
return value;
return new Long(value.longValue() + combineValue.longValue());
}
public Object initialValue() {
return JRLongIncrementerFactory.ZERO;
}
}

Some files were not shown because too many files have changed in this diff Show More