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

📄 treejuxtaposer.java

📁 生物物种进化历程的演示
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*   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.util.*;import java.awt.*;import javax.swing.*;import java.io.*;import AccordionDrawer.*;import AccordionTreeDrawer.*;import Parser.status.*;/** * A class representing a tree juxtaposer. *  * A TreeJuxtaposer takes a set of trees and build the data structures * for each pair for best corresponding nodes lookup and range * intersection queries.  The TreePairs class encapsulates all the * Tree2Tree classes required to relate pairs of trees in the list * "trees". *  * * @author Tamara Munzner, Serdar Tasiran, Li Zhang, Yunhong Zhou * @version  * @see     AccordionDrawer.Tree * @see     AccordionDrawer.TreeNode * @see     AccordionDrawer.CellGeom * @see     TreeJuxtaposer.TreePairs * @see     AccordionDrawer.AccordionTreeDrawer * @see     TreeJuxtaposer.AccordionTreeDrawerFinal */public class TreeJuxtaposer extends Object {// implements WindowListener, WindowFocusListener {        public static final String versionNumber = "1.2";        Frame mainFrame;    String title;        StateFrame stateFrame;    SettingsFrame settingsFrame;    IncrementalSearch searchFrame;    DebugFrame debugFrame;    ButterflyFrame butterflyFrame;    JPanel controlPanel;    Panel drawPanel;    GridLayout drawLayout;           /**     * Resizeable array of AccordionTreeDrawerFinal objects     */    ArrayList treeDrawers;     ArrayList ATDMatrix;    /**     * Resizeable array of Tree objects     */    ArrayList trees;        /**     * Rearrangable list of RangeLists (groups)     */    LinkedList groups;     Vector groupsByIndex;    /**     * an array of TreePairs objects      * each TreePair contains the necessary data structure for     * each pair     **/    // ST: Don't understand this one well. Need help documenting.    TreePairs TPs;    Color backgroundColor;    Color objectColor;    Color labelColor;    Color labelBackColor;    Color labelHiColor;    Color labelBackHiColor;//    Color rubberbandColor;    /** these numbers are permanent, but the ordering of the groups     * changes to reflect user interactions for which color wins out     * in a tie     */    static int flashGroup;    static int diffGroup;    static int lcaGroup;    static int markGroup[] = new int[4];    static int foundGroup;    static int treeCount;    CellGeom flashGeomOld;    // for debug    boolean showStructDiffs;    boolean matrix;    int linethickness = 1;    static Status parser_status = new Status(System.in);    boolean firstTime = true;    private int treeArgs;    boolean quasimode;    AccordionTreeDrawer wantsFocusATD;    int edgeweightLevels;    int edgeweightLevelUsed;        static TreeJuxtaposer self;        UI ui;    float bcnScore;        // TODO: this belongs in the ATD, not HERE!//    int viewDirection;//    int leftRight;//    public static boolean drawButterFly;        int[] winSize = new int[2];	public ArrayList lcaNode = new ArrayList();        public TreeJuxtaposer() {	self = this;	AccordionTreeDrawer.fullyQualified = false; // if true, all nodes will have fully qualified names	// fully qualified names are good for trees that look like file systems	// fully qualified names are bad for trees that look like phylogenies	showStructDiffs = true;	matrix = false;	// we use both swing and awt components,	// so must disable the swing focus manager!	FocusManager.disableSwingFocusManager();//	doUI();    title="TreeJuxtaposer";    ui = new UI(this, title);    mainFrame = ui.getMainFrame();//    mainFrame.addWindowFocusListener(this);//    mainFrame.addWindowListener(this);        drawPanel = ui.getDrawPanel();    controlPanel = ui.getControlPanel();    searchFrame = ui.getSearchFrame();    stateFrame = ui.getStateFrame();    debugFrame = ui.getDebugFrame();    settingsFrame = ui.getSettingsFrame();       butterflyFrame = ui.getButterflyFrame();     	treeDrawers = new ArrayList();	ATDMatrix = new	ArrayList(); 	trees = new ArrayList();	groups = new LinkedList();	groupsByIndex = new Vector(7);	backgroundColor = Color.getHSBColor(0.0f/360f,0f,1f);	// remember that rbcol is xor'ed against backcolor, 	// so set to opposite of desired color...//	rubberbandColor = Color.getHSBColor(0.0f/360f,.0f,0.3f);	objectColor = Color.getHSBColor(0.0f/360f,.0f,0.15f);	//labelColor = Color.getHSBColor(0f/360f,.0f,0.15f);	//labelBackColor = Color.getHSBColor(0.0f/360f,0.0f,0.90f);	//labelColor = Color.getHSBColor(100f/360f,1f,0.7f);	labelColor = Color.getHSBColor(0f/360f,0f,0f);	labelBackColor = Color.getHSBColor(0.0f/360f,0.0f,1f);	labelHiColor = Color.getHSBColor(0.0f/360f,.0f,0.15f);	labelBackHiColor = Color.getHSBColor(36f/360f,1f,1f);	Color flashCol = Color.getHSBColor(36f/360f,1f,1f); //orange	Color foundCol = Color.getHSBColor(310f/360f,1f,1f); //pink	Color diffCol = Color.getHSBColor(0f/360f,1f,1f); //red	Color lcaCol = new Color(87, 152, 64);	//Color diffCol = new Color(87, 152, 64); // dark green, maybe good for contest?		Color markCol[] = new Color[4];	markCol[0] = Color.getHSBColor(250f/360f,1f,1f); //blue	markCol[1] = Color.getHSBColor(140f/360f,1f,1f); //green	markCol[2] = Color.getHSBColor(180f/360f,1f,1f); //cyan	markCol[3] = Color.getHSBColor(280f/360f,1f,1f); //magenta// Original color choices.//	Color flashCol = new Color(1.0f,.7f,0.0f); // orange//	Color foundCol = new Color(1.0f,0.0f,1.0f); // magenta//	Color diffCol = new Color(1.0f,.0f,.0f); //red//	Color markCol[] = new Color[4];//	markCol[0] = new Color(.0f,1.0f,.0f); // green//	markCol[1] = new Color(.0f,.0f,1.0f); // blue//	markCol[2] = new Color(.0f,1.0f,1.0f); // cyan//	markCol[3] = new Color(1.0f,1.0f,.0f); // yellow//	labelColor = new Color(.9f,.9f,.9f); // unused//	labelBackColor = new Color(0.0f,0.0f,0.0f); // black//	labelHiColor = new Color(0.0f,0.0f,0.0f); // black//	labelBackHiColor = new Color(1.0f,.7f,0.0f); // orange//	objectColor = new Color(.7f,.7f,.7f); // white//	backgroundColor = new Color(0.0f,0.0f,0.0f); // background black	TPs = new TreePairs();	treeCount = 0;	// the order of adding groups matters: the *first* group found	// gets precedence for color. so the mouseover	// highlight trumps everything, then the leaf selection.	// finally, we want the structural differences to	// take priority over the manual highlighting./*	flashGroup = addGroup(false);	setGroupColor(flashGroup, flashCol);	// enabled by default, unset since should be off	setGroupEnable(flashGroup, false);	foundGroup = addGroup(false);	setGroupColor(foundGroup, foundCol);	diffGroup = addGroup(true);	setGroupColor(diffGroup, diffCol);	// order of markgroups can change, with setGroupPriority	markGroup[0] = addGroup(false);	setGroupColor(markGroup[0], markCol[0]);	markGroup[1] = addGroup(false);	setGroupColor(markGroup[1], markCol[1]);	markGroup[2] = addGroup(false);	setGroupColor(markGroup[2], markCol[2]);	markGroup[3] = addGroup(false);	setGroupColor(markGroup[3], markCol[3]);	setGroupPriority(markGroup[3]);	setGroupPriority(markGroup[2]);	setGroupPriority(markGroup[1]);	setGroupPriority(markGroup[0]);	setShowDiffs(true);*///	fc.addChoosableFileFilter(new NexusFilter());//	fc.addChoosableFileFilter(new NewickFilter());//	fc.setMultiSelectionEnabled(true);	diffGroup = addGroup(true);	setGroupColor(diffGroup, diffCol);		markGroup[0] = addGroup(false);	 setGroupColor(markGroup[0], markCol[0]);	 markGroup[1] = addGroup(false);	 setGroupColor(markGroup[1], markCol[1]);	 markGroup[2] = addGroup(false);	 setGroupColor(markGroup[2], markCol[2]);	 markGroup[3] = addGroup(false);	 setGroupColor(markGroup[3], markCol[3]);	flashGroup = addGroup(false);	setGroupColor(flashGroup, flashCol);	// enabled by default, unset since should be off	setGroupEnable(flashGroup, false);	foundGroup = addGroup(false);	setGroupColor(foundGroup, foundCol);	lcaGroup = addGroup(false);	setGroupColor(lcaGroup, lcaCol);		setGroupPriority(markGroup[3]);	setGroupPriority(markGroup[2]);	setGroupPriority(markGroup[1]);	setGroupPriority(markGroup[0]);		setShowDiffs(true);	quasimode = false;	wantsFocusATD = null;	edgeweightLevels = 1;	edgeweightLevelUsed = 0;    bcnScore = 1.0f;//    viewDirection = 1;//    leftRight=0;    }    /*    void lostFocusInQuasi(AccordionTreeDrawer atd) {	lostFocusATD = atd;    }    */    void wantsFocusInQuasi(AccordionTreeDrawer atd) {	wantsFocusATD = atd;    }    void setQuasimode(boolean on) {	if (quasimode == true && on == false && wantsFocusATD != null) {	    //lostFocusATD.transferFocus();	    wantsFocusATD.requestFocus();	}	quasimode = on;	//quasiATD = null;	wantsFocusATD = null;    }    boolean getQuasimode() { return quasimode; }    public void updateTitle() {        title = "TreeJuxtaposer v" + versionNumber;        if (trees.size() > 0) title += ": ";        for (int i = 0; i < treeDrawers.size(); i++)        {        	String currTree = ((Tree)trees.get(i)).getName();             title += currTree.substring(currTree.lastIndexOf('/')+1) + " ";         }	mainFrame.setTitle(title);    }    /**     * Adds a new tree to "trees", performs all the pairwise tree     * comparisons and stores results.     *     * @author  Tamara Munzner     *     * @see AccordionDrawer.Tree     * @see TreePairs.addTree     */    public void addTree(Tree newTree) {	newTree.setKey(treeCount);	treeCount++;	int height, width;	int hgap = 8;	int vgap = 8;	//System.out.println("ADDTREE " + treeCount + " " + treeCount);	if(1 ==treeCount) {//        if(!drawButterFly)	    {	    	height = 540; 	         width = 640;	    }//	    else//	    {//	    	height = winSize[1];//	    	width = winSize[0];//	    }	    // hardwired assumption of controlPanel placement, must	    // change if we move controlPanel! 10/10/02 TMM	    int controlWidth = controlPanel.getWidth();	    width = (controlWidth > width) ? controlWidth : width;	    if (matrix) {		// set this very small so that it doesn't override the		// small windows later - when loading multiple files		// from command line, after we set the initial size it		// doesn't seem to be possible to shrink things		// afterward.		height = 10;		width = 10;	    }	    drawPanel.setSize(width, height);	    mainFrame.setSize(width, height+controlPanel.getHeight());

⌨️ 快捷键说明

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