public void CloseAllFigures()
        {
            ExtendedGeneralPath p  = new ExtendedGeneralPath();
            PathIterator        pi = NativeObject.getPathIterator(null);
            JPI lastSeg            = JPI.SEG_CLOSE;

            float [] points = new float[6];

            p.setWindingRule(pi.getWindingRule());
            while (!pi.isDone())
            {
                JPI curSeg = (JPI)pi.currentSegment(points);
                switch (curSeg)
                {
                case JPI.SEG_CLOSE:
                    p.closePath();
                    break;

                case JPI.SEG_MOVETO:
                    if (lastSeg != JPI.SEG_CLOSE)
                    {
                        p.closePath();
                    }
                    p.moveTo(points[0], points[1]);
                    break;

                case JPI.SEG_LINETO:
                    p.lineTo(points[0], points[1]);
                    break;

                case JPI.SEG_QUADTO:
                    p.quadTo(points[0], points[1], points[2], points[3]);
                    break;

                case JPI.SEG_CUBICTO:
                    p.curveTo(points[0], points[1], points[2], points[3], points[4], points[5]);
                    break;

                default:
                    break;
                }
                lastSeg = curSeg;
                pi.next();
            }

            p.closePath();
            Shape = p;
        }
Пример #2
0
        public void append(PathIterator path, bool connect)
        {
            while (!path.isDone())
            {
                float[] coords = new float[6];
                switch (path.currentSegment(coords))
                {
                case PathIteratorConstants.SEG_MOVETO:
                    if (!connect || typeSize == 0)
                    {
                        moveTo(coords[0], coords[1]);
                        break;
                    }
                    if (types[typeSize - 1] != PathIteratorConstants.SEG_CLOSE &&
                        points[pointSize - 2] == coords[0] &&
                        points[pointSize - 1] == coords[1])
                    {
                        break;
                    }
                    // NO BREAK;
                    lineTo(coords[0], coords[1]);
                    break;

                case PathIteratorConstants.SEG_LINETO:
                    lineTo(coords[0], coords[1]);
                    break;

                case PathIteratorConstants.SEG_QUADTO:
                    quadTo(coords[0], coords[1], coords[2], coords[3]);
                    break;

                case PathIteratorConstants.SEG_CUBICTO:
                    curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
                    break;

                case PathIteratorConstants.SEG_CLOSE:
                    closePath();
                    break;
                }
                path.next();
                connect = false;
            }
        }
Пример #3
0
        public void append(PathIterator pi, bool connect)
        {
            ClearCache();
            float [] coords = new float [6];
            while (!pi.isDone())
            {
                switch (pi.currentSegment(coords))
                {
                case SEG_MOVETO:
                    if (!connect || _typesCount < 1 || _coordsCount < 2)
                    {
                        moveTo(coords [0], coords [1]);
                        break;
                    }
                    if (_types [_typesCount - 1] != SEG_CLOSE &&
                        _coords [_coordsCount - 2] == coords [0] &&
                        _coords [_coordsCount - 1] == coords [1])
                    {
                        break;
                    }
                    goto case SEG_LINETO;

                case SEG_LINETO:
                    lineTo(coords [0], coords [1]);
                    break;

                case SEG_QUADTO:
                    quadTo(coords [0], coords [1], coords [2], coords [3]);
                    break;

                case SEG_CUBICTO:
                    curveTo(coords [0], coords [1], coords [2], coords [3], coords [4], coords [5]);
                    break;

                case SEG_CLOSE:
                    closePath();
                    break;
                }
                pi.next();
                connect = false;
            }
        }
