Package net.sf.jasperreports.engine.design

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


      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 don't 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 = Utils.cloneStyle(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 = Utils.cloneStyle(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

    contents.setBackcolor(colors[colors.length-1][colors[0].length-1]);
    contents.setMode(new Byte(Transparency.OPAQUE.getValue()));

    jrcross.setHeaderCell(contents);

    JRDesignTextField element = new JRDesignTextField();
    String text = "";
    int auxHeight = 0;
    int auxWidth = 0;

    if (djcross.isAutomaticTitle())
      text = createAutomaticMainHeaderTitle();
    else if (djcross.getMainHeaderTitle() != null)
      text = "\"" + djcross.getMainHeaderTitle() "\"";

    for (Iterator iterator = djcross.getColumns().iterator(); iterator.hasNext();) {
      DJCrosstabColumn col = (DJCrosstabColumn) iterator.next();
      auxHeight += col.getHeaderHeight();
    }
    for (Iterator iterator = djcross.getRows().iterator(); iterator.hasNext();) {
      DJCrosstabRow row = (DJCrosstabRow) iterator.next();
      auxWidth += row.getHeaderWidth();
    }

    JRDesignExpression exp = ExpressionUtils.createStringExpression(text);
    element.setExpression(exp);

    element.setWidth(auxWidth);
    element.setHeight(auxHeight);
    element.setStretchWithOverflow(true);

    if (djcross.getHeaderStyle() != null)
      layoutManager.applyStyleToElement(djcross.getHeaderStyle(), element);

    applyCellBorder(contents);
