/// <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); }
/// <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); }