Examples of JRDesignTextField


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

  public Object createObject(Attributes atts)
  {
    JRXmlLoader xmlLoader = (JRXmlLoader)digester.peek(digester.getCount() - 1);
    JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2);

    JRDesignTextField textField = new JRDesignTextField(jasperDesign);

    String isStretchWithOverflow = atts.getValue(JRXmlConstants.ATTRIBUTE_isStretchWithOverflow);
    if (isStretchWithOverflow != null && isStretchWithOverflow.length() > 0)
    {
      textField.setStretchWithOverflow(Boolean.valueOf(isStretchWithOverflow).booleanValue());
    }

    EvaluationTimeEnum evaluationTime = EvaluationTimeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_evaluationTime));
    if (evaluationTime != null)
    {
      textField.setEvaluationTime(evaluationTime);
    }
    if (textField.getEvaluationTimeValue() == EvaluationTimeEnum.GROUP)
    {
      xmlLoader.addGroupEvaluatedTextField(textField);
     
      String groupName = atts.getValue(JRXmlConstants.ATTRIBUTE_evaluationGroup);
      if (groupName != null)
      {
        JRDesignGroup group = new JRDesignGroup();
        group.setName(groupName);
        textField.setEvaluationGroup(group);
      }
    }
   
    textField.setPattern(atts.getValue(JRXmlConstants.ATTRIBUTE_pattern));

    String isBlankWhenNull = atts.getValue(JRXmlConstants.ATTRIBUTE_isBlankWhenNull);
    if (isBlankWhenNull != null && isBlankWhenNull.length() > 0)
    {
      textField.setBlankWhenNull(Boolean.valueOf(isBlankWhenNull));
    }

    textField.setLinkType(atts.getValue(JRXmlConstants.ATTRIBUTE_hyperlinkType));
    textField.setLinkTarget(atts.getValue(JRXmlConstants.ATTRIBUTE_hyperlinkTarget));
   
    String bookmarkLevelAttr = atts.getValue(JRXmlConstants.ATTRIBUTE_bookmarkLevel);
    if (bookmarkLevelAttr != null)
    {
      textField.setBookmarkLevel(Integer.parseInt(bookmarkLevelAttr));
    }

    return textField;
  }
