| Home | Developers | Screenshots | Downloads | Roadmap | Documentation | Bugs | Resources | Acknowledgement |


Documentation

On this page you will find all the documentation of the OWL2Prefuse package. There is an API which you can use to find the details about the objects and methods of the OWL2Prefuse package. There are also a few simple HOWTO's to help beginning users get started.

OWL2Prefuse API

The complete JavaDoc of this package can be found here: OWL2Prefuse API.

HOWTO's

These HOWTO's are available:

Tree - create from an OWL file

To create a Prefuse tree from an OWL file and put it into a JPanel, these three things need to be done:

  1. Convert the OWL file to a Prefuse tree
  2. Create a tree display (extension of Prefuse display) for the tree
  3. Create a tree panel (extension of JPanel) for the tree display

The following method realizes this:


<?php /**
 * This method creates a JPanel which depicts a Prefuse tree from an OWL file.
 * @param p_OWLFile The file path to the OWL file.
 * @return The JPanel containing the Prefuse tree.
 */
public TreePanel createTreePanel(String p_OWLFile)
{
    
// Step 1 - Create the Prefuse tree from an OWL file.
    
OWLTreeConverter treeConverter = new OWLTreeConverter(p_OWLFile);
    
Tree tree treeConverter.getTree();
    
    
// Step 2 - Create a tree display.
    
TreeDisplay treeDisp = new TreeDisplay(tree);
    
    
// Step 3 - Create a panel for the tree display, showing the legend and the 
    // widgets to control the orientation of the tree.
    
TreePanel treePanel = new TreePanel(treeDisptruetrue);

    return 
treePanel;
}

The resulting JPanel can than be added to you GUI to start using the tree representations of the OWL ontology.
Note #1: if you do not want to have control widgets for the orientation of the tree in you JPanel, the second argument in new TreePanel(treeDisp, true) should be false.

Tree - create from a Jena OntModel

To create a Prefuse tree from a Jena OntModel and put it into a JPanel only the first step of the Tree - from an OWL file HOWTO needs to be changed. Instead of converting an OWL file to a Prefuse tree, a Jena OntModel needs to be converted. The following method creates a JPanel containing a Prefuse tree, created from a Jena OntModel:


<?php /**
 * This method creates a JPanel which depicts a Prefuse tree, created from a Jena OntModel.
 * @param p_ontModel The Jena OntModel.
 * @return The JPanel containing the Prefuse tree.
 */
public TreePanel createTreePanel(OntModel p_ontModel)
{
    
// Step 1 - Create the Prefuse tree from a Jena OntModel.
    
OWLTreeConverter treeConverter = new OWLTreeConverter(p_ontModel);
    
Tree tree treeConverter.getTree();
    
    
// Step 2 - Create a tree display.
    
TreeDisplay treeDisp = new TreeDisplay(tree);
    
    
// Step 3 - Create a panel for the tree display, showing the legend and the 
    // widgets to control the orientation of the tree.
    
TreePanel treePanel = new TreePanel(treeDisptruetrue);

    return 
treePanel;
}

Tree - create from a TreeML file

To create a Prefuse tree from a TreeML file and put it into a JPanel only the first step of the Tree - from an OWL file HOWTO needs to be changed. Instead of converting an OWL file to a Prefuse tree, a TreeML file needs to be loaded. The following method creates a JPanel containing a Prefuse tree, loaded from TreeML:


<?php /**
 * This method creates a JPanel which depicts a Prefuse tree from a TreeML file.
 * @param p_TreeMLFile The file path to the TreeML file.
 * @return The JPanel containing the Prefuse tree.
 */
public TreePanel createTreePanel(String p_TreeMLFile)
{
    
// Step 1 - Create the Prefuse tree from a TreeML file.
    
Tree tree Loader.loadTreeML(p_TreeMLFile);
    
    
// Step 2 - Create a tree display.
    
TreeDisplay treeDisp = new TreeDisplay(tree);
    
    
// Step 3 - Create a panel for the tree display, showing the legend and the 
    // widgets to control the orientation of the tree.
    
TreePanel treePanel = new TreePanel(treeDisptruetrue);

    return 
treePanel;
}

Tree - export to a TreeML file

The OWL2Prefsue package is able to export the Prefuse tree to a TreeML file. The following method realizes this:


<?php /**
 * This exports a Prefuse tree to TreeML.
 * @param p_tree The tree to be written to TreeML.
 * @param p_file The file to which the TreeML is written.
 */
public void writeTreeML(Tree p_treeString p_File)
{
    
Writer.writeTreeML(p_treep_file);
}

Graph - create from an OWL file

To create a Prefuse graph from an OWL file and put it into a JPanel, these three things need to be done:

  1. Convert the OWL file to a Prefuse graph
  2. Create a graph display (extension of Prefuse display) for the graph
  3. Create a graph panel (extension of JPanel) for the graph display

The following method realizes this:


