Exemple #1
0
        public void FracsWhenRemovingWords()
        {
            WordTargetLayout layout = new WordTargetLayout(new List <string> {
                "VARIABLE", "VALUE", "VAGUE", "UNCLEAR", "STATE"
            });

            layout.AssignWord("VALUE", 3);
            layout.AssignWord("UNCLEAR", 3);
            Assert.AreEqual(2, layout.GetFracsInCircle(3).Count);
            layout.RemoveWord("UNCLEAR", 3);
            Assert.AreEqual(1, layout.GetFracsInCircle(3).Count);
            layout.RemoveWord("VALUE", 3);
            Assert.AreEqual(0, layout.GetFracsInCircle(3).Count);
        }
Exemple #2
0
        public void GetUnassignedWords()
        {
            WordTargetLayout layout = new WordTargetLayout(new List <string> {
                "VARIABLE", "VALUE", "VAGUE", "UNCLEAR", "NUCLEAR", "STATE"
            });

            layout.AssignWord("VALUE", 2);
            layout.AssignWord("VAGUE", 2);
            List <string> unassigned = new List <string> {
                "UNCLEAR", "NUCLEAR"
            };

            Assert.IsTrue(Enumerable.SequenceEqual(unassigned, layout.GetUnassignedWords()));
        }
Exemple #3
0
        public void EmptySpace()
        {
            WordTargetLayout layout = new WordTargetLayout(new List <string> {
                "VARIABLE", "VALUE", "VAGUE", "UNCLEAR", "STATE"
            });

            layout.AssignWord("VALUE", 3);
            layout.AssignWord("UNCLEAR", 3);
            Assert.AreEqual(0.660, layout.GetEmptySpace(3), 0.001);
            Assert.AreEqual(1.0, layout.GetEmptySpace(4));
            Assert.AreEqual(0.892, layout.GetEmptySpace(5), 0.001);
            Assert.ThrowsException <System.Exception>(() => layout.GetEmptySpace(6));
            Assert.ThrowsException <System.Exception>(() => layout.GetEmptySpace(1));
        }
Exemple #4
0
        public void FindWord()
        {
            WordTargetLayout layout = new WordTargetLayout(new List <string> {
                "VARIABLE", "VALUE", "VAGUE", "UNCLEAR", "STATE"
            });

            layout.AssignWord("VALUE", 3);
            layout.AssignWord("UNCLEAR", 4);
            layout.AssignWord("VAGUE", 2);
            Assert.AreEqual(2, layout.FindWord("VAGUE"));
            Assert.AreEqual(3, layout.FindWord("VALUE"));
            Assert.AreEqual(4, layout.FindWord("UNCLEAR"));
            Assert.AreEqual(5, layout.FindWord("VARIABLE"));
            Assert.AreEqual(1, layout.FindWord("STATE"));
            Assert.AreEqual(null, layout.FindWord("NUCLEAR"));
        }
        private static WordTargetLayout createTextLayout(List <string> words, int circle, int startingAngle)
        {
            List <string> allWords = new List <string>();

            if (circle != 5)
            {
                allWords.Add("FIRST");
            }
            allWords.AddRange(words);
            allWords.Add("LAST");
            WordTargetLayout layout = new WordTargetLayout(allWords);

            if (circle != 5)
            {
                layout.SetStartingAngle(circle, startingAngle);
            }
            foreach (string word in words)
            {
                if (circle == 5 && word == words[0])
                {
                    continue;
                }
                layout.AssignWord(word, circle);
            }
            layout.CalculateAnglesInCircle();
            return(layout);
        }
Exemple #6
0
        public void RemoveWord()
        {
            WordTargetLayout layout = new WordTargetLayout(new List <string> {
                "VARIABLE", "VALUE", "UNCLEAR", "STATE"
            });

            layout.AssignWord("VALUE", 3);
            layout.AssignWord("UNCLEAR", 4);
            Assert.ThrowsException <System.Exception>(() => layout.RemoveWord("NUCLEAR", 2));
            Assert.ThrowsException <System.Exception>(() => layout.RemoveWord("UNCLEAR", 3));
            Assert.ThrowsException <System.Exception>(() => layout.RemoveWord("VARIABLE", 5));
            Assert.ThrowsException <System.Exception>(() => layout.RemoveWord("STATE", 1));
            layout.RemoveWord("VALUE", 3);
            Assert.AreEqual(0, layout.GetWordsInCircle(3).Count);
            Assert.AreEqual(1, layout.GetWordsInCircle(4).Count);
            Assert.AreEqual("UNCLEAR", layout.GetWordsInCircle(4)[0]);
        }
