public override PathMatch Matches(PathDefinitionIterator definitionSteps, PathIterator step) { InvocationCount++; DefinitionIterator = definitionSteps; PathIterator = step; return(Result); }
public ExtendedGeneralPath(Shape s) : this(WIND_NON_ZERO, INIT_SIZE, INIT_SIZE) { PathIterator pi = s.getPathIterator(null); setWindingRule(pi.getWindingRule()); append(pi, false); }
public void ReadAllConsumesPath() { var eater = new PathIterator("/foo//bar////baz"); Assert.AreEqual("foo/bar/baz", eater.ReadAll()); Assert.IsTrue(eater.IsAtEnd); }
public FlatteningPathIterator(PathIterator path, double flatness, int limit) { if (flatness < 0.0) { // awt.206=Flatness is less then zero throw new java.lang.IllegalArgumentException("Flatness is less then zero"); //$NON-NLS-1$ } if (limit < 0) { // awt.207=Limit is less then zero throw new java.lang.IllegalArgumentException("Limit is less then zero"); //$NON-NLS-1$ } if (path == null) { // awt.208=Path is null throw new java.lang.NullPointerException("Path is null"); //$NON-NLS-1$ } this.p = path; this.flatness = flatness; this.flatness2 = flatness * flatness; this.bufLimit = limit; this.bufSize = java.lang.Math.min(bufLimit, BUFFER_SIZE); this.buf = new double[bufSize]; this.bufIndex = bufSize; }
public void ConsumeEmptyTest() { var eater = new PathIterator(""); Assert.AreEqual("", eater.Next()); Assert.IsTrue(eater.IsAtEnd); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 15JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Strokes the outline of a IShape using the settings of the current * Graphics2D context. * @param brush the brush used to fill the shape. * @param shape the IShape to be rendered. */ public void Fill(Brush brush, IShape shape) { if (brush != null) { _graphicsFP.SetBrush(brush._wrappedBrushFP); _defaultBrush = brush; } PathIterator pathIterator = shape.GetPathIterator(null); int[] coords = new int[6]; GraphicsPathFP graphicsPathFP = new GraphicsPathFP(); PointFP pointFP1 = new PointFP(); PointFP pointFPCtl1 = new PointFP(); PointFP pointFPCtl2 = new PointFP(); while (!pathIterator.IsDone()) { int type = pathIterator.CurrentSegment(coords); switch (type) { case PathIterator.SEG_MOVETO: pointFP1.Reset(coords[0] << SingleFP.DECIMAL_BITS, coords[1] << SingleFP.DECIMAL_BITS); graphicsPathFP.AddMoveTo(pointFP1); break; case PathIterator.SEG_CLOSE: graphicsPathFP.AddClose(); break; case PathIterator.SEG_LINETO: pointFP1.Reset(coords[0] << SingleFP.DECIMAL_BITS, coords[1] << SingleFP.DECIMAL_BITS); graphicsPathFP.AddLineTo(pointFP1); break; case PathIterator.SEG_QUADTO: pointFPCtl1.Reset(coords[0] << SingleFP.DECIMAL_BITS, coords[1] << SingleFP.DECIMAL_BITS); pointFP1.Reset(coords[2] << SingleFP.DECIMAL_BITS, coords[3] << SingleFP.DECIMAL_BITS); graphicsPathFP.AddQuadTo(pointFPCtl1, pointFP1); break; case PathIterator.SEG_CUBICTO: pointFPCtl1.Reset(coords[0] << SingleFP.DECIMAL_BITS, coords[1] << SingleFP.DECIMAL_BITS); pointFPCtl2.Reset(coords[2] << SingleFP.DECIMAL_BITS, coords[3] << SingleFP.DECIMAL_BITS); pointFP1.Reset(coords[4] << SingleFP.DECIMAL_BITS, coords[5] << SingleFP.DECIMAL_BITS); graphicsPathFP.AddCurveTo(pointFPCtl1, pointFPCtl2, pointFP1); break; } pathIterator.Next(); } _graphicsFP.FillPath(graphicsPathFP); }
private GeneralPath GetGeneralPath() { PathIterator iter = getPathIterator(null); GeneralPath path = new GeneralPath(); path.append(iter, false); return(path); }
public PathMatch MatchesNext(PathIterator step) { var nextDefinitionStep = HasStep ? Current : PathTerminationStep.Instance; return(nextDefinitionStep.Matches(MoveNext(), step)); }
public GeneralPath(Shape shape) : this(WIND_NON_ZERO, BUFFER_SIZE) { PathIterator p = shape.getPathIterator(null); setWindingRule(p.getWindingRule()); append(p, false); }
public void ConsumeTest() { var eater = new PathIterator("foo/bar/baz"); Assert.AreEqual("foo", eater.Next()); Assert.IsFalse(eater.IsAtEnd); Assert.AreEqual("bar", eater.Next()); Assert.AreEqual("baz", eater.Next()); Assert.IsTrue(eater.IsAtEnd); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 15JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Strokes the outline of a IShape using the settings of the current * Graphics2D context. * @param pen the pen used to stroke the shape. * @param shape the IShape to be rendered. */ public void Draw(Pen pen, IShape shape) { SetGraphicsFPPenAttribute(pen); PathIterator pathIterator = shape.GetPathIterator(null); int[] coords = new int[6]; GraphicsPathFP graphicsPathFP = new GraphicsPathFP(); PointFP pointFP1 = new PointFP(); PointFP pointFPCtl1 = new PointFP(); PointFP pointFPCtl2 = new PointFP(); while (!pathIterator.IsDone()) { int type = pathIterator.CurrentSegment(coords); switch (type) { case PathIterator.SEG_MOVETO: pointFP1.Reset(coords[0] << SingleFP.DECIMAL_BITS, coords[1] << SingleFP.DECIMAL_BITS); graphicsPathFP.AddMoveTo(pointFP1); break; case PathIterator.SEG_CLOSE: graphicsPathFP.AddClose(); break; case PathIterator.SEG_LINETO: pointFP1.Reset(coords[0] << SingleFP.DECIMAL_BITS, coords[1] << SingleFP.DECIMAL_BITS); graphicsPathFP.AddLineTo(pointFP1); break; case PathIterator.SEG_QUADTO: pointFPCtl1.Reset(coords[0] << SingleFP.DECIMAL_BITS, coords[1] << SingleFP.DECIMAL_BITS); pointFP1.Reset(coords[2] << SingleFP.DECIMAL_BITS, coords[3] << SingleFP.DECIMAL_BITS); graphicsPathFP.AddQuadTo(pointFPCtl1, pointFP1); break; case PathIterator.SEG_CUBICTO: pointFPCtl1.Reset(coords[0] << SingleFP.DECIMAL_BITS, coords[1] << SingleFP.DECIMAL_BITS); pointFPCtl2.Reset(coords[2] << SingleFP.DECIMAL_BITS, coords[3] << SingleFP.DECIMAL_BITS); pointFP1.Reset(coords[4] << SingleFP.DECIMAL_BITS, coords[5] << SingleFP.DECIMAL_BITS); graphicsPathFP.AddCurveTo(pointFPCtl1, pointFPCtl2, pointFP1); break; } pathIterator.Next(); } _graphicsFP.DrawPath(graphicsPathFP); }
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; }
public Shape createTransformedShape(Shape src) { if (src == null) { return(null); } if (src is GeneralPath) { return(((GeneralPath)src).createTransformedShape(this)); } PathIterator path = src.getPathIterator(this); GeneralPath dst = new GeneralPath(path.getWindingRule()); dst.append(path, false); return(dst); }
static void Main(string[] args) { Point start = new Point(0, 0); Point end = new Point(5, 5); Direction[,] inputlabyrinth = new ToCommonFormatConverter().Convert(rawlabyrinth); IEnumerable <Direction> way = PathIterator.GetWay(inputlabyrinth, start, end); foreach (var step in way) { Console.WriteLine(step); } Console.ReadKey(); }
public void Flatten(Matrix matrix, float flatness) { AffineTransform tr = null; if (matrix != null) { tr = matrix.NativeObject; } //FIXME : Review (perfomance reasons). PathIterator pi = NativeObject.getPathIterator(tr, flatness); ExtendedGeneralPath newPath = new ExtendedGeneralPath(); newPath.append(pi, false); Shape = newPath; }
/// <summary> /// Constructs a new <code>FlatteningPathIterator</code> object /// that flattens a path as it iterates over it. /// The <code>limit</code> parameter allows you to control the /// maximum number of recursive subdivisions that the iterator /// can make before it assumes that the curve is flat enough /// without measuring against the <code>flatness</code> parameter. /// The flattened iteration therefore never generates more than /// a maximum of <code>(2^limit)</code> line segments per curve. </summary> /// <param name="src"> the original unflattened path being iterated over </param> /// <param name="flatness"> the maximum allowable distance between the /// control points and the flattened curve </param> /// <param name="limit"> the maximum number of recursive subdivisions /// allowed for any curved segment </param> /// <exception cref="IllegalArgumentException"> if /// <code>flatness</code> or <code>limit</code> /// is less than zero </exception> public FlatteningPathIterator(PathIterator src, double flatness, int limit) { if (flatness < 0.0) { throw new IllegalArgumentException("flatness must be >= 0"); } if (limit < 0) { throw new IllegalArgumentException("limit must be >= 0"); } this.Src = src; this.Squareflat = flatness * flatness; this.Limit = limit; this.Levels = new int[limit + 1]; // prime the first path segment Next(false); }
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; } }
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; } }
public void append(Shape shape, bool connect) { PathIterator p = shape.getPathIterator(null); append(p, connect); }
/// <summary> /// Given a path, attempts to match the next part of it to the current segment. /// </summary> /// <param name="route">The route.</param> /// <param name="path">The path.</param> /// <returns>An object that indicates whether the path was successfully matched.</returns> public abstract SegmentPathMatch MatchPath(IRoute route, PathIterator path);
private static ArrayList PathToCurves(PathIterator pi) { ArrayList curves = new ArrayList(); int windingRule = pi.WindingRule; // coords array is big enough for holding: // coordinates returned from currentSegment (6) // OR // two subdivided quadratic curves (2+4+4=10) // AND // 0-1 horizontal splitting parameters // OR // 2 parametric equation derivative coefficients // OR // three subdivided cubic curves (2+6+6+6=20) // AND // 0-2 horizontal splitting parameters // OR // 3 parametric equation derivative coefficients double[] coords = new double[23]; double movx = 0, movy = 0; double curx = 0, cury = 0; double newx, newy; while (!pi.Done) { switch (pi.CurrentSegment(coords)) { case PathIterator_Fields.SEG_MOVETO: Curve.insertLine(curves, curx, cury, movx, movy); curx = movx = coords[0]; cury = movy = coords[1]; Curve.insertMove(curves, movx, movy); break; case PathIterator_Fields.SEG_LINETO: newx = coords[0]; newy = coords[1]; Curve.insertLine(curves, curx, cury, newx, newy); curx = newx; cury = newy; break; case PathIterator_Fields.SEG_QUADTO: newx = coords[2]; newy = coords[3]; Curve.insertQuad(curves, curx, cury, coords); curx = newx; cury = newy; break; case PathIterator_Fields.SEG_CUBICTO: newx = coords[4]; newy = coords[5]; Curve.insertCubic(curves, curx, cury, coords); curx = newx; cury = newy; break; case PathIterator_Fields.SEG_CLOSE: Curve.insertLine(curves, curx, cury, movx, movy); curx = movx; cury = movy; break; } pi.Next(); } Curve.insertLine(curves, curx, cury, movx, movy); AreaOp @operator; if (windingRule == PathIterator_Fields.WIND_EVEN_ODD) { @operator = new AreaOp.EOWindOp(); } else { @operator = new AreaOp.NZWindOp(); } return(@operator.calculate(curves, EmptyCurves)); }
public FlatteningPathIterator(PathIterator path, double flatness) : this(path, flatness, BUFFER_LIMIT) { }
internal bool Done_Renamed; // True when iteration is done /// <summary> /// Constructs a new <code>FlatteningPathIterator</code> object that /// flattens a path as it iterates over it. The iterator does not /// subdivide any curve read from the source iterator to more than /// 10 levels of subdivision which yields a maximum of 1024 line /// segments per curve. </summary> /// <param name="src"> the original unflattened path being iterated over </param> /// <param name="flatness"> the maximum allowable distance between the /// control points and the flattened curve </param> public FlatteningPathIterator(PathIterator src, double flatness) : this(src, flatness, 10) { }
public void append(Shape s, bool connect) { PathIterator pi = s.getPathIterator(null); append(pi, connect); }
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; } }
/** * 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()); }