// For adding Edge To Graph public void AddEdgeToGraph( String First_IP, String Second_IP, String edge_details, boolean IsSwitch_1, boolean IsSwitch_2) { try { String temp_1 = "OpenVSwitch"; String temp_2 = "OpenVSwitch"; if (!IsSwitch_1) { temp_1 = "EndHost"; } if (!IsSwitch_2) { temp_2 = "EndHost"; } String node_name_1 = temp_1 + " [" + First_IP + "]"; String node_name_2 = temp_2 + " [" + Second_IP + "]"; network_graph.addEdge(edge_details, node_name_1, node_name_2); Edge edge = network_graph.getEdge(edge_details); edge.addAttribute("ui.label", edge.getId()); } catch (Exception e) { } }
private void defaultVisit(CFrame frame) { MultiGraph graph = this.view.getGraph(); graph.getNodeSet().clear(); graph.getEdgeSet().clear(); // this.baseIRIList = new HashSet<String>(); // Получение всех элементов и формирование из них визуального части. for (OWLNamedIndividual owlName : frame.getContent().getConcepts()) { String label = this.model.getLabel(owlName); if (label.equals("_EMPTY_")) { label = owlName.getIRI().getFragment().toString(); } Node node = graph.addNode(owlName.getIRI().toString()); node.addAttribute("OWLNamedIndividual", owlName); node.addAttribute("ui.label", label); if (owlName.getIRI().equals(frame.getTrgConcept().getIRI())) { node.setAttribute("ui.class", "concept"); } } // Связывает все элементы линиями. for (Branch br : frame.getContent().getBranches()) { Node nodeSub = null; Node nodeObj = null; for (Node node : graph.getNodeSet()) { if (node.getId().equals(br.getSubject().getIRI().toString())) { nodeSub = node; continue; } else { if (node.getId().equals(br.getObject().getIRI().toString())) { nodeObj = node; continue; } } if (nodeSub != null && nodeObj != null) { break; } } // Создает элемент линия для двух node. Edge edge = graph.addEdge(br.getBrachIndIRI().toString(), nodeSub, nodeObj, true); String labelEdge = this.model.getAnnotationValue(br.getPrp().getIRI()); if (labelEdge.equals("_EMPTY_")) { labelEdge = br.getPrp().getIRI().getFragment().toString(); } edge.addAttribute("ui.label", labelEdge); } }