Examples of JRDesignStyle


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

      }

      for (Iterator iter = imageBanners.iterator(); iter.hasNext();) {
        ImageBanner imageBanner = (ImageBanner) iter.next();
        String path = "\"" + imageBanner.getImagePath().replaceAll("\\\\", "/") + "\"";
        JRDesignImage image = new JRDesignImage(new JRDesignStyle().getDefaultStyleProvider());
        JRDesignExpression imageExp = new JRDesignExpression();
        imageExp.setText(path);

        imageExp.setValueClass(String.class);
        image.setExpression(imageExp);
View Full Code Here

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

        ? columnsGroup.getFooterSubreports()
        : columnsGroup.getHeaderSubreports();

    for (Iterator iterator = subreportsList.iterator(); iterator.hasNext();) {
      Subreport sr = (Subreport) iterator.next();
      JRDesignSubreport subreport = new JRDesignSubreport(new JRDesignStyle().getDefaultStyleProvider());

      //The data source
      int dataSourceOrigin = sr.getDatasource().getDataSourceOrigin();
      if (DJConstants.DATA_SOURCE_ORIGIN_USE_REPORT_CONNECTION == dataSourceOrigin){
        JRDesignExpression connectionExpression = ExpressionUtils.getReportConnectionExpression();
        subreport.setConnectionExpression(connectionExpression);
      } else if (DJConstants.DATA_SOURCE_TYPE_SQL_CONNECTION == sr.getDatasource().getDataSourceType()) {
        JRDesignExpression connectionExpression = ExpressionUtils.getConnectionExpression(sr.getDatasource());
        subreport.setConnectionExpression(connectionExpression);
      } else {
        JRDesignExpression dataSourceExpression = ExpressionUtils.getDataSourceExpression(sr.getDatasource());
        subreport.setDataSourceExpression(dataSourceExpression);
      }

//      int random_ = subReportRandom.nextInt();
      //the subreport design
      String paramname = sr.getReport().toString(); //TODO ensure this name is unique among all possible subreports
      ((DynamicJasperDesign)getDesign()).getParametersWithValues().put(paramname, sr.getReport());
      String expText = "("+JasperReport.class.getName()+")$P{REPORT_PARAMETERS_MAP}.get( \""+ paramname +"\" )";
      JRDesignExpression srExpression = ExpressionUtils.createExpression(expText, JasperReport.class);
      subreport.setExpression(srExpression );


      //set the parameters
      subreport.setParametersMapExpression(ExpressionUtils.getParameterExpression(sr));
      for (Iterator subreportParamsIter = sr.getParameters().iterator(); subreportParamsIter.hasNext();) {
        SubreportParameter srparam = (SubreportParameter) subreportParamsIter.next();
        JRDesignSubreportParameter subreportParameter = new JRDesignSubreportParameter();
        subreportParameter.setName(srparam.getName());
        JRExpression expression2 = ExpressionUtils.createExpression(srparam);
        subreportParameter.setExpression(expression2);
        try {
          subreport.addParameter(subreportParameter );
        } catch (JRException e) {
          log.error("Error registering parameter for subreport, there must be another parameter with the same name");
          throw new CoreException(e.getMessage(),e);
        }
      }

      //some other options (cosmetic)
      //subreport.setStretchType(JRDesignElement.STRETCH_TYPE_NO_STRETCH);
      int offset = LayoutUtils.findVerticalOffset(band);
      subreport.setY(offset);
      subreport.setX(-getReport().getOptions().getLeftMargin().intValue());
      subreport.setWidth(getReport().getOptions().getPage().getWidth());
      subreport.setHeight(SUBREPORT_DEFAULT_HEIGHT);
      subreport.setPositionType(JRElement.POSITION_TYPE_FLOAT);
      subreport.setStretchType(JRElement.STRETCH_TYPE_NO_STRETCH);
      subreport.setRemoveLineWhenBlank(true); //No subreport, no reserved space

      band.setHeight(offset + subreport.getHeight());
     
      if (sr.getStyle() != null)
        applyStyleToElement(sr.getStyle(), subreport);

      //adding to the band
      if (sr.isStartInNewPage()) {
        JRDesignGroup jrgroup = getJRGroupFromDJGroup(columnsGroup);
        JRDesignBand targetBand = null;
        int idx = getDesign().getGroupsList().indexOf(jrgroup);
        if (DJConstants.HEADER.equals(position)) {
//          if (idx == 0){
//            if (getDesign().getColumnHeader() != null)
//              targetBand = (JRDesignBand) getDesign().getColumnHeader();
//            else if (getDesign().getPageHeader() != null)
//              targetBand = (JRDesignBand) getDesign().getPageHeader();
//            else
//              targetBand = band;
//          }
//          else
//            targetBand = (JRDesignBand) ((JRDesignGroup) getDesign().getGroupsList().get(idx-1)).getGroupHeader();
        }
        else { //footer subreport (and concatenated report)
          if (idx+1 <  getDesign().getGroupsList().size())
            idx++;
          targetBand = (JRDesignBand) ((JRDesignGroup) getDesign().getGroupsList().get(idx)).getGroupFooter();
        }

        /**
         * There is no meaning in adding a page-break in header sub reports since
         * they will be placed right after the group header
         */
        if (DJConstants.FOOTER.equals(position)){
          JRDesignBreak pageBreak = new JRDesignBreak(new JRDesignStyle().getDefaultStyleProvider());
          pageBreak.setKey(PAGE_BREAK_FOR_ + jrgroup.toString()); //set up a name to recognize the item later
          pageBreak.setY(0);
          targetBand.addElement(pageBreak);
        }

View Full Code Here

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

  /**
   * @param baseStyle
   * @throws JRException
   */
  public void addStyleToDesign(Style style)  {
    JRDesignStyle jrstyle = style.transform();
    try {
      if (jrstyle.getName() == null) {
        String name = createUniqueStyleName();
        jrstyle.setName(name);
        style.setName(name);
        getReportStyles().put(name, jrstyle);
        design.addStyle(jrstyle);
      }

      JRStyle old = (JRStyle) design.getStylesMap().get(jrstyle.getName());
      if (old != null && style.isOverridesExistingStyle()){
        log.debug("Overriding style with name \""+ style.getName() +"\"");

        design.removeStyle(style.getName());
        design.addStyle(jrstyle);
View Full Code Here

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

      /**
       * Barcode column
       */
      if (column instanceof BarCodeColumn) {
        BarCodeColumn barcodeColumn = (BarCodeColumn)column;
        JRDesignImage image = new JRDesignImage(new JRDesignStyle().getDefaultStyleProvider());
        JRDesignExpression imageExp = new JRDesignExpression();
//        imageExp.setText("ar.com.fdvs.dj.core.BarcodeHelper.getBarcodeImage("+barcodeColumn.getBarcodeType() + ", "+ column.getTextForExpression()+ ", "+ barcodeColumn.isShowText() + ", " + barcodeColumn.isCheckSum() + ", " + barcodeColumn.getApplicationIdentifier() + ","+ column.getWidth() +", "+ report.getOptions().getDetailHeight().intValue() + " )" );

        //Do not pass column height and width mecause barbecue
        //generates the image with wierd dimensions. Pass 0 in both cases
        String applicationIdentifier = barcodeColumn.getApplicationIdentifier();
        if (applicationIdentifier != null && !"".equals(applicationIdentifier.trim()) ){
          applicationIdentifier = "$F{" + applicationIdentifier + "}";
        } else {
          applicationIdentifier = "\"\"";
        }
        imageExp.setText("ar.com.fdvs.dj.core.BarcodeHelper.getBarcodeImage("+barcodeColumn.getBarcodeType() + ", "+ column.getTextForExpression()+ ", "+ barcodeColumn.isShowText() + ", " + barcodeColumn.isCheckSum() + ", " + applicationIdentifier + ",0,0 )" );


        imageExp.setValueClass(java.awt.Image.class);
        image.setExpression(imageExp);
        image.setHeight(getReport().getOptions().getDetailHeight().intValue());
        image.setWidth(column.getWidth().intValue());
        image.setX(column.getPosX().intValue());
        image.setScaleImage(barcodeColumn.getScaleMode().getValue());

        image.setOnErrorType(JRDesignImage.ON_ERROR_TYPE_ICON); //FIXME should we provide control of this to the user?

        applyStyleToElement(column.getStyle(), image);

        detail.addElement(image);
      }
      /**
       * Image columns
       */
      else if (column instanceof ImageColumn) {
        ImageColumn imageColumn = (ImageColumn)column;
        JRDesignImage image = new JRDesignImage(new JRDesignStyle().getDefaultStyleProvider());
        JRDesignExpression imageExp = new JRDesignExpression();
        imageExp.setText(column.getTextForExpression());

        imageExp.setValueClassName(imageColumn.getColumnProperty().getValueClassName());
        image.setExpression(imageExp);
View Full Code Here

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

   * @param designElemen
   */
  public void applyStyleToElement(Style style, JRDesignElement designElemen) {
    if (style == null){
//      log.warn("NULL style passed to object");
      JRDesignStyle style_ = new JRDesignStyle();
      style_.setName( createUniqueStyleName());
      designElemen.setStyle(style_);
      try {
        getDesign().addStyle(style_);
      } catch (JRException e) {
        //duplicated style, its ok
      }
//      return null;
      return;
    }
    boolean existsInDesign = style.getName() != null
                && design.getStylesMap().get(style.getName()) != null;
            //    && !style.isOverridesExistingStyle();

    JRDesignStyle jrstyle = null;
    if (existsInDesign && !style.isOverridesExistingStyle()){
      jrstyle = (JRDesignStyle) design.getStylesMap().get(style.getName());
    } else {
      addStyleToDesign(style); //Order maters. This line fist
      jrstyle = style.transform();
View Full Code Here

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

        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 dont 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 = new JRDesignStyle();
            try {
              if (jrstyle != null)
                BeanUtils.copyProperties(groupStyle, jrstyle);
      } catch (Exception e) {
        throw new DJException("Could not copy properties for shared group style: " + e.getMessage(),e);
      }

      groupStyle.setName(groupStyle.getFontName() +"_for_group_"+index);
      textField.setStyle(groupStyle);
      try {
        design.addStyle(groupStyle);
      } catch (JRException e) { /**e.printStackTrace(); //Already there, nothing to do **/}

 
View Full Code Here

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

    this.verticalAlign = verticalAlign;
  }

  public JRDesignStyle transform() {

    JRDesignStyle transformedStyle = new JRDesignStyle();
    if (getBorder()!=null)
      transformedStyle.setBorder(getBorder().getValue());

    transformedStyle.setName(this.name);
    transformedStyle.setParentStyleNameReference(this.parentStyleName);

    //Borders
    if (getBorderBottom()!= null)
      transformedStyle.setBottomBorder(getBorderBottom().getValue());
    if (getBorderTop()!= null)
      transformedStyle.setTopBorder(getBorderTop().getValue());
    if (getBorderLeft()!= null)
      transformedStyle.setLeftBorder(getBorderLeft().getValue());
    if (getBorderRight()!= null)
      transformedStyle.setRightBorder(getBorderRight().getValue());

    transformedStyle.setPadding(getPadding());

    if (paddingBotton != null)
      transformedStyle.setBottomPadding(paddingBotton);
    if (paddingTop != null)
      transformedStyle.setTopPadding(paddingTop);
    if (paddingLeft != null)
      transformedStyle.setLeftPadding(paddingLeft);
    if (paddingRight != null)
      transformedStyle.setRightPadding(paddingRight);

    if (getHorizontalAlign() != null)
      transformedStyle.setHorizontalAlignment(getHorizontalAlign().getValue());

    if (getVerticalAlign() != null)
      transformedStyle.setVerticalAlignment(getVerticalAlign().getValue());

    transformedStyle.setBlankWhenNull(blankWhenNull);

    if (font != null) {
      transformedStyle.setFontName(font.getFontName());
      transformedStyle.setFontSize(font.getFontSize());
      transformedStyle.setBold(font.isBold());
      transformedStyle.setItalic(font.isItalic());
      transformedStyle.setUnderline(font.isUnderline());
      transformedStyle.setPdfFontName(font.getPdfFontName());
      transformedStyle.setPdfEmbedded(font.isPdfFontEmbedded());
      transformedStyle.setPdfEncoding(font.getPdfFontEncoding());
    }

    transformedStyle.setBackcolor(getBackgroundColor());
    transformedStyle.setForecolor(getTextColor());
    transformedStyle.setBorderColor(borderColor);
    if (getTransparency() != null)
      transformedStyle.setMode(getTransparency().getValue());

    if (getRotation() != null)
      transformedStyle.setRotation(getRotation().getValue());

    if (getRadius() != null)
      transformedStyle.setRadius(getRadius().intValue());

    transformedStyle.setPattern(this.pattern);

    /**
     * This values are needed when exporting to JRXML
     */
    transformedStyle.setPen((byte)0);
    transformedStyle.setFill((byte)1);
    transformedStyle.setScaleImage(ImageScaleMode.NO_RESIZE.getValue());
   
   

    return transformedStyle;
  }
View Full Code Here

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

   * @return
   */
  protected JRDesignChart createChart(DJChart djChart){
      JRDesignGroup jrGroupChart = getJRGroupFromDJGroup(djChart.getColumnsGroup());

      JRDesignChart chart = new JRDesignChart(new JRDesignStyle().getDefaultStyleProvider(), djChart.getType());
      JRDesignGroup parentGroup = getParent(jrGroupChart);
      List chartVariables = registerChartVariable(djChart);
      JRDesignChartDataset chartDataset = DataSetFactory.getDataset(djChart, jrGroupChart, parentGroup, chartVariables);
      chart.setDataset(chartDataset);
      interpeterOptions(djChart, chart);
View Full Code Here

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

        jasperPrint.setOrientation(JasperReport.ORIENTATION_PORTRAIT);
        jasperPrint.setPageWidth(convert(210));
        jasperPrint.setPageHeight(convert(297));
       
        //Fonts
        titleStyle = new JRDesignStyle();
        titleStyle.setName("Arial_Title");
        titleStyle.setDefault(true);
        titleStyle.setFontName("Arial");
        titleStyle.setFontSize(14);
        titleStyle.setBold(true);
        titleStyle.setPdfFontName("Helvetica");
        titleStyle.setPdfEncoding("Cp1252");
        titleStyle.setPdfEmbedded(false);
        jasperPrint.addStyle(titleStyle);
       
        JRDesignStyle normalStyle = new JRDesignStyle();
        normalStyle.setName("Arial_Normal");
        normalStyle.setDefault(true);
        normalStyle.setFontName("Arial");
        normalStyle.setFontSize(10);
        normalStyle.setPdfFontName("Helvetica");
        normalStyle.setPdfEncoding("Cp1252");
        normalStyle.setPdfEmbedded(false);
        jasperPrint.addStyle(normalStyle);
       
        JRDesignStyle boldStyle = new JRDesignStyle();
        boldStyle.setName("Arial_Bold");
        boldStyle.setDefault(true);
        boldStyle.setFontName("Arial");
        boldStyle.setFontSize(12);
        boldStyle.setBold(true);
        boldStyle.setPdfFontName("Helvetica");
        boldStyle.setPdfEncoding("Cp1252");
        boldStyle.setPdfEmbedded(false);
        jasperPrint.addStyle(boldStyle);
       
        JRDesignStyle studentNameStyle = new JRDesignStyle();
        studentNameStyle.setName("Arial_Footer");
        studentNameStyle.setDefault(true);
        studentNameStyle.setFontName("Arial");
        studentNameStyle.setFontSize(8);
        studentNameStyle.setPdfFontName("Helvetica");
        studentNameStyle.setPdfEncoding("Cp1252");
        studentNameStyle.setPdfEmbedded(false);
        jasperPrint.addStyle(studentNameStyle);

       
        try {
            int numberTotalComputers = 0;
View Full Code Here

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

        jasperPrint.setName("Relat�rio de Matr�cula");
        jasperPrint.setPageWidth(convert(210));
        jasperPrint.setPageHeight(convert(297));
       
        //Fonts
        titleStyle = new JRDesignStyle();
        titleStyle.setName("Arial_Title");
        titleStyle.setDefault(true);
        titleStyle.setBold(true);
        titleStyle.setFontName("Arial");
        titleStyle.setFontSize(18);
        titleStyle.setPdfFontName("Helvetica");
        titleStyle.setPdfEncoding("Cp1252");
        titleStyle.setPdfEmbedded(false);
        jasperPrint.addStyle(titleStyle);
       
        bodyStyle = new JRDesignStyle();
        bodyStyle.setName("Arial_Normal");
        bodyStyle.setDefault(true);
        bodyStyle.setFontName("Arial");
        bodyStyle.setFontSize(9);
        bodyStyle.setPdfFontName("Helvetica");
        bodyStyle.setPdfEncoding("Cp1252");
        bodyStyle.setPdfEmbedded(false);
        jasperPrint.addStyle(bodyStyle);
       
        JRDesignStyle footerStyle = new JRDesignStyle();
        footerStyle.setName("Arial_Footer");
        footerStyle.setDefault(true);
        footerStyle.setFontName("Arial");
        footerStyle.setFontSize(10);
        footerStyle.setForecolor(new Color(1, 51, 52));
        footerStyle.setPdfFontName("Helvetica");
        footerStyle.setPdfEncoding("Cp1252");
        footerStyle.setPdfEmbedded(false);
        jasperPrint.addStyle(footerStyle);
       
        boldStyle = new JRDesignStyle();
        boldStyle.setName("Arial_Bold");
        boldStyle.setDefault(true);
        boldStyle.setFontName("Arial");
        boldStyle.setFontSize(12);
        boldStyle.setBold(true);
        boldStyle.setPdfFontName("Helvetica");
        boldStyle.setPdfEncoding("Cp1252");
        boldStyle.setPdfEmbedded(false);
        jasperPrint.addStyle(boldStyle);
       
        boldStyle_10 = new JRDesignStyle();
        boldStyle_10.setName("Arial_Bold_10");
        boldStyle_10.setDefault(true);
        boldStyle_10.setFontName("Arial_10");
        boldStyle_10.setFontSize(10);
        boldStyle_10.setBold(true);
        boldStyle_10.setPdfFontName("Helvetica");
        boldStyle_10.setPdfEncoding("Cp1252");
        boldStyle_10.setPdfEmbedded(false);
        jasperPrint.addStyle(boldStyle_10);
       
        boldStyle_8 = new JRDesignStyle();
        boldStyle_8.setName("Arial_Bold_8");
        boldStyle_8.setDefault(true);
        boldStyle_8.setFontName("Arial_8");
        boldStyle_8.setFontSize(10);
        boldStyle_8.setBold(true);
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.