Package net.sf.jasperreports.crosstabs.design

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

      if (crosstabColumn.getHeaderStyle() != null)
        layoutManager.applyStyleToElement(crosstabColumn.getHeaderStyle(),colTitle);


      colHeaerContent.addElement(colTitle);
      colHeaerContent.setBackcolor(colors[i][rows.length-1]);
      colHeaerContent.setMode(new Byte(Transparency.OPAQUE.getValue()));
      applyCellBorder(colHeaerContent);

      ctColGroup.setHeader(colHeaerContent);

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


    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

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

      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

    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

        if (crosstabRow.getProperty() != null)
          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);
          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);
          }
         
          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

      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

      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

    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

      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

TOP

Related Classes of net.sf.jasperreports.crosstabs.design.JRDesignCellContents

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.