package hozo.maptool; import java.awt.Color; import java.awt.Font; import java.io.File; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.Vector; import javax.swing.JOptionPane; import jp.ac.osaka_u.sanken.sparql.gui.SparqlBuilderPanel; import org.biohackathon.SPARQLBuilder.OWL.ClassLink; import org.biohackathon.SPARQLBuilder.OWL.Direction; import org.biohackathon.SPARQLBuilder.OWL.Path; /*** 2008/10/18 #kozaki  MAP生成のために,法造やOWLのAPIから,マップ用のデータを作成するための  メソッド類をこのクラスにまとめる. ***/ public class MapFactory implements Runnable{ ExtendBP exbp; public ExtendFrame exbpframe; Vector focal_points;//最初に選択したNode(など)を保持する boolean isSubLung; static boolean isGrayView=false; Vector checked_nodes; boolean search_shortest=true;//サーチパスで最短パスを検索する int serch_depth = 10;//サーチパスで最短パスを検索する深さ(最短パス検索をしないときは必ず使う) Vector temp_nodes; SparqlBuilderPanel spBuilder; public static void main (String[] args) { MapFactory map = new MapFactory(); //map.loadPathList(map.getDummyPathList()); } public List getDummyPathList(){ ArrayList pathlist = new ArrayList(); ArrayList class_link_list = new ArrayList() {{ add(new ClassLink("propertyURI", "linkedClassURI2", Direction.forward)); add(new ClassLink("propertyURI2", "linkedClassURI3", Direction.forward)); add(new ClassLink("propertyURI3", "linkedClassURI4", Direction.forward)); }}; Path path = new Path("StartClass1", class_link_list); pathlist.add(path); return pathlist; } public void setSPARQLbuilder(SparqlBuilderPanel builder){ this.spBuilder = builder; } // void setSPARQLquery(Path path){ // this.spBuilder; // } public MapFactory() { exbpframe = new ExtendFrame(this); exbp = exbpframe.getExtendBP(); focal_points = new Vector(); temp_nodes = new Vector(); // focal_points.add("TEST"); // focal_points.add("TEST2"); // isSubLung=hze.isSubLang; // isGrayView=hze.isGrayView;//#kozaki 2009/07/28 // exbp.setHZEditor(hze); // exbpframe.select_dialog = new EtendBPSelectDialog(exbp,exbpframe); exbpframe.setVisible(true); exbpframe.RefreshExbp(); // if(focal_points.size()==1){ // exbp.cmd_dialog.setCommandOptions(exbp.exbp_node_center); // } // // treeSelectDialog = new TreeSelectDialog(true); // treeSelectDialog.setHZEditor(this.hzEditor); // treeSelectDialog.setSubLang(this.isSubLung); // treeSelectDialog.setSize(450, 600); // } public void loadPathList(Path[] pathlist){ Path path = pathlist[0]; this.exbp.exbp_node_center = new ExbpNode(path.getStartClass()); for(int i = 0; i"+path.getClassLinks().size()); String target_class = path.getStartClass(); ExbpNode node = this.exbp.findExbpNode(target_class); List links = path.getClassLinks(); for(ClassLink link : links){ String next_class = link.getLinkedClassURI(); System.out.println("==>"+next_class); ExbpNode next_node = new ExbpNode(next_class); next_node.setOrgNode(path); node.addChild(next_node); node = next_node; String prop = link.getPropertyURI(); if(link.getDirection().equals(Direction.reverse)){ prop += "[<=]"; } else if(link.getDirection().equals(Direction.both)){ prop += "[<=>]"; } next_node.key = prop; } } //元となるEditor等でMapToolを管理しているVectorを返す【Hozo以外ではオーバーライドする】 Vector getMapVec(){ return null; } //元となるオントロジーのファイルを返す【Hozo以外ではオーバーライドする】 File getFile(){ return null; } //すべてのロールの一覧を返す Vector getRoleList(){ Vector roles = new Vector(); /* Enumeration en = this.hzEditor.WCEditor.browsingPanel.node_lists.elements(); while(en.hasMoreElements()){ Node n =(Node)en.nextElement(); Enumeration slot_en = n.getSlots().elements(); while(slot_en.hasMoreElements()){ Slot slot =(Slot)slot_en.nextElement(); if(!roles.contains(slot.getRoleName())){ roles.addElement(slot.getRoleName()); } } } */ return roles; } //元となるオントロジーでの選択(クリック)処理【Hozo以外ではオーバーライドする】 void selected(ExbpNode exbpnode){ // this.hzEditor.WCEditor.browsingPanel.Jump(exbpnode.getHozoNode()); } //元となるオントロジーでの選択(クリック)処理【Hozo以外ではオーバーライドする】 void selectedClear(){ // this.hzEditor.WCEditor.definitionPanel.uncursel(); // this.hzEditor.WCEditor.browsingPanel.pick(null, false); } //OpenしたMAPとオントロジーの元データの対応づけ void setOrgNodes(){ /* if (this.hzEditor==null) { System.out.println("ERROR!!:::HzEditor is NOT FOUND!"); return; } Enumeration en =exbp.nodes.elements(); while(en.hasMoreElements()){ ExbpNode node =(ExbpNode)en.nextElement(); String lbl = node.getLabel(); Node org_node; if(lbl.endsWith("[RH]")){ lbl=lbl.substring(0,lbl.indexOf("[RH]")); //System.out.println(node.getLabel()+"====>"+lbl); if(this.isSubLung){ org_node = this.hzEditor.WCEditor.findNodeWithSubLang(lbl); } else{ org_node = this.hzEditor.findRH(lbl); } } else{ if(this.isSubLung){ org_node = this.hzEditor.WCEditor.findNodeWithSubLang(lbl); } else{ org_node = this.hzEditor.findNode(lbl); } } node.setOrgNode(org_node); if(org_node!=null){ //System.out.println("setOrgNodes:::"+lbl+"<=>"+org_node.getLabel()); }else{ //System.out.println("setOrgNodes:::"+lbl+"<=>NOT FOUND!"); } } */ } //元となるObjectからFocalPointとなるExbpNodeを作る【Hozo以外ではオーバーライドする】 ExbpNode[] setFocalPoints(){ // if (this.hzEditor==null) return null; ExbpNode[] exbpnodes = null; exbp.nodes.removeAllElements(); // Vector chi_nodes; // GraphicObject gobj=null; // Object ob=null; if (focal_points.size() == 1) {//1つのNodeを選択した際の処理 Object gobj = focal_points.firstElement(); //gobj =(GraphicObject) focal_points.firstElement(); if(gobj instanceof String){ exbp.exbp_node_center =new ExbpNode((String)gobj); exbp.exbp_node_center.setOrgNode(gobj); exbp.nodes.add(exbp.exbp_node_center); exbpnodes = new ExbpNode[1]; exbpnodes[0]=exbp.exbp_node_center; } else if(gobj instanceof Object){ System.out.println("*** ERROR:Nodeを選択する必要があります::" ); } else{//選択なしの場合は,エラーを出して終了 JOptionPane.showMessageDialog(exbpframe, "You Have to select [Node]!", "ERROR", JOptionPane.ERROR_MESSAGE); System.out.println("ERROR:Nodeを選択する必要があります::" ); exbpframe.dispose(); } } else {//複数Nodeを選択した際の処理 if(focal_points.size() > 1){ exbp.exbp_node_center = new ExbpNode("(ROOT)"); exbp.nodes.addElement(exbp.exbp_node_center); Vector chi_nodes = new Vector(); Enumeration node_en = focal_points.elements(); while(node_en.hasMoreElements()){ Object gobj2 = node_en.nextElement(); if(gobj2 instanceof String){ ExbpNode chinode = new ExbpNode((String)gobj2); chinode.setOrgNode(gobj2); exbp.exbp_node_center.addChild(chinode); exbp.nodes.add(chinode); } exbpnodes = new ExbpNode[exbp.exbp_node_center.children.size()]; for(int i=0;i exbpnodes){} /* public String[] getSelectedClass(String[] labels){ TreeSelectDialog treeSelectDialog = new TreeSelectDialog(true); treeSelectDialog.setHZEditor(this.hzEditor); treeSelectDialog.setSubLang(this.isSubLung); treeSelectDialog.updateTree(); //treeSelectDialog.setSize(320, 450); if(labels.length>0){ String label = labels[0]; for(int i=1;i