Examples of JRDesignCellContents


Examples of net.sf.jasperreports.crosstabs.design.JRDesignCellContents

      cellContent.setBox(box);
    }
  }

  private void createColumTotalHeader(JRDesignCrosstabColumnGroup ctColGroup, DJCrosstabColumn crosstabColumn) {
    JRDesignCellContents totalHeaderContent = new JRDesignCellContents();
    ctColGroup.setTotalHeader(totalHeaderContent);
    ctColGroup.setTotalPosition(BucketDefinition.TOTAL_POSITION_END);

    totalHeaderContent.setBackcolor(colors[colors.length/2][colors[0].length/2]);
    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 (crosstabColumn.getTotalHeaderStyle() != null)
      layoutManager.applyStyleToElement(crosstabColumn.getTotalHeaderStyle(), element);

    //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

Examples of net.sf.jasperreports.crosstabs.design.JRDesignCellContents

    jrcross.setColumnBreakOffset(djcross.getColumnBreakOffset());

  }

  private void createMainHeaderCell() {
    JRDesignCellContents contents = new JRDesignCellContents();

    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);
    contents.addElement(element);
  }
View Full Code Here

Examples of net.sf.jasperreports.crosstabs.design.JRDesignCellContents

          cell.setColumnTotalGroup(crosstabColumn.getProperty().getProperty());

        if (isRowTotal)
          cell.setRowTotalGroup(crosstabRow.getProperty().getProperty());

        JRDesignCellContents contents = new JRDesignCellContents();

        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);
         
          boolean isTotalCell = isRowTotal || isColumnTotal;
         
          if (!isTotalCell){
            if (djmeasure.getValueFormatter()== null){
              measureExp.setValueClassName(djmeasure.getProperty().getValueClassName());
              measureExp.setText("$V{"+djmeasure.getProperty().getProperty()+"}");
            } else {
              measureExp.setText(djmeasure.getTextForValueFormatterExpression(djmeasure.getProperty().getProperty()));
              measureExp.setValueClassName(djmeasure.getValueFormatter().getClassName());
            }
          } else { //is a total cell
            if (djmeasure.getValueFormatter()== null){
              if (djmeasure.getPrecalculatedTotalProvider() == null) {
                measureExp.setValueClassName(djmeasure.getProperty().getValueClassName());
                measureExp.setText("$V{"+djmeasure.getProperty().getProperty()+"}");
              } else {
                //call the precalculated value AND the value formatter
                setExpressionForPrecalculatedTotalValue(auxCols, auxRows, measureExp, djmeasure, crosstabColumn, crosstabRow);
              }
            } else { //have value formatter
              if (djmeasure.getPrecalculatedTotalProvider() == null) {
                //no vlue formatter, no total provider
                measureExp.setValueClassName(djmeasure.getProperty().getValueClassName());
                measureExp.setText("$V{"+djmeasure.getProperty().getProperty()+"}");
              } else {
                //no vlue formatter, call the precalculated value only
//                measureExp.setValueClass(String.class);
//                measureExp.setText("\"VF, prec\"");
                setExpressionForPrecalculatedTotalValue(auxCols, auxRows, measureExp, djmeasure, crosstabColumn, crosstabRow);
              }
            }
          }
         
