Package net.sf.jasperreports.engine.design

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


   * @param ColumnsGroup group
   * @return JRDesignTextField
   */
  protected final JRDesignTextField generateTextFieldFromColumn(AbstractColumn col, int height, ColumnsGroup group) {
    JRDesignTextField textField = new JRDesignTextField();
    JRDesignExpression exp = new JRDesignExpression();

    if (col.getPattern() != null && "".equals(col.getPattern().trim())) {
      textField.setPattern(col.getPattern());
        }

    exp.setText(col.getTextForExpression());
    exp.setValueClassName(col.getValueClassNameForExpression());
    textField.setExpression(exp);
    textField.setWidth(col.getWidth().intValue());
    textField.setX(col.getPosX().intValue());
    textField.setY(col.getPosY().intValue());
    textField.setHeight(height);
View Full Code Here


    Class clazz = null;
    try { clazz = Class.forName(chart.getColumn().getValueClassNameForExpression());
    } catch (ClassNotFoundException e) { /*Should never happen*/ }

    JRDesignExpression expression = new JRDesignExpression();
//    expression.setText("$F{" + chart.getColumn().getTitle().toLowerCase() + "}");
    expression.setText("$F{" + ((PropertyColumn) chart.getColumn()).getColumnProperty().getProperty()  + "}");
    expression.setValueClass(clazz);

    JRDesignVariable var = new JRDesignVariable();
    var.setValueClass(clazz);
    var.setExpression(expression);
    var.setCalculation(chart.getOperation());
View Full Code Here

    //if there is no title band, but there are banner images for the first page, we create a title band
    if (pageHeader == null && !getReport().getOptions().getImageBanners().isEmpty()){
      pageHeader = new JRDesignBand();
      getDesign().setPageHeader(pageHeader);
    }
    JRDesignExpression printWhenExpression = null;
    if (!getReport().getOptions().getFirstPageImageBanners().isEmpty()){
      printWhenExpression = new JRDesignExpression();
      printWhenExpression.setValueClass(Boolean.class);
      printWhenExpression.setText(EXPRESSION_TRUE_WHEN_NOT_FIRST_PAGE);
    }
    applyImageBannersToBand(pageHeader,getReport().getOptions().getImageBanners().values(),printWhenExpression);


  }
