List of usage examples for com.itextpdf.text.pdf PdfContentByte circle
public void circle(final double x, final double y, final double r)
From source file:adams.flow.transformer.pdfproclet.Circle.java
License:Open Source License
/** * The actual processing of the document. * * @param generator the context/*from ww w. j a v a2 s.co m*/ * @param file the file to add * @return true if successfully added * @throws Exception if something goes wrong */ protected boolean doProcess(PDFGenerator generator, File file) throws Exception { PdfContentByte cb; cb = generator.getWriter().getDirectContent(); cb.saveState(); cb.setColorStroke(new BaseColor(m_Color.getRGB())); cb.setColorFill(new BaseColor(m_Color.getRGB())); cb.setLineWidth(m_LineWidth); cb.circle(m_X, m_Y, m_Radius); if (m_Fill) cb.fillStroke(); else cb.stroke(); cb.restoreState(); return true; }
From source file:bouttime.report.bracketsheet.BracketSheetUtil.java
License:Open Source License
public static void drawCircle(PdfContentByte cb, float x, float y, float r, float lineWidth, float grayStroke) { setLineWidthGrayStroke(cb, lineWidth, grayStroke); cb.circle(x, y, r); cb.stroke();//from www . j a v a2 s .c o m }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
/** * Prints 3 circles in different colors that intersect with eachother. * @param x/* www.java2 s . com*/ * @param y * @param cb * @throws Exception */ public void pictureCircles(float x, float y, PdfContentByte cb) throws Exception { cb.saveState(); PdfGState gs1 = new PdfGState(); gs1.setFillOpacity(1.0f); cb.setGState(gs1); cb.setColorFill(new BaseColor(Color.red)); cb.circle(x + 70, y + 70, 50); cb.fill(); cb.restoreState(); cb.setColorFill(new BaseColor(Color.yellow)); cb.circle(x + 100, y + 130, 50); cb.fill(); cb.setColorFill(new BaseColor(Color.blue)); cb.circle(x + 130, y + 70, 50); cb.fill(); }
From source file:EplanPrinter.PDFPrint.java
License:Open Source License
public String insertSketch(String points, String color, String opac, int pageNum, int masterHeight, int masterWidth, int lineWeight, String lineStyle) throws DocumentException, IOException { float f = Float.valueOf(opac); PdfGState gs1 = new PdfGState(); int t = points.indexOf("POLYGON"); gs1.setFillOpacity(f);//ww w .jav a2s . co m PdfContentByte fg = pds.getOverContent(pageNum); fg.setGState(gs1); float[] pointsSt = shatterSketches(points); color = "0x" + color.substring(1); Color c = Color.decode(color); fg.setLineWidth(lineWeight * getRatio(masterHeight, masterWidth, pageNum)); if (lineStyle.equals("dash")) { fg.setLineDash(lineWeight * 4f, lineWeight); } else { fg.setLineDash(0); } //fg.setLineWidth(5); fg.setColorStroke(new BaseColor(c.getRGB())); fg.setColorFill(new BaseColor(c.getRGB())); float[] prefl = scaleShape(pointsSt, masterHeight, masterWidth, pageNum); float[] fl = sketchTrans(prefl, pageNum); /* Addition. ftorres - 7/22/2015 - Added to account for rotated pages * with the origin (0,0) not set to the bottom-left of the page. [1400] */ float flTrans[] = translateRotation(fl[0], fl[1], pageNum); if (points.indexOf("LINEPOINT") != -1) { fg.circle(flTrans[0], flTrans[1], 5); fg.fillStroke(); if (t == -1) { gs1.setFillOpacity(0f); } else { gs1.setFillOpacity(f); } fg.setGState(gs1); } fg.moveTo(flTrans[0], flTrans[1]); for (int i = 2; i < pointsSt.length; i = i + 2) { flTrans = translateRotation(fl[i], fl[i + 1], pageNum); fg.lineTo(flTrans[0], flTrans[1]); } if (t != -1) { fg.closePathFillStroke(); fg.fill(); } else { fg.stroke(); } return ""; }
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 ww .ja va2 s .c o 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.NodeRenderer.java
License:Open Source License
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); size /= 2f;// w w w .jav a 2s. co m Color color = item.getData(NodeItem.COLOR); Color borderColor = ((DependantColor) properties.getValue(PreviewProperty.NODE_BORDER_COLOR)) .getColor(color); float borderSize = properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH); float alpha = properties.getFloatValue(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); } cb.circle(x, -y, size); if (borderSize > 0) { cb.fillStroke(); } else { cb.fill(); } if (alpha < 1f) { cb.restoreState(); } }