//          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 ){
            //this is the inner most cell
            layoutManager.applyStyleToElement(djmeasure.getStyle() , element);
          } else if (crosstabRow.getTotalStyle() != null) {
            layoutManager.applyStyleToElement(crosstabRow.getTotalStyle(), element);
          }
          else if (crosstabColumn.getTotalStyle() != null) {
            layoutManager.applyStyleToElement(crosstabColumn.getTotalStyle(), element);
          }*/
         
          //measure
          if (!isRowTotal && !isColumnTotal && djmeasure.getStyle() != null ){
            //this is the inner most cell
            layoutManager.applyStyleToElement(djmeasure.getStyle() , element);
          }
          //row total only
          if (isRowTotal && !isColumnTotal) {
            Style style = getRowTotalStyle(crosstabRow);
            if (style == null)
              style = djmeasure.getStyle();
            if (style != null)
              layoutManager.applyStyleToElement(style, element);
          }
          //column total only
          if (isColumnTotal && !isRowTotal) {
            Style style = getColumnTotalStyle(crosstabColumn);
            if (style == null)
              style = djmeasure.getStyle();
            if (style != null)
              layoutManager.applyStyleToElement(style, element);
          }
          //row and column total
          if (isRowTotal && isColumnTotal) {
            Style style = getRowTotalStyle(crosstabRow);
            if (style == null)
              style = getColumnTotalStyle(crosstabColumn);
            if (style == null)
              style = djmeasure.getStyle();
            if (style != null)
              layoutManager.applyStyleToElement(style, element);
          }
         
          JRDesignStyle jrstyle = (JRDesignStyle) element.getStyle();
          //FIXME this is a hack
          if (jrstyle == null){
            if (log.isDebugEnabled()){
              log.warn("jrstyle is null in crosstab cell, this should have not happened.");
            }
            layoutManager.applyStyleToElement(null, element);
            jrstyle = (JRDesignStyle)element.getStyle();
            jrstyle.setBlankWhenNull(true);
          }
         
          JRDesignStyle alternateStyle = Utils.cloneStyle(jrstyle);
          alternateStyle.setName(alternateStyle.getFontName() +"_for_column_" + djmeasure.getProperty());
          alternateStyle.getConditionalStyleList().clear();
          element.setStyle(alternateStyle);
          try {
            design.addStyle(alternateStyle);
          } catch (JRException e) { /**e.printStackTrace(); //Already there, nothing to do **/}
          setUpConditionStyles(alternateStyle, djmeasure, measureExp.getText());
         
          if (djmeasure.getLink() != null){
            String name = "cell_" + i + "_" +  j + "_ope" + djmeasure.getOperation().getValue();
            HyperLinkUtil.applyHyperLinkToElement((DynamicJasperDesign)this.design, djmeasure.getLink(), element, name);
          }
 
          contents.addElement(element);
         
        }
       
        contents.setMode(new Byte(Transparency.OPAQUE.getValue()));
       
        applyBackgroundColor(contents,crosstabRow,crosstabColumn,i,j);
       
        applyCellBorder(contents);

View Full Code Here

Examples of net.sf.jasperreports.crosstabs.design.JRDesignCellContents

      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);
        rowHeaderContents.setBackcolor(headerstyle.getBackgroundColor());
      }

      rowHeaderContents.addElement(rowTitle);
      rowHeaderContents.setMode(new Byte(Transparency.OPAQUE.getValue()));
      applyCellBorder(rowHeaderContents);

      ctRowGroup.setHeader(rowHeaderContents );

      if (crosstabRow.isShowTotals())
View Full Code Here

Examples of net.sf.jasperreports.crosstabs.design.JRDesignCellContents

      JRDesignExpression bucketExp = ExpressionUtils.createExpression("$F{"+crosstabColumn.getProperty().getProperty()+"}", crosstabColumn.getProperty().getValueClassName());
      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);
        colHeaerContent.setBackcolor(headerstyle.getBackgroundColor());
      }


      colHeaerContent.addElement(colTitle);
      colHeaerContent.setMode(new Byte(Transparency.OPAQUE.getValue()));
      applyCellBorder(colHeaerContent);

      ctColGroup.setHeader(colHeaerContent);

      if (crosstabColumn.isShowTotals())
View Full Code Here