View Full Code Here

        int counter = 0;
        int measureHeight = crosstabRow.getHeight() / djcross.getMeasures().size();
        for (Iterator iterator = djcross.getMeasures().iterator(); iterator.hasNext(); counter++) {
          DJCrosstabMeasure djmeasure = (DJCrosstabMeasure) iterator.next();
         
          JRDesignTextField element = new JRDesignTextField();
          element.setWidth(crosstabColumn.getWidth());
          element.setHeight(measureHeight);
          element.setY(counter*measureHeight);
         

          JRDesignExpression measureExp = new JRDesignExpression();
//          DJCrosstabMeasure measure = djcross.getMeasure(0);
          measureExp.setValueClassName(djmeasure.getProperty().getValueClassName());
          measureExp.setText("$V{"+djmeasure.getProperty().getProperty()+"}");
         
          element.setExpression(measureExp);

          /**
           * Is there any style for this object?
           */
          if (crosstabRow.getProperty() == null && crosstabColumn.getProperty() == null && djmeasure.getStyle() != null ){
View Full Code Here

      JRDesignExpression bucketExp = ExpressionUtils.createExpression("$F{"+crosstabRow.getProperty().getProperty()+"}", crosstabRow.getProperty().getValueClassName());
      rowBucket.setExpression(bucketExp);


      JRDesignCellContents rowHeaderContents = new JRDesignCellContents();
      JRDesignTextField rowTitle = new JRDesignTextField();

      JRDesignExpression rowTitExp = new JRDesignExpression();
      rowTitExp.setValueClassName(crosstabRow.getProperty().getValueClassName());
      rowTitExp.setText("$V{"+crosstabRow.getProperty().getProperty()+"}");

      rowTitle.setExpression(rowTitExp);
      rowTitle.setWidth(crosstabRow.getHeaderWidth());

      //The width can be the sum of the with of all the rows starting from the current one, up to the inner most one.
      int auxHeight = getRowHeaderMaxHeight(crosstabRow);
//      int auxHeight = crosstabRow.getHeight(); //FIXME getRowHeaderMaxHeight() must be FIXED because it breaks when 1rs row shows total and 2nd doesn't
      rowTitle.setHeight(auxHeight);

      Style headerstyle = crosstabRow.getHeaderStyle() == null ? this.djcross.getRowHeaderStyle(): crosstabRow.getHeaderStyle();

      if (headerstyle != null){
        layoutManager.applyStyleToElement(headerstyle, rowTitle);
View Full Code Here

      bucket.setExpression(bucketExp);

      ctColGroup.setBucket(bucket);

      JRDesignCellContents colHeaerContent = new JRDesignCellContents();
      JRDesignTextField colTitle = new JRDesignTextField();

      JRDesignExpression colTitleExp = new JRDesignExpression();
      colTitleExp.setValueClassName(crosstabColumn.getProperty().getValueClassName());
      colTitleExp.setText("$V{"+crosstabColumn.getProperty().getProperty()+"}");


      colTitle.setExpression(colTitleExp);
      colTitle.setWidth(crosstabColumn.getWidth());
      colTitle.setHeight(crosstabColumn.getHeaderHeight());

      //The height can be the sum of the heights of all the columns starting from the current one, up to the inner most one.
      int auxWidth = calculateRowHeaderMaxWidth(crosstabColumn);
      colTitle.setWidth(auxWidth);

      Style headerstyle = crosstabColumn.getHeaderStyle() == null ? this.djcross.getColumnHeaderStyle(): crosstabColumn.getHeaderStyle();
     
      if (headerstyle != null){
        layoutManager.applyStyleToElement(headerstyle,colTitle);
View Full Code Here

    Style totalHeaderstyle = crosstabRow.getTotalHeaderStyle() == null ? this.djcross.getRowTotalheaderStyle(): crosstabRow.getTotalHeaderStyle();
   
    totalHeaderContent.setMode(new Byte(Transparency.OPAQUE.getValue()));
   
    JRDesignTextField element = new JRDesignTextField();
    JRDesignExpression exp = ExpressionUtils.createExpression("\"Total "+crosstabRow.getTitle()+"\"",String.class);
    element.setExpression(exp);
    element.setHeight(crosstabRow.getHeight());

    if (totalHeaderstyle != null) {
      totalHeaderContent.setBackcolor(totalHeaderstyle.getBackgroundColor());
      layoutManager.applyStyleToElement(totalHeaderstyle, element);
    }

    //The width can be the sum of the with of all the rows starting from the current one, up to the inner most one.
    int auxWidth = 0;
    boolean found = false;
    for (Iterator iterator = djcross.getRows().iterator(); iterator.hasNext();) {
      DJCrosstabRow row = (DJCrosstabRow) iterator.next();
      if (!row.equals(crosstabRow) && found == false){
        continue;
      } else {
        found = true;
      }

      auxWidth += row.getHeaderWidth();
    }
    element.setWidth(auxWidth);

    applyCellBorder(totalHeaderContent);

    totalHeaderContent.addElement(element);
  }
View Full Code Here

    Style totalHeaderstyle = crosstabColumn.getTotalHeaderStyle() == null ? this.djcross.getColumnTotalheaderStyle(): crosstabColumn.getTotalHeaderStyle();
   
    totalHeaderContent.setMode(new Byte(Transparency.OPAQUE.getValue()));

    JRDesignExpression exp = ExpressionUtils.createExpression("\"Total "+crosstabColumn.getTitle()+"\"",String.class);
    JRDesignTextField element = new JRDesignTextField();
    element.setExpression(exp);
    element.setWidth(crosstabColumn.getWidth());


    if (totalHeaderstyle != null) {
      layoutManager.applyStyleToElement(totalHeaderstyle, element);
      totalHeaderContent.setBackcolor(totalHeaderstyle.getBackgroundColor());
    }

    //The height can be the sum of the heights of all the columns starting from the current one, up to the inner most one.
    int auxWidth = 0;
    boolean found = false;
    for (Iterator iterator = djcross.getColumns().iterator(); iterator.hasNext();) {
      DJCrosstabColumn col = (DJCrosstabColumn) iterator.next();
      if (!col.equals(crosstabColumn) && found == false){
        continue;
      } else {
        found = true;
      }

      auxWidth += col.getHeaderHeight();
    }
    element.setHeight(auxWidth);

    applyCellBorder(totalHeaderContent);

    totalHeaderContent.addElement(element);
View Full Code Here

    chunk.setText(columnVO.getDbName());
    chunk.setType(JRDesignExpressionChunk.TYPE_FIELD);
    JRDesignExpression expression = new JRDesignExpression();
    expression.addChunk(chunk);
    expression.setValueClass(columnVO.getFieldClass());
    JRDesignTextField textField = new JRDesignTextField();
    textField.setWidth(columnVO.getWidth());
    textField.setHeight(bDetalle.getHeight());
    textField.setX(px);
    textField.setExpression(expression);
    textField.setBlankWhenNull(true);
    textField.setFontName(gridReportVO.getDetailBandStyle().getFontName());
    textField.setFontSize(gridReportVO.getDetailBandStyle().getFontSize());
    textField.setForecolor(gridReportVO.getDetailBandStyle().getForeColor());
    textField.setBold(gridReportVO.getDetailBandStyle().isBold());
    textField.setItalic(gridReportVO.getDetailBandStyle().isItalic());
    textField.setUnderline(gridReportVO.getDetailBandStyle().isUnderline());
    textField.setStretchWithOverflow(true);
    textField.setStretchType(JRElement.STRETCH_TYPE_RELATIVE_TO_TALLEST_OBJECT);

    bDetalle.addElement(textField);
  }
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.