public override ISvgNodeRenderer CreateDeepCopy() { PolygonSvgNodeRenderer copy = new PolygonSvgNodeRenderer(); DeepCopyAttributesAndStyles(copy); return(copy); }
public virtual void PolygonLinkedPointCheckerImplicit() { PdfDocument doc = new PdfDocument(new PdfWriter(new MemoryStream())); doc.AddNewPage(); ISvgNodeRenderer root = new PolygonSvgNodeRenderer(); IDictionary <String, String> polyLineAttributes = new Dictionary <String, String>(); polyLineAttributes.Put(SvgConstants.Attributes.POINTS, "0,0 100,100 200,200 300,300"); root.SetAttributesAndStyles(polyLineAttributes); SvgDrawContext context = new SvgDrawContext(null, null); PdfCanvas cv = new PdfCanvas(doc, 1); context.PushCanvas(cv); root.Draw(context); IList <Point> expectedPoints = new List <Point>(); expectedPoints.Add(new Point(0, 0)); expectedPoints.Add(new Point(75, 75)); expectedPoints.Add(new Point(150, 150)); expectedPoints.Add(new Point(225, 225)); expectedPoints.Add(new Point(0, 0)); IList <Point> attributePoints = ((PolygonSvgNodeRenderer)root).GetPoints(); NUnit.Framework.Assert.AreEqual(expectedPoints.Count, attributePoints.Count); for (int x = 0; x < attributePoints.Count; x++) { NUnit.Framework.Assert.AreEqual(expectedPoints[x], attributePoints[x]); } }
public virtual void ConnectPointsWithSameYCoordinateTest() { PdfDocument doc = new PdfDocument(new PdfWriter(new MemoryStream())); doc.AddNewPage(); ISvgNodeRenderer root = new PolygonSvgNodeRenderer(); IDictionary <String, String> polyLineAttributes = new Dictionary <String, String>(); polyLineAttributes.Put(SvgConstants.Attributes.POINTS, "100,100 100,200 150,200 150,100"); polyLineAttributes.Put(SvgConstants.Attributes.FILL, "none"); polyLineAttributes.Put(SvgConstants.Attributes.STROKE, "black"); root.SetAttributesAndStyles(polyLineAttributes); SvgDrawContext context = new SvgDrawContext(null, null); PdfCanvas cv = new PdfCanvas(doc, 1); context.PushCanvas(cv); root.Draw(context); doc.Close(); IList <Point> expectedPoints = new List <Point>(); expectedPoints.Add(new Point(75, 75)); expectedPoints.Add(new Point(75, 150)); expectedPoints.Add(new Point(112.5, 150)); expectedPoints.Add(new Point(112.5, 75)); expectedPoints.Add(new Point(75, 75)); IList <Point> attributePoints = ((PolygonSvgNodeRenderer)root).GetPoints(); NUnit.Framework.Assert.AreEqual(expectedPoints.Count, attributePoints.Count); for (int x = 0; x < attributePoints.Count; x++) { NUnit.Framework.Assert.AreEqual(expectedPoints[x], attributePoints[x]); } }
public virtual void DeepCopyTest() { PolygonSvgNodeRenderer expected = new PolygonSvgNodeRenderer(); expected.SetAttribute(SvgConstants.Attributes.FILL, "blue"); ISvgNodeRenderer actual = expected.CreateDeepCopy(); NUnit.Framework.Assert.AreEqual(expected, actual); }
public virtual void PolygonLineRendererTest() { String filename = "polygonLineRendererTest.pdf"; PdfDocument doc = new PdfDocument(new PdfWriter(destinationFolder + filename)); doc.AddNewPage(); ISvgNodeRenderer root = new PolygonSvgNodeRenderer(); IDictionary <String, String> polyLineAttributes = new Dictionary <String, String>(); polyLineAttributes.Put(SvgConstants.Attributes.POINTS, "60,20 100,40 100,80 60,100 20,80 20,40"); root.SetAttributesAndStyles(polyLineAttributes); SvgDrawContext context = new SvgDrawContext(null, null); PdfCanvas cv = new PdfCanvas(doc, 1); context.PushCanvas(cv); root.Draw(context); doc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareVisually(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); }
public virtual void PolygonEmptyPointCheckerTest() { String filename = "polygonEmptyPointCheckerTest.pdf"; PdfDocument doc = new PdfDocument(new PdfWriter(destinationFolder + filename)); doc.AddNewPage(); ISvgNodeRenderer root = new PolygonSvgNodeRenderer(); IDictionary <String, String> polyLineAttributes = new Dictionary <String, String>(); root.SetAttributesAndStyles(polyLineAttributes); SvgDrawContext context = new SvgDrawContext(null, null); PdfCanvas cv = new PdfCanvas(doc, 1); context.PushCanvas(cv); root.Draw(context); doc.Close(); int numPoints = ((PolygonSvgNodeRenderer)root).GetPoints().Count; NUnit.Framework.Assert.AreEqual(numPoints, 0); NUnit.Framework.Assert.IsNull(new CompareTool().CompareVisually(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); }