View Full Code Here

      for (Iterator iter = imageBanners.iterator(); iter.hasNext();) {
        ImageBanner imageBanner = (ImageBanner) iter.next();
        String path = "\"" + imageBanner.getImagePath().replaceAll("\\\\", "/") + "\"";
        JRDesignImage image = new JRDesignImage(new JRDesignStyle().getDefaultStyleProvider());
        JRDesignExpression imageExp = new JRDesignExpression();
        imageExp.setText(path);

        imageExp.setValueClass(String.class);
        image.setExpression(imageExp);
        image.setHeight(imageBanner.getHeight());
        image.setWidth(imageBanner.getWidth());
        image.setPrintWhenExpression(printWhenExpression);
        image.setRemoveLineWhenBlank(true);
View Full Code Here

        band = new JRDesignBand();
        getDesign().setTitle(band);
      }
    }

    JRDesignExpression printWhenExpression = new JRDesignExpression();
    printWhenExpression.setValueClass(Boolean.class);
    printWhenExpression.setText(EXPRESSION_TRUE_WHEN_FIRST_PAGE);

    JRDesignTextField title = new JRDesignTextField();
    JRDesignExpression exp = new JRDesignExpression();
    exp.setText("\"" + getReport().getTitle() + "\"");
    exp.setValueClass(String.class);
    title.setExpression(exp);
    title.setWidth(getReport().getOptions().getPrintableWidth());
    title.setHeight(getReport().getOptions().getTitleHeight().intValue());
    title.setY(yOffset);
    title.setPrintWhenExpression(printWhenExpression);
    title.setRemoveLineWhenBlank(true);
    applyStyleToElement(getReport().getTitleStyle(), title);
    band.addElement(title);

    JRDesignTextField subtitle = new JRDesignTextField();
    if (getReport().getSubtitle() != null) {
      JRDesignExpression exp2 = new JRDesignExpression();
      exp2.setText("\"" + getReport().getSubtitle() + "\"");
      exp2.setValueClass(String.class);
      subtitle.setExpression(exp2);
      subtitle.setWidth(getReport().getOptions().getPrintableWidth());
      subtitle.setHeight(getReport().getOptions().getSubtitleHeight().intValue());
      subtitle.setY(title.getY() + title.getHeight());
      subtitle.setPrintWhenExpression(printWhenExpression);
View Full Code Here

   * @param col
   * @return
   */
  private JRDesignTextField createColumnNameTextField(ColumnsGroup columnsGroup, AbstractColumn col) {
    JRDesignTextField designStaticText = new JRDesignTextField();
    JRDesignExpression exp = new JRDesignExpression();
    exp.setText("\"" + col.getTitle() + "\"");
    exp.setValueClass(String.class);
    designStaticText.setExpression(exp);
    designStaticText.setHeight(columnsGroup.getHeaderHeight().intValue());
    designStaticText.setWidth(col.getWidth().intValue());
    designStaticText.setX(col.getPosX().intValue());
    designStaticText.setY(col.getPosY().intValue());
View Full Code Here

      JRDesignSubreport subreport = new JRDesignSubreport(new JRDesignStyle().getDefaultStyleProvider());

      //The data source
      int dataSourceOrigin = sr.getDatasource().getDataSourceOrigin();
      if (DJConstants.DATA_SOURCE_ORIGIN_USE_REPORT_CONNECTION == dataSourceOrigin){
        JRDesignExpression connectionExpression = ExpressionUtils.getReportConnectionExpression();
        subreport.setConnectionExpression(connectionExpression);
      } else if (DJConstants.DATA_SOURCE_TYPE_SQL_CONNECTION == sr.getDatasource().getDataSourceType()) {
        JRDesignExpression connectionExpression = ExpressionUtils.getConnectionExpression(sr.getDatasource());
        subreport.setConnectionExpression(connectionExpression);       
      } else {
        JRDesignExpression dataSourceExpression = ExpressionUtils.getDataSourceExpression(sr.getDatasource());
        subreport.setDataSourceExpression(dataSourceExpression);
      }

//      int random_ = subReportRandom.nextInt();
      //the subreport design
      String paramname = sr.getReport().toString(); //TODO ensure this name is unique among all possible subreports
      ((DynamicJasperDesign)getDesign()).getParametersWithValues().put(paramname, sr.getReport());
      String expText = "("+JasperReport.class.getName()+")$P{REPORT_PARAMETERS_MAP}.get( \""+ paramname +"\" )";
      JRDesignExpression srExpression = ExpressionUtils.createExpression(expText, JasperReport.class);
      subreport.setExpression(srExpression );


      //set the parameters
      subreport.setParametersMapExpression(ExpressionUtils.getParameterExpression(sr));
View Full Code Here

        ColumnsGroupVariable var = (ColumnsGroupVariable) it.next();
        AbstractColumn col = var.getColumnToApplyOperation();

        String variableName = col.getGroupVariableName(type, columnsGroup.getColumnToGroupBy().getColumnProperty().getProperty());

        JRDesignExpression expression = new JRDesignExpression();
        JRDesignTextField textField = new JRDesignTextField();
        expression.setText("$V{" + variableName + "}");
        expression.setValueClassName(col.getVariableClassName(var.getOperation()));
        if (var.getOperation() != ColumnsGroupVariableOperation.COUNT)
          textField.setPattern(col.getPattern());

        textField.setKey(variableName);
        textField.setExpression(expression);

        if (DJConstants.FOOTER.equals(type)){
          textField.setPositionType(JRDesignElement.POSITION_TYPE_FIX_RELATIVE_TO_TOP);
        }

        textField.setX(col.getPosX().intValue());
        if (yOffset!=0)
          textField.setY(yOffset);

//        textField.setHeight(columnsGroup.getHeaderHeight().intValue());
        textField.setHeight(2 + getReport().getOptions().getDetailHeight().intValue()); //XXX be carefull with the "2+ ..."
        textField.setWidth(col.getWidth().intValue());

        textField.setEvaluationTime(JRExpression.EVALUATION_TIME_GROUP);

        textField.setEvaluationGroup(jgroup);
        //Assign the style to the element.
        //First we look for the specific element style, then the default style for the group variables
        //and finally the column style.
        Style defStyle = DJConstants.HEADER.equals(type)?columnsGroup.getDefaulHeaderStyle():columnsGroup.getDefaulFooterStyle();

        if (var.getStyle() != null)
          applyStyleToElement(var.getStyle(), textField);
        else if (defStyle != null)
          applyStyleToElement(defStyle, textField);
        else
          applyStyleToElement(col.getStyle(), textField);


        band.addElement(textField);

      }

      if (columnsGroup.getColumnToGroupBy() instanceof GlobalGroupColumn) {
        int totalWidth = 0;

        ColumnsGroupVariable leftmostColumn = findLeftMostColumn(variables);
        totalWidth = leftmostColumn.getColumnToApplyOperation().getPosX().intValue();

        GlobalGroupColumn globalCol = (GlobalGroupColumn) columnsGroup.getColumnToGroupBy();

        JRDesignTextField globalTextField = new JRDesignTextField();
        JRDesignExpression globalExp = new JRDesignExpression();
        globalExp.setText(globalCol.getTextForExpression());
        globalExp.setValueClassName(globalCol.getValueClassNameForExpression());
        globalTextField.setExpression(globalExp);

//        globalTextField.setHeight(band.getHeight()); //XXX Changed, see if its ok
        globalTextField.setHeight(2 + getReport().getOptions().getDetailHeight().intValue()); //XXX be carefull with the "2+ ..."
        globalTextField.setWidth(totalWidth);
View Full Code Here

        image.setY(0);
        image.setWidth(mapSize.width);
        image.setHeight(mapSize.height);
        image.setScaleImage(ScaleImageEnum.RETAIN_SHAPE);
       
        final JRDesignExpression expression = new JRDesignExpression();
        expression.setText(imageExpression);
        image.setExpression(expression);
       
        return image;
    }
View Full Code Here

            colHeaderField.setHorizontalAlignment(HorizontalAlignEnum.LEFT);
            colHeaderField.setStyle(columnHeaderStyle);
            colHeaderField.setStretchWithOverflow(true);
            colHeaderField.setStretchType(StretchTypeEnum.RELATIVE_TO_TALLEST_OBJECT);

            JRDesignExpression headerExpression = new JRDesignExpression();
            headerExpression.setText('"' + columnName + '"');
            colHeaderField.setExpression(headerExpression);
            headerBand.addElement(colHeaderField);

            // Add fields to the detailBand
            if (this.converters.isEmpty()) {
                // if no converters are used, create a field depending on the type
                JRDesignElement designElement;
                if (RenderedImage.class.isAssignableFrom(valueClass)) {
                    designElement = createImageElement(templateDesign, columnName);
                    addElement(detailBand, designElement, detailPosX, detailPosY,
                            columnWidth, detailHeight, columnDetailStyle);
                } else {
                    JRDesignTextField textField = createTextField(columnName);
                    addElement(detailBand, textField, detailPosX, detailPosY,
                            columnWidth, detailHeight, columnDetailStyle);
                }
            } else {
                // image element
                JRDesignElement imageElement = createImageElement(templateDesign, columnName);
                // condition: use this element for images
                JRDesignExpression printWhenExpression = new JRDesignExpression();
                printWhenExpression.setText("new Boolean($F{" + columnName + "}.getClass().equals(java.awt.image.BufferedImage.class))");
                imageElement.setPrintWhenExpression(printWhenExpression);

                addElement(detailBand, imageElement, detailPosX, detailPosY,
                        columnWidth, detailHeight, columnDetailStyle);

                // text field element
                JRDesignTextField textField = createTextField(columnName);
                // condition: use this element for non-images
                printWhenExpression = new JRDesignExpression();
                printWhenExpression.setText("new Boolean(!$F{" + columnName + "}.getClass().equals(java.awt.image.BufferedImage.class))");
                textField.setPrintWhenExpression(printWhenExpression);

                addElement(detailBand, textField, detailPosX, detailPosY,
                        columnWidth, detailHeight, columnDetailStyle);
            }
View Full Code Here

TOP

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

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.