Package net.sf.jasperreports.engine.design

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


    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:
View Full Code Here


      italicFont.setPdfEncoding("Cp1252");
      italicFont.setPdfEmbedded(false);
      jasperDesign.addFont(italicFont);

      //Title
      JRDesignBand band = new JRDesignBand();
      band.setHeight(50);
      JRDesignLine line = new JRDesignLine();
      line.setX(0);
      line.setY(0);
      line.setWidth(968);
      line.setHeight(0);
      band.addElement(line);
     
      JRDesignStaticText text = new JRDesignStaticText();
     
      text.setX(0);
      text.setY(10);
      text.setWidth(968);
      text.setHeight(30);
      text.setTextAlignment(JRTextElement.TEXT_ALIGN_CENTER);
      JRDesignReportFont bigFont = new JRDesignReportFont();
      bigFont.setName("Arial_Normal");
      bigFont.setDefault(true);
      bigFont.setFontName("Arial");
      bigFont.setSize(22);
      bigFont.setPdfFontName("Helvetica");
      bigFont.setPdfEncoding("Cp1252");
      bigFont.setPdfEmbedded(false);
      text.setFont(bigFont);
      text.setText(reportDefinition.getName());
      band.addElement(text);
      jasperDesign.setTitle(band);
     
  }
View Full Code Here

    return band;
  }
 
  private JRDesignBand getFieldsHeader(SpreadSheetFieldArray fields, boolean isSub) throws JRException {
    //Page header
    JRDesignBand band = new JRDesignBand();
    band.setHeight(20);
    return addFieldsHeader(band, fields, isSub);
  }
View Full Code Here

    return band;
  }
 
  private JRDesignBand getDetail(SpreadSheetFieldArray fields, JRGroup group) throws JRException {
    //Detail
    JRDesignBand band = new JRDesignBand();
    return addDetail(band, fields, group);
  }
View Full Code Here

    return addDetail(band, fields, group);
  }
 
  private JRDesignBand getAggregatableFooter(SpreadSheetFieldArray fields) throws JRException {
   
    JRDesignBand band = new JRDesignBand();
    band.setHeight(40);
    Iterator iterator = fields.iterator();
    int x = 0;
    while(iterator.hasNext()) {
      Field field = (Field)iterator.next();
      if(isAggregable(field)) {
        JRDesignLine line = new JRDesignLine();
        line.setX(x);
        line.setY(0);
        line.setWidth(field.getColumnWidth());
        line.setHeight(0);
        band.addElement(line);
        line.setY(2);
        band.addElement(line);

        JRDesignTextField textField = new JRDesignTextField();
        textField.setX(x);
        textField.setY(4);
        textField.setWidth(field.getColumnWidth());
        textField.setHeight(12);
        textField.setTextAlignment(JRTextElement.TEXT_ALIGN_RIGHT);
        textField.setFont(normalFont);
        JRDesignExpression expression = new JRDesignExpression();

       
        // Money (double) or Duration(long)
        if(field.isMoney()) {
          expression.setValueClass(getFieldClass(field, true));
          textField.setPattern(getFieldPattern(field));
          expression.setText("$V{" + getFieldName(field, true) + "Sum}");
        } else if (field.isWork()) {
          expression.setValueClass(String.class);
          expression.setText("com.projity.datatype.DurationFormat.formatWork($V{" + getFieldName(field, true) + "Sum})" );
        } else if(field.isDuration()) {
          expression.setValueClass(String.class);
          expression.setText("com.projity.datatype.DurationFormat.format($V{" + getFieldName(field, true) + "Sum})" );
        }

        textField.setExpression(expression);
        band.addElement(textField);
      }

      x += field.getColumnWidth();
    }
View Full Code Here

    return band;

  }
 
  private void addLastPageFooter(SpreadSheetFieldArray fields) throws JRException {
    JRDesignBand band = getAggregatableFooter(fields);
    band.addElement(getPageFooter());
   
    jasperDesign.setLastPageFooter(band);
  }
View Full Code Here

   
    jasperDesign.setLastPageFooter(band);
  }
  private void addPageFooter() throws JRException {
    //page footer
    JRDesignBand band = new JRDesignBand();
    band.setHeight(30);
    JRDesignLine line = new JRDesignLine();
    line.setX(0);
    line.setY(0);
    line.setWidth(968);
    line.setHeight(0);
    band.addElement(line);
   
    band.addElement(getPageFooter());
    jasperDesign.setPageFooter(band);
  }
View Full Code Here

          group.setExpression(expression);
          break;
        }
      }
     
      JRDesignBand band = getDetail(mainFields, group);
      band = addFieldsHeader(band, detailFields, true);
      group.setGroupHeader(band);

      if(hasAggregableField) {
        group.setGroupFooter(getAggregatableFooter(detailFields));
View Full Code Here

        design.addField(field);
     
        System.out.println("column header is " + interval.getText2());
       
        // add columns
        JRDesignBand columnHeader = (JRDesignBand) design.getColumnHeader();
 
        JRDesignStaticText staticText = new JRDesignStaticText();
        staticText.setX(maxX);
        staticText.setY(0);
        staticText.setWidth(80);
        staticText.setHeight(15);
        staticText.setTextAlignment(JRTextElement.TEXT_ALIGN_RIGHT);
        staticText.setFont(normalFont);
        staticText.setText(interval.getText1());
        staticText.setPrintWhenDetailOverflows(true);
        columnHeader.addElement(staticText);

        // add textFields
        JRDesignBand detailBand = (JRDesignBand) design.getDetail();
 
        JRDesignTextField textField = new JRDesignTextField();
        textField.setX(maxX);
        textField.setY(0);
        textField.setWidth(80);
        textField.setHeight(15);
        textField.setTextAlignment(JRTextElement.TEXT_ALIGN_RIGHT);
        textField.setFont(normalFont);
  //      textField.setFont((JRReportFont)fonts.get("normalFont"));
        JRDesignExpression expression = new JRDesignExpression();
        expression.setValueClass(fieldType);
        expression.setText("$F{" + fieldName + "}");
        textField.setExpression(expression);
        textField.setPrintWhenDetailOverflows(true);
        detailBand.addElement(textField);
        maxX += 80;
      }

    } catch (JRException e) {
      // TODO Auto-generated catch block
View Full Code Here

    log.debug("setting up WHEN NO DATA band");
    String whenNoDataText = getReport().getWhenNoDataText();
    Style style = getReport().getWhenNoDataStyle();
    if (whenNoDataText == null || "".equals(whenNoDataText))
      return;
    JRDesignBand band = new JRDesignBand();
    getDesign().setNoData(band);

    JRDesignTextField text = new JRDesignTextField();
    JRDesignExpression expression = ExpressionUtils.createStringExpression("\""+whenNoDataText+"\"");
    text.setExpression(expression);

    if (style == null){
      style = getReport().getOptions().getDefaultDetailStyle();
    }

    if (getReport().isWhenNoDataShowTitle())
      LayoutUtils.copyBandElements(band, getDesign().getPageHeader());
    if (getReport().isWhenNoDataShowColumnHeader())
      LayoutUtils.copyBandElements(band, getDesign().getColumnHeader());

    int offset = LayoutUtils.findVerticalOffset(band);
    text.setY(offset);
    applyStyleToElement(style, text);
    text.setWidth(getReport().getOptions().getPrintableWidth());
    text.setHeight(50);
    band.addElement(text);
    log.debug("OK setting up WHEN NO DATA band");

  }
View Full Code Here

TOP

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

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.