Example #1
0
        /**
         * Closes the current subpath.
         */
        public virtual void CloseSubpath()
        {
            Subpath lastSubpath = this.LastSubpath;

            lastSubpath.Closed = true;

            Point2D startPoint = lastSubpath.GetStartPoint();

            MoveTo((float)startPoint.GetX(), (float)startPoint.GetY());
        }
Example #2
0
        /**
         * Begins a new subpath by moving the current point to coordinates <CODE>(x, y)</CODE>.
         */
        public virtual void MoveTo(float x, float y)
        {
            currentPoint = new Point2D.Float(x, y);
            Subpath lastSubpath = this.LastSubpath;

            if (lastSubpath != null && lastSubpath.IsSinglePointOpen())
            {
                lastSubpath.SetStartPoint(currentPoint);
            }
            else
            {
                subpaths.Add(new Subpath(currentPoint));
            }
        }
Example #3
0
 /**
  * Copy constuctor.
  * @param subpath
  */
 public Subpath(Subpath subpath)
 {
     this.startPoint = subpath.startPoint;
     Util.AddAll(this.segments, subpath.GetSegments());
     this.closed = subpath.closed;
 }
Example #4
0
 /**
  * Adds the subpath to this path.
  *
  * @param subpath The subpath to be added to this path.
  */
 public void AddSubpath(Subpath subpath)
 {
     subpaths.Add(subpath);
     currentPoint = subpath.GetLastPoint();
 }
        private static Subpath ConstructSquare(Point2D squareCenter, double widthHalf, double rotationAngle) {
            // Orthogonal square is the square with sides parallel to one of the axes.
            Point2D[] ortogonalSquareVertices = {
                new Point2D.Double(-widthHalf, -widthHalf),
                new Point2D.Double(-widthHalf, widthHalf),
                new Point2D.Double(widthHalf, widthHalf),
                new Point2D.Double(widthHalf, -widthHalf)
        };

            Point2D[] rotatedSquareVertices = GetRotatedSquareVertices(ortogonalSquareVertices, rotationAngle, squareCenter);

            Subpath square = new Subpath();
            square.AddSegment(new Line(rotatedSquareVertices[0], rotatedSquareVertices[1]));
            square.AddSegment(new Line(rotatedSquareVertices[1], rotatedSquareVertices[2]));
            square.AddSegment(new Line(rotatedSquareVertices[2], rotatedSquareVertices[3]));
            square.AddSegment(new Line(rotatedSquareVertices[3], rotatedSquareVertices[0]));

            return square;
        }
        /**
     * Converts specified degenerate subpaths to circles.
     * Note: actually the resultant subpaths are not real circles but approximated.
     *
     * @param radius Radius of each constructed circle.
     * @return {@link java.util.List} consisting of circles constructed on given degenerated subpaths.
     */
        private static IList<Subpath> ConvertToCircles(IList<Subpath> degenerateSubpaths, double radius) {
            IList<Subpath> circles = new List<Subpath>(degenerateSubpaths.Count);

            foreach (Subpath subpath in degenerateSubpaths) {
                BezierCurve[] circleSectors = ApproximateCircle(subpath.GetStartPoint(), radius);

                Subpath circle = new Subpath();
                circle.AddSegment(circleSectors[0]);
                circle.AddSegment(circleSectors[1]);
                circle.AddSegment(circleSectors[2]);
                circle.AddSegment(circleSectors[3]);

                circles.Add(circle);
            }

            return circles;
        }
Example #7
0
 /**
  * Adds the subpath to this path.
  *
  * @param subpath The subpath to be added to this path.
  */
 public void AddSubpath(Subpath subpath) {
     subpaths.Add(subpath);
     currentPoint = subpath.GetLastPoint();
 }
Example #8
0
 /**
  * Copy constuctor.
  * @param subpath
  */
 public Subpath(Subpath subpath) {
     this.startPoint = subpath.startPoint;
     Util.AddAll(this.segments, subpath.GetSegments());
     this.closed = subpath.closed;
 }