/// <summary>
        ///   Constructs a new Tikz figure
        /// </summary>
        /// <param name="caption">LaTeX figure caption text</param>
        /// <param name="label">LaTeX figure label/name</param>
        /// <param name="rootNode">The initial node used in the figure</param>
        public TikzFigure(string caption, string label, ITikzNode rootNode)
        {
            Caption = caption;
            Label   = label;

            _nodeAssociations.Add(new NodeAssociation(rootNode, rootNode, Direction.None));
        }
示例#2
0
        /// <summary>
        ///   Compiles a node to Tikz format
        /// </summary>
        /// <param name="node">The node to compile</param>
        /// <returns>Returns the current node as a string in Tikz format</returns>
        public string CompileNode(ITikzNode node)
        {
            if (node is null)
            {
                throw new ArgumentNullException(nameof(node));
            }

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

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

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

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

            return(@$ "\node[{string.Join(", ", nodeArgs)}[0]] ({node.Name}){label};");
        }
 /// <summary>
 ///   Adds a new node association with another node
 /// </summary>
 /// <param name="source">The source node</param>
 /// <param name="target">The target node</param>
 /// <param name="direction">The direction of <paramref name="target" /> relative to <paramref name="source" /></param>
 public void AddNode(ITikzNode source, ITikzNode target, Direction direction)
 {
     _nodeAssociations.Add(new NodeAssociation(source, target, direction));
 }
 /// <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));
 }