public static DefaultGraph createGraphFromOntoSpreadState(OntologyDAO ontologyDAO, OntoSpreadState ontoSpreadState) throws Exception{
DefaultGraph graph = new DefaultGraph();
ArrayList <Node> nodes = new ArrayList <Node> ();
ArrayList <Edge> edges = new ArrayList <Edge> ();
//FIXME: Refactor, using relations and draw instances and concepts, equals
Node root = new PrintNode( ApplicationResources.getString("info.node.root"));
Node initialRoot = new PrintNode( ApplicationResources.getString("initial.node.root"));
Map<String, Double> concepts = ontoSpreadState.getConcepts();
for (ScoredConceptTO initialConcept : ontoSpreadState.getInitialConcepts()) {
ConceptTO conceptTO = ontologyDAO.getConceptTO(initialConcept.getConceptUri());
Node node = new InitialNode(formatActivation(conceptTO.getName(),concepts.get(conceptTO.getUri())),conceptTO.getUri());
edges.add(new LineEdge(initialRoot,node));
nodes.add(node);
}
Node spreadedRoot = new PrintNode( ApplicationResources.getString("initial.node.spreaded"));
for (String currentSpread : ontoSpreadState.getSpreadedConcepts()) {
ConceptTO conceptTO = ontologyDAO.getConceptTO(currentSpread);
Node currentNode = new SpreadNode(formatActivation(conceptTO.getName(),concepts.get(conceptTO.getUri())),conceptTO.getUri());
edges.add(new LineEdge(spreadedRoot,currentNode));
nodes.add(currentNode);
}
Node activatedRoot = new PrintNode(ApplicationResources.getString("initial.node.activated") );
for (UriDepthPair activated : ontoSpreadState.getSortedList()) {
ConceptTO conceptTO = ontologyDAO.getConceptTO(activated.getUri());
Node currentNode = new ActivateNode(formatActivation(conceptTO.getName(),concepts.get(conceptTO.getUri())),conceptTO.getUri());
edges.add(new ArrowEdge(activatedRoot,currentNode));
nodes.add(currentNode);
}
//Creating skeleton of graph
edges.add(new LineEdge(root,initialRoot));