/** * Sets the stroke that will be used to draw shapes. Only {@code BasicStroke} is supported. * * @param s the stroke ({@code null} not permitted). * @see #getStroke() */ @Override public void setStroke(Stroke s) { Args.nullNotPermitted(s, "s"); if (this.stroke.equals(s)) { return; } this.stroke = s; this.gs.applyStroke(s); }
/** * Sets the composite (only {@code AlphaComposite} is handled). * * @param comp the composite ({@code null} not permitted). * @see #getComposite() */ @Override public void setComposite(Composite comp) { Args.nullNotPermitted(comp, "comp"); this.composite = comp; if (comp instanceof AlphaComposite) { AlphaComposite ac = (AlphaComposite) comp; this.gs.applyComposite(ac); } else { this.gs.applyComposite(null); } }
/** * Creates a new instance of {@code PDFGraphics2D}. You won't normally create this directly, * instead you will call the {@link Page#getGraphics2D()} method. * * @param gs the graphics stream ({@code null} not permitted). * @param width the width. * @param height the height. * @param skipJava2DTransform a flag that allows the PDF to Java2D transform to be skipped (used * for watermarks which are appended to an existing stream that already has the transform). */ public PDFGraphics2D(GraphicsStream gs, int width, int height, boolean skipJava2DTransform) { Args.nullNotPermitted(gs, "gs"); this.width = width; this.height = height; this.hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); this.gs = gs; // flip the y-axis to match the Java2D convention if (!skipJava2DTransform) { this.gs.applyTransform(AffineTransform.getTranslateInstance(0.0, height)); this.gs.applyTransform(AffineTransform.getScaleInstance(1.0, -1.0)); } this.gs.applyFont(getFont()); this.gs.applyStrokeColor(getColor()); this.gs.applyFillColor(getColor()); this.gs.applyStroke(getStroke()); }