Beispiel #1
0
 private void AddChildNodes(ShapeBase currentShape, Parse[] childParses)
 {
     foreach (Parse childParse in childParses)
     {
         // if this is not a token node (token node = one of the words of the sentence)
         if (childParse.Type != MaximumEntropyParser.TokenNode)
         {
             ShapeBase childShape = currentShape.AddChild(childParse.Type);
             if (childParse.IsPosTag)
             {
                 childShape.ShapeColor = Color.DarkGoldenrod;
             }
             else
             {
                 childShape.ShapeColor = Color.SteelBlue;
             }
             AddChildNodes(childShape, childParse.GetChildren());
             childShape.Expand();
         }
         else
         {
             Span      parseSpan  = childParse.Span;
             string    token      = childParse.Text.Substring(parseSpan.Start, (parseSpan.End) - (parseSpan.Start));
             ShapeBase childShape = currentShape.AddChild(token);
             childShape.ShapeColor = Color.Ivory;
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Makes a simple demo diagram (not scientifically correct)
        /// </summary>
        private void MakeExample()
        {
            this.lithiumControl.Root.Text = "Ecosystem";
            ShapeBase root = this.lithiumControl.Root;

            ShapeBase ert = root.AddChild("Earth");
            ShapeBase com = root.AddChild("Community");

            ShapeBase pop = com.AddChild("Population");
            ShapeBase org = com.AddChild("Organism");
            ShapeBase bac = com.AddChild("Bacteria");
            ShapeBase vir = com.AddChild("Virus");

            com.Expand();

            ShapeBase euk  = bac.AddChild("Eukaryotes");
            ShapeBase arch = bac.AddChild("Archea");
            ShapeBase pro  = euk.AddChild("Protista");
            ShapeBase fla  = pro.AddChild("Flagellates");
            ShapeBase amo  = pro.AddChild("Amoeba");
            ShapeBase alg  = pro.AddChild("Algae");
            ShapeBase par  = pro.AddChild("Parasites");


            ShapeBase anim = pop.AddChild("Animals");
            ShapeBase pla  = pop.AddChild("Plants");
            ShapeBase ins  = pop.AddChild("Insects");

            ShapeBase ant = ins.AddChild("Ants");

            ShapeBase mus = pop.AddChild("Mushrooms");


            //re-order and center a bit to please the eyes
            root.Move(new Point(20 - root.X, Convert.ToInt32(this.lithiumControl.Height / 2) - root.Y));
            bac.Collapse(true);

            //as well as some coloring
            this.mnuColorLevels_Click(null, EventArgs.Empty);
        }