Example usage for com.lowagie.text.pdf PdfGState setBlendMode

List of usage examples for com.lowagie.text.pdf PdfGState setBlendMode

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfGState setBlendMode.

Prototype

public void setBlendMode(PdfName bm) 

Source Link

Document

The current blend mode to be used in the transparent imaging model.

Usage

From source file:org.geomajas.plugin.print.component.PdfContext.java

License:Open Source License

/**
 * Draws the specified image with the first rectangle's bounds, clipping with the second one.
 *
 * @param img image/* w  w w .ja va  2 s  .  c o m*/
 * @param rect rectangle
 * @param clipRect clipping bounds
 * @param opacity opacity of the image (1 = opaque, 0= transparent)
 */
public void drawImage(Image img, Rectangle rect, Rectangle clipRect, float opacity) {
    try {
        template.saveState();
        // opacity
        PdfGState state = new PdfGState();
        state.setFillOpacity(opacity);
        state.setBlendMode(PdfGState.BM_NORMAL);
        template.setGState(state);
        // clipping code
        if (clipRect != null) {
            template.rectangle(clipRect.getLeft() + origX, clipRect.getBottom() + origY, clipRect.getWidth(),
                    clipRect.getHeight());
            template.clip();
            template.newPath();
        }
        template.addImage(img, rect.getWidth(), 0, 0, rect.getHeight(), origX + rect.getLeft(),
                origY + rect.getBottom());
    } catch (DocumentException e) {
        log.warn("could not draw image", e);
    } finally {
        template.restoreState();
    }
}

From source file:org.geomajas.plugin.print.component.PdfContext.java

License:Open Source License

private void setStroke(Color color, float linewidth, float[] dashArray) {
    // Color and transparency
    PdfGState state = new PdfGState();
    state.setStrokeOpacity(color.getAlpha());
    state.setBlendMode(PdfGState.BM_NORMAL);
    template.setGState(state);//  w  w  w . ja va  2s  .  c  om
    template.setColorStroke(color);
    // linewidth
    template.setLineWidth(linewidth);
    if (dashArray != null) {
        template.setLineDash(dashArray, 0f);
    }
}

From source file:org.geomajas.plugin.print.component.PdfContext.java

License:Open Source License

private void setFill(Color color) {
    // Color and transparency
    PdfGState state = new PdfGState();
    state.setFillOpacity(color.getAlpha() / 255f);
    state.setBlendMode(PdfGState.BM_NORMAL);
    template.setGState(state);/*from  w w w.j ava2  s  .  c o m*/
    template.setColorFill(color);
}