Search in sources :

Example 1 with ImageBanner

use of ar.com.fdvs.dj.domain.ImageBanner in project DynamicJasper by intive-FDV.

the class ClassicLayoutManager method applyImageBannersToBand.

/**
 * Create the image elements for the banners tha goes into the
 * title band
 * @param printWhenExpression
 */
protected void applyImageBannersToBand(JRDesignBand band, Collection imageBanners, JRDesignExpression printWhenExpression, boolean placeOnTop) {
    int maxHeight = 0;
    if (placeOnTop) {
        for (Object imageBanner1 : imageBanners) {
            ImageBanner imageBanner = (ImageBanner) imageBanner1;
            if (imageBanner.getHeight() > maxHeight)
                maxHeight = imageBanner.getHeight();
        }
    } else {
        maxHeight = LayoutUtils.findVerticalOffset(band);
    }
    if (band != null) {
        // move everything down
        if (placeOnTop) {
            for (JRChild jrChild : band.getChildren()) {
                JRDesignElement element = (JRDesignElement) jrChild;
                element.setY(element.getY() + maxHeight);
            }
        }
        int yPosition = 0;
        if (!placeOnTop)
            yPosition = maxHeight + 1;
        for (Object imageBanner1 : imageBanners) {
            ImageBanner imageBanner = (ImageBanner) imageBanner1;
            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);
            image.setHeight(imageBanner.getHeight());
            image.setWidth(imageBanner.getWidth());
            image.setPrintWhenExpression(printWhenExpression);
            image.setRemoveLineWhenBlank(true);
            image.setScaleImage(ScaleImageEnum.getByValue(imageBanner.getScaleMode().getValue()));
            if (imageBanner.getAlign() == ImageBanner.Alignment.Left)
                image.setX(0);
            else if (imageBanner.getAlign() == ImageBanner.Alignment.Right)
                image.setX(getReport().getOptions().getPage().getWidth() - getReport().getOptions().getLeftMargin() - getReport().getOptions().getRightMargin() - imageBanner.getWidth());
            else if (imageBanner.getAlign() == ImageBanner.Alignment.Center) {
                int x = (getReport().getOptions().getPage().getWidth() - getReport().getOptions().getRightMargin() - getReport().getOptions().getLeftMargin() - imageBanner.getWidth()) / 2;
                image.setX(getReport().getOptions().getLeftMargin() + x);
            }
            image.setY(yPosition);
            band.addElement(image);
        }
        band.setHeight(band.getHeight() + maxHeight);
    }
}
Also used : JRDesignExpression(net.sf.jasperreports.engine.design.JRDesignExpression) JRDesignImage(net.sf.jasperreports.engine.design.JRDesignImage) JRDesignStyle(net.sf.jasperreports.engine.design.JRDesignStyle) ImageBanner(ar.com.fdvs.dj.domain.ImageBanner) JRDesignElement(net.sf.jasperreports.engine.design.JRDesignElement) JRChild(net.sf.jasperreports.engine.JRChild)

Example 2 with ImageBanner

use of ar.com.fdvs.dj.domain.ImageBanner in project DynamicJasper by intive-FDV.

the class DynamicReportBuilder method addFooterImageBanner.

public DynamicReportBuilder addFooterImageBanner(String path, int width, int height, ImageBanner.Alignment alignment, ImageScaleMode scaleMode) {
    ImageBanner banner = new ImageBanner(path, width, height, alignment);
    banner.setScaleMode(scaleMode);
    options.getFooterImageBanners().put(alignment, banner);
    return this;
}
Also used : ImageBanner(ar.com.fdvs.dj.domain.ImageBanner)

Example 3 with ImageBanner

use of ar.com.fdvs.dj.domain.ImageBanner in project DynamicJasper by intive-FDV.

the class DynamicReportBuilder method addFooterImageBanner.

@Deprecated
public DynamicReportBuilder addFooterImageBanner(String path, int width, int height, byte align, ImageScaleMode scaleMode) {
    ImageBanner.Alignment alignment = ImageBanner.Alignment.fromValue(align);
    if (alignment == null)
        throw new DJException("Invalid ImageBanner.Alignment");
    ImageBanner banner = new ImageBanner(path, width, height, alignment);
    banner.setScaleMode(scaleMode);
    options.getFooterImageBanners().put(alignment, banner);
    return this;
}
Also used : ImageBanner(ar.com.fdvs.dj.domain.ImageBanner) DJException(ar.com.fdvs.dj.core.DJException)

Example 4 with ImageBanner

use of ar.com.fdvs.dj.domain.ImageBanner in project DynamicJasper by intive-FDV.

the class DynamicReportBuilder method addFirstPageImageBanner.

public DynamicReportBuilder addFirstPageImageBanner(String path, int width, int height, ImageBanner.Alignment align) {
    ImageBanner banner = new ImageBanner(path, width, height, align);
    options.getFirstPageImageBanners().put(align, banner);
    return this;
}
Also used : ImageBanner(ar.com.fdvs.dj.domain.ImageBanner)

Example 5 with ImageBanner

use of ar.com.fdvs.dj.domain.ImageBanner in project DynamicJasper by intive-FDV.

the class DynamicReportBuilder method addFirstPageFooterImageBanner.

public DynamicReportBuilder addFirstPageFooterImageBanner(String path, int width, int height, ImageBanner.Alignment alignment) {
    ImageBanner banner = new ImageBanner(path, width, height, alignment);
    options.getFirstPageFooterImageBanners().put(alignment, banner);
    return this;
}
Also used : ImageBanner(ar.com.fdvs.dj.domain.ImageBanner)

Aggregations

ImageBanner (ar.com.fdvs.dj.domain.ImageBanner)13 DJException (ar.com.fdvs.dj.core.DJException)6 JRChild (net.sf.jasperreports.engine.JRChild)1 JRDesignElement (net.sf.jasperreports.engine.design.JRDesignElement)1 JRDesignExpression (net.sf.jasperreports.engine.design.JRDesignExpression)1 JRDesignImage (net.sf.jasperreports.engine.design.JRDesignImage)1 JRDesignStyle (net.sf.jasperreports.engine.design.JRDesignStyle)1