View Full Code Here

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

    expression.setText("$F{City}");
    group.setExpression(expression);

    JRDesignBand band = new JRDesignBand();
    band.setHeight(20);
    JRDesignTextField textField = new JRDesignTextField();
    textField.setX(0);
    textField.setY(4);
    textField.setWidth(515);
    textField.setHeight(15);
    textField.setBackcolor(new Color(0xC0, 0xC0, 0xC0));
    textField.setMode(ModeEnum.OPAQUE);
    textField.setHorizontalAlignment(HorizontalAlignEnum.LEFT);
    textField.setStyle(boldStyle);
    expression = new JRDesignExpression();
    expression.setValueClass(java.lang.String.class);
    expression.setText("\"  \" + String.valueOf($V{CityNumber}) + \". \" + String.valueOf($F{City})");
    textField.setExpression(expression);
    band.addElement(textField);
    JRDesignLine line = new JRDesignLine();
    line.setX(0);
    line.setY(19);
    line.setWidth(515);
    line.setHeight(0);
    band.addElement(line);
    ((JRDesignSection)group.getGroupHeaderSection()).addBand(band);

    band = new JRDesignBand();
    band.setHeight(20);
    line = new JRDesignLine();
    line.setX(0);
    line.setY(-1);
    line.setWidth(515);
    line.setHeight(0);
    band.addElement(line);
    JRDesignStaticText staticText = new JRDesignStaticText();
    staticText.setX(400);
    staticText.setY(0);
    staticText.setWidth(60);
    staticText.setHeight(15);
    staticText.setHorizontalAlignment(HorizontalAlignEnum.RIGHT);
    staticText.setStyle(boldStyle);
    staticText.setText("Count : ");
    band.addElement(staticText);
    textField = new JRDesignTextField();
    textField.setX(460);
    textField.setY(0);
    textField.setWidth(30);
    textField.setHeight(15);
    textField.setHorizontalAlignment(HorizontalAlignEnum.RIGHT);
    textField.setStyle(boldStyle);
    expression = new JRDesignExpression();
    expression.setValueClass(java.lang.Integer.class);
    expression.setText("$V{CityGroup_COUNT}");
    textField.setExpression(expression);
    band.addElement(textField);
    ((JRDesignSection)group.getGroupFooterSection()).addBand(band);

    jasperDesign.addGroup(group);

    //Title
    band = new JRDesignBand();
    band.setHeight(50);
    line = new JRDesignLine();
    line.setX(0);
    line.setY(0);
    line.setWidth(515);
    line.setHeight(0);
    band.addElement(line);
    textField = new JRDesignTextField();
    textField.setBlankWhenNull(true);
    textField.setX(0);
    textField.setY(10);
    textField.setWidth(515);
    textField.setHeight(30);
    textField.setHorizontalAlignment(HorizontalAlignEnum.CENTER);
    textField.setStyle(normalStyle);
    textField.setFontSize(22);
    expression = new JRDesignExpression();
    expression.setValueClass(java.lang.String.class);
    expression.setText("$P{ReportTitle}");
    textField.setExpression(expression);
    band.addElement(textField);
    jasperDesign.setTitle(band);
   
    //Page header
    band = new JRDesignBand();
    band.setHeight(20);
    JRDesignFrame frame = new JRDesignFrame();
    frame.setX(0);
    frame.setY(5);
    frame.setWidth(515);
    frame.setHeight(15);
    frame.setForecolor(new Color(0x33, 0x33, 0x33));
    frame.setBackcolor(new Color(0x33, 0x33, 0x33));
    frame.setMode(ModeEnum.OPAQUE);
    band.addElement(frame);
    staticText = new JRDesignStaticText();
    staticText.setX(0);
    staticText.setY(0);
    staticText.setWidth(55);
    staticText.setHeight(15);
    staticText.setForecolor(Color.white);
    staticText.setBackcolor(new Color(0x33, 0x33, 0x33));
    staticText.setMode(ModeEnum.OPAQUE);
    staticText.setHorizontalAlignment(HorizontalAlignEnum.CENTER);
    staticText.setStyle(boldStyle);
    staticText.setText("ID");
    frame.addElement(staticText);
    staticText = new JRDesignStaticText();
    staticText.setX(55);
    staticText.setY(0);
    staticText.setWidth(205);
    staticText.setHeight(15);
    staticText.setForecolor(Color.white);
    staticText.setBackcolor(new Color(0x33, 0x33, 0x33));
    staticText.setMode(ModeEnum.OPAQUE);
    staticText.setStyle(boldStyle);
    staticText.setText("Name");
    frame.addElement(staticText);
    staticText = new JRDesignStaticText();
    staticText.setX(260);
    staticText.setY(0);
    staticText.setWidth(255);
    staticText.setHeight(15);
    staticText.setForecolor(Color.white);
    staticText.setBackcolor(new Color(0x33, 0x33, 0x33));
    staticText.setMode(ModeEnum.OPAQUE);
    staticText.setStyle(boldStyle);
    staticText.setText("Street");
    frame.addElement(staticText);
    jasperDesign.setPageHeader(band);

    //Column header
    band = new JRDesignBand();
    jasperDesign.setColumnHeader(band);

    //Detail
    band = new JRDesignBand();
    band.setHeight(20);
    textField = new JRDesignTextField();
    textField.setX(0);
    textField.setY(4);
    textField.setWidth(50);
    textField.setHeight(15);
    textField.setHorizontalAlignment(HorizontalAlignEnum.RIGHT);
    textField.setStyle(normalStyle);
    expression = new JRDesignExpression();
    expression.setValueClass(java.lang.Integer.class);
    expression.setText("$F{Id}");
    textField.setExpression(expression);
    band.addElement(textField);
    textField = new JRDesignTextField();
    textField.setStretchWithOverflow(true);
    textField.setX(55);
    textField.setY(4);
    textField.setWidth(200);
    textField.setHeight(15);
    textField.setPositionType(PositionTypeEnum.FLOAT);
    textField.setStyle(normalStyle);
    expression = new JRDesignExpression();
    expression.setValueClass(java.lang.String.class);
    expression.setText("$F{FirstName} + \" \" + $F{LastName}");
    textField.setExpression(expression);
    band.addElement(textField);
    textField = new JRDesignTextField();
    textField.setStretchWithOverflow(true);
    textField.setX(260);
    textField.setY(4);
    textField.setWidth(255);
    textField.setHeight(15);
    textField.setPositionType(PositionTypeEnum.FLOAT);
    textField.setStyle(normalStyle);
    expression = new JRDesignExpression();
    expression.setValueClass(java.lang.String.class);
    expression.setText("$F{Street}");
    textField.setExpression(expression);
    band.addElement(textField);
    line = new JRDesignLine();
    line.setX(0);
    line.setY(19);
    line.setWidth(515);
