Exemplo n.º 1
0
 public OntologyReader(IOwlParser owlParser)
 {
     this.owlParser = owlParser;
 }
Exemplo n.º 2
0
        public void test9(string file)
        {
            parser = new OwlXmlParser();
            graph  = parser.ParseOwl(file);

            System.Windows.Forms.Form form = new System.Windows.Forms.Form();

            form.Size = new Size(1200, 700);

            //create a viewer object
            viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object
            graph2 = new Microsoft.Msagl.Drawing.Graph("graph2");

            graph2.LayoutAlgorithmSettings = new Microsoft.Msagl.Layout.MDS.MdsLayoutSettings();


            form2 = new System.Windows.Forms.Form();

            lista.Size      = new Size(200, 30);
            lista.Location  = new Point(40, 30);
            lista2.Size     = new Size(200, 30);
            lista2.Location = new Point(40, 80);
            System.Windows.Forms.Button button = new System.Windows.Forms.Button();
            button.Size     = new Size(200, 30);
            button.Location = new Point(40, 130);
            button.Text     = "Wybierz";
            button.Click   += button_click;

            IDictionaryEnumerator nEnumerator = (IDictionaryEnumerator)graph.Nodes.GetEnumerator();

            while (nEnumerator.MoveNext())
            {
                // Get the node from the graph
                OwlNode node = (OwlNode)graph.Nodes[(nEnumerator.Key).ToString()];

                // We will cast the node to a OwlIndividual because we are looking for individuals
                OwlIndividual indNode = node as OwlIndividual;
                // If indNode is different from null, then we are dealing with an OwlIndividual -> OK
                // If the indNode is not anonymous, means that we have an individual with a proper name -> OK
                if ((indNode != null) && (!indNode.IsAnonymous()))
                {
                    // So, now we have a good owl-individual

                    Console.WriteLine(indNode.ID.Replace("urn:absolute:sample#", "") + ":");
                    foreach (OwlEdge a in indNode.ChildEdges)
                    {
                        Console.WriteLine((a.ParentNode.ID + " " + a.ID + " " + a.ChildNode.ID));

                        if (a.ChildNode.ID != "http://www.w3.org/2002/07/owl#NamedIndividual")
                        {
                            Microsoft.Msagl.Drawing.Edge edge = graph2.AddEdge(a.ParentNode.ID, a.ChildNode.ID);
                            edge.LabelText = a.ID;

                            if (!lista.Items.Contains(a.ParentNode.ID))
                            {
                                lista.Items.Add(a.ParentNode.ID);
                                lista2.Items.Add(a.ParentNode.ID);
                            }
                        }
                    }

                    /*
                     * foreach (OwlEdge a in indNode.ParentEdges)
                     * {
                     *  Console.WriteLine((a.ParentNode.ID + " " + a.ID + " " + a.ChildNode.ID).Replace("urn:absolute:sample#", "").Replace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "").Replace("http://www.w3.org/2000/01/rdf-schema#", ""));
                     * }
                     */


                    Console.Write("\n \n");
                }
            }
            //bind the graph to the viewer
            viewer.Graph = graph2;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            //show the form
            form.Show();


            form2.Controls.Add(lista);

            form2.Controls.Add(lista2);

            form2.Controls.Add(button);

            //show the form
            form2.ShowDialog();


            //Console.WriteLine(graph.Edges.Count);
            Console.ReadLine();
        }
Exemplo n.º 3
0
 public OntologyReader()
 {
     owlParser = ObjectFactory.GetInstance<IOwlParser>();
 }