コード例 #1
0
        /// <summary>
        /// Applies transformations set to this object, if any, and delegates the drawing of this element and its children
        /// to the
        /// <see cref="DoDraw(iText.Svg.Renderers.SvgDrawContext)">doDraw</see>
        /// method.
        /// </summary>
        /// <param name="context">the object that knows the place to draw this element and maintains its state</param>
        public void Draw(SvgDrawContext context)
        {
            PdfCanvas currentCanvas = context.GetCurrentCanvas();

            if (this.attributesAndStyles != null)
            {
                String transformString = this.attributesAndStyles.Get(SvgConstants.Attributes.TRANSFORM);
                if (transformString != null && !String.IsNullOrEmpty(transformString))
                {
                    AffineTransform transformation = TransformUtils.ParseTransform(transformString);
                    if (!transformation.IsIdentity())
                    {
                        currentCanvas.ConcatMatrix(transformation);
                    }
                }
                if (attributesAndStyles.ContainsKey(SvgConstants.Attributes.ID))
                {
                    context.AddUsedId(attributesAndStyles.Get(SvgConstants.Attributes.ID));
                }
            }

            /* If a (non-empty) clipping path exists, drawing operations must be surrounded by q/Q operators
             * and may have to be drawn multiple times
             */
            if (!DrawInClipPath(context))
            {
                PreDraw(context);
                DoDraw(context);
                PostDraw(context);
            }
            if (attributesAndStyles.ContainsKey(SvgConstants.Attributes.ID))
            {
                context.RemoveUsedId(attributesAndStyles.Get(SvgConstants.Attributes.ID));
            }
        }
コード例 #2
0
        /// <summary>Evaluates the 'gradientTransform' transformations</summary>
        /// <returns>
        /// an
        /// <see cref="iText.Kernel.Geom.AffineTransform"/>
        /// object representing the specified gradient transformation
        /// </returns>
        protected internal virtual AffineTransform GetGradientTransform()
        {
            String gradientTransform = GetAttribute(SvgConstants.Attributes.GRADIENT_TRANSFORM);

            if (gradientTransform != null && !String.IsNullOrEmpty(gradientTransform))
            {
                return(TransformUtils.ParseTransform(gradientTransform));
            }
            return(null);
        }