/// <summary> /// Called by Graph.AddEdge after object creation. /// </summary> public void Initialize(Graph g, GraphNode startNode, GraphNode endNode, string label, EdgeStyle style) { StartNode = startNode; EndNode = endNode; Label = label; Style = style; text = GetComponentInChildren <TMPro.TextMeshProUGUI>(); if (text != null) { text.text = label; if (style.Font != null) { text.font = style.Font; } if (style.FontSize != 0) { text.fontSize = style.FontSize; } text.fontStyle = style.FontStyle; text.color = Style.Color; } rectTransform = GetComponent <RectTransform>(); UpdatePosition(); }
/// <summary> /// Called by Graph.AddEdge after object creation. /// </summary> public void Initialize(Graph g, GraphNode startNode, GraphNode endNode, string label, EdgeStyle style) { this.StartNode = startNode; this.EndNode = endNode; this.Label = label; this.Style = style; text = GetComponent <Text>(); if (text != null) { text.text = label; if (style.Font != null) { text.font = style.Font; } if (style.FontSize != 0) { text.fontSize = style.FontSize; } text.fontStyle = style.FontStyle; } rectTransform = GetComponent <RectTransform>(); UpdatePosition(); }
/// <summary> /// Add a single edge to the graph. /// </summary> /// <param name="start">Node from which edge starts.</param> /// <param name="end">Node the edge leads to.</param> /// <param name="label">Label for the edge</param> /// <param name="style">Style in which to render the label. If null, this will use the style whose name is the same as the label, if any, otherwise the first entry in EdgeStyles.</param> public void AddEdge(NodeType start, NodeType end, string label, EdgeStyle style = null) { Graph.AddEdge(start, end, label, style); }