Package net.sf.jasperreports.engine.design

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


        ? 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
      subreport.setDataSourceExpression(ExpressionUtils.getDataSourceExpression(sr.getDatasource()));

//      int random_ = subReportRandom.nextInt();
View Full Code Here


  /**
   * @param baseStyle
   * @throws JRException
   */
  public void addStyleToDesign(Style style)  {
    JRDesignStyle jrstyle = style.transform();
    try {
      if (jrstyle.getName() == null) {
        String name = "dj_style_" + (getReportStyles().values().size() + 1);
        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.info("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?

        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

    rectangle.setStretchType(JRDesignRectangle.STRETCH_TYPE_RELATIVE_TO_TALLEST_OBJECT);
    Style oddRowBackgroundStyle = options.getOddRowBackgroundStyle();

    addStyleToDesign(oddRowBackgroundStyle);//register this style in the jasperDesign

    JRDesignStyle style = oddRowBackgroundStyle.transform();
    style.setForecolor(oddRowBackgroundStyle.getBackgroundColor());

    applyStyleToElement(oddRowBackgroundStyle, rectangle);
//    rectangle.setStyle(style);
    rectangle.setBackcolor(oddRowBackgroundStyle.getBackgroundColor());
    rectangle.setForecolor(oddRowBackgroundStyle.getBorderColor());
View Full Code Here

  private JRDesignChart createChart(DJChart djChart){

      JRDesignGroup jrGroup = getGroupFromColumnsGroup(djChart.getColumnsGroup());

      JRDesignChart chart = new JRDesignChart(new JRDesignStyle().getDefaultStyleProvider(), djChart.getType());
      chart.setDataset(DataSetFactory.getDataset(djChart.getType(), jrGroup, getParent(jrGroup), registerChartVariable(djChart)));
      interpeterOptions(djChart, chart);
     
      chart.setEvaluationTime(JRExpression.EVALUATION_TIME_GROUP);
      chart.setEvaluationGroup(jrGroup);
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

   * @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;
    //Let's allways add a new JR style
      if (existsInDesign && !style.isOverridesExistingStyle()){
      jrstyle = (JRDesignStyle) design.getStylesMap().get(style.getName());
    } else {
      addStyleToDesign(style); //Order maters. This line fist
View Full Code Here

        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 don't 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 = Utils.cloneStyle(jrstyle);

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

        } else {
         
          JRDesignStyle alternateStyle = Utils.cloneStyle(jrstyle);

      alternateStyle.setName(alternateStyle.getFontName() +"_for_column_"+col.getName());
      alternateStyle.getConditionalStyleList().clear();
      textField.setStyle(alternateStyle);
      try {
        design.addStyle(alternateStyle);
      } catch (JRException e) { /**e.printStackTrace(); //Already there, nothing to do **/}
         
View Full Code Here

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

    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 (paddingBottom != null)
      transformedStyle.setBottomPadding(paddingBottom);
    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

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.