java - Rdf and Taxonomie -
i want display result of program tree. need hand finish work , thank in advance.
the program works jdk 8 , version 3 jena. here code:
private void jbutton4actionperformed(java.awt.event.actionevent evt) {//gen-first:event_jbutton4actionperformed jtextarea1.settext(""); model model = modelfactory.createdefaultmodel(); inputstream in = filemanager.get().open("c:/users/samsung/desktop/wicm2/projet/opus_august2007.rdf"); model m = model.read(in,null); nodeiterator nit = m.listobjects(); list<string> lclass = new arraylist<>(); map<string,list<string>> map = new hashmap<>(); stmtiterator si = m.liststatements(); while(si.hasnext()){ statement statement = si.next(); if(statement.getpredicate().getlocalname().equalsignorecase("subclassof")){ string mere = statement.getobject().tostring(); string fils = statement.getsubject().getlocalname(); if(map.containskey(mere)){ list<string> l = map.get(mere); l.add(fils); map.replace(mere, l); }else{ list<string> l = new arraylist<>(); l.add(fils); map.put(mere, l); } } if(statement.getobject().isresource() && statement.getpredicate().getlocalname().equalsignorecase("type")){ if(!lclass.contains(statement.getsubject().getlocalname())){ lclass.add(statement.getsubject().getlocalname()) ; } } } jtextarea1.append("les classes:\n"); for(string classe:lclass){ jtextarea1.append(classe+"\n"); } jtextarea1.append("les classe et les sous classes:\n"); for(string l : map.keyset()){ jtextarea1.append("classe mere : "+l+"\n"); for(string s:map.get(l)){ jtextarea1.append(" classe fils:"+s+"\n"); } } }
or simple program of tree in java gui okay. thanks