예제 #1
0
        //CREATING CONNECTIVE/TABLEAUX TREE PICTURE
        public static string CreateStructurePicture(Connective startCon)
        {
            if (startCon == null)
            {
                throw new NullReferenceException();
            }
            //Console.WriteLine("PropositionReader: creating structure picture");
            List <Connective> allConnectives = startCon.GetAllConnectives();

            FileStream   fs;
            StreamWriter sw;
            string       fileName = "abc.dot";

            try
            {
                fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
                sw = new StreamWriter(fs);
                sw.WriteLine("graph calculus {");
                sw.WriteLine("node [ fontname = \"Arial\" ]");

                for (int i = 0; i < allConnectives.Count; i++)
                {
                    sw.WriteLine("node" + (allConnectives[i].ID) + " [ label = \"" + allConnectives[i].GetLocalString() + "\" ]");
                    //if (allNodes[i].Parent != null)
                    //{
                    //    sw.WriteLine("node" + (allNodes[i].Parent.ID) + " -- node" + (allNodes[i].ID));
                    //}
                    //if (allConnectives[i].Con1 != null)
                    //{
                    //    sw.WriteLine("node" + (allConnectives[i].ID) + " -- node" + (allConnectives[i].Con1.ID));
                    //}
                    //if (allConnectives[i].Con2 != null)
                    //{
                    //    sw.WriteLine("node" + (allConnectives[i].ID) + " -- node" + (allConnectives[i].Con2.ID));
                    //}
                    if (allConnectives[i] is ConnectiveOne)
                    {
                        sw.WriteLine("node" + (allConnectives[i].ID) + " -- node" + ((ConnectiveOne)allConnectives[i]).Con1.ID);
                    }
                    if (allConnectives[i] is ConnectiveTwo)
                    {
                        sw.WriteLine("node" + (allConnectives[i].ID) + " -- node" + ((ConnectiveTwo)allConnectives[i]).Con2.ID);
                    }
                }
                sw.WriteLine("}");
                sw.Close();
            }
            catch (IOException)
            {
                throw new Exception("Structure picture failed");
            }
            return(CreateDotPNG(fileName));
        }
예제 #2
0
        public override List <Connective> GetAllConnectives()
        {
            List <Connective> fullList = new List <Connective>();

            fullList.Add(this);
            if (con1 != null)
            {
                foreach (Connective con in con1.GetAllConnectives())
                {
                    fullList.Add(con);
                }
            }
            return(fullList);
        }