Package net.sf.jasperreports.engine.design

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


    return mostLeftColumn;
  }

  protected void insertValueInHeader(JRDesignBand headerBand, ColumnsGroup columnsGroup, int headerOffset) {
//    JRDesignTextField textField = generateTextFieldFromColumn(columnsGroup.getColumnToGroupBy(), columnsGroup.getHeaderHeight().intValue(), columnsGroup);
    JRDesignTextField textField = generateTextFieldFromColumn(columnsGroup.getColumnToGroupBy(), getReport().getOptions().getDetailHeight().intValue(), columnsGroup);
    textField.setHorizontalAlignment(columnsGroup.getColumnToGroupBy().getStyle().getHorizontalAlign().getValue());
    textField.setStretchType(JRDesignElement.STRETCH_TYPE_NO_STRETCH); //XXX this is a patch for subreports, ensure it works well.
    textField.setY(textField.getY() + headerOffset);
    headerBand.addElement(textField);
  }
View Full Code Here


      jasperDesign.setTitle(band);
     
  }
 
  public JRDesignTextField getPageFooter() {
    JRDesignTextField textField = new JRDesignTextField();
    textField.setX(0);
    textField.setY(10);
    textField.setWidth(968);
    textField.setHeight(15);
    textField.setTextAlignment(JRTextElement.TEXT_ALIGN_CENTER);
    textField.setFont(normalFont);
    JRDesignExpression expression = new JRDesignExpression();
    expression.setValueClass(java.lang.String.class);
    expression.setText("\"Page \" + String.valueOf($V{PAGE_NUMBER})"); //  + \" of\"");
    textField.setExpression(expression);
    return textField;
  }
View Full Code Here

    } else {
      band.setHeight(15);
    }
    while(iterator.hasNext()) {
      Field field = (Field)iterator.next();
      JRDesignTextField textField = new JRDesignTextField();
      if(null != group) {
        textField.setEvaluationTime(JRDesignExpression.EVALUATION_TIME_GROUP);
        textField.setEvaluationGroup(group);
//        textField.setBackcolor(Color.black);
//        textField.setForecolor(Color.white);
        textField.setY(5);
        textField.setFont(boldFont);
        textField.setHeight(15);
      }
      else {
        textField.setY(0);
        textField.setFont(normalFont);
        textField.setHeight(12);
      }
      textField.setX(x);
      textField.setWidth(field.getColumnWidth());
      textField.setTextAlignment(JRTextElement.TEXT_ALIGN_RIGHT);

      String fieldName = getFieldName(field, false);
      if(field.isMoney()) {
        // Double
        textField.setPattern(getFieldPattern(field));
      }

      JRDesignExpression expression = new JRDesignExpression();
      expression.setValueClass(getFieldClass(field, false));
      expression.setText("$F{" + fieldName + "}");

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

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

        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

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

    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

      }
      /**
       * Regular Column
       */
      else {
        JRDesignTextField textField = generateTextFieldFromColumn(column, getReport().getOptions().getDetailHeight().intValue(), null);
        transformDetailBandTextField(column, textField);
       
        if (textField.getExpression() != null)
          detail.addElement(textField);
       
//        if (column.getConditionalStyles() != null && !column.getConditionalStyles().isEmpty() ){
//          for (Iterator iterator = column.getConditionalStyles().iterator(); iterator.hasNext();) {
//            ConditionalStyle condition = (ConditionalStyle) iterator.next();
View Full Code Here

      AbstractColumn col = (AbstractColumn) iter.next();
      if (col.getTitle() == null)
        continue;

      JRDesignExpression expression = new JRDesignExpression();
      JRDesignTextField textField = new JRDesignTextField();
      expression.setText("\""+ col.getTitle() + "\"");

      expression.setValueClass(String.class);

      textField.setKey("header_"+col.getTitle());
      textField.setExpression(expression);

      textField.setX(col.getPosX().intValue());
      textField.setY(col.getPosY().intValue());
      textField.setHeight(band.getHeight());
      textField.setWidth(col.getWidth().intValue());

      textField.setPrintWhenDetailOverflows(true);
      textField.setBlankWhenNull(true);

      Style headerStyle = col.getHeaderStyle();
      if (headerStyle == null)
        headerStyle = report.getOptions().getDefaultHeaderStyle();
View Full Code Here

        textField.setStretchType(style.getStreching().getValue());
      textField.setPositionType(JRTextField.POSITION_TYPE_FLOAT);

    }
    if (designElemen instanceof JRDesignTextField ) {
      JRDesignTextField textField = (JRDesignTextField) designElemen;
      textField.setStretchWithOverflow(style.isStretchWithOverflow());

      if (textField.isBlankWhenNull() == false && style.isBlankWhenNull()) //TODO Re check if this condition is ok
        textField.setBlankWhenNull(true);
    }
//    return jrstyle;
    return;
  }
View Full Code Here

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

    if (col.getPattern() != null && "".equals(col.getPattern().trim())) {
      textField.setPattern(col.getPattern());
        }
   
    if (col.getTruncateSuffix() != null){
      textField.getPropertiesMap().setProperty(JRTextElement.PROPERTY_TRUNCATE_SUFFIX, col.getTruncateSuffix());
    }

    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);

    textField.setBlankWhenNull(col.getBlankWhenNull());

    textField.setPattern(col.getPattern());

    textField.setPrintRepeatedValues(col.getPrintRepeatedValues().booleanValue());

        textField.setPrintWhenDetailOverflows(true);

        Style columnStyle = col.getStyle();
        if (columnStyle == null)
          columnStyle = report.getOptions().getDefaultDetailStyle();

        applyStyleToElement(columnStyle, textField);
        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 dont want that for group
             * columns, that's why we create our own style from the existing one, and remove proper odd-row conditional
             * style if present
             */
            JRDesignStyle groupStyle = new JRDesignStyle();
            Utils.copyProperties(groupStyle, jrstyle);

      groupStyle.setName(groupStyle.getFontName() +"_for_group_"+index);
      textField.setStyle(groupStyle);
      try {
        design.addStyle(groupStyle);
      } catch (JRException e) { /**e.printStackTrace(); //Already there, nothing to do **/}

        } else {
         
            JRDesignStyle alternateStyle = new JRDesignStyle();
            Utils.copyProperties(alternateStyle, jrstyle);

      alternateStyle.setName(alternateStyle.getFontName() +"_for_column_"+col.getName());
      alternateStyle.getConditionalStyleList().clear();
      textField.setStyle(alternateStyle);
      try {
        design.addStyle(alternateStyle);
      } catch (JRException e) { /**e.printStackTrace(); //Already there, nothing to do **/}
         
         
View Full Code Here

TOP

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

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.