Package net.sf.jasperreports.engine.design

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


      }

      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

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

    for (Iterator iterator = footerSubreportsList.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(100);
      subreport.setPositionType(JRElement.POSITION_TYPE_FIX_RELATIVE_TO_TOP);
      subreport.setStretchType(JRElement.STRETCH_TYPE_NO_STRETCH);
      subreport.setRemoveLineWhenBlank(true);

      if (sr.getStyle() != null)
        applyStyleToElement(sr.getStyle(), subreport);

      //adding to the band
      if (sr.isStartInNewPage()) {
        JRDesignBreak pageBreak = new JRDesignBreak(new JRDesignStyle().getDefaultStyleProvider());
        band.addElement(pageBreak);
      }
      band.addElement(subreport);
    }
  }
View Full Code Here

    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

    initStyles();
    createTable();
  }
 
  private void initStyles() throws JRException{
    tableStyle = new JRDesignStyle();
    tableStyle.setName("Table");
    tableStyle.setDefault(false);
    tableStyle.setParentStyle(builder.getNormalStyle());
    JRLineBox box = tableStyle.getLineBox();
    box.getPen().setLineStyle(JRPen.LINE_STYLE_SOLID);
View Full Code Here

   * @throws net.sf.jasperreports.engine.JRException
   */
 
  @SuppressWarnings("unchecked")
  void initStyles() throws JRException{
    normalStyle = new JRDesignStyle();
    normalStyle.setName("Normal");
    normalStyle.setDefault(true);
    normalStyle.setForecolor(new Color(0, 0, 0));
    normalStyle.setBlankWhenNull(true);
    normalStyle.setFontSize(options.textSize);
    normalStyle.setMode(JRElement.MODE_TRANSPARENT);
    normalStyle.getLineBox().setPadding(options.padding);
        normalStyle.setPdfEmbedded(true);
        normalStyle.setPdfEncoding("Cp1251");
        normalStyle.setPdfFontName("/usr/share/fonts/truetype/freefont/lucon.ttf");
    targetDesting.addStyle(normalStyle);
    targetDesting.setDefaultStyle(normalStyle);
    headerStyle = new JRDesignStyle();
    headerStyle.setName("Header");
    headerStyle.setDefault(false);
    headerStyle.setParentStyle(normalStyle);
        headerStyle.setBold(true);
    headerStyle.setFontSize(options.textSize + 2);
View Full Code Here

    }   
  }
 
 
  public static void main(String[] args) {
    JRDesignStyle s1 = new Style().transform();
    JRDesignStyle s2 = new Style().transform();
   
    s1.setBold(Boolean.TRUE);
    s1.setItalic(Boolean.TRUE);
    s1.setUnderline(Boolean.TRUE);
   
    Utils.copyProperties(s2, s1);
   
    System.out.println(s2.isBold() + " - " + s2.isItalic() + " - " + s2.isUnderline());
   
   
  }
View Full Code Here

    return ret;
   
  }

  public JRDesignStyle transform() {
    JRDesignStyle transformedStyle = new JRDesignStyle();
    transformedStyle.setName(this.name);
    transformedStyle.setParentStyleNameReference(this.parentStyleName);
    setJRBaseStyleProperties(transformedStyle);
    return transformedStyle;
  }
View Full Code Here

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

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

        if (column.getLink() != null) {
          String name = "column_" + getReport().getColumns().indexOf(column);
          HyperLinkUtil.applyHyperLinkToElement((DynamicJasperDesign) getDesign(), column.getLink(),image,name);
        }       
       
        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

TOP

Related Classes of net.sf.jasperreports.engine.design.JRDesignStyle

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.