private static void AddSvgComponent(ICollection<Line> lines, ICollection<Text> texts, int startingXPosition, int startingYPosition, Anchor anchor, ICollection<Anchor> usedAnchor) { var oldStartingXPosition = startingXPosition; var oldStartingYPosition = startingYPosition; startingXPosition += ConfigSettings.IncreamentedXPosition; if (anchor.Children == null || anchor.Children.Count == ConfigSettings.NotAcceptableValue) return; if (!UsedParent.Contains(anchor)) { AddLine(lines, oldStartingXPosition + 20, startingYPosition - 5, startingXPosition - 20, startingYPosition - 5); } UsedParent.Add(anchor); foreach (var child in anchor.Children.Where(child => !usedAnchor.Contains(child))) { texts.Add(new Text {Content = child.Data, PositionX = startingXPosition, PositionY = startingYPosition}); usedAnchor.Add(child); AddLine(lines, oldStartingXPosition + 30, startingYPosition - 5, startingXPosition, startingYPosition - 5); AddLine(lines, oldStartingXPosition + 30, oldStartingYPosition - 5, oldStartingXPosition + 30, startingYPosition - 5); AddSvgComponent(lines, texts, startingXPosition, startingYPosition, child, usedAnchor); UsedParent.Add(child); startingYPosition += ConfigSettings.IncreamentedYPosition; _positionY += ConfigSettings.IncreamentedYPosition; } }
private static void CreateNodeList(ICollection<Anchor> usedKeys, Anchor anchor) { usedKeys.Add(anchor); if (anchor.Children == null) return; foreach (var childNode in anchor.Children) { if (usedKeys.Contains(childNode)) return; CreateNodeList(usedKeys, childNode); } }
private static void CheckForNonParent(ICollection<Anchor> usedKeys, Anchor anchor, ICollection<Anchor> result) { usedKeys.Add(anchor); if (anchor.Children == null) return; foreach (var childNode in anchor.Children) { if (usedKeys.Contains(childNode) || result.Contains(anchor)) { result.Remove(childNode); } CheckForNonParent(usedKeys, childNode, result); } }
public void Init() { var dictionary = new Dictionary<string, IEnumerable<Fact>>(); var list1 = new List<Fact> {new Fact {FactId = "2"}, new Fact {FactId = "3"}}; var list2 = new List<Fact> {new Fact {FactId = "1"}, new Fact {FactId = "5"}}; dictionary.Add("1", list1); dictionary.Add("4", list2); _stringListDictionary = dictionary; _expected = new List<Anchor>(); var nodeList1 = new List<Anchor> {new Anchor {Data = "2"}, new Anchor {Data = "3"}}; var nodeList2 = new List<Anchor> {new Anchor {Data = "1"}, new Anchor {Data = "5"}}; var node1 = new Anchor {Data = "1", Children = nodeList1}; var node2 = new Anchor {Data = "4", Children = nodeList2}; _expected.Add(node1); }
private static void CreateAnchorChildTree(Anchor anchor, ICollection<string> rowList, StringBuilder tree) { rowList.Add(anchor.Data); tree.Append(anchor.Data.PadRight(ConfigSettings.KeySize, ' ')); if (anchor.Children == null) { AddLine(rowList, tree); return; } foreach (var child in anchor.Children) { if (rowList.Contains(child.Data)) return; tree.Append(" " + ConfigSettings.Arrow+ " "); CreateAnchorChildTree(child, rowList, tree); rowList.Remove(child.Data); } }
public void Init() { var anchor1 = new Anchor {Data = "1"}; var anchor2 = new Anchor {Data = "2"}; var anchor3 = new Anchor {Data = "3"}; anchor1.Children = new List<Anchor> {anchor2, anchor3}; _parentListForSingleLevelChild = new List<Anchor> {anchor1}; _expectedForSingleLevelChild = "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n" + "<text x=\"0\" y=\"10\" font-family=\"Verdana\" font-size=\"10\">1</text>\n" + "<text x=\"50\" y=\"10\" font-family=\"Verdana\" font-size=\"10\">2</text>\n" + "<text x=\"50\" y=\"30\" font-family=\"Verdana\" font-size=\"10\">3</text>\n" + "<line x1=\"20\" y1=\"5\" x2=\"30\" y2=\"5\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "<line x1=\"30\" y1=\"5\" x2=\"50\" y2=\"5\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "<line x1=\"30\" y1=\"5\" x2=\"30\" y2=\"5\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "<line x1=\"30\" y1=\"25\" x2=\"50\" y2=\"25\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "<line x1=\"30\" y1=\"5\" x2=\"30\" y2=\"25\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "</svg>"; var anchor4 = new Anchor {Data = "1"}; var anchor5 = new Anchor {Data = "2"}; var anchor6 = new Anchor {Data = "3"}; var anchor7 = new Anchor {Data = "4"}; var anchor8 = new Anchor {Data = "5"}; anchor4.Children = new List<Anchor> {anchor5, anchor6}; anchor8.Children = new List<Anchor> {anchor7, anchor4}; _parentListForMultiLevelChild = new List<Anchor> {anchor8}; _expectedForMultiLevelChild = "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n" + "<text x=\"0\" y=\"10\" font-family=\"Verdana\" font-size=\"10\">5</text>\n" + "<text x=\"50\" y=\"10\" font-family=\"Verdana\" font-size=\"10\">4</text>\n" + "<text x=\"50\" y=\"30\" font-family=\"Verdana\" font-size=\"10\">1</text>\n" + "<text x=\"100\" y=\"30\" font-family=\"Verdana\" font-size=\"10\">2</text>\n" + "<text x=\"100\" y=\"50\" font-family=\"Verdana\" font-size=\"10\">3</text>\n" + "<line x1=\"20\" y1=\"5\" x2=\"30\" y2=\"5\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "<line x1=\"30\" y1=\"5\" x2=\"50\" y2=\"5\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "<line x1=\"30\" y1=\"5\" x2=\"30\" y2=\"5\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "<line x1=\"30\" y1=\"25\" x2=\"50\" y2=\"25\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "<line x1=\"30\" y1=\"5\" x2=\"30\" y2=\"25\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "<line x1=\"70\" y1=\"25\" x2=\"80\" y2=\"25\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "<line x1=\"80\" y1=\"25\" x2=\"100\" y2=\"25\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "<line x1=\"80\" y1=\"25\" x2=\"80\" y2=\"25\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "<line x1=\"80\" y1=\"45\" x2=\"100\" y2=\"45\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "<line x1=\"80\" y1=\"25\" x2=\"80\" y2=\"45\" style=\"stroke:rgb(255,0,0);stroke-width:2\"/>\n" + "</svg>"; }
public void Init() { var dictionary = new Dictionary<string, IEnumerable<Fact>>(); var list1 = new List<Fact> {new Fact {FactId = "2"}, new Fact {FactId = "3"}}; var list2 = new List<Fact> {new Fact {FactId = "4"}, new Fact {FactId = "1"}}; dictionary.Add("1", list1); dictionary.Add("5", list2); _stringListDictionary = dictionary; _expected = new List<Anchor>(); var anchor1 = new Anchor {Data = "1"}; var anchor2 = new Anchor {Data = "2"}; var anchor3 = new Anchor {Data = "3"}; var anchor4 = new Anchor {Data = "4"}; var anchor5 = new Anchor {Data = "5"}; var anchorList1 = new List<Anchor>{anchor2 , anchor3}; var anchorList2 = new List<Anchor>{anchor4 , anchor1}; anchor1.Children = anchorList1; anchor5.Children = anchorList2; _expected.Add(anchor5); }