/** * <p>getVariable.</p> * * @return a {@link net.sf.dynamicreports.report.base.DRVariable} object. */ public DRVariable<T> getVariable() { return build(); }
/** * <p>variable.</p> * * @param expression a {@link net.sf.dynamicreports.report.definition.expression.DRIExpression} object. * @param calculation a {@link net.sf.dynamicreports.report.constant.Calculation} object. * @param <T> a T object. * @return a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. */ public static <T> VariableBuilder<T> variable(DRIExpression<?> expression, Calculation calculation) { return new VariableBuilder<T>(expression, calculation); }
/** * <p>setInitialValueExpression.</p> * * @param initialValueExpression a {@link net.sf.dynamicreports.report.definition.expression.DRIJasperExpression} object. * @return a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. */ public VariableBuilder<T> setInitialValueExpression(DRIJasperExpression<?> initialValueExpression) { getObject().setInitialValueExpression(initialValueExpression); return this; }
/** * <p>setResetGroup.</p> * * @param resetGroup a {@link net.sf.dynamicreports.report.builder.group.GroupBuilder} object. * @return a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. */ public VariableBuilder<T> setResetGroup(GroupBuilder<?> resetGroup) { if (resetGroup != null) { getObject().setResetGroup(resetGroup.getGroup()); setResetType(Evaluation.GROUP); } else { getObject().setResetGroup(null); } return this; }
private void build() { TextColumnBuilder<String> countryColumn = col.column("Country", "country", type.stringType()); TextColumnBuilder<String> itemColumn = col.column("Item", "item", type.stringType()); TextColumnBuilder<Integer> quantityColumn = col.column("Quantity", "quantity", type.integerType()); TextColumnBuilder<BigDecimal> priceColumn = col.column("Price", "price", type.bigDecimalType()); ColumnGroupBuilder countryGroup = grp.group(countryColumn); VariableBuilder<Integer> quantitySum = variable(quantityColumn, Calculation.SUM); VariableBuilder<BigDecimal> priceSum = variable(priceColumn, Calculation.SUM); VariableBuilder<Integer> quantityGrpSum = variable(quantityColumn, Calculation.SUM); quantityGrpSum.setResetGroup(countryGroup); VariableBuilder<BigDecimal> priceGrpSum = variable(priceColumn, Calculation.SUM); priceGrpSum.setResetType(Evaluation.FIRST_GROUP); StyleBuilder subtotalStyle = stl.style().bold().setTopBorder(stl.pen1Point()).setHorizontalTextAlignment(HorizontalTextAlignment.CENTER); TextFieldBuilder<String> summarySbt = cmp.text(new CustomTextSubtotal(quantitySum, priceSum)).setStyle(subtotalStyle); TextFieldBuilder<String> groupSbt = cmp.text(new CustomTextSubtotal(quantityGrpSum, priceGrpSum)).setStyle(subtotalStyle); countryGroup.footer(groupSbt); try { report().setTemplate(Templates.reportTemplate) .variables(quantitySum, priceSum, quantityGrpSum, priceGrpSum) .columns(countryColumn, itemColumn, quantityColumn, priceColumn) .groupBy(countryGroup) .summary(summarySbt) .title(Templates.createTitleComponent("CustomTextSubtotal")) .pageFooter(Templates.footerComponent) .setDataSource(createDataSource()) .show(); } catch (DRException e) { e.printStackTrace(); } }
private CountryHeadingExpression() { VariableBuilder<Integer> minCountryPage = variable(pageIndexField, Calculation.LOWEST).setResetType(Evaluation.FIRST_GROUP); addExpression(minCountryPage); VariableBuilder<Integer> maxCountryPage = variable(pageIndexField, Calculation.HIGHEST).setResetType(Evaluation.FIRST_GROUP); addExpression(maxCountryPage); }
/** * <p>addExpression.</p> * * @param variable a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. */ protected void addExpression(VariableBuilder<?> variable) { Validate.notNull(variable, "variable must not be null"); this.expressions.add(variable.getVariable()); }
private void build() { TextColumnBuilder<String> countryColumn = col.column("Country", "country", type.stringType()); TextColumnBuilder<String> itemColumn = col.column("Item", "item", type.stringType()); TextColumnBuilder<Integer> quantityColumn = col.column("Quantity", "quantity", type.integerType()); Bar3DChartBuilder chart1 = cht.bar3DChart() .setFixedHeight(180) .setCategory(countryColumn) .series(cht.serie(exp.number(1)).setLabel("Items (group count)")) .setCategoryAxisFormat(cht.axisFormat().setLabel("Country")); VariableBuilder<Integer> itemVariable = variable(itemColumn, Calculation.DISTINCT_COUNT); itemVariable.setResetType(Evaluation.FIRST_GROUP); Bar3DChartBuilder chart2 = cht.bar3DChart() .setFixedHeight(180) .setCategory(countryColumn) .series(cht.serie(itemVariable).setLabel("Items (group distinct count)")) .setCategoryAxisFormat(cht.axisFormat().setLabel("Country")); try { report().setTemplate(Templates.reportTemplate) .columns(countryColumn, itemColumn, quantityColumn) .title(Templates.createTitleComponent("GroupCountChart")) .groupBy(grp.group(countryColumn)) .summary(cmp.horizontalList(chart1, chart2)) .pageFooter(Templates.footerComponent) .setDataSource(createDataSource()) .show(); } catch (DRException e) { e.printStackTrace(); } }
/** * {@inheritDoc} */ @Override public String getName() { return getVariable().getName(); } }
/** * <p>setClose.</p> * * @param variable a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. * @return a T object. */ public T setClose(VariableBuilder<? extends Number> variable) { Validate.notNull(variable, "variable must not be null"); getDataset().setCloseExpression(variable.build()); return (T) this; }
/** * <p>variable.</p> * * @param name a {@link java.lang.String} object. * @param expression a {@link net.sf.dynamicreports.report.definition.expression.DRIExpression} object. * @param calculation a {@link net.sf.dynamicreports.report.constant.Calculation} object. * @param <T> a T object. * @return a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. */ public static <T> VariableBuilder<T> variable(String name, DRIExpression<?> expression, Calculation calculation) { return new VariableBuilder<T>(name, expression, calculation); }
/** * <p>setText.</p> * * @param variable a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. * @return a {@link net.sf.dynamicreports.report.builder.component.TextFieldBuilder} object. */ public TextFieldBuilder<T> setText(VariableBuilder<T> variable) { Validate.notNull(variable, "variable must not be null"); getObject().setValueExpression(variable.getVariable()); return this; }
/** * <p>setResetType.</p> * * @param resetType a {@link net.sf.dynamicreports.report.constant.Evaluation} object. * @return a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. */ public VariableBuilder<T> setResetType(Evaluation resetType) { getObject().setResetType(resetType); return this; }
/** * <p>setGroup.</p> * * @param variable a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. * @return a {@link net.sf.dynamicreports.report.builder.chart.GroupedCategoryChartSerieBuilder} object. */ public GroupedCategoryChartSerieBuilder setGroup(VariableBuilder<String> variable) { Validate.notNull(variable, "variable must not be null"); getObject().setGroupExpression(variable.build()); return this; } }
/** * <p>variable.</p> * * @param name a {@link java.lang.String} object. * @param field a {@link net.sf.dynamicreports.report.builder.FieldBuilder} object. * @param calculation a {@link net.sf.dynamicreports.report.constant.Calculation} object. * @param <T> a T object. * @return a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. */ public static <T> VariableBuilder<T> variable(String name, FieldBuilder<T> field, Calculation calculation) { return new VariableBuilder<T>(name, field, calculation); }
/** * <p>addVariable.</p> * * @param variables a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. * @return a T object. */ public T addVariable(VariableBuilder<?>... variables) { Validate.notNull(variables, "variables must not be null"); Validate.noNullElements(variables, "variables must not contains null variable"); for (VariableBuilder<?> variable : variables) { getObject().addVariable(variable.getVariable()); } return (T) this; }
/** * <p>setPercent.</p> * * @param variable a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. * @return a {@link net.sf.dynamicreports.report.builder.chart.GanttChartSerieBuilder} object. */ public GanttChartSerieBuilder setPercent(VariableBuilder<? extends Number> variable) { Validate.notNull(variable, "variable must not be null"); getObject().setPercentExpression(variable.build()); return this; }
/** * <p>variable.</p> * * @param field a {@link net.sf.dynamicreports.report.builder.FieldBuilder} object. * @param calculation a {@link net.sf.dynamicreports.report.constant.Calculation} object. * @param <T> a T object. * @return a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. */ public static <T> VariableBuilder<T> variable(FieldBuilder<T> field, Calculation calculation) { Validate.notNull(field, "field must not be null"); return new VariableBuilder<T>(field, calculation); }
/** * <p>addVariable.</p> * * @param variables a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. * @return a {@link net.sf.dynamicreports.report.builder.DatasetBuilder} object. */ public DatasetBuilder addVariable(VariableBuilder<?>... variables) { Validate.notNull(variables, "variables must not be null"); Validate.noNullElements(variables, "variables must not contains null variable"); for (VariableBuilder<?> variable : variables) { getObject().addVariable(variable.getVariable()); } return this; }
/** * <p>setYValue.</p> * * @param variable a {@link net.sf.dynamicreports.report.builder.VariableBuilder} object. * @return a {@link net.sf.dynamicreports.report.builder.chart.XyChartSerieBuilder} object. */ public XyChartSerieBuilder setYValue(VariableBuilder<? extends Number> variable) { Validate.notNull(variable, "variable must not be null"); getObject().setYValueExpression(variable.build()); return this; }