List of usage examples for com.itextpdf.text.pdf PdfContentByte curveTo
public void curveTo(final double x2, final double y2, final double x3, final double y3)
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 av a 2s . 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()); } }