List of usage examples for com.itextpdf.text.pdf PdfContentByte setRGBColorFill
public void setRGBColorFill(final int red, final int green, final int blue)
From source file:PrefichaPDF.java
public static void drawRectangle(PdfContentByte content, float x, float y, float width, float height) { content.saveState();/*from w w w . ja v a2s .c om*/ PdfGState state = new PdfGState(); content.setGState(state); content.setRGBColorFill(232, 232, 232); content.setColorStroke(BaseColor.LIGHT_GRAY); // content.setr content.setLineWidth((float) .5); content.rectangle(x, y, width, height); content.fillStroke(); content.restoreState(); }
From source file:PrefichaPDF.java
public static void drawRectangleSC(PdfContentByte content, float x, float y, float width, float height) { content.saveState();/* w w w . ja v a 2 s . c o m*/ PdfGState state = new PdfGState(); // state.setFillOpacity(0.6f); content.setGState(state); content.setRGBColorFill(0xFF, 0xFF, 0xFA); content.setColorStroke(BaseColor.LIGHT_GRAY); content.setLineWidth((float) .5); content.rectangle(x, y, width, height); content.fillStroke(); content.restoreState(); }
From source file:PrefichaPDF.java
public static void drawRectangleText(PdfContentByte content, float x, float y, float width, float height) { content.saveState();//from ww w. ja v a2s. c o m PdfGState state = new PdfGState(); content.setGState(state); content.setRGBColorFill(0, 230, 255); content.setColorStroke(BaseColor.LIGHT_GRAY); content.setLineWidth((float) .5); content.rectangle(x, y, width, height); content.fillStroke(); content.restoreState(); }
From source file:com.qmetric.document.watermark.strategy.MessageWatermarkStrategy.java
License:Open Source License
private void addTextToPage(final Rectangle page, final PdfContentByte overContent, final String watermarkText) throws DocumentException, IOException { // Add text - adapted from example found at // http://footheory.com/blogs/donnfelker/archive/2008/05/11/using-itextsharp-to-watermark-write-text-to-existing-pdf-s.aspx overContent.beginText();/*from w w w . j a va 2s.c om*/ final BaseFont baseFont = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, false); overContent.setFontAndSize(baseFont, 14); overContent.setRGBColorFill(RED, 0, 0); overContent.showTextAligned(PdfContentByte.ALIGN_LEFT, watermarkText, xAxisPosition(page), yAxisPosition(page), NO_ROTATION); overContent.endText(); }
From source file:ConexionBD.CreaPrefichaPDF.java
public static void drawRectangle(PdfContentByte content, float x, float y, float width, float height) { content.saveState();//from w w w .j a v a2 s. c o m PdfGState state = new PdfGState(); content.setGState(state); content.setRGBColorFill(232, 232, 232); content.setColorStroke(BaseColor.BLUE); content.setLineWidth((float) .5); content.rectangle(x, y, width, height); content.fillStroke(); content.restoreState(); }
From source file:ConexionBD.CreaPrefichaPDF.java
public static void drawRectangleSC(PdfContentByte content, float x, float y, float width, float height) { content.saveState();//from www . j av a 2s . co m PdfGState state = new PdfGState(); content.setGState(state); content.setRGBColorFill(0xFF, 0xFF, 0xFA); content.setColorStroke(BaseColor.BLUE); content.setLineWidth((float) .5); content.rectangle(x, y, width, height); content.fillStroke(); content.restoreState(); }
From source file:ConexionBD.CreaPrefichaPDF.java
public static void drawRectangleText(PdfContentByte content, float x, float y, float width, float height) { content.saveState();//from w w w.j a v a2s . c om PdfGState state = new PdfGState(); content.setGState(state); content.setRGBColorFill(0, 230, 255); content.setColorStroke(BaseColor.BLUE); content.setLineWidth((float) .5); content.rectangle(x, y, width, height); content.fillStroke(); content.restoreState(); }
From source file:org.frobic.colorednodes.renderers.NewNodeRenderer.java
License:Open Source License
@Override public void renderPDF(Item item, PDFTarget target, PreviewProperties properties) { Float x = item.getData(NodeItem.X); Float y = item.getData(NodeItem.Y); Float size = item.getData(NodeItem.SIZE); Float angle = item.getData(NodeItem.ANGLE); size /= 2f;/*from w w w . j a va2 s .co m*/ Color color = item.getData(NodeItem.COLOR); Integer nbcolors = item.getData(NodeItem.NBCOLOR); Color[] colors = item.getData(NodeItem.COLORS); Color borderColor = ((DependantColor) properties.getValue(PreviewProperty.NODE_BORDER_COLOR)) .getColor(color); float borderSize = properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH); float alpha = properties.getIntValue(PreviewProperty.NODE_OPACITY) / 100f; PdfContentByte cb = target.getContentByte(); cb.setRGBColorStroke(borderColor.getRed(), borderColor.getGreen(), borderColor.getBlue()); cb.setLineWidth(borderSize); cb.setRGBColorFill(color.getRed(), color.getGreen(), color.getBlue()); if (alpha < 1f) { cb.saveState(); PdfGState gState = new PdfGState(); gState.setFillOpacity(alpha); gState.setStrokeOpacity(alpha); cb.setGState(gState); } for (int i = 0; i < nbcolors; i++) { cb.setRGBColorFill(colors[nbcolors - i - 1].getRed(), colors[nbcolors - i - 1].getGreen(), colors[nbcolors - i - 1].getBlue()); if (size >= 0.5) { cb.newPath(); ArrayList ar = cb.bezierArc(x - size, -y + size, x + size, 0 - size - y, 360f * (nbcolors - i - 1) / nbcolors + (360f / 6.28f) * angle, 360f * (1) / nbcolors); //cb.arc(x-size,-y+size,x+size,0-size-y,360f*(nbcolors-i-1)/nbcolors+angle,360f*(1)/nbcolors) ; cb.moveTo(x, -y); float pt[] = (float[]) ar.get(0); cb.moveTo(pt[0], pt[1]); for (int k = 0; k < ar.size(); ++k) { pt = (float[]) ar.get(k); cb.curveTo(pt[2], pt[3], pt[4], pt[5], pt[6], pt[7]); } cb.lineTo(x, -y); //strokeAndFill(); // cb.ClosePathFillStroke(); if (borderSize > 0) { cb.fill(); } else { cb.fill(); } if (borderSize > 0) { cb.circle(x, -y, size); cb.stroke(); } } } if (alpha < 1f) { cb.restoreState(); } }
From source file:org.gephi.preview.plugin.renderers.ArrowRenderer.java
License:Open Source License
public void renderStraight(RenderTarget target, Item item, float x1, float y1, float x2, float y2, float radius, float size, Color color) { Edge edge = (Edge) item.getSource(); PVector direction = new PVector(x2, y2); direction.sub(new PVector(x1, y1)); direction.normalize();//from w ww . ja v a2 s.c o m PVector p1 = new PVector(direction.x, direction.y); p1.mult(radius); p1.add(new PVector(x2, y2)); PVector p1r = new PVector(direction.x, direction.y); p1r.mult(radius - size); p1r.add(new PVector(x2, y2)); PVector p2 = new PVector(-direction.y, direction.x); p2.mult(size * BASE_RATIO); p2.add(p1r); PVector p3 = new PVector(direction.y, -direction.x); p3.mult(size * BASE_RATIO); p3.add(p1r); if (target instanceof ProcessingTarget) { PGraphics graphics = ((ProcessingTarget) target).getGraphics(); graphics.noStroke(); graphics.fill(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); graphics.triangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y); } else if (target instanceof SVGTarget) { SVGTarget svgTarget = (SVGTarget) target; Element arrowElem = svgTarget.createElement("polyline"); arrowElem.setAttribute("points", String.format(Locale.ENGLISH, "%f,%f %f,%f %f,%f", p1.x, p1.y, p2.x, p2.y, p3.x, p3.y)); arrowElem.setAttribute("class", edge.getSource().getNodeData().getId() + " " + edge.getTarget().getNodeData().getId()); arrowElem.setAttribute("fill", svgTarget.toHexString(color)); arrowElem.setAttribute("fill-opacity", (color.getAlpha() / 255f) + ""); arrowElem.setAttribute("stroke", "none"); svgTarget.getTopElement(SVGTarget.TOP_ARROWS).appendChild(arrowElem); } else if (target instanceof PDFTarget) { PDFTarget pdfTarget = (PDFTarget) target; PdfContentByte cb = pdfTarget.getContentByte(); cb.moveTo(p1.x, -p1.y); cb.lineTo(p2.x, -p2.y); cb.lineTo(p3.x, -p3.y); cb.closePath(); cb.setRGBColorFill(color.getRed(), color.getGreen(), color.getBlue()); if (color.getAlpha() < 255) { cb.saveState(); float alpha = color.getAlpha() / 255f; PdfGState gState = new PdfGState(); gState.setFillOpacity(alpha); cb.setGState(gState); } cb.fill(); if (color.getAlpha() < 255) { cb.restoreState(); } } }
From source file:org.gephi.preview.plugin.renderers.EdgeLabelRenderer.java
License:Open Source License
public void renderPDF(PDFTarget target, String label, float x, float y, Color color, float outlineSize, Color outlineColor) {/*from w w w. j a va2 s.c o m*/ PdfContentByte cb = target.getContentByte(); cb.setRGBColorFill(color.getRed(), color.getGreen(), color.getBlue()); BaseFont bf = target.getBaseFont(font); float textHeight = getTextHeight(bf, font.getSize(), label); if (outlineSize > 0) { cb.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_STROKE); cb.setRGBColorStroke(outlineColor.getRed(), outlineColor.getGreen(), outlineColor.getBlue()); cb.setLineWidth(outlineSize); cb.setLineJoin(PdfContentByte.LINE_JOIN_ROUND); cb.setLineCap(PdfContentByte.LINE_CAP_ROUND); if (outlineColor.getAlpha() < 255) { cb.saveState(); float alpha = outlineColor.getAlpha() / 255f; PdfGState gState = new PdfGState(); gState.setStrokeOpacity(alpha); cb.setGState(gState); } cb.beginText(); cb.setFontAndSize(bf, font.getSize()); cb.showTextAligned(PdfContentByte.ALIGN_CENTER, label, x, -y - (textHeight / 2f), 0f); cb.endText(); if (outlineColor.getAlpha() < 255) { cb.restoreState(); } } cb.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL); cb.beginText(); cb.setFontAndSize(bf, font.getSize()); cb.showTextAligned(PdfContentByte.ALIGN_CENTER, label, x, -y - (textHeight / 2f), 0f); cb.endText(); }