Пример #4
0
        /**
         * Returns a <code>Shape</code> whose interior defines the
         * stroked outline of a specified <code>Shape</code>.
         * @param s the <code>Shape</code> boundary be stroked
         * @return the <code>Shape</code> of the stroked outline.
         */
        public Shape createStrokedShape(Shape s)
        {
            FillAdapter  filler  = new FillAdapter();
            PathStroker  stroker = new PathStroker(filler);
            PathConsumer consumer;

            stroker.setPenDiameter(width);
            switch (_penFit)
            {
            case PenFit.Thin:
                stroker.setPenFitting(PenUnits, MinPenUnits);
                break;

            case PenFit.ThinAntiAlias:
                stroker.setPenFitting(PenUnits, MinPenUnitsAA);
                break;
            }

            float[] t4 = null;
            if (PenTransform != null && !PenTransform.isIdentity() && (PenTransform.getDeterminant() > 1e-25))
            {
                t4 = new float[] {
                    (float)PenTransform.getScaleX(), (float)PenTransform.getShearY(),
                    (float)PenTransform.getShearX(), (float)PenTransform.getScaleY()
                };
            }

            float[] t6 = null;
            if (OutputTransform != null && !OutputTransform.isIdentity())
            {
                t6 = new float[] {
                    (float)OutputTransform.getScaleX(), (float)OutputTransform.getShearY(),
                    (float)OutputTransform.getShearX(), (float)OutputTransform.getScaleY(),
                    (float)OutputTransform.getTranslateX(), (float)OutputTransform.getTranslateY()
                };
            }

            stroker.setPenT4(t4);
            stroker.setOutputT6(t6);
            stroker.setCaps(RasterizerCaps[cap]);
            stroker.setCorners(RasterizerCorners[join], miterlimit);
            if (dash != null)
            {
                PathDasher dasher = new PathDasher(stroker);
                dasher.setDash(dash, dash_phase);
                dasher.setDashT4(t4);
                consumer = dasher;
            }
            else
            {
                consumer = stroker;
            }

            PathIterator pi = s.getPathIterator(null);

            try {
                consumer.beginPath();
                bool    pathClosed = false;
                float   mx         = 0.0f;
                float   my         = 0.0f;
                float[] point      = new float[6];

                while (!pi.isDone())
                {
                    int type = pi.currentSegment(point);
                    if (pathClosed == true)
                    {
                        pathClosed = false;
                        if (type != PathIterator__Finals.SEG_MOVETO)
                        {
                            // Force current point back to last moveto point
                            consumer.beginSubpath(mx, my);
                        }
                    }
                    switch ((GraphicsPath.JPI)type)
                    {
                    case GraphicsPath.JPI.SEG_MOVETO:
                        mx = point[0];
                        my = point[1];
                        consumer.beginSubpath(point[0], point[1]);
                        break;

                    case GraphicsPath.JPI.SEG_LINETO:
                        consumer.appendLine(point[0], point[1]);
                        break;

                    case GraphicsPath.JPI.SEG_QUADTO:
                        // Quadratic curves take two points
                        consumer.appendQuadratic(point[0], point[1],
                                                 point[2], point[3]);
                        break;

                    case GraphicsPath.JPI.SEG_CUBICTO:
                        // Cubic curves take three points
                        consumer.appendCubic(point[0], point[1],
                                             point[2], point[3],
                                             point[4], point[5]);
                        break;

                    case GraphicsPath.JPI.SEG_CLOSE:
                        consumer.closedSubpath();
                        pathClosed = true;
                        break;
                    }
                    pi.next();
                }

                consumer.endPath();
            } catch (PathException e) {
                throw new InternalError("Unable to Stroke shape (" +
                                        e.Message + ")");
            }

            return(filler.getShape());
        }
		public void append(PathIterator pi, bool connect) 
		{
			ClearCache ();
			float [] coords = new float [6];
			while (!pi.isDone ()) {
				switch (pi.currentSegment (coords)) {
					case SEG_MOVETO:
						if (!connect || _typesCount < 1 || _coordsCount < 2) {
							moveTo (coords [0], coords [1]);
							break;
						}
						if (_types [_typesCount - 1] != SEG_CLOSE &&
							_coords [_coordsCount - 2] == coords [0] &&
							_coords [_coordsCount - 1] == coords [1])
							break;	
						goto case SEG_LINETO;
					case SEG_LINETO:
						lineTo (coords [0], coords [1]);
						break;
					case SEG_QUADTO:
						quadTo (coords [0], coords [1], coords [2], coords [3]);
						break;
					case SEG_CUBICTO:
						curveTo (coords [0], coords [1], coords [2], coords [3], coords [4], coords [5]);
						break;
					case SEG_CLOSE:
						closePath ();
					break;
				}
				pi.next	();
				connect = false;
			}
		}
Пример #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;
            }
        }
 public void append(PathIterator path, bool connect)
 {
     while (!path.isDone()) {
     float[] coords = new float[6];
     switch (path.currentSegment(coords)) {
     case PathIteratorConstants.SEG_MOVETO:
         if (!connect || typeSize == 0) {
             moveTo(coords[0], coords[1]);
             break;
         }
         if (types[typeSize - 1] != PathIteratorConstants.SEG_CLOSE &&
             points[pointSize - 2] == coords[0] &&
             points[pointSize - 1] == coords[1])
         {
             break;
         }
     // NO BREAK;
         lineTo(coords[0], coords[1]);
         break;
     case PathIteratorConstants.SEG_LINETO:
         lineTo(coords[0], coords[1]);
         break;
     case PathIteratorConstants.SEG_QUADTO:
         quadTo(coords[0], coords[1], coords[2], coords[3]);
         break;
     case PathIteratorConstants.SEG_CUBICTO:
         curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
         break;
     case PathIteratorConstants.SEG_CLOSE:
         closePath();
         break;
     }
     path.next();
     connect = false;
     }
 }