Пример #1
0
        private Point[] GetCoordinates(SvgDrawContext context, bool isObjectBoundingBox)
        {
            Point start;
            Point end;

            if (isObjectBoundingBox)
            {
                start = new Point(GetCoordinateForObjectBoundingBox(SvgConstants.Attributes.X1, 0), GetCoordinateForObjectBoundingBox
                                      (SvgConstants.Attributes.Y1, 0));
                end = new Point(GetCoordinateForObjectBoundingBox(SvgConstants.Attributes.X2, 1), GetCoordinateForObjectBoundingBox
                                    (SvgConstants.Attributes.Y2, 0));
            }
            else
            {
                Rectangle currentViewPort = context.GetCurrentViewPort();
                double    x      = currentViewPort.GetX();
                double    y      = currentViewPort.GetY();
                double    width  = currentViewPort.GetWidth();
                double    height = currentViewPort.GetHeight();
                float     em     = GetCurrentFontSize();
                float     rem    = context.GetRemValue();
                start = new Point(GetCoordinateForUserSpaceOnUse(SvgConstants.Attributes.X1, x, x, width, em, rem), GetCoordinateForUserSpaceOnUse
                                      (SvgConstants.Attributes.Y1, y, y, height, em, rem));
                end = new Point(GetCoordinateForUserSpaceOnUse(SvgConstants.Attributes.X2, x + width, x, width, em, rem),
                                GetCoordinateForUserSpaceOnUse(SvgConstants.Attributes.Y2, y, y, height, em, rem));
            }
            return(new Point[] { start, end });
        }
 /// <summary>Parse absolute length.</summary>
 /// <param name="length">
 ///
 /// <see cref="System.String"/>
 /// for parsing
 /// </param>
 /// <param name="percentRelativeValue">the value on which percent length is based on</param>
 /// <param name="defaultValue">default value if length is not recognized</param>
 /// <param name="context">
 /// current
 /// <see cref="iText.Svg.Renderers.SvgDrawContext"/>
 /// </param>
 /// <returns>absolute value in points</returns>
 protected internal virtual float ParseAbsoluteLength(String length, float percentRelativeValue, float defaultValue
                                                      , SvgDrawContext context)
 {
     if (CssUtils.IsPercentageValue(length))
     {
         return(CssUtils.ParseRelativeValue(length, percentRelativeValue));
     }
     else
     {
         float     em        = GetCurrentFontSize();
         float     rem       = context.GetRemValue();
         UnitValue unitValue = CssUtils.ParseLengthValueToPt(length, em, rem);
         if (unitValue != null && unitValue.IsPointValue())
         {
             return(unitValue.GetValue());
         }
         else
         {
             return(defaultValue);
         }
     }
 }