sun.awt.geom.PathConsumer2D Java Examples

The following examples show how to use sun.awt.geom.PathConsumer2D. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransformingPathConsumer2D.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #2
Source File: RenderingEngine.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #3
Source File: TransformingPathConsumer2D.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
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 {
        final float det = mxx * myy - mxy * myx;
        return iv_DeltaTransformFilter.init(out,
                                            myy / det,
                                           -mxy / det,
                                           -myx / det,
                                            mxx / det);
    }
}
 
Example #4
Source File: TransformingPathConsumer2D.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #5
Source File: RenderingEngine.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #6
Source File: TransformingPathConsumer2D.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #7
Source File: RenderingEngine.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #8
Source File: TransformingPathConsumer2D.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
boolean splitQuad(final float x0, final float y0,
                  final float x1, final float y1,
                  final float x2, final float y2,
                  final int outCodeOR,
                  final PathConsumer2D out)
{
    if (TRACE) {
        MarlinUtils.logInfo("divQuad P0(" + x0 + ", " + y0 + ") P1(" + x1 + ", " + y1 + ") P2(" + x2 + ", " + y2 + ")");
    }

    if (DO_CHECK_LENGTH && Helpers.fastQuadLen(x0, y0, x1, y1, x2, y2) <= minLength) {
        return false;
    }

    final float[] mid = middle;
    mid[0] = x0;  mid[1] = y0;
    mid[2] = x1;  mid[3] = y1;
    mid[4] = x2;  mid[5] = y2;

    return subdivideAtIntersections(6, outCodeOR, out);
}
 
Example #9
Source File: TransformingPathConsumer2D.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #10
Source File: RenderingEngine.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #11
Source File: Stroker.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #12
Source File: TransformingPathConsumer2D.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #13
Source File: RenderingEngine.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #14
Source File: Stroker.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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]);
    }
}
 
Example #15
Source File: TransformingPathConsumer2D.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #16
Source File: RenderingEngine.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #17
Source File: TransformingPathConsumer2D.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #18
Source File: Stroker.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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]);
    }
}
 
Example #19
Source File: Stroker.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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
}
 
Example #20
Source File: Dasher.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a <code>Dasher</code>.
 *
 * @param out an output <code>PathConsumer2D</code>.
 * @param dash an array of <code>float</code>s containing the dash pattern
 * @param phase a <code>float</code> containing the dash phase
 */
public Dasher(PathConsumer2D out, float[] dash, float phase) {
    if (phase < 0) {
        throw new IllegalArgumentException("phase < 0 !");
    }

    this.out = out;

    // Normalize so 0 <= phase < dash[0]
    int idx = 0;
    dashOn = true;
    float d;
    while (phase >= (d = dash[idx])) {
        phase -= d;
        idx = (idx + 1) % dash.length;
        dashOn = !dashOn;
    }

    this.dash = dash;
    this.startPhase = this.phase = phase;
    this.startDashOn = dashOn;
    this.startIdx = idx;
    this.starting = true;

    // we need curCurvepts to be able to contain 2 curves because when
    // dashing curves, we need to subdivide it
    curCurvepts = new float[8 * 2];
}
 
Example #21
Source File: TransformingPathConsumer2D.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
DeltaTransformFilter(PathConsumer2D out,
                     float Mxx, float Mxy,
                     float Myx, float Myy)
{
    this.out = out;
    this.Mxx = Mxx;
    this.Mxy = Mxy;
    this.Myx = Myx;
    this.Myy = Myy;
}
 
Example #22
Source File: PiscesRenderingEngine.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void strokeTo(Shape src,
              AffineTransform at,
              BasicStroke bs,
              boolean thin,
              NormMode normalize,
              boolean antialias,
              PathConsumer2D pc2d)
{
    float lw;
    if (thin) {
        if (antialias) {
            lw = userSpaceLineWidth(at, 0.5f);
        } else {
            lw = userSpaceLineWidth(at, 1.0f);
        }
    } else {
        lw = bs.getLineWidth();
    }
    strokeTo(src,
             at,
             lw,
             normalize,
             bs.getEndCap(),
             bs.getLineJoin(),
             bs.getMiterLimit(),
             bs.getDashArray(),
             bs.getDashPhase(),
             pc2d);
}
 
Example #23
Source File: TransformingPathConsumer2D.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
DeltaScaleFilter init(PathConsumer2D out,
                      float mxx, float myy)
{
    this.out = out;
    sx = mxx;
    sy = myy;
    return this; // fluent API
}
 
Example #24
Source File: TransformingPathConsumer2D.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
TranslateFilter(PathConsumer2D out,
                float tx, float ty)
{
    this.out = out;
    this.tx = tx;
    this.ty = ty;
}
 
