Stroker.java revision 2638
0N/A/*
2362N/A * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.java2d.pisces;
0N/A
2638N/Apublic class Stroker implements LineSink {
0N/A
0N/A private static final int MOVE_TO = 0;
0N/A private static final int LINE_TO = 1;
0N/A private static final int CLOSE = 2;
0N/A
0N/A /**
0N/A * Constant value for join style.
0N/A */
0N/A public static final int JOIN_MITER = 0;
0N/A
0N/A /**
0N/A * Constant value for join style.
0N/A */
0N/A public static final int JOIN_ROUND = 1;
0N/A
0N/A /**
0N/A * Constant value for join style.
0N/A */
0N/A public static final int JOIN_BEVEL = 2;
0N/A
0N/A /**
0N/A * Constant value for end cap style.
0N/A */
0N/A public static final int CAP_BUTT = 0;
0N/A
0N/A /**
0N/A * Constant value for end cap style.
0N/A */
0N/A public static final int CAP_ROUND = 1;
0N/A
0N/A /**
0N/A * Constant value for end cap style.
0N/A */
0N/A public static final int CAP_SQUARE = 2;
0N/A
2638N/A private final LineSink output;
0N/A
2638N/A private final int capStyle;
2638N/A private final int joinStyle;
0N/A
2638N/A private final float m00, m01, m10, m11, det;
0N/A
2638N/A private final float lineWidth2;
2638N/A private final float scaledLineWidth2;
0N/A
0N/A // For any pen offset (pen_dx, pen_dy) that does not depend on
0N/A // the line orientation, the pen should be transformed so that:
0N/A //
0N/A // pen_dx' = m00*pen_dx + m01*pen_dy
0N/A // pen_dy' = m10*pen_dx + m11*pen_dy
0N/A //
0N/A // For a round pen, this means:
0N/A //
0N/A // pen_dx(r, theta) = r*cos(theta)
0N/A // pen_dy(r, theta) = r*sin(theta)
0N/A //
0N/A // pen_dx'(r, theta) = r*(m00*cos(theta) + m01*sin(theta))
0N/A // pen_dy'(r, theta) = r*(m10*cos(theta) + m11*sin(theta))
2638N/A private int numPenSegments;
2638N/A private final float[] pen_dx;
2638N/A private final float[] pen_dy;
2638N/A private boolean[] penIncluded;
2638N/A private final float[] join;
0N/A
2638N/A private final float[] offset = new float[2];
2638N/A private float[] reverse = new float[100];
2638N/A private final float[] miter = new float[2];
2638N/A private final float miterLimitSq;
0N/A
2638N/A private int prev;
2638N/A private int rindex;
2638N/A private boolean started;
2638N/A private boolean lineToOrigin;
2638N/A private boolean joinToOrigin;
0N/A
2638N/A private float sx0, sy0, sx1, sy1, x0, y0, px0, py0;
2638N/A private float mx0, my0, omx, omy;
0N/A
2638N/A private float m00_2_m01_2;
2638N/A private float m10_2_m11_2;
2638N/A private float m00_m10_m01_m11;
0N/A
0N/A /**
0N/A * Constructs a <code>Stroker</code>.
0N/A *
0N/A * @param output an output <code>LineSink</code>.
2638N/A * @param lineWidth the desired line width in pixels
0N/A * @param capStyle the desired end cap style, one of
0N/A * <code>CAP_BUTT</code>, <code>CAP_ROUND</code> or
0N/A * <code>CAP_SQUARE</code>.
0N/A * @param joinStyle the desired line join style, one of
0N/A * <code>JOIN_MITER</code>, <code>JOIN_ROUND</code> or
0N/A * <code>JOIN_BEVEL</code>.
2638N/A * @param miterLimit the desired miter limit
0N/A * @param transform a <code>Transform4</code> object indicating
0N/A * the transform that has been previously applied to all incoming
0N/A * coordinates. This is required in order to produce consistently
0N/A * shaped end caps and joins.
0N/A */
0N/A public Stroker(LineSink output,
2638N/A float lineWidth,
0N/A int capStyle,
0N/A int joinStyle,
2638N/A float miterLimit,
2638N/A float m00, float m01, float m10, float m11) {
0N/A this.output = output;
0N/A
2638N/A this.lineWidth2 = lineWidth / 2;
2638N/A this.scaledLineWidth2 = m00 * lineWidth2;
0N/A this.capStyle = capStyle;
0N/A this.joinStyle = joinStyle;
0N/A
2638N/A m00_2_m01_2 = m00*m00 + m01*m01;
2638N/A m10_2_m11_2 = m10*m10 + m11*m11;
2638N/A m00_m10_m01_m11 = m00*m10 + m01*m11;
0N/A
2638N/A this.m00 = m00;
2638N/A this.m01 = m01;
2638N/A this.m10 = m10;
2638N/A this.m11 = m11;
2638N/A det = m00*m11 - m01*m10;
0N/A
2638N/A float limit = miterLimit * lineWidth2 * det;
2638N/A this.miterLimitSq = limit*limit;
0N/A
2638N/A this.numPenSegments = (int)(3.14159f * lineWidth);
2638N/A this.pen_dx = new float[numPenSegments];
2638N/A this.pen_dy = new float[numPenSegments];
2638N/A this.penIncluded = new boolean[numPenSegments];
2638N/A this.join = new float[2*numPenSegments];
0N/A
0N/A for (int i = 0; i < numPenSegments; i++) {
2638N/A double theta = (i * 2.0 * Math.PI)/numPenSegments;
0N/A
0N/A double cos = Math.cos(theta);
0N/A double sin = Math.sin(theta);
2638N/A pen_dx[i] = (float)(lineWidth2 * (m00*cos + m01*sin));
2638N/A pen_dy[i] = (float)(lineWidth2 * (m10*cos + m11*sin));
0N/A }
0N/A
0N/A prev = CLOSE;
0N/A rindex = 0;
0N/A started = false;
0N/A lineToOrigin = false;
0N/A }
0N/A
2638N/A private void computeOffset(float x0, float y0,
2638N/A float x1, float y1, float[] m) {
2638N/A float lx = x1 - x0;
2638N/A float ly = y1 - y0;
0N/A
2638N/A float dx, dy;
0N/A if (m00 > 0 && m00 == m11 && m01 == 0 & m10 == 0) {
2638N/A float ilen = (float)Math.hypot(lx, ly);
0N/A if (ilen == 0) {
0N/A dx = dy = 0;
0N/A } else {
2638N/A dx = (ly * scaledLineWidth2)/ilen;
2638N/A dy = -(lx * scaledLineWidth2)/ilen;
0N/A }
0N/A } else {
0N/A int sdet = (det > 0) ? 1 : -1;
2638N/A float a = ly * m00 - lx * m10;
2638N/A float b = ly * m01 - lx * m11;
2638N/A float dh = (float)Math.hypot(a, b);
2638N/A float div = sdet * lineWidth2/dh;
2638N/A
2638N/A float ddx = ly * m00_2_m01_2 - lx * m00_m10_m01_m11;
2638N/A float ddy = ly * m00_m10_m01_m11 - lx * m10_2_m11_2;
2638N/A dx = ddx*div;
2638N/A dy = ddy*div;
0N/A }
0N/A
0N/A m[0] = dx;
0N/A m[1] = dy;
0N/A }
0N/A
0N/A private void ensureCapacity(int newrindex) {
0N/A if (reverse.length < newrindex) {
2638N/A reverse = java.util.Arrays.copyOf(reverse, 6*reverse.length/5);
0N/A }
0N/A }
0N/A
2638N/A private boolean isCCW(float x0, float y0,
2638N/A float x1, float y1,
2638N/A float x2, float y2) {
2638N/A return (x1 - x0) * (y2 - y1) < (y1 - y0) * (x2 - x1);
0N/A }
0N/A
2638N/A private boolean side(float x, float y,
2638N/A float x0, float y0,
2638N/A float x1, float y1) {
2638N/A return (y0 - y1)*x + (x1 - x0)*y + (x0*y1 - x1*y0) > 0;
0N/A }
0N/A
2638N/A private int computeRoundJoin(float cx, float cy,
2638N/A float xa, float ya,
2638N/A float xb, float yb,
0N/A int side,
0N/A boolean flip,
2638N/A float[] join) {
2638N/A float px, py;
0N/A int ncoords = 0;
0N/A
0N/A boolean centerSide;
0N/A if (side == 0) {
0N/A centerSide = side(cx, cy, xa, ya, xb, yb);
0N/A } else {
2638N/A centerSide = (side == 1);
0N/A }
0N/A for (int i = 0; i < numPenSegments; i++) {
0N/A px = cx + pen_dx[i];
0N/A py = cy + pen_dy[i];
0N/A
0N/A boolean penSide = side(px, py, xa, ya, xb, yb);
2638N/A penIncluded[i] = (penSide != centerSide);
0N/A }
0N/A
0N/A int start = -1, end = -1;
0N/A for (int i = 0; i < numPenSegments; i++) {
0N/A if (penIncluded[i] &&
0N/A !penIncluded[(i + numPenSegments - 1) % numPenSegments]) {
0N/A start = i;
0N/A }
0N/A if (penIncluded[i] &&
0N/A !penIncluded[(i + 1) % numPenSegments]) {
0N/A end = i;
0N/A }
0N/A }
0N/A
0N/A if (end < start) {
0N/A end += numPenSegments;
0N/A }
0N/A
0N/A if (start != -1 && end != -1) {
2638N/A float dxa = cx + pen_dx[start] - xa;
2638N/A float dya = cy + pen_dy[start] - ya;
2638N/A float dxb = cx + pen_dx[start] - xb;
2638N/A float dyb = cy + pen_dy[start] - yb;
0N/A
0N/A boolean rev = (dxa*dxa + dya*dya > dxb*dxb + dyb*dyb);
0N/A int i = rev ? end : start;
0N/A int incr = rev ? -1 : 1;
0N/A while (true) {
0N/A int idx = i % numPenSegments;
0N/A px = cx + pen_dx[idx];
0N/A py = cy + pen_dy[idx];
0N/A join[ncoords++] = px;
0N/A join[ncoords++] = py;
0N/A if (i == (rev ? start : end)) {
0N/A break;
0N/A }
0N/A i += incr;
0N/A }
0N/A }
0N/A
0N/A return ncoords/2;
0N/A }
0N/A
2638N/A // pisces used to use fixed point arithmetic with 16 decimal digits. I
2638N/A // didn't want to change the values of the constants below when I converted
2638N/A // it to floating point, so that's why the divisions by 2^16 are there.
2638N/A private static final float ROUND_JOIN_THRESHOLD = 1000/65536f;
2638N/A private static final float ROUND_JOIN_INTERNAL_THRESHOLD = 1000000000/65536f;
0N/A
2638N/A private void drawRoundJoin(float x, float y,
2638N/A float omx, float omy, float mx, float my,
0N/A int side,
0N/A boolean flip,
0N/A boolean rev,
2638N/A float threshold) {
0N/A if ((omx == 0 && omy == 0) || (mx == 0 && my == 0)) {
0N/A return;
0N/A }
0N/A
2638N/A float domx = omx - mx;
2638N/A float domy = omy - my;
2638N/A float len = domx*domx + domy*domy;
0N/A if (len < threshold) {
0N/A return;
0N/A }
0N/A
0N/A if (rev) {
0N/A omx = -omx;
0N/A omy = -omy;
0N/A mx = -mx;
0N/A my = -my;
0N/A }
0N/A
2638N/A float bx0 = x + omx;
2638N/A float by0 = y + omy;
2638N/A float bx1 = x + mx;
2638N/A float by1 = y + my;
0N/A
0N/A int npoints = computeRoundJoin(x, y,
0N/A bx0, by0, bx1, by1, side, flip,
0N/A join);
0N/A for (int i = 0; i < npoints; i++) {
0N/A emitLineTo(join[2*i], join[2*i + 1], rev);
0N/A }
0N/A }
0N/A
0N/A // Return the intersection point of the lines (ix0, iy0) -> (ix1, iy1)
0N/A // and (ix0p, iy0p) -> (ix1p, iy1p) in m[0] and m[1]
2638N/A private void computeMiter(float x0, float y0, float x1, float y1,
2638N/A float x0p, float y0p, float x1p, float y1p,
2638N/A float[] m) {
2638N/A float x10 = x1 - x0;
2638N/A float y10 = y1 - y0;
2638N/A float x10p = x1p - x0p;
2638N/A float y10p = y1p - y0p;
0N/A
2638N/A float den = x10*y10p - x10p*y10;
0N/A if (den == 0) {
2638N/A m[0] = x0;
2638N/A m[1] = y0;
0N/A return;
0N/A }
0N/A
2638N/A float t = x1p*(y0 - y0p) - x0*y10p + x0p*(y1p - y0);
2638N/A m[0] = x0 + (t*x10)/den;
2638N/A m[1] = y0 + (t*y10)/den;
0N/A }
0N/A
2638N/A private void drawMiter(float px0, float py0,
2638N/A float x0, float y0,
2638N/A float x1, float y1,
2638N/A float omx, float omy, float mx, float my,
0N/A boolean rev) {
0N/A if (mx == omx && my == omy) {
0N/A return;
0N/A }
0N/A if (px0 == x0 && py0 == y0) {
0N/A return;
0N/A }
0N/A if (x0 == x1 && y0 == y1) {
0N/A return;
0N/A }
0N/A
0N/A if (rev) {
0N/A omx = -omx;
0N/A omy = -omy;
0N/A mx = -mx;
0N/A my = -my;
0N/A }
0N/A
0N/A computeMiter(px0 + omx, py0 + omy, x0 + omx, y0 + omy,
0N/A x0 + mx, y0 + my, x1 + mx, y1 + my,
0N/A miter);
0N/A
0N/A // Compute miter length in untransformed coordinates
2638N/A float dx = miter[0] - x0;
2638N/A float dy = miter[1] - y0;
2638N/A float a = dy*m00 - dx*m10;
2638N/A float b = dy*m01 - dx*m11;
2638N/A float lenSq = a*a + b*b;
0N/A
0N/A if (lenSq < miterLimitSq) {
0N/A emitLineTo(miter[0], miter[1], rev);
0N/A }
0N/A }
0N/A
0N/A
2638N/A public void moveTo(float x0, float y0) {
0N/A // System.out.println("Stroker.moveTo(" + x0/65536.0 + ", " + y0/65536.0 + ")");
0N/A
0N/A if (lineToOrigin) {
0N/A // not closing the path, do the previous lineTo
0N/A lineToImpl(sx0, sy0, joinToOrigin);
0N/A lineToOrigin = false;
0N/A }
0N/A
0N/A if (prev == LINE_TO) {
0N/A finish();
0N/A }
0N/A
0N/A this.sx0 = this.x0 = x0;
0N/A this.sy0 = this.y0 = y0;
0N/A this.rindex = 0;
0N/A this.started = false;
0N/A this.joinSegment = false;
0N/A this.prev = MOVE_TO;
0N/A }
0N/A
0N/A boolean joinSegment = false;
0N/A
0N/A public void lineJoin() {
0N/A // System.out.println("Stroker.lineJoin()");
0N/A this.joinSegment = true;
0N/A }
0N/A
2638N/A public void lineTo(float x1, float y1) {
0N/A // System.out.println("Stroker.lineTo(" + x1/65536.0 + ", " + y1/65536.0 + ")");
0N/A
0N/A if (lineToOrigin) {
0N/A if (x1 == sx0 && y1 == sy0) {
0N/A // staying in the starting point
0N/A return;
0N/A }
0N/A
0N/A // not closing the path, do the previous lineTo
0N/A lineToImpl(sx0, sy0, joinToOrigin);
0N/A lineToOrigin = false;
0N/A } else if (x1 == x0 && y1 == y0) {
0N/A return;
0N/A } else if (x1 == sx0 && y1 == sy0) {
0N/A lineToOrigin = true;
0N/A joinToOrigin = joinSegment;
0N/A joinSegment = false;
0N/A return;
0N/A }
0N/A
0N/A lineToImpl(x1, y1, joinSegment);
0N/A joinSegment = false;
0N/A }
0N/A
2638N/A private void lineToImpl(float x1, float y1, boolean joinSegment) {
0N/A computeOffset(x0, y0, x1, y1, offset);
2638N/A float mx = offset[0];
2638N/A float my = offset[1];
0N/A
0N/A if (!started) {
0N/A emitMoveTo(x0 + mx, y0 + my);
0N/A this.sx1 = x1;
0N/A this.sy1 = y1;
0N/A this.mx0 = mx;
0N/A this.my0 = my;
0N/A started = true;
0N/A } else {
0N/A boolean ccw = isCCW(px0, py0, x0, y0, x1, y1);
0N/A if (joinSegment) {
0N/A if (joinStyle == JOIN_MITER) {
0N/A drawMiter(px0, py0, x0, y0, x1, y1, omx, omy, mx, my,
0N/A ccw);
0N/A } else if (joinStyle == JOIN_ROUND) {
0N/A drawRoundJoin(x0, y0,
0N/A omx, omy,
0N/A mx, my, 0, false, ccw,
0N/A ROUND_JOIN_THRESHOLD);
0N/A }
0N/A } else {
0N/A // Draw internal joins as round
0N/A drawRoundJoin(x0, y0,
0N/A omx, omy,
0N/A mx, my, 0, false, ccw,
0N/A ROUND_JOIN_INTERNAL_THRESHOLD);
0N/A }
0N/A
0N/A emitLineTo(x0, y0, !ccw);
0N/A }
0N/A
0N/A emitLineTo(x0 + mx, y0 + my, false);
0N/A emitLineTo(x1 + mx, y1 + my, false);
0N/A
0N/A emitLineTo(x0 - mx, y0 - my, true);
0N/A emitLineTo(x1 - mx, y1 - my, true);
0N/A
0N/A this.omx = mx;
0N/A this.omy = my;
0N/A this.px0 = x0;
0N/A this.py0 = y0;
0N/A this.x0 = x1;
0N/A this.y0 = y1;
0N/A this.prev = LINE_TO;
0N/A }
0N/A
0N/A public void close() {
0N/A // System.out.println("Stroker.close()");
0N/A
0N/A if (lineToOrigin) {
0N/A // ignore the previous lineTo
0N/A lineToOrigin = false;
0N/A }
0N/A
0N/A if (!started) {
0N/A finish();
0N/A return;
0N/A }
0N/A
0N/A computeOffset(x0, y0, sx0, sy0, offset);
2638N/A float mx = offset[0];
2638N/A float my = offset[1];
0N/A
0N/A // Draw penultimate join
0N/A boolean ccw = isCCW(px0, py0, x0, y0, sx0, sy0);
0N/A if (joinSegment) {
0N/A if (joinStyle == JOIN_MITER) {
0N/A drawMiter(px0, py0, x0, y0, sx0, sy0, omx, omy, mx, my, ccw);
0N/A } else if (joinStyle == JOIN_ROUND) {
0N/A drawRoundJoin(x0, y0, omx, omy, mx, my, 0, false, ccw,
0N/A ROUND_JOIN_THRESHOLD);
0N/A }
0N/A } else {
0N/A // Draw internal joins as round
0N/A drawRoundJoin(x0, y0,
0N/A omx, omy,
0N/A mx, my, 0, false, ccw,
0N/A ROUND_JOIN_INTERNAL_THRESHOLD);
0N/A }
0N/A
0N/A emitLineTo(x0 + mx, y0 + my);
0N/A emitLineTo(sx0 + mx, sy0 + my);
0N/A
0N/A ccw = isCCW(x0, y0, sx0, sy0, sx1, sy1);
0N/A
0N/A // Draw final join on the outside
0N/A if (!ccw) {
0N/A if (joinStyle == JOIN_MITER) {
0N/A drawMiter(x0, y0, sx0, sy0, sx1, sy1,
0N/A mx, my, mx0, my0, false);
0N/A } else if (joinStyle == JOIN_ROUND) {
0N/A drawRoundJoin(sx0, sy0, mx, my, mx0, my0, 0, false, false,
0N/A ROUND_JOIN_THRESHOLD);
0N/A }
0N/A }
0N/A
0N/A emitLineTo(sx0 + mx0, sy0 + my0);
0N/A emitLineTo(sx0 - mx0, sy0 - my0); // same as reverse[0], reverse[1]
0N/A
0N/A // Draw final join on the inside
0N/A if (ccw) {
0N/A if (joinStyle == JOIN_MITER) {
0N/A drawMiter(x0, y0, sx0, sy0, sx1, sy1,
0N/A -mx, -my, -mx0, -my0, false);
0N/A } else if (joinStyle == JOIN_ROUND) {
0N/A drawRoundJoin(sx0, sy0, -mx, -my, -mx0, -my0, 0,
0N/A true, false,
0N/A ROUND_JOIN_THRESHOLD);
0N/A }
0N/A }
0N/A
0N/A emitLineTo(sx0 - mx, sy0 - my);
0N/A emitLineTo(x0 - mx, y0 - my);
0N/A for (int i = rindex - 2; i >= 0; i -= 2) {
0N/A emitLineTo(reverse[i], reverse[i + 1]);
0N/A }
0N/A
0N/A this.x0 = this.sx0;
0N/A this.y0 = this.sy0;
0N/A this.rindex = 0;
0N/A this.started = false;
0N/A this.joinSegment = false;
0N/A this.prev = CLOSE;
0N/A emitClose();
0N/A }
0N/A
0N/A public void end() {
0N/A // System.out.println("Stroker.end()");
0N/A
0N/A if (lineToOrigin) {
0N/A // not closing the path, do the previous lineTo
0N/A lineToImpl(sx0, sy0, joinToOrigin);
0N/A lineToOrigin = false;
0N/A }
0N/A
0N/A if (prev == LINE_TO) {
0N/A finish();
0N/A }
0N/A
0N/A output.end();
0N/A this.joinSegment = false;
0N/A this.prev = MOVE_TO;
0N/A }
0N/A
2638N/A double userSpaceLineLength(double dx, double dy) {
2638N/A double a = (dy*m00 - dx*m10)/det;
2638N/A double b = (dy*m01 - dx*m11)/det;
2638N/A return Math.hypot(a, b);
0N/A }
0N/A
0N/A private void finish() {
0N/A if (capStyle == CAP_ROUND) {
0N/A drawRoundJoin(x0, y0,
0N/A omx, omy, -omx, -omy, 1, false, false,
0N/A ROUND_JOIN_THRESHOLD);
0N/A } else if (capStyle == CAP_SQUARE) {
2638N/A float dx = px0 - x0;
2638N/A float dy = py0 - y0;
2638N/A float len = (float)userSpaceLineLength(dx, dy);
2638N/A float s = lineWidth2/len;
0N/A
2638N/A float capx = x0 - dx*s;
2638N/A float capy = y0 - dy*s;
0N/A
0N/A emitLineTo(capx + omx, capy + omy);
0N/A emitLineTo(capx - omx, capy - omy);
0N/A }
0N/A
0N/A for (int i = rindex - 2; i >= 0; i -= 2) {
0N/A emitLineTo(reverse[i], reverse[i + 1]);
0N/A }
0N/A this.rindex = 0;
0N/A
0N/A if (capStyle == CAP_ROUND) {
0N/A drawRoundJoin(sx0, sy0,
0N/A -mx0, -my0, mx0, my0, 1, false, false,
0N/A ROUND_JOIN_THRESHOLD);
0N/A } else if (capStyle == CAP_SQUARE) {
2638N/A float dx = sx1 - sx0;
2638N/A float dy = sy1 - sy0;
2638N/A float len = (float)userSpaceLineLength(dx, dy);
2638N/A float s = lineWidth2/len;
0N/A
2638N/A float capx = sx0 - dx*s;
2638N/A float capy = sy0 - dy*s;
0N/A
0N/A emitLineTo(capx - mx0, capy - my0);
0N/A emitLineTo(capx + mx0, capy + my0);
0N/A }
0N/A
0N/A emitClose();
0N/A this.joinSegment = false;
0N/A }
0N/A
2638N/A private void emitMoveTo(float x0, float y0) {
0N/A // System.out.println("Stroker.emitMoveTo(" + x0/65536.0 + ", " + y0/65536.0 + ")");
0N/A output.moveTo(x0, y0);
0N/A }
0N/A
2638N/A private void emitLineTo(float x1, float y1) {
0N/A // System.out.println("Stroker.emitLineTo(" + x0/65536.0 + ", " + y0/65536.0 + ")");
0N/A output.lineTo(x1, y1);
0N/A }
0N/A
2638N/A private void emitLineTo(float x1, float y1, boolean rev) {
0N/A if (rev) {
0N/A ensureCapacity(rindex + 2);
0N/A reverse[rindex++] = x1;
0N/A reverse[rindex++] = y1;
0N/A } else {
0N/A emitLineTo(x1, y1);
0N/A }
0N/A }
0N/A
0N/A private void emitClose() {
0N/A // System.out.println("Stroker.emitClose()");
0N/A output.close();
0N/A }
0N/A}
2638N/A