List of usage examples for com.itextpdf.text.pdf PdfContentByte LINE_JOIN_ROUND
int LINE_JOIN_ROUND
To view the source code for com.itextpdf.text.pdf PdfContentByte LINE_JOIN_ROUND.
Click Source Link
From source file:com.vectorprint.report.itext.style.stylers.Shape.java
License:Open Source License
@Override protected void draw(PdfContentByte canvas, float x, float y, float width, float height, String genericTag) { if (getBorderWidth() > 0) { canvas.setLineWidth(getBorderWidth()); canvas.setColorStroke(itextHelper.fromColor((isDrawShadow()) ? getShadowColor() : getBorderColor())); }/*from w w w . j a va 2 s . co m*/ if (width == -1) { width = getWidth(); } if (height == -1) { height = getHeight(); } canvas.setColorFill(itextHelper.fromColor((isDrawShadow()) ? getShadowColor() : getColor())); if (isRounded()) { canvas.setLineJoin(PdfContentByte.LINE_JOIN_ROUND); } float xx = x, yy = y; float[] points = getPoints(); float padding = getPadding(); switch (getShape()) { case free: float xdif = x - points[0]; float ydif = y - points[1]; xx = points[0] + xdif; yy = points[1] + ydif; canvas.moveTo(points[0] + xdif, points[1] + ydif); for (int i = 2; i < points.length; i = i + 2) { canvas.lineTo(points[i], points[i + 1]); } break; case bezier: xdif = x - points[0]; ydif = y - points[1]; xx = points[0] + xdif; yy = points[1] + ydif; canvas.moveTo(points[0] + xdif, points[1] + ydif); for (int i = 2; i < points.length; i = i + 4) { canvas.curveTo(points[i] + xdif, points[i + 1] + ydif, points[i + 2] + xdif, points[i + 3] + ydif); } break; case rectangle: if (isClose()) { xx = x - padding; yy = y - padding - height; canvas.rectangle(xx, yy, width + padding * 2, height + padding * 2); } else { canvas.rectangle(x, y, width, height); } break; case roundrectangle: if (isEnclosing()) { xx = x - padding; yy = y - padding - height; canvas.roundRectangle(xx, yy, width + padding * 2, height + padding * 2, getRadius()); } else { canvas.roundRectangle(x, y, width, height, getRadius()); } break; case ellipse: if (isEnclosing()) { xx = x - padding; yy = y - padding - height; canvas.ellipse(xx, yy, x + width + 2 * padding, y + 2 * padding); } else { canvas.ellipse(x, y, x + width, y + height); } break; } if (isClose()) { if (isFill()) { canvas.closePathFillStroke(); } else { canvas.closePathStroke(); } } else { canvas.stroke(); } if (getSettings().getBooleanProperty(Boolean.FALSE, ReportConstants.DEBUG)) { DebugHelper.styleLink(canvas, getStyleClass(), " (styling)", xx, yy, getSettings(), getLayerManager()); } }
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 av a2s .com 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(); }
From source file:org.gephi.preview.plugin.renderers.NodeLabelRenderer.java
License:Open Source License
public void renderPDF(PDFTarget target, Node node, String label, float x, float y, int fontSize, Color color, float outlineSize, Color outlineColor, boolean showBox, Color boxColor) { Font font = fontCache.get(fontSize); PdfContentByte cb = target.getContentByte(); BaseFont bf = target.getBaseFont(font); //Box//from w ww. ja v a2 s . c o m if (showBox) { cb.setRGBColorFill(boxColor.getRed(), boxColor.getGreen(), boxColor.getBlue()); if (boxColor.getAlpha() < 255) { cb.saveState(); float alpha = boxColor.getAlpha() / 255f; PdfGState gState = new PdfGState(); gState.setFillOpacity(alpha); cb.setGState(gState); } float textWidth = getTextWidth(bf, fontSize, label); float textHeight = getTextHeight(bf, fontSize, label); //A height of just textHeight seems to be half the text height sometimes //BaseFont getAscentPoint and getDescentPoint may be not very precise cb.rectangle(x - textWidth / 2f - outlineSize / 2f, -y - outlineSize / 2f - textHeight, textWidth + outlineSize, textHeight * 2f + outlineSize); cb.fill(); if (boxColor.getAlpha() < 255) { cb.restoreState(); } } cb.setRGBColorFill(color.getRed(), color.getGreen(), color.getBlue()); float textHeight = getTextHeight(bf, fontSize, 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(); }