Examples of JRDesignCellContents


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

  public static final String ATTRIBUTE_mode = "mode";
  public static final String ATTRIBUTE_style = "style";

  public Object createObject(Attributes attributes)
  {
    JRDesignCellContents cell = new JRDesignCellContents();
   
    String backcolor = attributes.getValue(ATTRIBUTE_backcolor);
    if (backcolor != null && backcolor.length() > 0)
    {
      cell.setBackcolor(JRColorUtil.getColor(backcolor, null));
    }
   
    ModeEnum mode = ModeEnum.getByName(attributes.getValue(ATTRIBUTE_mode));
    if (mode != null)
    {
      cell.setMode(mode);
    }
   
    String styleName = attributes.getValue(ATTRIBUTE_style);
    if (styleName != null)
    {
      JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2);
      Map stylesMap = jasperDesign.getStylesMap();

      if (stylesMap.containsKey(styleName))
      {
        JRStyle style = (JRStyle) stylesMap.get(styleName);
        cell.setStyle(style);
      }
      else
      {
        cell.setStyleNameReference(styleName);
      }
    }

    return cell;
  }
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

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

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

    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

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

        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

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