View Full Code Here

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

      JRDesignExpression exp = new JRDesignExpression();
      exp.addVariableChunk("PAGE_NUMBER");
      exp.setValueClass(Integer.class);

      JRDesignTextField txt = new JRDesignTextField();
      txt.setExpression(exp);
      txt.setX(40);
      txt.setY(0);
      txt.setHeight(15);
      txt.setWidth(100);

      band.addElement(txt);

      jasperDesign.setPageFooter(band);
    }

    JRDesignBand emptyBand = new JRDesignBand();
    emptyBand.setHeight(0);
    jasperDesign.setPageHeader(emptyBand);
    jasperDesign.setColumnFooter(emptyBand);
    jasperDesign.setSummary(emptyBand);

    JRField[] fields = jasperDesign.getFields();

    // add column header and detail bands
    JRDesignBand bandDetail = new JRDesignBand();
    bandDetail.setHeight(20);

    JRDesignBand bandHeader = new JRDesignBand();
    bandHeader.setHeight(20);
   
    int fieldWidth = (jasperDesign.getPageWidth() - jasperDesign.getLeftMargin()
        - jasperDesign.getRightMargin() - (fields.length - 1) * jasperDesign.getColumnSpacing())
        / fields.length; 

    for (int i = 0; i < fields.length; i++)
    {
      try
      {
        JRField field = fields[i];

        JRDesignExpression exp = new JRDesignExpression();
        exp.addFieldChunk(field.getName());
       
        if (field.getValueClassName().equals("java.sql.Date"))
        {
          // JasperReports does not support java.sql.Date in text field expression
          exp.setValueClass(java.util.Date.class);
        }
        else
        {
          exp.setValueClass(field.getValueClass());
        }

        JRDesignTextField txt = new JRDesignTextField();
        txt.setExpression(exp);
        txt.setX(i * fieldWidth);
        txt.setY(0);
        txt.setHeight(20);
        txt.setWidth(fieldWidth);

        if (field.getValueClass().equals(Double.class))
        {
          txt.setPattern("0.00");
        }

        bandDetail.addElement(txt);

        JRDesignStaticText sText = new JRDesignStaticText();
View Full Code Here

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

    //titleBand.setSplitAllowed(true);
   
    for( DynamicColumn item: reportParam.getDynamicColumns() ){
      if( !item.isHidden() ){
        //add text field
        JRDesignTextField textField = new JRDesignTextField();
        textField.setX( item.getX() );
        textField.setY( item.getY() );
        textField.setWidth( item.getWidth() );
        textField.setHeight( item.getHeight() );
        //textField.setPositionType(JRElement.POSITION_TYPE_FLOAT); //
        textField.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_LEFT );
        //textField.setStyle( design.getDefaultStyle() );
       
        JRDesignExpression expression = new JRDesignExpression();
        expression.setValueClass( item.getClazz() );
        expression.setText( "$F{" + item.getField() +"}" );
        textField.setExpression(expression);
       
        textFieldBand.addElement( textField )
       
        //add column header
        JRDesignStaticText columnHeaderText = new JRDesignStaticText();     
View Full Code Here

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

    columnHeaderBand.setHeight( 20 ); //^~
   
    for( DynamicColumn item: reportParam.getDynamicColumns() ){
      if( !item.isHidden() ){
        //add text field
        JRDesignTextField textField = new JRDesignTextField();
        textField.setX( item.getX() );
        textField.setY( item.getY() );
        textField.setWidth( item.getWidth() );
        textField.setHeight( item.getHeight() );
        //textField.setPositionType(JRElement.POSITION_TYPE_FLOAT); //
        textField.setHorizontalAlignment( HorizontalAlignEnum.LEFT );
        //textField.setStyle( design.getDefaultStyle() );
       
        JRDesignExpression expression = new JRDesignExpression();
        expression.setValueClass( item.getClazz() );
        expression.setText( "$F{" + item.getField() +"}" );
        textField.setExpression(expression)
        textField.setBlankWhenNull( true );
       
        textFieldBand.addElement( textField )
       
        //add column header
        JRDesignStaticText columnHeaderText = new JRDesignStaticText();     
View Full Code Here

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

    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);
    title.setStretchType(JRGraphicElement.STRETCH_TYPE_NO_STRETCH);
    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);
      subtitle.setRemoveLineWhenBlank(true);
      applyStyleToElement(getReport().getSubtitleStyle(), subtitle);
      title.setStretchType(JRGraphicElement.STRETCH_TYPE_NO_STRETCH);
      band.addElement(subtitle);
    }
View Full Code Here

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

          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);
        }
      }
      layoutGroupVariables(columnsGroup, jgroup);
      layoutGroupSubreports(columnsGroup, jgroup);
