List of usage examples for com.lowagie.text.pdf PdfGState setBlendMode
public void setBlendMode(PdfName bm)
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); }