コード例 #1
0
 public void setCurve(QuadCurve2D curve)
 {
     setCurve(
         curve.getX1(), curve.getY1(),
         curve.getCtrlX(), curve.getCtrlY(),
         curve.getX2(), curve.getY2());
 }
コード例 #2
0
 public static void subdivide(QuadCurve2D src, QuadCurve2D left, QuadCurve2D right)
 {
     double x1 = src.getX1();
     double y1 = src.getY1();
     double cx = src.getCtrlX();
     double cy = src.getCtrlY();
     double x2 = src.getX2();
     double y2 = src.getY2();
     double cx1 = (x1 + cx) / 2.0;
     double cy1 = (y1 + cy) / 2.0;
     double cx2 = (x2 + cx) / 2.0;
     double cy2 = (y2 + cy) / 2.0;
     cx = (cx1 + cx2) / 2.0;
     cy = (cy1 + cy2) / 2.0;
     if (left != null) {
     left.setCurve(x1, y1, cx1, cy1, cx, cy);
     }
     if (right != null) {
     right.setCurve(cx, cy, cx2, cy2, x2, y2);
     }
 }
コード例 #3
0
        public static void subdivide(QuadCurve2D src, QuadCurve2D left, QuadCurve2D right)
        {
            double x1  = src.getX1();
            double y1  = src.getY1();
            double cx  = src.getCtrlX();
            double cy  = src.getCtrlY();
            double x2  = src.getX2();
            double y2  = src.getY2();
            double cx1 = (x1 + cx) / 2.0;
            double cy1 = (y1 + cy) / 2.0;
            double cx2 = (x2 + cx) / 2.0;
            double cy2 = (y2 + cy) / 2.0;

            cx = (cx1 + cx2) / 2.0;
            cy = (cy1 + cy2) / 2.0;
            if (left != null)
            {
                left.setCurve(x1, y1, cx1, cy1, cx, cy);
            }
            if (right != null)
            {
                right.setCurve(cx, cy, cx2, cy2, x2, y2);
            }
        }
コード例 #4
0
 public void subdivide(QuadCurve2D left, QuadCurve2D right)
 {
     subdivide(this, left, right);
 }
コード例 #5
0
 /*
  * Constructs a new QuadCurve2D.Iterator for given line and transformation
  * @param q - the source QuadCurve2D object
  * @param at - the AffineTransform object to apply rectangle path
  */
 internal Iterator(QuadCurve2D q, AffineTransform t)
 {
     this.c = q;
     this.t = t;
 }
コード例 #6
0
        /*
         * Calculates flat path points for current segment of the source shape.
         *
         * Line segment is flat by itself. Flatness of quad and cubic curves evaluated by getFlatnessSq() method.
         * Curves subdivided until current flatness is bigger than user defined and subdivision limit isn't exhausted.
         * Single source segment translated to series of buffer points. The less flatness the bigger serries.
         * Every currentSegment() call extract one point from the buffer. When series completed evaluate() takes next source shape segment.
         */
        void evaluate()
        {
            if (bufEmpty)
            {
                bufType = p.currentSegment(coords);
            }

            switch (bufType)
            {
            case PathIteratorConstants.SEG_MOVETO:
            case PathIteratorConstants.SEG_LINETO:
                px = coords[0];
                py = coords[1];
                break;

            case PathIteratorConstants.SEG_QUADTO:
                if (bufEmpty)
                {
                    bufIndex         -= 6;
                    buf[bufIndex + 0] = px;
                    buf[bufIndex + 1] = py;
                    java.lang.SystemJ.arraycopy(coords, 0, buf, bufIndex + 2, 4);
                    bufSubdiv = 0;
                }

                while (bufSubdiv < bufLimit)
                {
                    if (QuadCurve2D.getFlatnessSq(buf, bufIndex) < flatness2)
                    {
                        break;
                    }

                    // Realloc buffer
                    if (bufIndex <= 4)
                    {
                        double[] tmp = new double[bufSize + BUFFER_CAPACITY];
                        java.lang.SystemJ.arraycopy(
                            buf, bufIndex,
                            tmp, bufIndex + BUFFER_CAPACITY,
                            bufSize - bufIndex);
                        buf       = tmp;
                        bufSize  += BUFFER_CAPACITY;
                        bufIndex += BUFFER_CAPACITY;
                    }

                    QuadCurve2D.subdivide(buf, bufIndex, buf, bufIndex - 4, buf, bufIndex);

                    bufIndex -= 4;
                    bufSubdiv++;
                }

                bufIndex += 4;
                px        = buf[bufIndex];
                py        = buf[bufIndex + 1];

                bufEmpty = (bufIndex == bufSize - 2);
                if (bufEmpty)
                {
                    bufIndex = bufSize;
                    bufType  = PathIteratorConstants.SEG_LINETO;
                }
                break;

            case PathIteratorConstants.SEG_CUBICTO:
                if (bufEmpty)
                {
                    bufIndex         -= 8;
                    buf[bufIndex + 0] = px;
                    buf[bufIndex + 1] = py;
                    java.lang.SystemJ.arraycopy(coords, 0, buf, bufIndex + 2, 6);
                    bufSubdiv = 0;
                }

                while (bufSubdiv < bufLimit)
                {
                    if (CubicCurve2D.getFlatnessSq(buf, bufIndex) < flatness2)
                    {
                        break;
                    }

                    // Realloc buffer
                    if (bufIndex <= 6)
                    {
                        double [] tmp = new double[bufSize + BUFFER_CAPACITY];
                        java.lang.SystemJ.arraycopy(
                            buf, bufIndex,
                            tmp, bufIndex + BUFFER_CAPACITY,
                            bufSize - bufIndex);
                        buf       = tmp;
                        bufSize  += BUFFER_CAPACITY;
                        bufIndex += BUFFER_CAPACITY;
                    }

                    CubicCurve2D.subdivide(buf, bufIndex, buf, bufIndex - 6, buf, bufIndex);

                    bufIndex -= 6;
                    bufSubdiv++;
                }

                bufIndex += 6;
                px        = buf[bufIndex];
                py        = buf[bufIndex + 1];

                bufEmpty = (bufIndex == bufSize - 2);
                if (bufEmpty)
                {
                    bufIndex = bufSize;
                    bufType  = PathIteratorConstants.SEG_LINETO;
                }
                break;
            }
        }
コード例 #7
0
 /**
  * Constructs a new QuadCurve2D.Iterator for given line and transformation
  * @param q - the source QuadCurve2D object
  * @param at - the AffineTransform object to apply rectangle path
  */
 internal Iterator(QuadCurve2D q, AffineTransform t)
 {
     this.c = q;
     this.t = t;
 }
コード例 #8
0
 public void subdivide(QuadCurve2D left, QuadCurve2D right)
 {
     subdivide(this, left, right);
 }
コード例 #9
0
 public void setCurve(QuadCurve2D curve)
 {
     setCurve(
         curve.getX1(), curve.getY1(),
         curve.getCtrlX(), curve.getCtrlY(),
         curve.getX2(), curve.getY2());
 }