View Full Code Here

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

   * @param columnsGroup
   * @param col
   * @return
   */
  protected JRDesignTextField createColumnNameTextField(DJGroup 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());

    Style headerStyle = columnsGroup.getColumnHeaderStyle(col);
    if (headerStyle == null)
      headerStyle = columnsGroup.getDefaultColumnHeaederStyle();
    if (headerStyle == null)
View Full Code Here

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

    //VALUE_IN_HEADER_WITH_HEADERS,
    //VALUE_IN_HEADER_AND_FOR_EACH,
    //VALUE_IN_HEADER_AND_FOR_EACH_WITH_HEADERS
    if (layout.isShowValueInHeader() && layout.isHideColumn() && !layout.isShowColumnName()){
      //textfield for the current value
      JRDesignTextField currentValue = generateTextFieldFromColumn(column, getReport().getOptions().getDetailHeight().intValue(), group);

      //The width will be all the page
      currentValue.setWidth(getReport().getOptions().getPrintableWidth());

      //fix the height depending on the font size
      currentValue.setHeight(FontHelper.getHeightFor(column.getStyle().getFont()));
      yOffset += currentValue.getHeight();

      //Move down existing elements in the band.
      LayoutUtils.moveBandsElemnts(yOffset-1, headerBand); //Don't know why, but without the "-1" it wont show the headers

      headerBand.addElement(currentValue);
    }
    //DEFAULT and DEFAULT_WITH_HEADER
    else if (layout.isShowValueInHeader() && !layout.isHideColumn() && !layout.isShowColumnName()){
      headerOffset = changeHeaderBandHeightForVariables(headerBand, group);
      insertValueInHeader(headerBand, group, headerOffset);
    }
    //VALUE_IN_HEADER_WITH_HEADERS_AND_COLUMN_NAME
    else if (layout.isShowValueInHeader() && layout.isHideColumn() && layout.isShowColumnName()){
      //Create the element for the column name
      JRDesignTextField columnNameTf = createColumnNameTextField(group, column);
      columnNameTf.setY(columnNameTf.getY() + headerOffset);

      //textfield for the current value
      JRDesignTextField currentValue = generateTextFieldFromColumn(column, getReport().getOptions().getDetailHeight().intValue(), group);

      //The width will be (width of the page) - (column name width)
      currentValue.setWidth(getReport().getOptions().getPrintableWidth() - columnNameTf.getWidth());
      //The x position for the current value is right next to the column name
      currentValue.setX(columnNameTf.getWidth());

      //fix the height depending on the font size
      currentValue.setHeight(FontHelper.getHeightFor(column.getStyle().getFont()));
      columnNameTf.setHeight(currentValue.getHeight());

      yOffset += currentValue.getHeight();

      //Move down existing elements in the band.
      LayoutUtils.moveBandsElemnts(yOffset, headerBand);

      headerBand.addElement(columnNameTf);
View Full Code Here

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

        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() != DJCalculation.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.getDefaulHeaderVariableStyle():columnsGroup.getDefaulFooterVariableStyle();

        if (var.getStyle() != null)
          applyStyleToElement(var.getStyle(), textField);
        else if (defStyle != null)
          applyStyleToElement(defStyle, textField);
        else {
          //Last resource is tu use the column style, but a copy of it because
          //the one in the internal cache can get modified by the layout manager (like in the odd row case)
          Style style = col.getStyle();
          try {
            style = (Style) BeanUtils.cloneBean(style);
            style.setName(null); //set to null to make applyStyleToElement(...) assign a name
          } catch (Exception e) {  }
          applyStyleToElement(style, textField);
        }


        band.addElement(textField);

      }

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

        DJGroupVariable 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);
//        globalTextField.setX(((AbstractColumn)getReport().getColumns().get(0)).getPosX().intValue());
        globalTextField.setX(0);
        if (type.equals(ColumnsGroupVariablesRegistrationManager.HEADER))
          globalTextField.setY(yOffset);
        globalTextField.setKey("global_legend_"+type);

        applyStyleToElement(globalCol.getStyle(), globalTextField);

        band.addElement(globalTextField);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.