}
private void buildGraph(final File firstFile, final File secondFile) throws IOException {
try {
this.main.log(String.format("Loading %s...", firstFile.getName()));
final OntologyManager firstOntologyManager = new OntologyManager(firstFile, this.main);
final IOntologyGraph[] firstOntologyGraph = {null};
Thread firstGraphThread = new Thread(new Runnable() {
public void run() {
try {
firstOntologyGraph[0] = firstOntologyManager.load(new ClassAnnotationVisitor(), new PropertyVisitor());
} catch (Throwable e1) {
handleException(e1);
}
}
});
firstGraphThread.start();
final OntologyManager secondOntologyManager = new OntologyManager(secondFile, this.main);
Open.this.main.log(String.format("Loading %s...", secondFile.getName()));
IOntologyGraph secondOntologyGraph = secondOntologyManager.load(new ClassAnnotationVisitor(), new PropertyVisitor());
try {
firstGraphThread.join();
} catch (InterruptedException e) {
// ignore;
}
if (firstOntologyGraph[0] == null) {
return;
}
this.main.log("Merging ontologies...");
IOntologyComparator ontologyComparator = new OntologyComparator(firstOntologyGraph[0], secondOntologyGraph, this.main);
IOntologyGraph ontologyGraph = ontologyComparator.mapOntologies().getFirst();
int similarity = (int) (ontologyComparator.getSimilarity() * 100);
final IGraphModelBuilder myGraphModelBuilder =
new GraphModelBuilder(firstOntologyGraph[0], secondOntologyGraph, ontologyGraph, similarity, this.main);
this.main.log("Visualising ontologies...");
GraphModel graphModel = myGraphModelBuilder.buildGraphModel(main.getGraphPane(), main.areUnmappedConceptsVisible(), main.areUnmappedConceptsWithSynsetsVisible());
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology result = OntologyManager.saveOntologies(manager, firstOntologyManager.getOntology(), secondOntologyManager.getOntology());
onGraphModelBuilt(manager, result);
this.main.setGraphModel(graphModel);
ITreeBuilder firstTreeBuilder = new TreeBuilder(firstFile.getName(), firstOntologyGraph[0].getRoots());
ITreeBuilder secondTreeBuilder = new TreeBuilder(secondFile.getName(), secondOntologyGraph.getRoots());
this.main.setTrees(firstTreeBuilder.buildTree(main.areUnmappedConceptsVisible(), main.areUnmappedConceptsWithSynsetsVisible()), secondTreeBuilder.buildTree(main.areUnmappedConceptsVisible(), main.areUnmappedConceptsWithSynsetsVisible()));