Пример #1
0
 private void ApplyUserSpaceScaling(SvgDrawContext context)
 {
     if (!this.attributesAndStyles.ContainsKey(SvgConstants.Attributes.MARKER_UNITS) || SvgConstants.Values.STROKEWIDTH
         .Equals(this.attributesAndStyles.Get(SvgConstants.Attributes.MARKER_UNITS)))
     {
         String parentValue = this.GetParent().GetAttribute(SvgConstants.Attributes.STROKE_WIDTH);
         if (parentValue != null)
         {
             // If stroke width is a percentage value is always computed as a percentage of the normalized viewBox diagonal length.
             double rootViewPortHeight    = context.GetRootViewPort().GetHeight();
             double rootViewPortWidth     = context.GetRootViewPort().GetWidth();
             double viewBoxDiagonalLength = CssUtils.ConvertPxToPts(Math.Sqrt(rootViewPortHeight * rootViewPortHeight +
                                                                              rootViewPortWidth * rootViewPortWidth));
             float strokeWidthScale = CssUtils.ConvertPtsToPx(ParseAbsoluteLength(parentValue, (float)viewBoxDiagonalLength
                                                                                  , 1f, context));
             context.GetCurrentCanvas().ConcatMatrix(AffineTransform.GetScaleInstance(strokeWidthScale, strokeWidthScale
                                                                                      ));
         }
     }
 }
        public virtual void DrawMarker(SvgDrawContext context, MarkerVertexType markerVertexType)
        {
            Point point = null;

            if (MarkerVertexType.MARKER_START.Equals(markerVertexType))
            {
                point = points[0];
            }
            else
            {
                if (MarkerVertexType.MARKER_END.Equals(markerVertexType))
                {
                    point = points[points.Count - 1];
                }
            }
            if (point != null)
            {
                String moveX = SvgCssUtils.ConvertDoubleToString(CssUtils.ConvertPtsToPx(point.x));
                String moveY = SvgCssUtils.ConvertDoubleToString(CssUtils.ConvertPtsToPx(point.y));
                MarkerSvgNodeRenderer.DrawMarker(context, moveX, moveY, markerVertexType, this);
            }
        }