package hozo.maptool; import java.awt.BorderLayout; import java.awt.Checkbox; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.GridLayout; import java.awt.Image; import java.awt.Point; import java.awt.Toolkit; import java.awt.event.*; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import java.io.*; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComboBox; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.JList; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.beans.*; public class ExtendFrame extends JFrame { private static final long serialVersionUID = 1L; //#kozaki 2008/10/05�@GUI�̃A�N�Z�X��private����ύX private ExtendBP _exbp = null; JScrollPane jsp_exbp; JTextField jtf_nodesize = new JTextField("12",5); JTextField jtf_layer = new JTextField("4",5); JTextField jtf_width = new JTextField("100",5); JTextField jtf_scale = new JTextField("10",5); JTextField jtf_rotation = new JTextField("0",5); JCheckBox jCB_VisibleCenter; JCheckBox jCB_VisibleInflu; JCheckBox jCB_VisibleLink; JCheckBox jCB_VisibleLayer; JCheckBox jCB_VisibleBorder; JTextField jTF_Option; private JComboBox jCB_LayoputOption; private JComboBox jCB_LocalPath; private String _localProjectRootPath; private List _localPathList; private static final int MAX_HISTORY_SIZE = 10; private static String HISTORY_PATH = "temp"; private static String LOCAL_HISTORY_FILE_NAME = "map.his"; private static final String DEFAULT_TITLE = "Hozo2Map"; private static final String SERVICE_URL_FILE = "extools.ini"; protected static final String DEFAULT_SERVICE_URL = "http://localhost:8080"; protected static String SERVICE_URL = DEFAULT_SERVICE_URL; private JButton select_option = new JButton("..."); // EtendBPSelectDialog select_dialog; JCheckBox jCB_stop; JCheckBox jCB_PlaceOnLayer; JCheckBox jCB_showEdges; public int rotation = 0; Double arc = 1.0; JCheckBox jCB_stoplist; String[] stoplist_string={ "process","object","quantity","flow","agent","value", "attribute","natural construction","substance","Artificial object", "action","activity","situation","substrate","Big","Speed","direction of change", "�v���Z�X","��","�l�H��","����","����","��","����","�G�[�W�F���g","�l"}; JMenuItem JMI_stoplist = new JMenuItem("Edit Stop List"); JMenuBar menubar = new JMenuBar(); JMenu filemenu = new JMenu("File"); JMenu viewmenu = new JMenu("View"); //#ohta 2008/11/18 View���j���[�̒lj� JMenuItem JMI_OpenMap = new JMenuItem("OpenMap"); JMenuItem JMI_SaveMap = new JMenuItem("SaveMap"); JMenuItem JMI_MergeMap = new JMenuItem("MergeMap"); JMenuItem JMI_CompareMap = new JMenuItem("Compare Maps"); JMenuItem JMI_ShowAspects = new JMenuItem("show Aspect Dialog"); JMenuItem JMI_ChangeView = new JMenuItem("Change View"); JMenuItem JMI_SerachPath = new JMenuItem("Search Path"); JMenuItem JMI_SerachPathEasy = new JMenuItem("Search Path (Easy)"); JMenuItem JMI_ChangeViewRole = new JMenuItem("Change View(by Role)"); JCheckBoxMenuItem JCMI_isSublang = new JCheckBoxMenuItem("Sub Langage"); // #hirota 09/5/14 JMenuItem JMI_ChangeViewRole_at = new JMenuItem("Change View(by Role_attribute)"); // #kozaki�@2010/01/25�@�\������MAP����I�������X���b�g�l�i�����j�����ƒm�[�h���n�C���C�g JMenuItem JMI_ChangeViewClass_at = new JMenuItem("Change View(by Class_attribute)"); // #kozaki�@2009/05/27 JMenuItem JMI_MatrixView = new JMenuItem("Matrix View"); public ExtendFrame compare_map; //#kozaki 2008/08/18 //#hirota mappath��r�p int max_node_tensuu=0,max_link_tensuu=0; public Vector path_list = new Vector(); // ���ϐ� public Vector subpath_list = new Vector(); // /** * This is the default constructor */ public ExtendFrame(MapFactory fac) { super(); _exbp = new ExtendBP(fac); _exbp._extendFrame=this; _exbp.setPreferredSize(new Dimension(2000,2000)); // #hirota 09/4/27 add // _exbp._extendFrame.setLocation(_exbp.cmd_dialog.getWidth(), 0); //new DockingListener(_exbp._extendFrame, _exbp.cmd_dialog); initialize(); this._localPathList = new ArrayList(); this.setLocalPathHistory(); // �q�X�g���[�̓Ǎ� this.updateDisplay(); // ��ʂ��X�V���� this.getServiceURL(); // URL�̎�荞�� } public static void main (String[] args) { ExtendFrame exfm = new ExtendFrame(null); //exfm.setHZEditor(_hzEditor); exfm._exbp.exbp_node_center=new ExbpNode(0,0,0,0); exfm.setVisible(true); //exfm.RefreshExbp(); } //#kozaki 2008/08/18 //#hirota 08/20 void setCompare(){ //System.out.println("setCompare:::"); if(this._exbp.mapfactory.getMapVec().size() == 1){ System.out.println("not Compare!!!"); return; } // Map_vec dialog �\�� Vector tmp = new Vector();// select_name�Ǘ� Vector Exf = new Vector(); Enumeration e = this._exbp.mapfactory.getMapVec().elements(); while(e.hasMoreElements()){ ExtendFrame f = (ExtendFrame)e.nextElement(); if(!this.equals(f)) { tmp.add(f._exbp.exbp_node_center.getLabel() + ":" + f.getOption()); Exf.add(f); } } JList jlist = new JList(tmp); JScrollPane jsc = new JScrollPane(jlist); int ans = JOptionPane.showConfirmDialog(this,jsc,"Compare ",JOptionPane.YES_NO_CANCEL_OPTION ); this._exbp.topicColorList.add(Color.red); this._exbp.topicColorList.add(Color.blue); ExtendFrame comp=null; if(ans==JOptionPane.YES_OPTION ){ comp = (ExtendFrame)Exf.elementAt(jlist.getSelectedIndex()); comp._exbp.topicColorList.add(Color.red); comp._exbp.topicColorList.add(Color.blue); System.out.println("select ::"+ comp._exbp.exbp_node_center.getLabel() + ":" + comp.getOption()); // check Enumeration en = this.getExtendBP().nodes.elements(); while(en.hasMoreElements()){ ExbpNode node = (ExbpNode)en.nextElement(); // ROOT�͏��O if(node.getOrgNode() != null/* && !(node.getHozoNode() instanceof NodeRH)*/){ Object hozonode = node.getOrgNode(); //System.out.println("Check:::"+hozonode.getLabel()); Enumeration en_comp = comp._exbp.nodes.elements(); while(en_comp.hasMoreElements()){ ExbpNode node_comp = (ExbpNode)en_comp.nextElement(); //ROOT�͏��O if( node_comp.getOrgNode() != null/* && !(node_comp.getOrgNode() instanceof NodeRH)*/){ if(node_comp.getOrgNode().equals(hozonode)){ //node.highlight=true; //node_comp.highlight=true; node.setHighLight(true, Color.darkGray); /*node.color=Color.white; node_comp.setHighLight(true, Color.darkGray); node_comp.color=Color.white;*/ node.addTopicColor(Color.red); node.addTopicColor(Color.blue); node_comp.addTopicColor(Color.red); node_comp.addTopicColor(Color.blue); System.out.println("March:::"+node.getLabel()); //break; } } } }else{ // ozonode = null; } } this.getExtendBP().repaint(); } } int addTopicColorToALLNode(Color clr){ int count=0; Enumeration en = this.getExtendBP().nodes.elements(); while(en.hasMoreElements()){ ExbpNode node = (ExbpNode)en.nextElement(); if(node.open_sub=false){ node.setChildrenVisible(false); } } en = this.getExtendBP().nodes.elements(); while(en.hasMoreElements()){ ExbpNode node = (ExbpNode)en.nextElement(); if(node.visible){ node.addTopicColor(clr); count++; } else{ node.color=Color.white; } } return count; } int compareMaps(ExtendFrame exf1, Color clr1, ExtendFrame exf2, Color clr2){ //System.out.println("setCompare:::"); int count=0; // this._exbp.topicColorList.add(Color.red); // this._exbp.topicColorList.add(Color.blue); // // comp = (ExtendFrame)Exf.elementAt(jlist.getSelectedIndex()); // // comp._exbp.topicColorList.add(Color.red); // comp._exbp.topicColorList.add(Color.blue); // // System.out.println("select ::"+ comp._exbp.exbp_node_center.getLabel() + ":" + comp.getOption()); // check Enumeration en = exf1.getExtendBP().nodes.elements(); while(en.hasMoreElements()){ ExbpNode node = (ExbpNode)en.nextElement(); // ROOT�͏��O if(node.visible && node.getOrgNode() != null/* && !(node.getHozoNode() instanceof NodeRH)*/){ Object hozonode = node.getOrgNode(); //System.out.println("Check:::"+hozonode.getLabel()); Enumeration en_comp = exf2._exbp.nodes.elements(); while(en_comp.hasMoreElements()){ ExbpNode node_comp = (ExbpNode)en_comp.nextElement(); //ROOT�͏��O if(node_comp.visible && node_comp.getOrgNode() != null/* && !(node_comp.getOrgNode() instanceof NodeRH)*/){ if(node_comp.getOrgNode().equals(hozonode)){ count++; //node.highlight=true; //node_comp.highlight=true; node.setHighLight(true, Color.darkGray); /*node.color=Color.white; node_comp.setHighLight(true, Color.darkGray); node_comp.color=Color.white;*/ node.addTopicColor(clr2); //node.addTopicColor(Color.blue); node_comp.addTopicColor(clr1); //node_comp.addTopicColor(Color.blue); //System.out.println("March:::"+node.getLabel()); //break; } }else{ //System.out.println("exf2:HOZO-NODE=NULL"); } } }else{ //System.out.println("exf1:HOZO-NODE=NULL"); // ozonode = null; } } return count; } // #hirota 09/12/17 void ComparePath(ExbpNode _exbpNode){ //System.out.println("setCompare:::"); if(this._exbp.mapfactory.getMapVec().size() == 1){ System.out.println("not Compare!!!"); return; } // Map_vec dialog �\�� Vector tmp = new Vector();// select_name�Ǘ� Vector Exf = new Vector(); Enumeration e = this._exbp.mapfactory.getMapVec().elements(); while(e.hasMoreElements()){ ExtendFrame f = (ExtendFrame)e.nextElement(); if(!this.equals(f)) { tmp.add(f._exbp.exbp_node_center.getLabel() + ":" + f.getOption()); Exf.add(f); } } JList jlist = new JList(tmp); JScrollPane jsc = new JScrollPane(jlist); int ans = JOptionPane.showConfirmDialog(this,jsc,"Compare ",JOptionPane.YES_NO_CANCEL_OPTION ); ExtendFrame comp=null; if(ans==JOptionPane.YES_OPTION ){ comp = (ExtendFrame)Exf.elementAt(jlist.getSelectedIndex()); System.out.println("select ::"+ comp._exbp.exbp_node_center.getLabel() + ":" + comp.getOption()); // check Enumeration en = this.getExtendBP().nodes.elements(); while(en.hasMoreElements()){ ExbpNode node = (ExbpNode)en.nextElement(); // ROOT�͏��O if(node.getOrgNode() != null/* && !(node.getHozoNode() instanceof NodeRH)*/){ Object hozonode = node.getOrgNode(); //System.out.println("Check:::"+hozonode.getLabel()); Enumeration en_comp = comp._exbp.nodes.elements(); while(en_comp.hasMoreElements()){ ExbpNode node_comp = (ExbpNode)en_comp.nextElement(); //ROOT�͏��O if( node_comp.getOrgNode() != null/* && !(node_comp.getOrgNode() instanceof NodeRH)*/){ if(node_comp.getOrgNode().equals(hozonode)){ //node.highlight=true; //node_comp.highlight=true; //System.out.println("March:::"+node.getLabel()); //break; } } } }else{ // ozonode = null; } } this.getExtendBP().repaint(); // #hirota 09/12/17 path��r���� // // ���ۂ̏��� // _exbpNode:���ƑI���p�X�C_exbp:�����}�b�v ExbpNode _exbpNode_moto = _exbpNode; Enumeration nodes_en =comp._exbp.nodes.elements(); while(nodes_en.hasMoreElements()){ ExbpNode exnode = (ExbpNode)nodes_en.nextElement(); int tensuu=0; if(exnode.visible == true){ // // ���ƑI���p�X�@��i���‚��炷 while(_exbpNode != null ){ // System.out.println("����:"+ _exbpNode.label ); // ���x����v����ƁC���s�C if(exnode.getLabel().equals(_exbpNode.getLabel())) { // �����N��v�����+1�_ if( exnode.key.equals(_exbpNode.key)){ //tensuu++; } //System.out.println("�� selected_path :"+ "("+ _exbpNode.label + ")" + exnode.getPath()); //String str = "�� selected_path :"+ "("+ _exbpNode.label + ")" + exnode.getPath(); String str = "�� selected_path :"; System.out.println(str); // old //exnode.tracepath(_exbpNode, tensuu, str); // // new �������������I�I // str = tracepath(_exbpNode,_exbpNode, tensuu, str); // System.out.println(str); }else{ } _exbpNode = _exbpNode.parent; } _exbpNode = _exbpNode_moto ; } else{ } } // } } // #hirota 09/12/21 new void CompareAllMAP_Path(ExbpNode _exbpNode){} void CompareAllMAP_Path_sub(ExbpNode _exbpNode){} public void tracepath(ExbpNode target_node, ExbpNode _exbpNode,int node_tensuu, int link_tensuu, String s){ if(target_node.parent != null){ if(_exbpNode != null ){ if(target_node.visible == true){ if(target_node.label.equals(_exbpNode.label)){ node_tensuu++; if(target_node.key.equals(_exbpNode.key) ){ link_tensuu++; } // System.out.println("*** :"+ this.label + ", �� " + "(" +this.key + ")" + this.parent.label + "tensuu:" + tensuu); // max���܂��X�V����Ă��Ȃ��ꍇ�̏��� cast�G���[���ł邽�� String str = null; if(max_node_tensuu == 0 && max_link_tensuu == 0){ str = " *"+ target_node.label + "�� "+ "(" +target_node.key + "):" + target_node.parent.label+ ","+node_tensuu+","+link_tensuu; }else{ String[] s_tmp = s.split(","); // s_tmp[0]:path str = s_tmp[0] + "\n *"+ target_node.label + "�� "+ "(" +target_node.key + "):" + target_node.parent.label+ ","+node_tensuu+"/"+max_node_tensuu+","+link_tensuu+"/"+max_link_tensuu; // str = " :"+ target_node.label + "�� "+ "(" +target_node.key + "):" // + target_node.parent.label+ ","+node_tensuu+"/"+max_node_tensuu+","+link_tensuu+"/"+max_link_tensuu; } System.out.println(str); //target_node.setColorFont(Color.red,font); path_list.add(str); subpath_list.add(target_node); //path_list.add(s+"\n"+str); //tracepath(target_node.parent,_exbpNode.parent,node_tensuu,link_tensuu,s+"\n"+str); tracepath(target_node.parent,_exbpNode.parent,node_tensuu,link_tensuu,str); }else{ // #hirota 09/12/24 �m�[�h��v���Ă��Ȃ��Ă��C�������‚Â���@���Ɠ����@���_�͂��Ȃ� if(target_node.key.equals(_exbpNode.key) ){ link_tensuu++; } // System.out.println("*** :"+ this.label + ", �� " + "(" +this.key + ")" + this.parent.label + "tensuu:" + tensuu); // max���܂��X�V����Ă��Ȃ��ꍇ�̏��� cast�G���[���ł邽�� String str = null; if(max_node_tensuu == 0 && max_link_tensuu == 0){ str = " **"+ target_node.label + "�� "+ "(" +target_node.key + "):" + target_node.parent.label+ ","+node_tensuu+","+link_tensuu; }else{ String[] s_tmp = s.split(","); // s_tmp[0]:path str = s_tmp[0] + "\n **"+ target_node.label + "�� "+ "(" +target_node.key + "):" + target_node.parent.label+ ","+node_tensuu+"/"+max_node_tensuu+","+link_tensuu+"/"+max_link_tensuu; } System.out.println(str); path_list.add(str); subpath_list.add(target_node); tracepath(target_node.parent,_exbpNode.parent,node_tensuu,link_tensuu,str); // System.out.println("*** error"); // return null; } } } }else{ // OK } //return null; } // 09/12/25 ��� // #hirota 09/12/17 �����̃p�X�]���p���� public void tracepathToTarget(ExbpNode target_node, ExbpNode _exbpNode,int node_tensuu, int link_tensuu, String s){ // �I�����ꂽ���ԖړI�m�[�h�ł͂Ȃ��ꍇ if( ! _exbpNode.equals(target_node) ){ if(_exbpNode != null ){ if(target_node.visible == true){ if(target_node.label.equals(_exbpNode.label)){ node_tensuu++; if(target_node.key.equals(_exbpNode.key) ){ link_tensuu++; } // System.out.println("*** :"+ this.label + ", �� " + "(" +this.key + ")" + this.parent.label + "tensuu:" + tensuu); // max���܂��X�V����Ă��Ȃ��ꍇ�̏��� cast�G���[���ł邽�� String str = null; if(max_node_tensuu == 0 && max_link_tensuu == 0){ str = " *"+ target_node.label + "�� "+ "(" +target_node.key + "):" + target_node.parent.label+ ","+node_tensuu+","+link_tensuu; }else{ String[] s_tmp = s.split(","); // s_tmp[0]:path str = s_tmp[0] + "\n *"+ target_node.label + "�� "+ "(" +target_node.key + "):" + target_node.parent.label+ ","+node_tensuu+"/"+max_node_tensuu+","+link_tensuu+"/"+max_link_tensuu; // str = " :"+ target_node.label + "�� "+ "(" +target_node.key + "):" // + target_node.parent.label+ ","+node_tensuu+"/"+max_node_tensuu+","+link_tensuu+"/"+max_link_tensuu; } System.out.println(str); //target_node.setColorFont(Color.red,font); path_list.add(str); subpath_list.add(target_node); //path_list.add(s+"\n"+str); //tracepath(target_node.parent,_exbpNode.parent,node_tensuu,link_tensuu,s+"\n"+str); tracepathToTarget(target_node,_exbpNode.parent,node_tensuu,link_tensuu,str); }else{ // #hirota 09/12/24 �m�[�h��v���Ă��Ȃ��Ă��C�������‚Â���@���Ɠ����@���_�͂��Ȃ� if(target_node.key.equals(_exbpNode.key) ){ link_tensuu++; } // System.out.println("*** :"+ this.label + ", �� " + "(" +this.key + ")" + this.parent.label + "tensuu:" + tensuu); // max���܂��X�V����Ă��Ȃ��ꍇ�̏��� cast�G���[���ł邽�� String str = null; if(max_node_tensuu == 0 && max_link_tensuu == 0){ str = " **"+ target_node.label + "�� "+ "(" +target_node.key + "):" + target_node.parent.label+ ","+node_tensuu+","+link_tensuu; }else{ String[] s_tmp = s.split(","); // s_tmp[0]:path str = s_tmp[0] + "\n **"+ target_node.label + "�� "+ "(" +target_node.key + "):" + target_node.parent.label+ ","+node_tensuu+"/"+max_node_tensuu+","+link_tensuu+"/"+max_link_tensuu; } System.out.println(str); path_list.add(str); subpath_list.add(target_node); tracepathToTarget(target_node,_exbpNode.parent,node_tensuu,link_tensuu,str); // System.out.println("*** error"); // return null; } } } }else{ // OK } //return null; } void saveMap(){ if(this._exbp.mapfactory.isSubLung){ Object[] msg={"Do you save this MAP in Sub Language?", "(*Warning* Some data may be lost!)"}; int ans = JOptionPane.showConfirmDialog(this._exbp._extendFrame, msg, "Save Map Data in Sub-Language", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if(ans!=JOptionPane.YES_OPTION){ return; } } String OPEN_DIRECTORY = "./data3/mapdata/"; File dir = new File(OPEN_DIRECTORY); if(!dir.exists()){ File ont_file = this._exbp.mapfactory.getFile(); if(ont_file!=null){ OPEN_DIRECTORY= ont_file.getParentFile().getAbsolutePath(); } } JFileChooser fd = new JFileChooser(OPEN_DIRECTORY); fd.showSaveDialog(this); File file = fd.getSelectedFile(); this.getExtendBP().saveMAPinXML(file); return; } void saveMap_old(){ // Map_vec dialog �\�� Vector tmp = new Vector();// select_name�Ǘ� Vector Exf = new Vector(); String chi_str=""; Enumeration e = this._exbp.mapfactory.getMapVec().elements(); while(e.hasMoreElements()){ ExtendFrame f = (ExtendFrame)e.nextElement(); //if(!this.equals(f)) { //ROOT�̂Ƃ��C�q�m�[�h���t�@�C���ɕۑ� if(f._exbp.exbp_node_center.getLabel().equals("(ROOT)")){ Enumeration node_en = f._exbp.exbp_node_center.children.elements(); while(node_en.hasMoreElements()){ ExbpNode chi = (ExbpNode)node_en.nextElement(); chi_str = chi_str+chi.getLabel()+","; } tmp.add("(ROOT)"+chi_str + ":" + f.getOption()); } // center ��‚̂Ƃ� else{ tmp.add(f._exbp.exbp_node_center.getLabel() + ":" + f.getOption()); } Exf.add(f); //} } JList jlist = new JList(tmp); JScrollPane jsc = new JScrollPane(jlist); //#kozaki JCheckBox saveAsAnother = new JCheckBox("Save as Another File"); Object[] msg = {jsc,saveAsAnother}; int ans = JOptionPane.showConfirmDialog(this,msg,"SAVE MAP_file ",JOptionPane.YES_NO_CANCEL_OPTION ); ExtendFrame comp=null; if(ans==JOptionPane.YES_OPTION ){ //2008/10/03�@#kozaki Save����MAP���I���ł��邱�Ƃ�h�� if(jlist.getSelectedIndex()<0){ comp=(ExtendFrame)Exf.elementAt(0); } else{ comp = (ExtendFrame)Exf.elementAt(jlist.getSelectedIndex()); } System.out.println("select ::"+ comp._exbp.exbp_node_center.getLabel() + ":" + comp.getOption()); //#kozaki 2008/10/03�@�ʂ̃t�@�C���Ƃ��ĕۑ����� if(saveAsAnother.isSelected()){ String OPEN_DIRECTORY = "./data3/mapdata/"; JFileChooser fd = new JFileChooser(OPEN_DIRECTORY); fd.showSaveDialog(this); File file = fd.getSelectedFile(); this.getExtendBP().saveMAPinXML(file); return; } // //save ���� String fileName = ""; String directoryName = ""; // �t�@�C�����㏑���ۑ����� if(this._exbp.mapfactory != null) { //_hzEditor.getOEManager().saveData_XML(_hzEditor.getFile(), true); //Command cmd = new CommandSave(this._exbp._hzeditor); //cmd.execute(); fileName = this._exbp.mapfactory.getFile().getName(); directoryName =this._exbp.mapfactory.getFile().getAbsolutePath(); //directoryName =hozo.oe.command.CommandExportText.OPEN_DIRECTORY; } try { String map_command =""; // center�P�‚̂Ƃ� if(chi_str.equals("")){ map_command = fileName +"::"+ comp._exbp.exbp_node_center.getLabel() + "::" + comp.getOption(); } //�@center�����̂Ƃ� else{ map_command = fileName +"::"+ "(ROOT)"+ chi_str + "::" + comp.getOption(); } System.out.println("write::"+map_command); File map_file = new File(directoryName+fileName+".hozo_map"); FileOutputStream os = null; //�@�lj����� if(map_file.exists()){ os = new FileOutputStream(map_file,true); } // �O�ɍ�������Ƃ��Ȃ������Ƃ��C�V�K�쐬 else{ os = new FileOutputStream(map_file); } OutputStreamWriter osw = new OutputStreamWriter(os , "MS932"); BufferedWriter bw = new BufferedWriter(osw); bw.write(map_command); bw.newLine(); bw.close(); osw.close(); os.close(); } catch (IOException ioe) { System.out.println(ioe.getStackTrace()); } } } /** * This method initializes this * * @return void */ private void initialize() { //this.setSize(650, 600); //#kozaki 2008/06/26 this.setSize(920, 800); //#hirota 2009/11/5 this.getContentPane().setLayout(new BorderLayout()); this.jsp_exbp = new JScrollPane(_exbp); this.getContentPane().add(jsp_exbp,BorderLayout.CENTER ); //this.getContentPane().add(new JScrollPane(new JTextArea(100,100)),BorderLayout.CENTER ); //this.setContentPane(getJContentPane()); JPanel panel_buttons=new JPanel(); this.getContentPane().add(panel_buttons,BorderLayout.SOUTH); JLabel j; // #hirota 08/08/20 this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.out.println("fin_Map :: "+ _exbp.exbp_node_center.getLabel() + ":"+_exbp._extendFrame.getOption()); if(_exbp.mapfactory!=null){ _exbp.mapfactory.getMapVec().removeElement(_exbp._extendFrame); } // if(_exbp._hzeditor!=null){ // _exbp._hzeditor.Map_vec.removeElement(_exbp._extendFrame); // } // _exbp.cmd_dialog.dispose(); dispose(); } }); //#kozaki 2008/10/04�@���j���[�o�[�̒lj� this.setJMenuBar(menubar); menubar.add(filemenu); filemenu.add(JMI_OpenMap); JMI_OpenMap.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed (ActionEvent e) { OpenMAPinXML(false); } }); // #hirota 08/10/21 filemenu.add(JMI_SaveMap); JMI_SaveMap.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed (ActionEvent e) { saveMap(); } }); filemenu.addSeparator(); filemenu.add(JMI_MergeMap); JMI_MergeMap.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed (ActionEvent e) { OpenMAPinXML(true); } }); //JMI_CompareMap filemenu.add(JMI_CompareMap); JMI_CompareMap.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed (ActionEvent e) { OpenMapsToCompare(); } }); //#ohta 2008/11/18 Aspect�_�C�A���O�̕\�����j���[�̒lj� menubar.add(viewmenu); viewmenu.add(JMI_ShowAspects); JMI_ShowAspects.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed (ActionEvent e) { // _exbp.cmd_dialog.setVisible(true); } }); //#kozaki�@2009/01/04�@�\������MAP����I�������N���X�̉��ʊT�O�̂��n�C���C�g viewmenu.add(JMI_ChangeView); JMI_ChangeView.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed (ActionEvent e) { //String[] cls_lists = _exbp.mapfactory.getSelectedClass(new String[0]); // Node[] cls_lists = _exbp.mapfactory.getSelectedClassNodes(null); //String opt = _exbp._extendFrame.select_dialog.commands[0].getSelectedClass(); // if(opt==null){ // opt="Any"; // } // String[] cls_lists = opt.split(" "+"\\" + Slot.OR_DELIMITER+" "); //_exbp.setClassRestrictedView(cls_lists); // new ChangeViewFrame(_exbp,cls_lists); } }); //#kozaki�@2009/01/21�@�\������MAP����I������Role�̃p�X���n�C���C�g viewmenu.add(JMI_ChangeViewRole); JMI_ChangeViewRole.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed (ActionEvent e) { // ChangeViewFrameRole frame = new ChangeViewFrameRole(_exbp); //Vector roles = _exbp.mapfactory.getRoleList(); /* Vector roles = _exbp.getLinkList(); String[] list = new String[roles.size()]; roles.copyInto(list); JList jlist = new JList(list); JScrollPane jsp = new JScrollPane(jlist); //jlist.setPreferredSize(new Dimension(100,300)); JOptionPane.showMessageDialog(null,jsp); //jsp.setPreferredSize(new Dimension(100,300)); int[] indexes =jlist.getSelectedIndices(); String[] values = new String[indexes.length]; for(int i=0;i 0 && getExtendBP() != null && getExtendBP().exbp_node_center != null) { _exbp.setNodes(_localProjectRootPath); RefreshExbp(); updateHsitoryPath(); // �������X�V���� updateDisplay(); // ��ʂ��X�V���� } } }); // #hirota 08/08/25 JButton jb_save = new JButton("SAVE"); jb_save.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed (ActionEvent e) { saveMap(); //System.out.println("save_Map :: "+ _exbp.exbp_node_center.getLabel() + ":"+_exbp._extendFrame.getOption()); } }); //#kozaki 2008/08/12�@�o�l���f���p���� jCB_stop = new JCheckBox("Stop"); jCB_stop.setSelected(_exbp.stop); jCB_PlaceOnLayer = new JCheckBox("Place on Layers"); jCB_PlaceOnLayer.setSelected(_exbp.stopOnLayer); jCB_showEdges = new JCheckBox("Show Edges"); jCB_showEdges.setSelected(_exbp.showEdges); jCB_stop.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e) { _exbp.stop=jCB_stop.isSelected(); } }); jCB_PlaceOnLayer.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e) { _exbp.stopOnLayer=jCB_PlaceOnLayer.isSelected(); } }); jCB_showEdges.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e) { _exbp.showEdges=jCB_showEdges.isSelected(); } }); // #hirota 2009/07/31 stopList���� jCB_stoplist = new JCheckBox("Stop_List"); jCB_stoplist.setSelected(true); jCB_stoplist.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e) { Enumeration nodes_en = _exbp.nodes.elements(); while(nodes_en.hasMoreElements()){ ExbpNode node = (ExbpNode)nodes_en.nextElement(); for(int i=0;i0){ String[] str = layer_str.split(","); layer = Integer.parseInt(str[1]); }else{ layer = Integer.parseInt(jtf_layer.getText()); } return layer; } //#kozaki 2008/07/31 void setLayerNum(int i){ jtf_layer.setText(Integer.toString(i)); } // �`������t���b�V������ public void RefreshExbp(){ int layer; Double arc = 1.0; //#kozaki 2008/03/25�@��`�̊p�x�ݒ� String layer_str = jtf_layer.getText(); if(layer_str.indexOf(",")>0){ String[] str = layer_str.split(","); arc = Double.parseDouble(str[0]); layer = Integer.parseInt(str[1]); }else{ layer = Integer.parseInt(jtf_layer.getText()); } System.out.println("center::"+ getExtendBP().exbp_node_center.getLabel()); // #hirota 08/08/19 node_size�ύX int node_size = Integer.parseInt(jtf_nodesize.getText()); ExtendBP.fontLink = new Font("Times", Font.PLAIN, node_size); //#kozaki 2008/08/19 //exbp_node_center.color = ExbpNode.CENTER_COLOR; getExtendBP().exbp_node_center.font = new Font("Times", Font.BOLD, (int)(node_size*(ExbpNode.Font_node_center))); int width = Integer.parseInt(jtf_width.getText()); int scale = Integer.parseInt(jtf_scale.getText()); getExtendBP().setNodesLoc(layer, width,arc, node_size);//#kozaki 2008/03/25�@��`�̊p�x�ݒ� //getExtendBP().setCanvasScale(scale); getExtendBP().setNodesLoc(); // �ʒu������� getExtendBP().setEdgesForSpringModel();//#kozaki�@2008/08/13�@ // getExtendBP().repaint(); // �^�C�g����ύX String subTitle = getExtendBP().exbp_node_center.getLabel(); if (subTitle == ExtendBP.DEFAULT_NAME) { subTitle = getExtendBP().mapfactory.getFile().getName(); } //#kozaki�@2008/08/18 if(compare_map==null){ this.setTitle(DEFAULT_TITLE, subTitle); } else{ this.setTitle(DEFAULT_TITLE, subTitle+""); //#kozaki 2008/08/18�@�}�b�v�̔�r���� this.setCompare(); } getExtendBP().repaint(); } // �^�C�g����ݒ肷�� private void setTitle(String mainTitle, String subTitle) { if (subTitle == null) { subTitle = ""; } super.setTitle(mainTitle + " - [" + subTitle + "]"); } /** * This method initializes jContentPane * * @return javax.swing.JPanel */ /* private ExtendBP getJContentPane() { if (_exbp == null) { //_exbp = new ExtendBP(); _exbp = new ExtendBP(this); _exbp.setLayout(new BorderLayout()); } return _exbp; }*/ public ExtendBP getExtendBP(){ return _exbp; } // public void setHZEditor(HZEditor hze){ // this._exbp.setHZEditor(hze); // select_dialog = new EtendBPSelectDialog(this._exbp,this); // hze.Map_vec.add(this); // } //#enegate# 08/07/07 �I���_�C�A���O��OK�{�^���������ꂽ���ǂ����H // public boolean isOK() { // return this.select_dialog.isOK(); // } // public HZEditor getHZEditor() { // if (this._exbp == null) { // return null; // } // return this._exbp.getHZEditor(); // } //#kozaki 2008/01/04 void setOption(String opt){ this.jTF_Option.setText(opt); this.jCB_LocalPath.getEditor().setItem(opt); } //#kozaki 2008/07/31 String getOption(){ return this.jTF_Option.getText(); } /** * * �p�X���X�g�擾 * * @param logPath ���O�p�X * @return */ private List loadPathList(String path) { ArrayList rtnList = new ArrayList(); //�p�X�t�@�C�� File pathFile = new File(path); //�t�@�C�������݂��Ȃ��ꍇ�͏����Ȃ� if (!pathFile.exists()) { return rtnList; } //�p�X���e��ǂݎ�� try { BufferedReader bReader = new BufferedReader( new InputStreamReader( new FileInputStream(pathFile.getAbsolutePath()), "SJIS")); try { String line; while((line = bReader.readLine()) != null){ rtnList.add(line); } } finally { bReader.close(); } } catch(Exception e) { e.printStackTrace(); } //return (String[]) rtnList.toArray(new String[rtnList.size()]); return rtnList; } /** * * �p�X���X�g�ۑ� * * @return */ private void savePathList(String path, String name, List pathList) { //�p�X�t�@�C�� File pathFile = new File(path); //�t�H���_�����݂��Ȃ��ꍇ�̓t�H���_�쐬 if (!pathFile.exists()) { pathFile.mkdir(); } String filePath = path + "/" + name; File filePathFile = new File(filePath); //�t�H���_�����݂��Ȃ��ꍇ�̓t�H���_�쐬 if (!filePathFile.exists()) { try { filePathFile.createNewFile(); } catch(Exception e) { e.printStackTrace(); } } try { FileWriter out = new FileWriter(filePathFile); Iterator it = pathList.iterator(); while(it.hasNext()) { out.write(it.next().toString()); out.write("\n"); } out.close(); } catch(Exception e) { e.printStackTrace(); } finally { } } /** * * ���[�J���̃p�X������ݒ肵�܂��B * */ private void setLocalPathHistory() { this._localPathList.clear(); String path = HISTORY_PATH + "/" + LOCAL_HISTORY_FILE_NAME; this._localPathList.addAll(this.loadPathList(path)); } /** * * ���[�J���̃p�X�������擾���܂��B * */ public List getLocalPathHistory() { return this._localPathList; } /** * * ���[�J���̃p�X������lj����܂��B * */ public void appendLocalPathHistory(String path) { if(_localPathList != null && path != null && _localPathList.contains(path)) { _localPathList.remove(path); } _localPathList.add(0, path); // �擪�ɒlj� // �ő�l�𒴂���Ζ��[�܂ŏ��� while (_localPathList.size() > MAX_HISTORY_SIZE) { int lastIndex = _localPathList.size() - 1; _localPathList.remove(lastIndex); } } /** * * ���[�J���̃p�X������ۑ����܂��B * */ public void saveLocalPathHistory() { this.savePathList(HISTORY_PATH, LOCAL_HISTORY_FILE_NAME, this._localPathList); } /** * * �p�X���X�V���܂��B * */ public boolean updateHsitoryPath() { try { // �p�X������lj� this.appendLocalPathHistory(this._localProjectRootPath); // �p�X��ۑ����� this.saveLocalPathHistory(); return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * * ��ʍX�V���܂��B * */ protected void updateDisplay() { if (_localProjectRootPath == null) _localProjectRootPath = ""; // �����܂� jCB_LocalPath.removeAllItems(); // �p�X�̕\�����X�V���� jCB_LocalPath.addItem(_localProjectRootPath); // �q�X�g���[�擾 List localPathList = this.getLocalPathHistory(); Iterator it = localPathList.iterator(); while (it.hasNext()) { String tmpLocalURL = (String) it.next(); if (!tmpLocalURL.equals(_localProjectRootPath)) { jCB_LocalPath.addItem(tmpLocalURL); } } } // �T�[�r�XURL�̓ǂݍ��� private void getServiceURL() { try { BufferedReader br = new BufferedReader(new FileReader(SERVICE_URL_FILE)); SERVICE_URL = br.readLine(); br.close(); String name = null; } catch(IOException f) { SERVICE_URL = DEFAULT_SERVICE_URL; } } } // #hirota 09/4/27 �E�C���h�E���� class DockingListener implements ComponentListener { private final JFrame frame1; private final JFrame frame2; public DockingListener(JFrame f1, JFrame f2) { frame1 = f1; frame1.addComponentListener(this); frame2 = f2; frame2.addComponentListener(this); } public void componentResized(ComponentEvent e) { positionFrames(e); } public void componentMoved(ComponentEvent e) { positionFrames(e); } public void componentShown(ComponentEvent e) { positionFrames(e); } public void componentHidden(ComponentEvent e) { positionFrames(e); } private void positionFrames(ComponentEvent e) { if(e.getComponent().equals(frame1)) { int x = frame1.getBounds().x - frame2.getWidth(); // + frame1.getBounds().width; int y = frame1.getBounds().y ;//+ frame1.getBounds().height; frame2.removeComponentListener(this); frame2.setLocation(x, y); frame2.addComponentListener(this); }else{ int x = frame2.getBounds().x + frame2.getWidth(); // - frame1.getBounds().width; int y = frame2.getBounds().y; //- frame1.getBounds().height; frame1.removeComponentListener(this); frame1.setLocation(x, y); frame1.addComponentListener(this); } } }