Examples of net.sf.jasperreports.crosstabs.design.JRDesignCellContents

    return auxWidth;
  }


  private void createRowTotalHeader(JRDesignCrosstabRowGroup ctRowGroup, DJCrosstabRow crosstabRow) {
    JRDesignCellContents totalHeaderContent = new JRDesignCellContents();
    ctRowGroup.setTotalHeader(totalHeaderContent);
    ctRowGroup.setTotalPosition(BucketDefinition.TOTAL_POSITION_END); //FIXME the total can be at the end of a group or at the beginin
   

    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

Examples of net.sf.jasperreports.crosstabs.design.JRDesignCellContents

      cellContent.setBox(box);
    }
  }

  private void createColumTotalHeader(JRDesignCrosstabColumnGroup ctColGroup, DJCrosstabColumn crosstabColumn) {
    JRDesignCellContents totalHeaderContent = new JRDesignCellContents();
    ctColGroup.setTotalHeader(totalHeaderContent);
    ctColGroup.setTotalPosition(BucketDefinition.TOTAL_POSITION_END);

    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

Examples of net.sf.jasperreports.crosstabs.design.JRDesignCellContents

    jrcross.setColumnBreakOffset(djcross.getColumnBreakOffset());

  }

  private void createMainHeaderCell() {
    JRDesignCellContents contents = new JRDesignCellContents();

    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);
    contents.addElement(element);
  }
View Full Code Here

Examples of net.sf.jasperreports.crosstabs.design.JRDesignCellContents

        if (crosstabRow.getProperty() != null)
          cell.setRowTotalGroup(crosstabRow.getProperty().getProperty());


        JRDesignCellContents contents = new JRDesignCellContents();

        JRDesignTextField element = new JRDesignTextField();
        element.setWidth(crosstabColumn.getWidth());
        element.setHeight(crosstabRow.getHeight());

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

        element.setExpression(measureExp);

        /**
         * Is there any style for this object?
         */
        if (crosstabRow.getProperty() == null && crosstabColumn.getProperty() == null && measure.getStyle() != null ){
          //this is the inner most cell
          layoutManager.applyStyleToElement(measure.getStyle() , element);
        } else if (crosstabRow.getTotalStyle() != null) {
          layoutManager.applyStyleToElement(crosstabRow.getTotalStyle(), element);
        }
        else if (crosstabColumn.getTotalStyle() != null) {
          layoutManager.applyStyleToElement(crosstabColumn.getTotalStyle(), element);
        }

//        if ((i == auxCols.length-1 &&  j != auxRows.length-1) || (i != auxCols.length-1 &&  j != auxRows.length-1)){
//          cell.setWidth(Integer.valueOf( 100));
//        }
//        if (crosstabColumn.getProperty() != null && j != auxRows.length-1 && crosstabRow.getTotalHeaderHeight() != 0){
//          cell.setWidth(Integer.valueOf( crosstabRow.getTotalHeaderHeight() ));
//        }
//        if (i != auxCols.length-1 && j != auxRows.length-1 && crosstabRow.getTotalHeaderHeight() != 0){
//          cell.setWidth(Integer.valueOf( crosstabRow.getTotalHeaderHeight() ));
//        }


        contents.setMode(new Byte(Transparency.OPAQUE.getValue()));
        contents.setBackcolor(colors[i][j]);
        contents.addElement(element);

        applyCellBorder(contents);

        cell.setContents(contents);

View Full Code Here

Examples of net.sf.jasperreports.crosstabs.design.JRDesignCellContents

      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 sho total and 2nd doesnt
      rowTitle.setHeight(auxHeight);


      if (crosstabRow.getHeaderStyle() != null)
        layoutManager.applyStyleToElement(crosstabRow.getHeaderStyle(), rowTitle);

      rowHeaderContents.addElement(rowTitle);
      rowHeaderContents.setBackcolor(colors[cols.length-1][i]);
//      rowHeaderContents.setBackcolor(colors[0][0]);
//      rowHeaderContents.setBackcolor(Color.blue);
      rowHeaderContents.setMode(new Byte(Transparency.OPAQUE.getValue()));
      applyCellBorder(rowHeaderContents);

      ctRowGroup.setHeader(rowHeaderContents );

      if (crosstabRow.isShowTotals())
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.