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

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

Introduction

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

Prototype

PdfName BM_NORMAL

To view the source code for com.lowagie.text.pdf PdfGState BM_NORMAL.

Click Source Link

Document

A possible blend mode

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// ww w.  j ava2 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);//from  w w w  .j  a va  2 s .c o  m
    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);//ww w  .  j  a  va2s  .  c o m
    template.setColorFill(color);
}