コード例 #1
0
 public override void SetCoordinates(String[] inputCoordinates, Point startPoint)
 {
     String[] normalizedCoords = new String[LineTo.ARGUMENT_SIZE];
     // An H or h command is equivalent to an L or l command with 0 specified for the y coordinate.
     normalizedCoords[0] = inputCoordinates[0];
     normalizedCoords[1] = IsRelative() ? "0" : SvgCssUtils.ConvertDoubleToString(startPoint.GetY());
     base.SetCoordinates(normalizedCoords, startPoint);
 }
コード例 #2
0
 public override void SetCoordinates(String[] coordinates, Point startPoint)
 {
     String[] normalizedCoords = new String[coordinates.Length * 2];
     // An H or h command is equivalent to an L or l command with 0 specified for the y coordinate.
     for (int i = 0; i < coordinates.Length; i++)
     {
         normalizedCoords[i * 2]     = coordinates[i];
         normalizedCoords[i * 2 + 1] = IsRelative() ? "0" : SvgCssUtils.ConvertDoubleToString(startPoint.GetY());
     }
     base.SetCoordinates(normalizedCoords, startPoint);
 }
コード例 #3
0
 /// <summary>
 /// Gets the coordinates that shall be passed to
 /// <see cref="iText.Svg.Renderers.Path.IPathShape.SetCoordinates(System.String[], iText.Kernel.Geom.Point)"/>
 /// for the current shape.
 /// </summary>
 /// <param name="shape">The current shape.</param>
 /// <param name="previousShape">The previous shape which can affect the coordinates of the current shape.</param>
 /// <param name="pathProperties">
 /// The operator and all arguments as a
 /// <see>String[]</see>
 /// </param>
 /// <returns>
 /// a
 /// <see>String[]</see>
 /// of coordinates that shall be passed to
 /// <see cref="iText.Svg.Renderers.Path.IPathShape.SetCoordinates(System.String[], iText.Kernel.Geom.Point)"/>
 /// </returns>
 private String[] GetShapeCoordinates(IPathShape shape, IPathShape previousShape, String[] pathProperties)
 {
     if (shape is ClosePath)
     {
         return(null);
     }
     String[] shapeCoordinates = null;
     String[] operatorArgs     = JavaUtil.ArraysCopyOfRange(pathProperties, 1, pathProperties.Length);
     if (shape is SmoothSCurveTo)
     {
         String[] startingControlPoint = new String[2];
         if (previousShape != null)
         {
             Point previousEndPoint = previousShape.GetEndingPoint();
             //if the previous command was a C or S use its last control point
             if (((previousShape is CurveTo)))
             {
                 Point lastControlPoint = ((CurveTo)previousShape).GetLastControlPoint();
                 float reflectedX       = (float)(2 * previousEndPoint.GetX() - lastControlPoint.GetX());
                 float reflectedY       = (float)(2 * previousEndPoint.GetY() - lastControlPoint.GetY());
                 startingControlPoint[0] = SvgCssUtils.ConvertFloatToString(reflectedX);
                 startingControlPoint[1] = SvgCssUtils.ConvertFloatToString(reflectedY);
             }
             else
             {
                 startingControlPoint[0] = SvgCssUtils.ConvertDoubleToString(previousEndPoint.GetX());
                 startingControlPoint[1] = SvgCssUtils.ConvertDoubleToString(previousEndPoint.GetY());
             }
         }
         else
         {
             // TODO RND-951
             startingControlPoint[0] = pathProperties[1];
             startingControlPoint[1] = pathProperties[2];
         }
         shapeCoordinates = Concatenate(startingControlPoint, operatorArgs);
     }
     if (shapeCoordinates == null)
     {
         shapeCoordinates = operatorArgs;
     }
     return(shapeCoordinates);
 }
コード例 #4
0
 /// <summary>
 /// Gets the coordinates that shall be passed to
 /// <see cref="iText.Svg.Renderers.Path.IPathShape.SetCoordinates(System.String[], iText.Kernel.Geom.Point)"/>
 /// for the current shape.
 /// </summary>
 /// <param name="shape">The current shape.</param>
 /// <param name="previousShape">The previous shape which can affect the coordinates of the current shape.</param>
 /// <param name="pathProperties">
 /// The operator and all arguments as a
 /// <see>String[]</see>
 /// </param>
 /// <returns>
 /// a
 /// <see>String[]</see>
 /// of coordinates that shall be passed to
 /// <see cref="iText.Svg.Renderers.Path.IPathShape.SetCoordinates(System.String[], iText.Kernel.Geom.Point)"/>
 /// </returns>
 private String[] GetShapeCoordinates(IPathShape shape, IPathShape previousShape, String[] pathProperties)
 {
     if (shape is ClosePath)
     {
         return(null);
     }
     String[] shapeCoordinates = null;
     if (shape is SmoothSCurveTo || shape is QuadraticSmoothCurveTo)
     {
         String[] startingControlPoint = new String[2];
         if (previousShape != null)
         {
             Point previousEndPoint = previousShape.GetEndingPoint();
             //if the previous command was a Bezier curve, use its last control point
             if (previousShape is IControlPointCurve)
             {
                 Point lastControlPoint = ((IControlPointCurve)previousShape).GetLastControlPoint();
                 float reflectedX       = (float)(2 * previousEndPoint.GetX() - lastControlPoint.GetX());
                 float reflectedY       = (float)(2 * previousEndPoint.GetY() - lastControlPoint.GetY());
                 startingControlPoint[0] = SvgCssUtils.ConvertFloatToString(reflectedX);
                 startingControlPoint[1] = SvgCssUtils.ConvertFloatToString(reflectedY);
             }
             else
             {
                 startingControlPoint[0] = SvgCssUtils.ConvertDoubleToString(previousEndPoint.GetX());
                 startingControlPoint[1] = SvgCssUtils.ConvertDoubleToString(previousEndPoint.GetY());
             }
         }
         else
         {
             // TODO RND-951
             startingControlPoint[0] = pathProperties[0];
             startingControlPoint[1] = pathProperties[1];
         }
         shapeCoordinates = Concatenate(startingControlPoint, pathProperties);
     }
     if (shapeCoordinates == null)
     {
         shapeCoordinates = pathProperties;
     }
     return(shapeCoordinates);
 }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        public virtual void DrawMarker(SvgDrawContext context, MarkerVertexType markerVertexType)
        {
            Object[] allShapesOrdered = GetShapes().ToArray();
            Point    point            = null;

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