예제 #1
0
        /// <summary>
        /// Draws the line transition latex.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="origin">The origin.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="transitionName">Name of the transition.</param>
        /// <param name="fontSize">Size of the font.</param>
        public static void drawLineTransitionLatex(StreamWriter file, DrawingState origin, DrawingState destination, string transitionName, string fontSize)
        {
            Vector length;
            Vector arrowOrigin = new Vector();
            Vector arrowDestination = new Vector();
            Vector arrowPoint = new Vector();
            Vector textPoint = new Vector();
            double textOffset = 0, transitionGap = 0, stateAngle = 0;
            double arrowAngleOffset = 0, arrowInclination = 0;

            length     = destination.position - origin.position;
            stateAngle = Math.Atan2(-length.Y, length.X);

            if (stateAngle < 0)
            {
                stateAngle += 2 * Math.PI;
            }

            if (origin.isAOrigin(destination))
            {
                transitionGap    = Constants.TRANSITION_OFFSET;
                arrowAngleOffset = Math.Atan2(transitionGap, length.Length -
                                              Constants.STATE_RADIUS - Constants.DISTANCE);

                if (arrowAngleOffset < 0)
                {
                    arrowAngleOffset += 2 * Math.PI;
                }
            }

            arrowOrigin.X = origin.position.X + Constants.STATE_RADIUS + Constants.DISTANCE;
            arrowOrigin.Y = origin.position.Y - transitionGap;

            arrowDestination.X = origin.position.X + length.Length - Constants.STATE_RADIUS - Constants.DISTANCE;
            arrowDestination.Y = arrowOrigin.Y;


            arrowPoint.X = origin.position.X + Math.Cos(stateAngle + arrowAngleOffset) * (length.Length - Constants.STATE_RADIUS - Constants.DISTANCE);
            arrowPoint.Y = origin.position.Y - Math.Sin(stateAngle + arrowAngleOffset) * (length.Length - Constants.STATE_RADIUS - Constants.DISTANCE);

            arrowInclination = stateAngle + Math.PI;

            drawLatexLine(file, arrowOrigin, arrowDestination, stateAngle, origin.position);
            drawLatexArrow(file, arrowPoint, -arrowInclination, arrowPoint);

            textOffset = Math.Atan2(Constants.TEXT_OFFSET + transitionGap, length.Length / 2);

            if (textOffset < 0)
            {
                textOffset += 2 * Math.PI;
            }

            textPoint.X = origin.position.X + Math.Cos(-textOffset + stateAngle) * (length.Length / 2);
            textPoint.Y = origin.position.Y - Math.Sin(-textOffset + stateAngle) * (length.Length / 2);

            writeTextLatex(file, textPoint, transitionName, fontSize, -stateAngle);
        }
예제 #2
0
        /// <summary>
        /// Draws the line transition.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="origin">The origin.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="transitionName">Name of the transition.</param>
        /// <param name="fontFill">The font fill.</param>
        /// <param name="fontSize">Size of the font.</param>
        public static void drawLineTransition(StreamWriter file, DrawingState origin, DrawingState destination,
                                              string transitionName, string fontFill, int fontSize)
        {
            Vector length, originPoint, destinationPoint, arrowPoint;
            Vector textPoint = new Vector();
            Vector fixTextPosition = new Vector();
            double x, y, textOffset = 0, transitionGap = 0;
            double stateAngle = 0, arrowAngleOffset = 0, arrowInclination = 0;

            length     = destination.position - origin.position;
            stateAngle = Math.Atan2(-length.Y, length.X);

            if (stateAngle < 0)
            {
                stateAngle += 2 * Math.PI;
            }

            if (origin.isAOrigin(destination))
            {
                transitionGap    = Constants.TRANSITION_OFFSET;
                arrowAngleOffset = Math.Atan2(transitionGap, length.Length -
                                              Constants.STATE_RADIUS - Constants.DISTANCE);

                if (arrowAngleOffset < 0)
                {
                    arrowAngleOffset += 2 * Math.PI;
                }
            }

            x           = origin.position.X + Constants.STATE_RADIUS + Constants.DISTANCE;
            y           = origin.position.Y - transitionGap;
            originPoint = new Vector(x, y);

            x = origin.position.X + length.Length - Constants.STATE_RADIUS - Constants.DISTANCE;
            y = originPoint.Y;
            destinationPoint = new Vector(x, y);

            x          = origin.position.X + Math.Cos(stateAngle + arrowAngleOffset) * (length.Length - Constants.STATE_RADIUS - Constants.DISTANCE);
            y          = origin.position.Y - Math.Sin(stateAngle + arrowAngleOffset) * (length.Length - Constants.STATE_RADIUS - Constants.DISTANCE);
            arrowPoint = new Vector(x, y);

            arrowInclination = stateAngle + Math.PI;

            drawSVGLine(file, originPoint, destinationPoint, -stateAngle, origin.position);
            drawSVGArrow(file, arrowPoint, arrowInclination, arrowPoint);

            textOffset = Math.Atan2(Constants.TEXT_OFFSET + transitionGap, length.Length / 2);

            if (textOffset < 0)
            {
                textOffset += 2 * Math.PI;
            }

            //correcão do posicionamnto do texto quando angulo vara entre 90 e 270 graus
            if (stateAngle >= Math.PI / 2 && stateAngle <= 3 * Math.PI / 2)
            {
                fixTextPosition.X = -Math.Sin(stateAngle) * Constants.TEXT_OFFSET;
                fixTextPosition.Y = -Math.Cos(stateAngle) * Constants.TEXT_OFFSET;
            }

            x = origin.position.X + Math.Cos(textOffset + stateAngle) * (length.Length / 2) + fixTextPosition.X;
            y = origin.position.Y - Math.Sin(textOffset + stateAngle) * (length.Length / 2) + fixTextPosition.Y;

            Vector gap = new Vector();

            writeTextSVG(file, textPoint, transitionName, stateAngle, gap, fontFill, fontSize);
        }