Package net.sf.jasperreports.engine.design

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


   * @param chart Chart that needs a variable to be generated
   * @return the generated variables
   */
  protected List registerChartVariable(DJChart chart) {
    //FIXME aca hay que iterar por cada columna. Cambiar DJChart para que tome muchas
    JRDesignGroup group = getJRGroupFromDJGroup(chart.getColumnsGroup());
    List vars = new ArrayList();

    int serieNum = 0;
    for (Iterator iterator = chart.getColumns().iterator(); iterator.hasNext();) {
      AbstractColumn col = (AbstractColumn) iterator.next();


      Class clazz = null;
      try { clazz = Class.forName(((PropertyColumn) col).getColumnProperty().getValueClassName());
      } catch (ClassNotFoundException e) {
        throw new DJException("Exeption creating chart variable: " + e.getMessage(),e);
      }

      JRDesignExpression expression = new JRDesignExpression();
      //FIXME Only PropertyColumn allowed?
      expression.setText("$F{" + ((PropertyColumn) col).getColumnProperty().getProperty()  + "}");
      expression.setValueClass(clazz);

      JRDesignVariable var = new JRDesignVariable();
      var.setValueClass(clazz);
      var.setExpression(expression);
      var.setCalculation(chart.getOperation());
      var.setResetGroup(group);
      var.setResetType(JRBaseVariable.RESET_TYPE_GROUP);

      //use the index as part of the name just because I may want 2
      //different types of chart from the very same column (with the same operation also) making the variables name to be duplicated
      int chartIndex = getReport().getCharts().indexOf(chart);
      var.setName("CHART_[" + chartIndex +"_s" +serieNum + "+]_" + group.getName() + "_" + col.getTitle() + "_" + chart.getOperation());

      try {
        getDesign().addVariable(var);
        vars.add(var);
      } catch (JRException e) {
View Full Code Here


    }
    return null;
  }
 
  protected JRDesignBand createGroupForChartAndGetBand(ar.com.fdvs.dj.domain.chart.DJChart djChart) {
    JRDesignGroup jrGroup = getChartColumnsGroup(djChart);
    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(ar.com.fdvs.dj.domain.chart.DJChart djChart, String name){
      JRDesignGroup jrGroupChart = getChartColumnsGroup(djChart);
      JRDesignGroup parentGroup = getParent(jrGroupChart);
      Map chartVariables = registerChartVariable(djChart);
      return djChart.transform((DynamicJasperDesign) getDesign(), name, jrGroupChart, parentGroup, chartVariables, getReport().getOptions().getPrintableWidth());
  }
View Full Code Here

   * @param chart Chart that needs a variable to be generated
   * @return the generated variables
   */
  protected Map registerChartVariable(ar.com.fdvs.dj.domain.chart.DJChart chart) {
    //FIXME aca hay que iterar por cada columna. Cambiar DJChart para que tome muchas
    JRDesignGroup group = getChartColumnsGroup(chart);
    Map vars = new HashMap();

    int serieNum = 0;
    for (Iterator iterator = chart.getDataset().getColumns().iterator(); iterator.hasNext();) {
      AbstractColumn col = (AbstractColumn) iterator.next();


      Class clazz = null;
      try { clazz = Class.forName(col.getValueClassNameForExpression());
      } catch (ClassNotFoundException e) {
        throw new DJException("Exeption creating chart variable: " + e.getMessage(),e);
      }

      JRDesignExpression expression = new JRDesignExpression();
      //FIXME Only PropertyColumn allowed?
      expression.setText("$F{" + ((PropertyColumn) col).getColumnProperty().getProperty()  + "}");
      expression.setValueClass(clazz);

      JRDesignVariable var = new JRDesignVariable();
      var.setValueClass(clazz);
      var.setExpression(expression);
      var.setCalculation(chart.getOperation());
      var.setResetGroup(group);
      var.setResetType(JRBaseVariable.RESET_TYPE_GROUP);

      //use the index as part of the name just because I may want 2
      //different types of chart from the very same column (with the same operation also) making the variables name to be duplicated
      int chartIndex = getReport().getNewCharts().indexOf(chart);
      var.setName("CHART_[" + chartIndex +"_s" +serieNum + "+]_" + group.getName() + "_" + col.getTitle() + "_" + chart.getOperation());

      try {
        getDesign().addVariable(var);
        vars.put(col, var);
      } catch (JRException e) {
View Full Code Here

   * @param group Group for which the parent is needed
   * @return The parent group of the given one. If the given one is the first one, it returns the same group
   */
  protected JRDesignGroup getParent(JRDesignGroup group){
    int index = realGroups.indexOf(group);
    JRDesignGroup parentGroup = (index > 0) ? (JRDesignGroup) realGroups.get(index-1): group;
    return parentGroup;
  }
View Full Code Here

   */
  protected void layoutGroups() {
    log.debug("Starting groups layout...");
    for (Iterator iter = getReport().getColumnsGroups().iterator(); iter.hasNext();) {
      DJGroup columnsGroup = (DJGroup) iter.next();
      JRDesignGroup jgroup = getJRGroupFromDJGroup(columnsGroup);

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

      JRDesignBand header = (JRDesignBand) jgroup.getGroupHeader();
      JRDesignBand footer = (JRDesignBand) jgroup.getGroupFooter();
     
      //double check to prevent NPE
      if (header == null){
        header = new JRDesignBand();
        jgroup.setGroupHeader(header);
      }
      if (footer == null){
        footer = new JRDesignBand();
        jgroup.setGroupFooter(footer);
      }
     
      header.setHeight(columnsGroup.getHeaderHeight().intValue());
//      footer.setHeight( getFooterVariableHeight(columnsGroup));
      footer.setHeight( columnsGroup.getFooterHeight().intValue());

      header.setSplitAllowed(columnsGroup.isAllowHeaderSplit());
      footer.setSplitAllowed(columnsGroup.isAllowFooterSplit());

      if (columnsGroup.getLayout().isPrintHeaders()) {
        boolean found = false;
        boolean skipPreviousGroupHeaders = false;
        int groupIdx = getReport().getColumnsGroups().indexOf(columnsGroup);
        if (groupIdx>0){
          DJGroup prevG =  (DJGroup) getReport().getColumnsGroups().get(groupIdx-1);
                    if(!(prevG.getColumnToGroupBy() instanceof GlobalGroupColumn))
                        skipPreviousGroupHeaders = !prevG.getLayout().isShowValueForEachRow();
        }
        for (Iterator iterator =  getVisibleColumns().iterator(); iterator.hasNext();) {
          AbstractColumn col = (AbstractColumn) iterator.next();

          //If in a nested group, header for column prior to this groups column
          //depends on configuration

          if (col.equals(columnsGroup.getColumnToGroupBy())) {
            found = true;
          }

          if (!found && skipPreviousGroupHeaders){
            continue;
          }

          JRDesignTextField designTextField = createColumnNameTextField(columnsGroup, col);
          designTextField.setPositionType(JRDesignElement.POSITION_TYPE_FLOAT); //XXX changed to see what happens  (must come from the column position property)
          designTextField.setStretchType(JRDesignElement.STRETCH_TYPE_NO_STRETCH); //XXX changed to see what happens (must come from the column property)
          header.addElement(designTextField);
        }
      }
      DJGroupLabel label = columnsGroup.getFooterLabel()
      if (label != null /*&& !footerVariables.isEmpty()*/) {
        List footerVariables = columnsGroup.getFooterVariables();
        PropertyColumn col = columnsGroup.getColumnToGroupBy();
        JRDesignBand band = (JRDesignBand)jgroup.getGroupFooter();
        int x = 0, y = 0;
        //max width
        int width = getDesign().getPageWidth() - getDesign().getLeftMargin() - getDesign().getRightMargin();
        int height = label.getHeight();
        int yOffset = 0;
View Full Code Here

      if (sr.getStyle() != null)
        applyStyleToElement(sr.getStyle(), subreport);

      //adding to the band
      if (sr.isStartInNewPage()) {
        JRDesignGroup jrgroup = getJRGroupFromDJGroup(columnsGroup);
        JRDesignBand targetBand = null;
        int idx = getDesign().getGroupsList().indexOf(jrgroup);
        if (DJConstants.HEADER.equals(position)) {
//          if (idx == 0){
//            if (getDesign().getColumnHeader() != null)
//              targetBand = (JRDesignBand) getDesign().getColumnHeader();
//            else if (getDesign().getPageHeader() != null)
//              targetBand = (JRDesignBand) getDesign().getPageHeader();
//            else
//              targetBand = band;
//          }
//          else
//            targetBand = (JRDesignBand) ((JRDesignGroup) getDesign().getGroupsList().get(idx-1)).getGroupHeader();
        }
        else { //footer subreport (and concatenated report)
          if (idx+1 <  getDesign().getGroupsList().size())
            idx++;
          targetBand = (JRDesignBand) ((JRDesignGroup) getDesign().getGroupsList().get(idx)).getGroupFooter();
        }

        /**
         * There is no meaning in adding a page-break in header sub reports since
         * they will be placed right after the group header
         */
        if (DJConstants.FOOTER.equals(position)){
          JRDesignBreak pageBreak = new JRDesignBreak(new JRDesignStyle().getDefaultStyleProvider());
          pageBreak.setKey(PAGE_BREAK_FOR_ + jrgroup.toString()); //set up a name to recognize the item later
          pageBreak.setY(0);
          pageBreak.setPositionType(JRDesignElement.POSITION_TYPE_FLOAT);
          targetBand.addElement(pageBreak);
        }

View Full Code Here

   */
  protected void layoutGroups() {
    log.debug("Starting groups layout...");
    for (Iterator iter = getReport().getColumnsGroups().iterator(); iter.hasNext();) {
      DJGroup columnsGroup = (DJGroup) iter.next();
      JRDesignGroup jgroup = getJRGroupFromDJGroup(columnsGroup);

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

      JRDesignBand header = (JRDesignBand) jgroup.getGroupHeader();
      JRDesignBand footer = (JRDesignBand) jgroup.getGroupFooter();
     
      //double check to prevent NPE
      if (header == null){
        header = new JRDesignBand();
        jgroup.setGroupHeader(header);
      }
      if (footer == null){
        footer = new JRDesignBand();
        jgroup.setGroupFooter(footer);
      }
     
      header.setHeight(columnsGroup.getHeaderHeight().intValue());
//      footer.setHeight( getFooterVariableHeight(columnsGroup));
      footer.setHeight( columnsGroup.getFooterHeight().intValue());
View Full Code Here

      if (sr.getStyle() != null)
        applyStyleToElement(sr.getStyle(), subreport);

      //adding to the band
      if (sr.isStartInNewPage()) {
        JRDesignGroup jrgroup = getJRGroupFromDJGroup(columnsGroup);
        JRDesignBand targetBand = null;
        int idx = getDesign().getGroupsList().indexOf(jrgroup);
        if (DJConstants.HEADER.equals(position)) {
//          if (idx == 0){
//            if (getDesign().getColumnHeader() != null)
//              targetBand = (JRDesignBand) getDesign().getColumnHeader();
//            else if (getDesign().getPageHeader() != null)
//              targetBand = (JRDesignBand) getDesign().getPageHeader();
//            else
//              targetBand = band;
//          }
//          else
//            targetBand = (JRDesignBand) ((JRDesignGroup) getDesign().getGroupsList().get(idx-1)).getGroupHeader();
        }
        else { //footer subreport (and concatenated report)
          if (idx+1 <  getDesign().getGroupsList().size())
            idx++;
          targetBand = (JRDesignBand) ((JRDesignGroup) getDesign().getGroupsList().get(idx)).getGroupFooter();
        }

        /**
         * There is no meaning in adding a page-break in header sub reports since
         * they will be placed right after the group header
         */
        if (DJConstants.FOOTER.equals(position)){
          JRDesignBreak pageBreak = new JRDesignBreak(new JRDesignStyle().getDefaultStyleProvider());
          pageBreak.setKey(PAGE_BREAK_FOR_ + jrgroup.toString()); //set up a name to recognize the item later
          pageBreak.setY(0);
          pageBreak.setPositionType(JRDesignElement.POSITION_TYPE_FLOAT);
          targetBand.addElement(pageBreak);
        }

View Full Code Here

        JRDesignStyle jrstyle = (JRDesignStyle) textField.getStyle();
       
        if (group != null) {
          int index = getReport().getColumnsGroups().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

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.