<?php /**
 * This method creates a JPanel which depicts a Prefuse graph from an OWL file.
 * @param p_OWLFile The file path to the OWL file.
 * @return The JPanel containing the Prefuse graph.
 */
public GraphPanel createGraphPanel(String p_OWLFile)
{
    
// Step 1 - Create the directed Prefuse graph from an OWL file.
    
OWLGraphConverter graphConverter = new OWLGraphConverter(p_OWLFiletrue);
    
Graph graph graphConverter.getGraph();
    
    
// Step 2 - Create a graph display, using the graph distance filter.
    
GraphDisplay graphDisp = new GraphDisplay(graphtrue);
    
    
// Step 3 - Create a panel for the graph display, showing the legend and the 
    // widget to control the number of hops of the graph distance filter.
    
GraphPanel graphPanel = new GraphPanel(graphDisptruetrue);

    return 
graphPanel;
}

The resulting JPanel can than be added to you GUI to start using the graph representations of the OWL ontology.
Note #1: if you want an undirected graph, the second argument in new OWLGraphConverter(OWL_FILE, true) should be false.
Note #2: if you do not want to use a graph distance filter, the second argument in new GraphDisplay(m_graph, true) should be false.
Note #3: if you do not want to have a control widget for the number of hops of the graph distance filter in your JPanel, the second argument in new GraphPanel(graphDisp, true) should be false.

Graph - create from a Jena OntModel

To create a Prefuse graph from a Jena OntModel and put it into a JPanel only the first step of the Graph - from an OWL file HOWTO needs to be changed. Instead of converting an OWL file to a Prefuse graph, a Jena OntModel needs to be converted. The following method creates a JPanel containing a Prefuse graph, created from a Jena OntModel:


<?php /**
 * This method creates a JPanel which depicts a Prefuse graph, created from a Jena OntModel.
 * @param p_ontModel The Jena OntModel.
 * @return The JPanel containing the Prefuse graph.
 */
public GraphPanel createGraphPanel(OntModel p_ontModel)
{
    
// Step 1 - Create the directed Prefuse graph from an OWL file.
    
OWLGraphConverter graphConverter = new OWLGraphConverter(p_ontModeltrue);
    
Graph graph graphConverter.getGraph();
    
    
// Step 2 - Create a graph display, using the graph distance filter.
    
GraphDisplay graphDisp = new GraphDisplay(graphtrue);
    
    
// Step 3 - Create a panel for the graph display, showing the legend and the 
    // widget to control the number of hops of the graph distance filter.
    
GraphPanel graphPanel = new GraphPanel(graphDisptruetrue);

    return 
graphPanel;
}

Graph - create from a GraphML file

To create a Prefuse graph from a GraphML file and put it into a JPanel only the first step of the Graph - from an OWL file HOWTO needs to be changed. Instead of converting an OWL file to a Prefuse graph, a GraphML file needs to be loaded. The following method creates a JPanel containing a Prefuse graph, loaded from GraphML:


<?php /**
 * This method creates a JPanel which depicts a Prefuse graph from a GraphML file.
 * @param p_GraphMLFile The file path to the GraphML file.
 * @return The JPanel containing the Prefuse graph.
 */
public GraphPanel createGraphPanel(String p_GraphMLFile)
{
    
// Step 1 - Create the Prefuse graph from a GraphML file.
    
Graph graph Loader.loadGraphML(p_GraphMLFile);
    
    
// Step 2 - Create a graph display, using the graph distance filter.
    
GraphDisplay graphDisp = new GraphDisplay(graphtrue);
    
    
// Step 3 - Create a panel for the graph display, showing the legend and the 
    // widget to control the number of hops of the graph distance filter.
    
GraphPanel graphPanel = new GraphPanel(graphDisptruetrue);

    return 
graphPanel;
}

Graph - export to a GraphML file

The OWL2Prefsue package is able to export the Prefuse graph to a GraphML file. The following method realizes this:


<?php /**
 * This exports a Prefuse graph to GraphML.
 * @param p_graph The graph to be written to GraphML.
 * @param p_file The file to which the GraphML is written.
 */
public void writeGraphML(Graph p_graphString p_File)
{
    
Writer.writeGraphML(p_graphp_file);
}

Tree and graph - export to an image file

The OWL2Prefuse package contains an interface called "ExportableGraphic". The tree- and graph-panels both implement this interface, which means that they have a method called "export" which exports the tree (or graph) to an image file. At this moment OWL2Prefuse only supports .png and .jpg files. The following piece of code displays the signature of the "export" function. If you have a GraphPanel of TreePanel object, this "export" method can be called upon.


<?php /**
 * Export the display of the object which implements this interface, to the 
 * given file type.
 * @param p_file The file which is going to contain the export, valid file types 
 * are: "png" and "jpg".
 * @param p_fileType The file type of the image to be created.
 */
void export(File p_fileString p_fileType);