⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nexustreeloader.java

📁 生物物种进化历程的演示
💻 JAVA
字号:
/*   Copyright (c) 2002 Compaq Computer Corporation      SOFTWARE RELEASE      Permission is hereby granted, free of charge, to any person obtaining   a copy of this software and associated documentation files (the   "Software"), to deal in the Software without restriction, including   without limitation the rights to use, copy, modify, merge, publish,   distribute, sublicense, and/or sell copies of the Software, and to   permit persons to whom the Software is furnished to do so, subject to   the following conditions:      - Redistributions of source code must retain the above copyright     notice, this list of conditions and the following disclaimer.      - Redistributions in binary form must reproduce the above copyright     notice, this list of conditions and the following disclaimer in the     documentation and/or other materials provided with the distribution.      - Neither the names of Compaq Research, Compaq Computer Corporation     nor the names of its contributors may be used to endorse or promote     products derived from this Software without specific prior written     permission.      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.    IN NO EVENT SHALL COMPAQ COMPUTER CORPORATION BE LIABLE FOR ANY CLAIM,   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR   OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR   THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/package TreeJuxtaposer; import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import AccordionTreeDrawer.*;class NexusTreeLoader extends JDialog implements ListSelectionListener, ActionListener {	    private JButton addButton, cancelButton;    private JList treeList;    private Object[] selectedValues = null;    private TreeJuxtaposer tj;     String fname;    public boolean enabled = true;        public NexusTreeLoader(TreeJuxtaposer tj_, String fname_, int nofTrees) {		tj = tj_;	fname = fname_;	Container contentPanel = getContentPane();	JPanel controlPanel = new JPanel();	controlPanel.setLayout(new BorderLayout());	setTitle("Add trees");	Object[] possibleValues = new Object[nofTrees];	JPanel dummyPanel = new JPanel();	dummyPanel.setLayout(new BorderLayout());	for(int i=0; i<nofTrees; i++) 	    possibleValues[i] = String.valueOf(i+1);	dummyPanel.add(new JLabel(fname_.substring(fname_.lastIndexOf('/')+1)), BorderLayout.NORTH);	treeList = new JList(possibleValues);	treeList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);	treeList.addListSelectionListener(this);	if (nofTrees == 1)	{	    treeList.setSelectedIndex(0);	    doAdd();	    enabled = false;	    return;	}	JScrollPane listScrollPane = new JScrollPane(treeList);	dummyPanel.add(listScrollPane, BorderLayout.SOUTH);		addButton = new JButton("Add");	addButton.addActionListener(this);	cancelButton = new JButton("Cancel");	cancelButton.addActionListener(this);	controlPanel.add(dummyPanel, BorderLayout.NORTH);	controlPanel.add(addButton, BorderLayout.WEST);	controlPanel.add(cancelButton, BorderLayout.EAST);	contentPanel.add(controlPanel, BorderLayout.SOUTH);    }        public void valueChanged(ListSelectionEvent e) {		if (e.getValueIsAdjusting())	    return;	selectedValues = treeList.getSelectedValues();    }        private void doAdd()    {        System.out.println("load1 " + fname);	    long start, loaded, processed;	    for(int sv = 0; sv<selectedValues.length; sv++) {		start  = System.currentTimeMillis();		System.out.println("Parse tree "+selectedValues[sv]);		Tree t = new Tree();		t.load_nexus(fname, Integer.parseInt((String)selectedValues[sv]));		loaded  = System.currentTimeMillis();		System.out.println("load/parse time " + (loaded-start)/1000.0f + " sec");		tj.addTree(t);		processed  = System.currentTimeMillis();		System.out.println("preprocess time " + (processed -loaded)/1000.0f + " sec");	    }    }        public void actionPerformed(ActionEvent e) {	Object ea = e.getSource();	if(ea == addButton) {	    doAdd();	} else if(ea == cancelButton) {	    // do nothing	}	dispose();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -