Package net.sf.jasperreports.engine.design

Examples of net.sf.jasperreports.engine.design.JRDesignGroup


      }
    }
  }

  protected JRDesignBand createGroupForChartAndGetBand(DJChart djChart) {
    JRDesignGroup jrGroup = getGroupFromColumnsGroup(djChart.getColumnsGroup());
    JRDesignGroup parentGroup = getParent(jrGroup);
    JRDesignGroup jrGroupChart = null;
    try {
      jrGroupChart = (JRDesignGroup) BeanUtils.cloneBean(parentGroup);
      jrGroupChart.setGroupFooter( new JRDesignBand());
      jrGroupChart.setGroupHeader( new JRDesignBand());
      jrGroupChart.setName(jrGroupChart.getName()+"_Chart" + getReport().getCharts().indexOf(djChart));
    } catch (Exception e) {
      throw new DJException("Problem creating band for chart: " + e.getMessage(),e);
    }

    //Charts should be added in its own band (to ensure page break, etc)
    //To achieve that, we create a group and insert it right before to the criteria group.
    //I need to find parent group of the criteria group, clone and insert after.
    //The only precaution is that if parent == child (only one group in the report) the we insert before
    if (jrGroup.equals(parentGroup)){
      getDesign().getGroupsList().add( getDesign().getGroupsList().indexOf(jrGroup) , jrGroupChart);
    } else {
      int index = getDesign().getGroupsList().indexOf(parentGroup);
      getDesign().getGroupsList().add(index, jrGroupChart);
    }

    JRDesignBand band = null;
    switch (djChart.getOptions().getPosition()) {
    case DJChartOptions.POSITION_HEADER:
      band = (JRDesignBand) jrGroupChart.getGroupHeader();
      break;
    case DJChartOptions.POSITION_FOOTER:
      band = (JRDesignBand) jrGroupChart.getGroupFooter();
    }
    return band;
  }
View Full Code Here


  protected void layoutGroups() {
    log.debug("Starting groups layout...");
    int i = 0;
    for (Iterator iter = getReport().getColumnsGroups().iterator(); iter.hasNext();) {
      ColumnsGroup columnsGroup = (ColumnsGroup) iter.next();
      JRDesignGroup jgroup = (JRDesignGroup) getDesign().getGroupsList().get(i++);

      jgroup.setStartNewPage(columnsGroup.getStartInNewPage().booleanValue());
      jgroup.setStartNewColumn(columnsGroup.getStartInNewColumn().booleanValue());

      JRDesignBand header = (JRDesignBand) jgroup.getGroupHeader();
      JRDesignBand footer = (JRDesignBand) jgroup.getGroupFooter();
      header.setHeight(columnsGroup.getHeaderHeight().intValue());
      footer.setHeight(columnsGroup.getFooterHeight().intValue());

      if (columnsGroup.getLayout().isPrintHeaders()) {
        for (Iterator iterator =  getVisibleColumns().iterator(); iterator.hasNext();) {
View Full Code Here

    }
    return null;
  }
 
  public static JRDesignGroup findParentJRGroup(DJGroup djgroup, DynamicReport dr, DynamicJasperDesign djd, LayoutManager layoutManager) {
    JRDesignGroup registeredGroup;
    int gidx = dr.getColumnsGroups().indexOf(djgroup);
    if (gidx > 0) {
      gidx--;
      DJGroup djParentGroup = (DJGroup) dr.getColumnsGroups().get(gidx);
      JRDesignGroup jrParentGroup = LayoutUtils.getJRDesignGroup(djd, layoutManager, djParentGroup);
      registeredGroup = jrParentGroup;
    } else
      registeredGroup = null;
    return registeredGroup;
 
View Full Code Here

  protected void registerEntity(Entity entity) {
    log.debug("registering group...");
    DJGroup djgroup = (DJGroup) entity;
    try {
      JRDesignGroup group = (JRDesignGroup)transformEntity(djgroup);
      getDjd().addGroup(group);
      //Variables are registered right after the group where they belong.
      String property = djgroup.getColumnToGroupBy().getColumnProperty().getProperty();
     
      if (djgroup.getFooterLabel() != null && djgroup.getFooterLabel().getLabelExpression() != null) {
        registerCustomExpressionParameter(group.getName() + "_labelExpression", djgroup.getFooterLabel().getLabelExpression());
      }

//      ColumnsGroupFieldVariablesRegistrationManager fieldVariablesRM = new ColumnsGroupFieldVariablesRegistrationManager(getDjd(),getDynamicReport(),getLayoutManager(), group);
//      fieldVariablesRM.registerEntities(djgroup.getFieldVariables());
     
View Full Code Here

  //PropertyColumn only can be used for grouping (not OperationColumn)
  protected Object transformEntity(Entity entity) throws JRException {
    log.debug("transforming group...");
    DJGroup djgroup = (DJGroup) entity;
    PropertyColumn column = djgroup.getColumnToGroupBy();
    JRDesignGroup group = new JRDesignGroup();

    if (djgroup.getName() == null) {
      int groupIndex = getDynamicReport().getColumnsGroups().indexOf(djgroup);
      int columnIndex = getDynamicReport().getColumns().indexOf(djgroup.getColumnToGroupBy());
      if (column instanceof GlobalGroupColumn){
        djgroup.setName("global_column_" + groupIndex);
      } else {
        djgroup.setName( "group["+groupIndex+"]_for_column_" + columnIndex + "-" +  column.getName());
      }     
    }
    group.setName(djgroup.getName());
   
    getLayoutManager().getReferencesMap().put(group.getName(), djgroup);

    group.setCountVariable(new JRDesignVariable());
    group.setGroupFooter(new JRDesignBand());
    group.setGroupHeader(new JRDesignBand());

    JRDesignExpression jrExpression = new JRDesignExpression();
   
    CustomExpression expressionToGroupBy = column.getExpressionToGroupBy();
   
    if (expressionToGroupBy != null) { //new in 3.0.7-b5
      useVariableForCustomExpression(group, jrExpression, expressionToGroupBy);
     
    } else {
      if (column instanceof ExpressionColumn){
        ExpressionColumn col = (ExpressionColumn)column;
        CustomExpression customExpression = col.getExpression();
        useVariableForCustomExpression(group, jrExpression, customExpression);
      } else {
        jrExpression.setText(column.getTextForExpression());
        jrExpression.setValueClassName(column.getValueClassNameForExpression());
      }
    }
   

    group.setExpression(jrExpression);

    return group;
  }
View Full Code Here

    JRDesignExpression expression = new JRDesignExpression();

    //only variables from the last registered group are important now
    List groupsList = getDjd().getGroupsList();
    JRDesignGroup registeredGroup = (JRDesignGroup)groupsList.get(groupsList.size()-1);
   
    String variableName = col.getGroupVariableName(type, columnToGroupByProperty);

    if (col instanceof ExpressionColumn && ((ExpressionColumn)col).getExpressionForCalculation() != null){
      ExpressionColumn expcol = (ExpressionColumn)col;
View Full Code Here

       */
      if (column instanceof PercentageColumn) {
        PercentageColumn percentageColumn = ((PercentageColumn) column);       
        for (Iterator iterator2 = dr.getColumnsGroups().iterator(); iterator2.hasNext();) {
          DJGroup djGroup = (DJGroup) iterator2.next();
          JRDesignGroup jrGroup = LayoutUtils.getJRDesignGroup(jd, layoutManager, djGroup);
          DJGroupVariableDefRegistrationManager variablesRM = new DJGroupVariableDefRegistrationManager(jd,dr,layoutManager, jrGroup);
          DJGroupVariableDef variable = new DJGroupVariableDef(percentageColumn.getGroupVariableName(djGroup), percentageColumn.getPercentageColumn(), DJCalculation.SUM);
          Collection entities = new ArrayList();
          entities.add(variable);
          variablesRM.registerEntities(entities);
View Full Code Here

        JRDesignStyle jrstyle = (JRDesignStyle) textField.getStyle();
       
        if (group != null) {
          int index = columnsGroups.indexOf(group);
//            JRDesignGroup previousGroup = (JRDesignGroup) getDesign().getGroupsList().get(index);
            JRDesignGroup previousGroup = getJRGroupFromDJGroup(group);
            textField.setPrintWhenGroupChanges(previousGroup);

            /**
             * Since a group column can share the style with non group columns, if oddRow coloring is enabled,
             * we modified this shared style to have a colored background on odd rows. We don't want that for group
View Full Code Here

      }
    }
  }

  protected JRDesignBand createGroupForChartAndGetBand(DJChart djChart) {
    JRDesignGroup jrGroup = getJRGroupFromDJGroup(djChart.getColumnsGroup());
    JRDesignGroup parentGroup = getParent(jrGroup);
    JRDesignGroup jrGroupChart = null;
    try {
      jrGroupChart = (JRDesignGroup) BeanUtils.cloneBean(parentGroup);
      jrGroupChart.setGroupFooter( new JRDesignBand());
      jrGroupChart.setGroupHeader( new JRDesignBand());
      jrGroupChart.setName(jrGroupChart.getName()+"_Chart" + getReport().getCharts().indexOf(djChart));
    } catch (Exception e) {
      throw new DJException("Problem creating band for chart: " + e.getMessage(),e);
    }

    //Charts should be added in its own band (to ensure page break, etc)
    //To achieve that, we create a group and insert it right before to the criteria group.
    //I need to find parent group of the criteria group, clone and insert after.
    //The only precaution is that if parent == child (only one group in the report) the we insert before
    if (jrGroup.equals(parentGroup)){
      jrGroupChart.setExpression(ExpressionUtils.createStringExpression("\"dummy_for_chart\""));
      getDesign().getGroupsList().add( getDesign().getGroupsList().indexOf(jrGroup) , jrGroupChart);
    } else {
      int index = getDesign().getGroupsList().indexOf(parentGroup);
      getDesign().getGroupsList().add(index, jrGroupChart);
    }

    JRDesignBand band = null;
    switch (djChart.getOptions().getPosition()) {
    case DJChartOptions.POSITION_HEADER:
      band = (JRDesignBand) jrGroupChart.getGroupHeader();
      break;
    case DJChartOptions.POSITION_FOOTER:
      band = (JRDesignBand) jrGroupChart.getGroupFooter();
    }
    return band;
  }
View Full Code Here

   * Creates the JRDesignChart from the DJChart. To do so it also creates needed variables and data-set
   * @param djChart
   * @return
   */
  protected JRDesignChart createChart(DJChart djChart){
      JRDesignGroup jrGroupChart = getJRGroupFromDJGroup(djChart.getColumnsGroup());

      JRDesignChart chart = new JRDesignChart(new JRDesignStyle().getDefaultStyleProvider(), djChart.getType());
      JRDesignGroup parentGroup = getParent(jrGroupChart);
      List chartVariables = registerChartVariable(djChart);
      JRDesignChartDataset chartDataset = DataSetFactory.getDataset(djChart, jrGroupChart, parentGroup, chartVariables);
      chart.setDataset(chartDataset);
      interpeterOptions(djChart, chart);

View Full Code Here

TOP

Related Classes of net.sf.jasperreports.engine.design.JRDesignGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.