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 hozo.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){ if(pathlist.length==0){ JOptionPane.showMessageDialog(null, "NO PATH!!"); return; } Path path = pathlist[0]; this.exbp.exbp_node_center = new ExbpNode(getTempLabel(path.getStartClass())); for(int i = 0; i"+path.getClassLinks().size()); String target_class = path.getStartClass(); // ExbpNode node = this.exbp.findExbpNode(target_class); ExbpNode node = this.exbp.exbp_node_center; List links = path.getClassLinks(); for(ClassLink link : links){ String next_class = link.getLinkedClassURI(); System.out.println("==>"+next_class); /* String next_class_lbl =""; int index = next_class.lastIndexOf("/"); if(index>0 && index0 && index20 && index0 && index2"+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