public virtual void TestEoAppliedGroupClipPathRenderer() { AbstractBranchSvgNodeRenderer clipPathRenderer = new ClipPathSvgNodeRenderer(); clipPathRenderer.SetAttribute(SvgConstants.Attributes.ID, "randomString"); ISvgNodeRenderer clippedRenderer = new RectangleSvgNodeRenderer(); clippedRenderer.SetAttribute(SvgConstants.Attributes.WIDTH, "80"); clippedRenderer.SetAttribute(SvgConstants.Attributes.HEIGHT, "80"); clippedRenderer.SetAttribute(SvgConstants.Attributes.CLIP_RULE, SvgConstants.Values.FILL_RULE_EVEN_ODD); ISvgNodeRenderer clippedRenderer2 = new RectangleSvgNodeRenderer(); clippedRenderer2.SetAttribute(SvgConstants.Attributes.WIDTH, "80"); clippedRenderer2.SetAttribute(SvgConstants.Attributes.HEIGHT, "80"); clipPathRenderer.AddChild(clippedRenderer); clipPathRenderer.AddChild(clippedRenderer2); sdc.AddNamedObject("randomString", clipPathRenderer); AbstractBranchSvgNodeRenderer groupRenderer = new GroupSvgNodeRenderer(); groupRenderer.SetAttributesAndStyles(new Dictionary <String, String>()); ISvgNodeRenderer drawnRenderer = new CircleSvgNodeRenderer(); drawnRenderer.SetAttribute(SvgConstants.Attributes.R, "84"); drawnRenderer.SetAttribute(SvgConstants.Attributes.CLIP_PATH, "url(#randomString)"); groupRenderer.AddChild(drawnRenderer); groupRenderer.Draw(sdc); String expected = "0 0 0 rg\n" + "q\n" + "q\n" + "% rect\n" + "0 0 60 60 re\n" + "W*\n" + "n\n" + "% ellipse\n" + "63 0 m\n" + "63 34.79 34.79 63 0 63 c\n" + "-34.79 63 -63 34.79 -63 0 c\n" + "-63 -34.79 -34.79 -63 0 -63 c\n" + "34.79 -63 63 -34.79 63 0 c\n" + "f\n" + "Q\n" + "q\n" + "% rect\n" + "0 0 60 60 re\n" + "W\n" + "n\n" + "% ellipse\n" + "63 0 m\n" + "63 34.79 34.79 63 0 63 c\n" + "-34.79 63 -63 34.79 -63 0 c\n" + "-63 -34.79 -34.79 -63 0 -63 c\n" + "34.79 -63 63 -34.79 63 0 c\n" + "f\n" + "Q\n" + "Q\n"; NUnit.Framework.Assert.AreEqual(expected, iText.IO.Util.JavaUtil.GetStringForBytes(cv.GetContentStream().GetBytes ())); }
public virtual void TestEmptyEoClipPathRendererNotDrawn() { ClipPathSvgNodeRenderer clipRenderer = new ClipPathSvgNodeRenderer(); clipRenderer.SetAttribute(SvgConstants.Attributes.CLIP_RULE, SvgConstants.Values.FILL_RULE_EVEN_ODD); clipRenderer.Draw(sdc); NUnit.Framework.Assert.AreEqual(0, cv.GetContentStream().GetBytes().Length); }
public virtual void TestEmptyClipPathRendererNotDrawn() { ClipPathSvgNodeRenderer clipRenderer = new ClipPathSvgNodeRenderer(); clipRenderer.SetAttributesAndStyles(new Dictionary <String, String>()); clipRenderer.Draw(sdc); NUnit.Framework.Assert.AreEqual(0, cv.GetContentStream().GetBytes().Length); }
public override ISvgNodeRenderer CreateDeepCopy() { AbstractBranchSvgNodeRenderer copy = new ClipPathSvgNodeRenderer(); DeepCopyAttributesAndStyles(copy); DeepCopyChildren(copy); return(copy); }
public virtual void DeepCopyTest() { ClipPathSvgNodeRenderer expected = new ClipPathSvgNodeRenderer(); expected.SetAttribute(SvgConstants.Attributes.FILL, "blue"); expected.AddChild(new CircleSvgNodeRenderer()); ISvgNodeRenderer actual = expected.CreateDeepCopy(); NUnit.Framework.Assert.AreEqual(expected, actual); }
public virtual void TestRectClipPathRenderer() { ClipPathSvgNodeRenderer clipRenderer = new ClipPathSvgNodeRenderer(); clipRenderer.SetAttributesAndStyles(new Dictionary <String, String>()); RectangleSvgNodeRenderer rectRenderer = new RectangleSvgNodeRenderer(); rectRenderer.SetAttribute(SvgConstants.Attributes.WIDTH, "400"); rectRenderer.SetAttribute(SvgConstants.Attributes.HEIGHT, "400"); clipRenderer.AddChild(rectRenderer); clipRenderer.Draw(sdc); NUnit.Framework.Assert.AreEqual("q\n% rect\n0 0 300 300 re\nW\nn\nQ\n", iText.IO.Util.JavaUtil.GetStringForBytes (cv.GetContentStream().GetBytes())); }
public virtual void TestRectClipPathEoRendererNoChange() { ClipPathSvgNodeRenderer clipRenderer = new ClipPathSvgNodeRenderer(); // clip-rule can only be set on elements in a clipPath, and must not have any influence on drawing clipRenderer.SetAttribute(SvgConstants.Attributes.CLIP_RULE, SvgConstants.Values.FILL_RULE_EVEN_ODD); RectangleSvgNodeRenderer rectRenderer = new RectangleSvgNodeRenderer(); rectRenderer.SetAttribute(SvgConstants.Attributes.WIDTH, "400"); rectRenderer.SetAttribute(SvgConstants.Attributes.HEIGHT, "400"); clipRenderer.AddChild(rectRenderer); clipRenderer.Draw(sdc); NUnit.Framework.Assert.AreEqual("q\n% rect\n0 0 300 300 re\nW\nn\nQ\n", iText.IO.Util.JavaUtil.GetStringForBytes (cv.GetContentStream().GetBytes())); }
private bool DrawInClipPath(SvgDrawContext context) { if (attributesAndStyles.ContainsKey(SvgConstants.Attributes.CLIP_PATH)) { String clipPathName = attributesAndStyles.Get(SvgConstants.Attributes.CLIP_PATH); ISvgNodeRenderer template = context.GetNamedObject(NormalizeLocalUrlName(clipPathName)); //Clone template to avoid muddying the state if (template is ClipPathSvgNodeRenderer) { ClipPathSvgNodeRenderer clipPath = (ClipPathSvgNodeRenderer)template.CreateDeepCopy(); clipPath.SetClippedRenderer(this); clipPath.Draw(context); return(!clipPath.GetChildren().IsEmpty()); } } return(false); }