public virtual void NoOpacitySet() { AbstractSvgNodeRenderer renderer = new CircleSvgNodeRenderer(); renderer.SetAttribute(SvgConstants.Attributes.STROKE, "blue"); renderer.Draw(sdc); PdfResources resources = cv.GetResources(); NUnit.Framework.Assert.IsTrue(resources.GetResourceNames().IsEmpty()); }
public virtual void NoOpacitySetWithNoneFillRGBA() { AbstractSvgNodeRenderer renderer = new CircleSvgNodeRenderer(); renderer.SetAttribute(SvgConstants.Attributes.FILL, SvgConstants.Values.NONE); renderer.Draw(sdc); PdfResources resources = cv.GetResources(); NUnit.Framework.Assert.IsTrue(resources.GetResourceNames().IsEmpty()); }
public virtual void StrokeOpacitySetWithoutStrokeRGBA() { AbstractSvgNodeRenderer renderer = new CircleSvgNodeRenderer(); renderer.SetAttribute(SvgConstants.Attributes.STROKE_OPACITY, "0.75"); renderer.Draw(sdc); PdfResources resources = cv.GetResources(); NUnit.Framework.Assert.IsTrue(resources.GetResourceNames().IsEmpty()); }
public virtual void DeepCopyTest() { //Deep copy of tree with nested svg and group and set attributes UseSvgNodeRenderer nestedUse = new UseSvgNodeRenderer(); nestedUse.SetAttribute(SvgConstants.Attributes.HREF, "#c1"); GroupSvgNodeRenderer nestedGroup = new GroupSvgNodeRenderer(); nestedGroup.SetAttribute(SvgConstants.Attributes.FILL, "blue"); nestedGroup.AddChild(nestedUse); CircleSvgNodeRenderer nestedCircle = new CircleSvgNodeRenderer(); nestedCircle.SetAttribute(SvgConstants.Attributes.R, "100"); SvgTagSvgNodeRenderer nestedSvg = new SvgTagSvgNodeRenderer(); nestedSvg.SetAttribute(SvgConstants.Attributes.X, "200"); nestedSvg.SetAttribute(SvgConstants.Attributes.Y, "200"); nestedSvg.SetAttribute(SvgConstants.Attributes.XMLNS, SvgConstants.Values.SVGNAMESPACEURL); nestedSvg.SetAttribute(SvgConstants.Attributes.VERSION, SvgConstants.Values.VERSION1_1); nestedSvg.AddChild(nestedCircle); nestedSvg.AddChild(nestedGroup); RectangleSvgNodeRenderer nestedRectangle = new RectangleSvgNodeRenderer(); nestedRectangle.SetAttribute(SvgConstants.Attributes.WIDTH, "100"); nestedRectangle.SetAttribute(SvgConstants.Attributes.HEIGHT, "50"); GroupSvgNodeRenderer topGroup = new GroupSvgNodeRenderer(); topGroup.SetAttribute(SvgConstants.Attributes.FILL, "red"); topGroup.AddChild(nestedRectangle); CircleSvgNodeRenderer topCircle = new CircleSvgNodeRenderer(); topCircle.SetAttribute(SvgConstants.Attributes.R, "80"); topCircle.SetAttribute(SvgConstants.Attributes.X, "100"); topCircle.SetAttribute(SvgConstants.Attributes.Y, "100"); topCircle.SetAttribute(SvgConstants.Attributes.STROKE, "red"); topCircle.SetAttribute(SvgConstants.Attributes.FILL, "green"); SvgTagSvgNodeRenderer topSvg = new SvgTagSvgNodeRenderer(); topSvg.SetAttribute(SvgConstants.Attributes.WIDTH, "800"); topSvg.SetAttribute(SvgConstants.Attributes.HEIGHT, "800"); topSvg.SetAttribute(SvgConstants.Attributes.XMLNS, SvgConstants.Values.SVGNAMESPACEURL); topSvg.SetAttribute(SvgConstants.Attributes.VERSION, SvgConstants.Values.VERSION1_1); topSvg.AddChild(topCircle); topSvg.AddChild(topGroup); EllipseSvgNodeRenderer ellipse = new EllipseSvgNodeRenderer(); ellipse.SetAttribute(SvgConstants.Attributes.CX, "10"); ellipse.SetAttribute(SvgConstants.Attributes.CY, "20"); ellipse.SetAttribute(SvgConstants.Attributes.RX, "30"); ellipse.SetAttribute(SvgConstants.Attributes.RX, "40"); topSvg.AddChild(ellipse); ISvgNodeRenderer copy = topSvg.CreateDeepCopy(); NUnit.Framework.Assert.AreEqual(topSvg, copy); }
public virtual void NoOpacitySetWithFillRGBA() { AbstractSvgNodeRenderer renderer = new CircleSvgNodeRenderer(); renderer.SetAttribute(SvgConstants.Attributes.FILL, "rgba(100,20,80,.75)"); renderer.Draw(sdc); PdfResources resources = cv.GetResources(); NUnit.Framework.Assert.AreEqual(1, resources.GetResourceNames().Count); PdfDictionary resDic = (PdfDictionary)resources.GetResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME ); NUnit.Framework.Assert.AreEqual(1, resDic.Size()); NUnit.Framework.Assert.AreEqual(resDic.Get(FILL_OPAC), new PdfNumber(0.75)); }
public virtual void StrokeOpacitySetWithStroke() { AbstractSvgNodeRenderer renderer = new CircleSvgNodeRenderer(); renderer.SetAttribute(SvgConstants.Attributes.STROKE_OPACITY, "0.75"); renderer.SetAttribute(SvgConstants.Attributes.STROKE, "blue"); renderer.Draw(sdc); PdfResources resources = cv.GetResources(); NUnit.Framework.Assert.AreEqual(1, resources.GetResourceNames().Count); PdfDictionary resDic = (PdfDictionary)resources.GetResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME ); NUnit.Framework.Assert.AreEqual(1, resDic.Size()); NUnit.Framework.Assert.AreEqual(resDic.Get(STROKE_OPAC), new PdfNumber(0.75)); }
public virtual void ApplyInheritanceToSubTreeFillTest() { String expectedFillAttribute = "blue"; UseSvgNodeRenderer newRoot = new UseSvgNodeRenderer(); newRoot.SetAttribute(SvgConstants.Attributes.FILL, expectedFillAttribute); GroupSvgNodeRenderer subTree = new GroupSvgNodeRenderer(); RectangleSvgNodeRenderer rect = new RectangleSvgNodeRenderer(); CircleSvgNodeRenderer circle = new CircleSvgNodeRenderer(); subTree.AddChild(rect); subTree.AddChild(circle); SvgNodeRendererInheritanceResolver sru = new SvgNodeRendererInheritanceResolver(); sru.ApplyInheritanceToSubTree(newRoot, subTree); NUnit.Framework.Assert.AreEqual(expectedFillAttribute, subTree.GetAttribute(SvgConstants.Attributes.FILL)); NUnit.Framework.Assert.AreEqual(expectedFillAttribute, rect.GetAttribute(SvgConstants.Attributes.FILL)); NUnit.Framework.Assert.AreEqual(expectedFillAttribute, circle.GetAttribute(SvgConstants.Attributes.FILL)); }