Esempio n. 1
0
        public virtual void HasCurve() 
		{
            GraphicsPath path = new GraphicsPath ();

			GraphicsPathIterator iterator = new GraphicsPathIterator (path);
			Assert.IsFalse (iterator.HasCurve ());

			path.AddLine (new Point (100, 100), new Point (400, 100));
			path.AddLine (new Point (400, 200), new Point (10, 100));

			iterator = new GraphicsPathIterator (path);
			Assert.IsFalse (iterator.HasCurve ());

			path.StartFigure ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.StartFigure ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));

			path.StartFigure ();
			path.AddLine (new Point (400, 400), new Point (400, 10));

			iterator = new GraphicsPathIterator (path);
			Assert.IsTrue (iterator.HasCurve ());
        }
        ///<summary>
        /// Extracts the points of the paths in a flat {@link PathIterator} into
        /// a list of Coordinate arrays.
        ///</summary>
        /// <param name="pathIt">A path iterator</param>
        /// <returns>A list of coordinate arrays</returns>
        /// <exception cref="ArgumentException">If a non-linear segment type is encountered</exception>
        public static IList<Coordinate[]> ToCoordinates(GraphicsPathIterator pathIt)
        {
            if (pathIt.HasCurve())
                throw new ArgumentException("Path must not have non-linear segments");

            var coordArrays = new List<Coordinate[]>();
            int startIndex, endIndex;
            bool isClosed;

            while (pathIt.NextSubpath(out startIndex, out endIndex, out isClosed) > 0)
            {
                Coordinate[] pts = NextCoordinateArray(pathIt, startIndex, endIndex, isClosed);
                coordArrays.Add(pts);
                if (endIndex == pathIt.Count - 1) break;

            }
            return coordArrays;
        }