Exemplo n.º 1
0
        /// <summary>
        ///   Compiles a edge to Tikz format
        /// </summary>
        /// <param name="edge">The edge to compile</param>
        /// <returns>Returns the current edge as a string in Tikz format</returns>
        public string CompileEdge(ITikzEdge edge)
        {
            if (edge is null)
            {
                throw new ArgumentNullException(nameof(edge));
            }

            var textDirection = edge.TextDirection == Direction.None
        ? string.Empty
        : edge.TextDirection.ToString().ToLowerInvariant();
            var edgeArgs = new[] { textDirection }.Where(x => !string.IsNullOrWhiteSpace(x));

            var label = edge.TextMode == TextMode.MathText ? @$ " {{${edge.Label}$}}" : @$ " {{{edge.Label}}}";

            label = edge.Label == string.Empty ? string.Empty : label;

            var xShift = edge.XShift != 0 ? $"xshift={edge.XShift}mm" : string.Empty;
            var yShift = edge.YShift != 0 ? $"yshift={edge.YShift}mm" : string.Empty;

            var nodeArgs = new[] { xShift, yShift }.Where(x => !string.IsNullOrWhiteSpace(x));
            var node = $" node[{string.Join(", ", nodeArgs)}]";


            return(@$ "([0]) edge[{string.Join(", ", edgeArgs)}]{node}{label} ([1])");
        }
Exemplo n.º 2
0
 /// <summary>
 ///   Adds a new edge associated with a source and target node
 /// </summary>
 /// <param name="edge">The edge object</param>
 /// <param name="source">The source node</param>
 /// <param name="target">The target node</param>
 public void AddEdge(ITikzEdge edge, ITikzNode source, ITikzNode target)
 {
     _edgeAssociations.Add(new EdgeAssociation(edge, source, target));
 }