Exemple #7
0
        public void IsCircleFull()
        {
            WordTargetLayout layout = new WordTargetLayout(new List <string> {
                "VARIABLE", "VALUE", "VAGUE", "UNCLEAR", "NUCLEAR", "CORE", "CORN", "COIN", "JOIN", "STATE"
            });

            layout.AssignWord("VALUE", 3);
            layout.AssignWord("VAGUE", 3);
            layout.AssignWord("UNCLEAR", 3);
            layout.AssignWord("NUCLEAR", 3);
            Assert.AreEqual(false, layout.IsCircleFull(3));
            layout.AssignWord("CORE", 3);
            layout.AssignWord("CORN", 3);
            layout.AssignWord("COIN", 3);
            layout.AssignWord("JOIN", 3);
            Assert.ThrowsException <System.Exception>(() => layout.IsCircleFull(1));
            Assert.ThrowsException <System.Exception>(() => layout.IsCircleFull(6));
            Assert.AreEqual(true, layout.IsCircleFull(3));
        }
        public void RenderWordTarget()
        {
            string           expected         = @"<svg width=""500"" height=""500"" viewBox=""-700 -700 1400 1400"" xmlns=""http://www.w3.org/2000/svg"">
  <style>
    .text1 { fill: black; font: 50px sans-serif; }
    .text2 { fill: white; font: 50px sans-serif; }
    .line2 { stroke: white; stroke-width:5; }
    .text3 { fill: black; font: 50px sans-serif; }
    .line3 { stroke: black; stroke-width:5; }
    .text4 { fill: white; font: 50px sans-serif; }
    .line4 { stroke: white; stroke-width:5; }
    .text5 { fill: black; font: 50px sans-serif; }
    .line5 { stroke: black; stroke-width:5; }
  </style>

  <circle cx=""0"" cy=""0"" r=""505"" fill=""black"" />
  <circle cx=""0"" cy=""0"" r=""500"" fill=""white"" />
  <circle cx=""0"" cy=""0"" r=""400"" fill=""black"" />
  <circle cx=""0"" cy=""0"" r=""300"" fill=""white"" />
  <circle cx=""0"" cy=""0"" r=""200"" fill=""black"" />
  <circle cx=""0"" cy=""0"" r=""100"" fill=""white"" />
  <line x1=""-415"" y1=""-415"" x2=""-390"" y2=""-390"" stroke=""black"" stroke-width=""20""/>
  <polygon points=""-375 -415, -415 -375, -360 -360"" />

  <path id=""circle2"" fill=""transparent""
      d=""
      M 0 0
      m -130, 0
      a 130,130 0 1,1 260,0
      a 130,130 0 1,1 -260,0
      ""
  />
  <path id=""circle3"" fill=""transparent""
      d=""
      M 0 0
      m -230, 0
      a 230,230 0 1,1 460,0
      a 230,230 0 1,1 -460,0
      ""
  />
  <path id=""circle4"" fill=""transparent""
      d=""
      M 0 0
      m -330, 0
      a 330,330 0 1,1 660,0
      a 330,330 0 1,1 -660,0
      ""
  />
  <path id=""circle5"" fill=""transparent""
      d=""
      M 0 0
      m -430, 0
      a 430,430 0 1,1 860,0
      a 430,430 0 1,1 -860,0
      ""
  />

  <!-- First circle -->
  <text x=""0"" y=""0"" dominant-baseline=""middle"" text-anchor=""middle"" class=""text1"">STATE</text>

  <!-- Second circle -->
  <line transform=""rotate(80 0,0)"" x1=""-200"" x2=""-100"" y1=""0"" y2=""0"" class=""line2""/>
  <text transform=""rotate(92 0,0)"" class=""text2""><textPath href=""#circle2"">STARE</textPath></text>
  <line transform=""rotate(181 0,0)"" x1=""-200"" x2=""-100"" y1=""0"" y2=""0"" class=""line2""/>
  <text transform=""rotate(194 0,0)"" class=""text2""><textPath href=""#circle2"">STAR</textPath></text>
  <line transform=""rotate(267 0,0)"" x1=""-200"" x2=""-100"" y1=""0"" y2=""0"" class=""line2""/>
  <text transform=""rotate(280 0,0)"" class=""text2""><textPath href=""#circle2"">JOIN</textPath></text>
  <line transform=""rotate(344 0,0)"" x1=""-200"" x2=""-100"" y1=""0"" y2=""0"" class=""line2""/>
  <text transform=""rotate(357 0,0)"" class=""text2""><textPath href=""#circle2"">RIGHT</textPath></text>

  <!-- Third circle -->
  <line transform=""rotate(0 0,0)"" x1=""-300"" x2=""-200"" y1=""0"" y2=""0"" class=""line3""/>
  <text transform=""rotate(6 0,0)"" class=""text3""><textPath href=""#circle3"">SPARE</textPath></text>
  <line transform=""rotate(55 0,0)"" x1=""-300"" x2=""-200"" y1=""0"" y2=""0"" class=""line3""/>
  <text transform=""rotate(62 0,0)"" class=""text3""><textPath href=""#circle3"">CORN</textPath></text>
  <line transform=""rotate(105 0,0)"" x1=""-300"" x2=""-200"" y1=""0"" y2=""0"" class=""line3""/>
  <text transform=""rotate(112 0,0)"" class=""text3""><textPath href=""#circle3"">VALUE</textPath></text>
  <line transform=""rotate(159 0,0)"" x1=""-300"" x2=""-200"" y1=""0"" y2=""0"" class=""line3""/>
  <text transform=""rotate(165 0,0)"" class=""text3""><textPath href=""#circle3"">POLARS</textPath></text>
  <line transform=""rotate(222 0,0)"" x1=""-300"" x2=""-200"" y1=""0"" y2=""0"" class=""line3""/>
  <text transform=""rotate(229 0,0)"" class=""text3""><textPath href=""#circle3"">STATEN</textPath></text>
  <line transform=""rotate(284 0,0)"" x1=""-300"" x2=""-200"" y1=""0"" y2=""0"" class=""line3""/>
  <text transform=""rotate(291 0,0)"" class=""text3""><textPath href=""#circle3"">VITAMIN A</textPath></text>

  <!-- Fourth circle -->
  <line transform=""rotate(5 0,0)"" x1=""-400"" x2=""-300"" y1=""0"" y2=""0"" class=""line4""/>
  <text transform=""rotate(11 0,0)"" class=""text4""><textPath href=""#circle4"">ANGLE</textPath></text>
  <line transform=""rotate(48 0,0)"" x1=""-400"" x2=""-300"" y1=""0"" y2=""0"" class=""line4""/>
  <text transform=""rotate(55 0,0)"" class=""text4""><textPath href=""#circle4"">UNCLEAR</textPath></text>
  <line transform=""rotate(103 0,0)"" x1=""-400"" x2=""-300"" y1=""0"" y2=""0"" class=""line4""/>
  <text transform=""rotate(110 0,0)"" class=""text4""><textPath href=""#circle4"">STATIN</textPath></text>
  <line transform=""rotate(148 0,0)"" x1=""-400"" x2=""-300"" y1=""0"" y2=""0"" class=""line4""/>
  <text transform=""rotate(155 0,0)"" class=""text4""><textPath href=""#circle4"">STATION</textPath></text>
  <line transform=""rotate(199 0,0)"" x1=""-400"" x2=""-300"" y1=""0"" y2=""0"" class=""line4""/>
  <text transform=""rotate(206 0,0)"" class=""text4""><textPath href=""#circle4"">POLAR</textPath></text>
  <line transform=""rotate(243 0,0)"" x1=""-400"" x2=""-300"" y1=""0"" y2=""0"" class=""line4""/>
  <text transform=""rotate(249 0,0)"" class=""text4""><textPath href=""#circle4"">VAGUE</textPath></text>
  <line transform=""rotate(287 0,0)"" x1=""-400"" x2=""-300"" y1=""0"" y2=""0"" class=""line4""/>
  <text transform=""rotate(294 0,0)"" class=""text4""><textPath href=""#circle4"">COORDINATES</textPath></text>

  <!-- Fifth circle -->
  <line transform=""rotate(24 0,0)"" x1=""-500"" x2=""-400"" y1=""0"" y2=""0"" class=""line5""/>
  <text transform=""rotate(28 0,0)"" class=""text5""><textPath href=""#circle5"">VARIABLE</textPath></text>
  <line transform=""rotate(66 0,0)"" x1=""-500"" x2=""-400"" y1=""0"" y2=""0"" class=""line5""/>
  <text transform=""rotate(71 0,0)"" class=""text5""><textPath href=""#circle5"">SIGHT</textPath></text>
  <line transform=""rotate(96 0,0)"" x1=""-500"" x2=""-400"" y1=""0"" y2=""0"" class=""line5""/>
  <text transform=""rotate(101 0,0)"" class=""text5""><textPath href=""#circle5"">NUCLEAR</textPath></text>
  <line transform=""rotate(138 0,0)"" x1=""-500"" x2=""-400"" y1=""0"" y2=""0"" class=""line5""/>
  <text transform=""rotate(143 0,0)"" class=""text5""><textPath href=""#circle5"">SPACE</textPath></text>
  <line transform=""rotate(170 0,0)"" x1=""-500"" x2=""-400"" y1=""0"" y2=""0"" class=""line5""/>
  <text transform=""rotate(175 0,0)"" class=""text5""><textPath href=""#circle5"">JOINT</textPath></text>
  <line transform=""rotate(199 0,0)"" x1=""-500"" x2=""-400"" y1=""0"" y2=""0"" class=""line5""/>
  <text transform=""rotate(204 0,0)"" class=""text5""><textPath href=""#circle5"">POLARIS</textPath></text>
  <line transform=""rotate(238 0,0)"" x1=""-500"" x2=""-400"" y1=""0"" y2=""0"" class=""line5""/>
  <text transform=""rotate(243 0,0)"" class=""text5""><textPath href=""#circle5"">COIN</textPath></text>
  <line transform=""rotate(264 0,0)"" x1=""-500"" x2=""-400"" y1=""0"" y2=""0"" class=""line5""/>
  <text transform=""rotate(269 0,0)"" class=""text5""><textPath href=""#circle5"">CAROTENOIDS</textPath></text>
  <line transform=""rotate(323 0,0)"" x1=""-500"" x2=""-400"" y1=""0"" y2=""0"" class=""line5""/>
  <text transform=""rotate(328 0,0)"" class=""text5""><textPath href=""#circle5"">ANKLE</textPath></text>
  <line transform=""rotate(355 0,0)"" x1=""-500"" x2=""-400"" y1=""0"" y2=""0"" class=""line5""/>
  <text transform=""rotate(359 0,0)"" class=""text5""><textPath href=""#circle5"">CORE</textPath></text>

</svg>
";
            WordTargetLayout wordTargetLayout = new WordTargetLayout(new List <string> {
                "VARIABLE", "VALUE", "VAGUE", "UNCLEAR", "NUCLEAR", "CORE", "CORN", "COIN", "JOIN", "JOINT", "ANKLE", "ANGLE", "RIGHT", "SIGHT", "VITAMIN A", "CAROTENOIDS", "COORDINATES", "POLAR", "POLARS", "POLARIS", "STAR", "STARE", "SPARE", "SPACE", "STATION", "STATIN", "STATEN", "STATE"
            });

            wordTargetLayout.AssignWord("STARE", 2);
            wordTargetLayout.AssignWord("STAR", 2);
            wordTargetLayout.AssignWord("JOIN", 2);
            wordTargetLayout.AssignWord("RIGHT", 2);
            wordTargetLayout.AssignWord("SPARE", 3);
            wordTargetLayout.AssignWord("CORN", 3);
            wordTargetLayout.AssignWord("VALUE", 3);
            wordTargetLayout.AssignWord("POLARS", 3);
            wordTargetLayout.AssignWord("STATEN", 3);
            wordTargetLayout.AssignWord("VITAMIN A", 3);
            wordTargetLayout.AssignWord("ANGLE", 4);
            wordTargetLayout.AssignWord("UNCLEAR", 4);
            wordTargetLayout.AssignWord("STATIN", 4);
            wordTargetLayout.AssignWord("STATION", 4);
            wordTargetLayout.AssignWord("POLAR", 4);
            wordTargetLayout.AssignWord("VAGUE", 4);
            wordTargetLayout.AssignWord("COORDINATES", 4);
            wordTargetLayout.AssignWord("SIGHT", 5);
            wordTargetLayout.AssignWord("NUCLEAR", 5);
            wordTargetLayout.AssignWord("SPACE", 5);
            wordTargetLayout.AssignWord("JOINT", 5);
            wordTargetLayout.AssignWord("POLARIS", 5);
            wordTargetLayout.AssignWord("COIN", 5);
            wordTargetLayout.AssignWord("CAROTENOIDS", 5);
            wordTargetLayout.AssignWord("ANKLE", 5);
            wordTargetLayout.AssignWord("CORE", 5);
            wordTargetLayout.SetStartingAngle(2, 80);
            wordTargetLayout.SetStartingAngle(3, 0);
            wordTargetLayout.SetStartingAngle(4, 5);
            string wordTarget = Renderer.RenderWordTarget(wordTargetLayout);

            //System.IO.File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\WordTargetOutput.svg", wordTarget);
            Assert.AreEqual(expected, wordTarget);
        }