Example #25
Source File: PiscesRenderingEngine.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void strokeTo(Shape src,
              AffineTransform at,
              BasicStroke bs,
              boolean thin,
              NormMode normalize,
              boolean antialias,
              PathConsumer2D pc2d)
{
    float lw;
    if (thin) {
        if (antialias) {
            lw = userSpaceLineWidth(at, 0.5f);
        } else {
            lw = userSpaceLineWidth(at, 1.0f);
        }
    } else {
        lw = bs.getLineWidth();
    }
    strokeTo(src,
             at,
             lw,
             normalize,
             bs.getEndCap(),
             bs.getLineJoin(),
             bs.getMiterLimit(),
             bs.getDashArray(),
             bs.getDashPhase(),
             pc2d);
}
 
Example #26
Source File: TransformingPathConsumer2D.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
DeltaTransformFilter(PathConsumer2D out,
                     float Mxx, float Mxy,
                     float Myx, float Myy)
{
    this.out = out;
    this.Mxx = Mxx;
    this.Mxy = Mxy;
    this.Myx = Myx;
    this.Myy = Myy;
}
 
Example #27
Source File: MarlinRenderingEngine.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
final void strokeTo(final RendererContext rdrCtx,
                    Shape src,
                    AffineTransform at,
                    BasicStroke bs,
                    boolean thin,
                    NormMode normalize,
                    boolean antialias,
                    PathConsumer2D pc2d)
{
    float lw;
    if (thin) {
        if (antialias) {
            lw = userSpaceLineWidth(at, MIN_PEN_SIZE);
        } else {
            lw = userSpaceLineWidth(at, 1.0f);
        }
    } else {
        lw = bs.getLineWidth();
    }
    strokeTo(rdrCtx,
             src,
             at,
             lw,
             normalize,
             bs.getEndCap(),
             bs.getLineJoin(),
             bs.getMiterLimit(),
             bs.getDashArray(),
             bs.getDashPhase(),
             pc2d);
}
 
Example #28
Source File: TransformingPathConsumer2D.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
DeltaTransformFilter(PathConsumer2D out,
                     float Mxx, float Mxy,
                     float Myx, float Myy)
{
    this.out = out;
    this.Mxx = Mxx;
    this.Mxy = Mxy;
    this.Myx = Myx;
    this.Myy = Myy;
}
 
Example #29
Source File: TransformingPathConsumer2D.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static PathConsumer2D
    transformConsumer(PathConsumer2D out,
                      AffineTransform at)
{
    if (at == null) {
        return out;
    }
    float Mxx = (float) at.getScaleX();
    float Mxy = (float) at.getShearX();
    float Mxt = (float) at.getTranslateX();
    float Myx = (float) at.getShearY();
    float Myy = (float) at.getScaleY();
    float Myt = (float) at.getTranslateY();
    if (Mxy == 0f && Myx == 0f) {
        if (Mxx == 1f && Myy == 1f) {
            if (Mxt == 0f && Myt == 0f) {
                return out;
            } else {
                return new TranslateFilter(out, Mxt, Myt);
            }
        } else {
            if (Mxt == 0f && Myt == 0f) {
                return new DeltaScaleFilter(out, Mxx, Myy);
            } else {
                return new ScaleFilter(out, Mxx, Myy, Mxt, Myt);
            }
        }
    } else if (Mxt == 0f && Myt == 0f) {
        return new DeltaTransformFilter(out, Mxx, Mxy, Myx, Myy);
    } else {
        return new TransformFilter(out, Mxx, Mxy, Mxt, Myx, Myy, Myt);
    }
}
 
Example #30
Source File: TransformingPathConsumer2D.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private boolean subdivideAtIntersections(final int type, final int outCodeOR,
                                         final PathConsumer2D out)
{
    final float[] mid = middle;
    final float[] subTs = subdivTs;

    if (init_clipRectPad) {
        init_clipRectPad = false;
        initPaddedClip();
    }

    final int nSplits = Helpers.findClipPoints(curve, mid, subTs, type,
                                                outCodeOR, clipRectPad);

    if (TRACE) {
        MarlinUtils.logInfo("nSplits: " + nSplits);
        MarlinUtils.logInfo("subTs: " + Arrays.toString(Arrays.copyOfRange(subTs, 0, nSplits)));
    }
    if (nSplits == 0) {
        // only curve support shortcut
        return false;
    }
    float prevT = 0.0f;

    for (int i = 0, off = 0; i < nSplits; i++, off += type) {
        final float t = subTs[i];

        Helpers.subdivideAt((t - prevT) / (1.0f - prevT),
                             mid, off, mid, off, type);
        prevT = t;
    }

    for (int i = 0, off = 0; i <= nSplits; i++, off += type) {
        if (TRACE) {
            MarlinUtils.logInfo("Part Curve " + Arrays.toString(Arrays.copyOfRange(mid, off, off + type)));
        }
        emitCurrent(type, mid, off, out);
    }
    return true;
}