/** * Constructs a <code>Stroker</code>. * * @param pc2d an output <code>PathConsumer2D</code>. * @param lineWidth the desired line width in pixels * @param capStyle the desired end cap style, one of * <code>CAP_BUTT</code>, <code>CAP_ROUND</code> or * <code>CAP_SQUARE</code>. * @param joinStyle the desired line join style, one of * <code>JOIN_MITER</code>, <code>JOIN_ROUND</code> or * <code>JOIN_BEVEL</code>. * @param miterLimit the desired miter limit */ public Stroker(PathConsumer2D pc2d, float lineWidth, int capStyle, int joinStyle, float miterLimit) { this.out = pc2d; this.lineWidth2 = lineWidth / 2; this.capStyle = capStyle; this.joinStyle = joinStyle; float limit = miterLimit * lineWidth2; this.miterLimitSq = limit*limit; this.prev = CLOSE; }
public void pop(PathConsumer2D io) { numCurves--; int type = curveTypes[numCurves]; end -= (type - 2); switch(type) { case 8: io.curveTo(curves[end+0], curves[end+1], curves[end+2], curves[end+3], curves[end+4], curves[end+5]); break; case 6: io.quadTo(curves[end+0], curves[end+1], curves[end+2], curves[end+3]); break; case 4: io.lineTo(curves[end], curves[end+1]); } }
public static PathConsumer2D deltaTransformConsumer(PathConsumer2D out, AffineTransform at) { if (at == null) { return out; } float Mxx = (float) at.getScaleX(); float Mxy = (float) at.getShearX(); float Myx = (float) at.getShearY(); float Myy = (float) at.getScaleY(); if (Mxy == 0f && Myx == 0f) { if (Mxx == 1f && Myy == 1f) { return out; } else { return new DeltaScaleFilter(out, Mxx, Myy); } } else { return new DeltaTransformFilter(out, Mxx, Mxy, Myx, Myy); } }
public static PathConsumer2D inverseDeltaTransformConsumer(PathConsumer2D out, AffineTransform at) { if (at == null) { return out; } float Mxx = (float) at.getScaleX(); float Mxy = (float) at.getShearX(); float Myx = (float) at.getShearY(); float Myy = (float) at.getScaleY(); if (Mxy == 0f && Myx == 0f) { if (Mxx == 1f && Myy == 1f) { return out; } else { return new DeltaScaleFilter(out, 1.0f/Mxx, 1.0f/Myy); } } else { float det = Mxx * Myy - Mxy * Myx; return new DeltaTransformFilter(out, Myy / det, -Mxy / det, -Myx / det, Mxx / det); } }
public void strokeTo(Shape src, AffineTransform at, BasicStroke bs, boolean thin, boolean normalize, boolean antialias, PathConsumer2D consumer) { System.out.println(name+".strokeTo("+ src.getClass().getName()+", "+ at+", "+ bs+", "+ (thin ? "thin" : "wide")+", "+ (normalize ? "normalized" : "pure")+", "+ (antialias ? "AA" : "non-AA")+", "+ consumer.getClass().getName()+")"); target.strokeTo(src, at, bs, thin, normalize, antialias, consumer); }
/** * Constructs a {@code Stroker}. * * @param pc2d an output {@code PathConsumer2D}. * @param lineWidth the desired line width in pixels * @param capStyle the desired end cap style, one of * {@code CAP_BUTT}, {@code CAP_ROUND} or * {@code CAP_SQUARE}. * @param joinStyle the desired line join style, one of * {@code JOIN_MITER}, {@code JOIN_ROUND} or * {@code JOIN_BEVEL}. * @param miterLimit the desired miter limit */ public Stroker(PathConsumer2D pc2d, float lineWidth, int capStyle, int joinStyle, float miterLimit) { this.out = pc2d; this.lineWidth2 = lineWidth / 2; this.capStyle = capStyle; this.joinStyle = joinStyle; float limit = miterLimit * lineWidth2; this.miterLimitSq = limit*limit; this.prev = CLOSE; }
/** * Inits the <code>Stroker</code>. * * @param pc2d an output <code>PathConsumer2D</code>. * @param lineWidth the desired line width in pixels * @param capStyle the desired end cap style, one of * <code>CAP_BUTT</code>, <code>CAP_ROUND</code> or * <code>CAP_SQUARE</code>. * @param joinStyle the desired line join style, one of * <code>JOIN_MITER</code>, <code>JOIN_ROUND</code> or * <code>JOIN_BEVEL</code>. * @param miterLimit the desired miter limit * @return this instance */ Stroker init(PathConsumer2D pc2d, float lineWidth, int capStyle, int joinStyle, float miterLimit) { this.out = pc2d; this.lineWidth2 = lineWidth / 2.0f; this.invHalfLineWidth2Sq = 1.0f / (2.0f * lineWidth2 * lineWidth2); this.capStyle = capStyle; this.joinStyle = joinStyle; float limit = miterLimit * lineWidth2; this.miterLimitSq = limit * limit; this.prev = CLOSE; rdrCtx.stroking = 1; return this; // fluent API }
PathConsumer2D deltaTransformConsumer(PathConsumer2D out, AffineTransform at) { if (at == null) { return out; } float mxx = (float) at.getScaleX(); float mxy = (float) at.getShearX(); float myx = (float) at.getShearY(); float myy = (float) at.getScaleY(); if (mxy == 0.0f && myx == 0.0f) { if (mxx == 1.0f && myy == 1.0f) { return out; } else { return dt_DeltaScaleFilter.init(out, mxx, myy); } } else { return dt_DeltaTransformFilter.init(out, mxx, mxy, myx, myy); } }
PathConsumer2D inverseDeltaTransformConsumer(PathConsumer2D out, AffineTransform at) { if (at == null) { return out; } float mxx = (float) at.getScaleX(); float mxy = (float) at.getShearX(); float myx = (float) at.getShearY(); float myy = (float) at.getScaleY(); if (mxy == 0.0f && myx == 0.0f) { if (mxx == 1.0f && myy == 1.0f) { return out; } else { return iv_DeltaScaleFilter.init(out, 1.0f/mxx, 1.0f/myy); } } else { float det = mxx * myy - mxy * myx; return iv_DeltaTransformFilter.init(out, myy / det, -mxy / det, -myx / det, mxx / det); } }
/** * Inits the <code>Stroker</code>. * * @param pc2d an output <code>PathConsumer2D</code>. * @param lineWidth the desired line width in pixels * @param capStyle the desired end cap style, one of * <code>CAP_BUTT</code>, <code>CAP_ROUND</code> or * <code>CAP_SQUARE</code>. * @param joinStyle the desired line join style, one of * <code>JOIN_MITER</code>, <code>JOIN_ROUND</code> or * <code>JOIN_BEVEL</code>. * @param miterLimit the desired miter limit * @return this instance */ Stroker init(PathConsumer2D pc2d, float lineWidth, int capStyle, int joinStyle, float miterLimit) { this.out = pc2d; this.lineWidth2 = lineWidth / 2f; this.invHalfLineWidth2Sq = 1f / (2f * lineWidth2 * lineWidth2); this.capStyle = capStyle; this.joinStyle = joinStyle; float limit = miterLimit * lineWidth2; this.miterLimitSq = limit * limit; this.prev = CLOSE; rdrCtx.stroking = 1; return this; // fluent API }
PathConsumer2D deltaTransformConsumer(PathConsumer2D out, AffineTransform at) { if (at == null) { return out; } float mxx = (float) at.getScaleX(); float mxy = (float) at.getShearX(); float myx = (float) at.getShearY(); float myy = (float) at.getScaleY(); if (mxy == 0f && myx == 0f) { if (mxx == 1f && myy == 1f) { return out; } else { return dt_DeltaScaleFilter.init(out, mxx, myy); } } else { return dt_DeltaTransformFilter.init(out, mxx, mxy, myx, myy); } }
PathConsumer2D inverseDeltaTransformConsumer(PathConsumer2D out, AffineTransform at) { if (at == null) { return out; } float mxx = (float) at.getScaleX(); float mxy = (float) at.getShearX(); float myx = (float) at.getShearY(); float myy = (float) at.getScaleY(); if (mxy == 0f && myx == 0f) { if (mxx == 1f && myy == 1f) { return out; } else { return iv_DeltaScaleFilter.init(out, 1.0f/mxx, 1.0f/myy); } } else { float det = mxx * myy - mxy * myx; return iv_DeltaTransformFilter.init(out, myy / det, -mxy / det, -myx / det, mxx / det); } }