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

📄 accordiontreedrawerfinal.java

📁 生物物种进化历程的演示
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		for (int xy = X; xy <= Y; xy++)		{			if (Math.abs(mouse[xy] - splitLine[xy].getMinStuckValue()) < fuzz[xy])			{				//System.out.println("close to minstuck? " + xy);				return xy + MIN_STUCK_X;			}			else if (Math.abs(mouse[xy] - splitLine[xy].getMaxStuckValue()) < fuzz[xy])			{				//System.out.println("close to maxstuck? " + xy);				return xy + MAX_STUCK_X;			}		}		return FAR_FROM_STUCK;	}    // clicked call means there weren't any drag events.    public void mouseClicked(MouseEvent e) {		if (mouseOutOfWindow(e))			return;		int action = getActionMode();		int stuckValue = closeToStuck();		if (MOUSEOVER == action && stuckValue != FAR_FROM_STUCK)		{//			System.out.println("picked stuck position: " + stuckValue);			baseBox = createBoxFromCells(stuckValue);			flashBox = baseBox;			setFlash(null, rubberbandColor, mouseNow[X], mouseNow[Y], true);			setActionMode(MOVE_STUCKPOS);		}	else if (RECT_FREEMOVE == getActionMode() || RECT_FREEMOVEAGAIN == getActionMode() ||	    ST_FREEMOVE == getActionMode() || ST_FREEMOVEAGAIN == getActionMode()) {	    // throw away return value, we just need the check of	    // whether faraway click means revert to mouseover		if (null == baseBox) {			actionmodeReset();		}//		else//	    	createRectFromPick(dragStart, dragEnd, baseBox);	      	}	mouseNow[X] = e.getX();	mouseNow[Y] = e.getY();	int temp = mouseNow[X];	if (!horiz) {		int x = getWinMax(X);		int y = getWinMax(Y);		mouseNow[X] = mouseNow[Y] * x / y;		mouseNow[Y] = temp * y / x;	}    }    public void mousePressed(MouseEvent e) {		if (mouseOutOfWindow(e))			return;		mouseDragging = true;	mouseNow[X] = e.getX();	mouseNow[Y] = e.getY();	int temp = mouseNow[X];	if (!horiz) {		int x = getWinMax(X);		int y = getWinMax(Y);		mouseNow[X] = mouseNow[Y] * x / y;		mouseNow[Y] = temp * y / x;	}	for (int xy = 0; xy < 2; xy++) {	    dragStart[xy] = mouseNow[xy];	    dragEnd[xy] = mouseNow[xy];	    //mousePrev[xy]= dragStart[xy]; // why???	}	if (baseBox != null)		baseBox.setDragPoints(dragStart, dragEnd);		if (MOUSEOVER == getActionMode()) {		//drawActiveSubtreeBox();	    		{					tj.clearDrawers();		}		actionmode = RECT_CREATE;	}	if (RECT_FREEMOVEAGAIN == getActionMode()) {	    setActionMode(RECT_RESHAPE);	    remakerectangle();	} else if (RECT_FREEMOVE == getActionMode()) {	    if (null != flashBox) {		setActionMode(RECT_RESHAPE);	    } else {		// no box yet. drag one out.		flashBoxWidth=3f;		setActionMode(RECT_CREATE);	    }	} else if (ST_FREEMOVE == getActionMode()) {	    setActionMode(ST_RESHAPE);	} else if (ST_FREEMOVEAGAIN == getActionMode()) {	    setActionMode(ST_RESHAPE);	    //remakerectangle();	}    }    public void mouseReleased(MouseEvent e) {		if (RECT_RESHAPE == getActionMode() || ST_RESHAPE == getActionMode())		{			baseBox.undraw();			flashBox.undraw();			doFlash();			requestRedraw(); // too much drawing			actionmodeReset();//			System.out.println("release");			return;		}//		if (mouseOutOfWindow(e))//			return;	mouseDragging = false;	if (RECT_CREATE == getActionMode()) {	    setActionMode(RECT_FREEMOVE);	} else if (RECT_RESHAPE == getActionMode() || MOVE_STUCKPOS == getActionMode()) {//	    setActionMode(RECT_FREEMOVEAGAIN);//        setActionMode(MOUSEOVER);           actionmodeReset();          //		flashBoxWidth=3f;//		baseBox = createBoxFromCells();//		flashBox = baseBox;//		setFlash(null, tj.rubberbandColor, mouseNow[X], mouseNow[Y], true);		 //       remakerectangle(); 		 			} else if (getActionMode() == ST_RESHAPE) {	    setActionMode(ST_FREEMOVEAGAIN);	}    }    public void mouseDragged(MouseEvent e) {		if (mouseOutOfWindow(e))			return;	mouseNow[X] = e.getX();	mouseNow[Y] = e.getY();	int temp = mouseNow[X];	if (!horiz) {		int x = getWinMax(X);		int y = getWinMax(Y);		mouseNow[X] = mouseNow[Y] * x / y;		mouseNow[Y] = temp * y / x;	}	dragEnd[X] = mouseNow[X];	dragEnd[Y] = mouseNow[Y];	if (baseBox != null)	{		baseBox.updateDrag(dragEnd);	} 	   	if (mouseNow[X] == mousePrev[X] && 	    mouseNow[Y] == mousePrev[Y]) return;		if (ST_FREEMOVE == getActionMode())	//if (ST_FREEMOVE == actionmode || ST_FREEMOVEAGAIN == actionmode)	    	setActionMode(ST_RESHAPE);	if (ST_RESHAPE == getActionMode()) {	    reshaperectangle(linkednav);	}	else if (getActionMode() == MOVE_STUCKPOS)	{//		System.out.println("moving stuck position");		moveStuckPosition(baseBox);	} else if ((RECT_CREATE == getActionMode())) {		tj.setQuasimode(true);		flashBox = null;		flashBoxWidth=3f;		int x=getWinMax(0);		int y=getWinMax(1);//		if(this.drawDirection == LEFT)//		{			baseBox = createBoxFromCells(dragStart, dragEnd);			flashBox = baseBox;//		}//		if(this.drawDirection == RIGHT)//		{//			int[] newDragStart = new int[2];//			int[] newDragEnd = new int[2];//			newDragStart[0] = this.getWinsize(X)-dragStart[X];//			newDragStart[1] = dragStart[Y];//			newDragEnd[0] = this.getWinsize(X)-dragEnd[X];//			newDragEnd[1] = dragEnd[Y];	//			baseBox = createBoxFromCells(newDragStart, newDragEnd);//			flashBox = baseBox;		//		}	//		if(this.drawDirection == UP)//			{//				int[] newDragStart = new int[2];//				int[] newDragEnd = new int[2];//				newDragStart[0] =x-dragStart[Y]*x/y;//				newDragStart[1] =dragStart[X]*y/x;//				newDragEnd[0] = x-dragEnd[Y]*x/y;//				newDragEnd[1] = dragEnd[X]*y/x;		//				baseBox = createBoxFromCells(newDragStart, newDragEnd);//				flashBox = baseBox;		//			}	//		if(this.drawDirection == DOWN)//			{//				int[] newDragStart = new int[2];//				int[] newDragEnd = new int[2];//				newDragStart[0] = dragStart[Y]*x/y;//				newDragStart[1] =y-dragStart[X]*y/x;//				newDragEnd[0] = dragEnd[Y]*x/y;//				newDragEnd[1] = y-dragEnd[X]*y/x;		//				baseBox = createBoxFromCells(newDragStart, newDragEnd);//				flashBox = baseBox;		//			}		    	    //               baseBox = createBoxFromCells(dragStart, dragEnd);//              flashBox = baseBox;//		     setFlash(	null,rubberbandColor,mouseNow[X],mouseNow[Y],true);			              setFlash(null, rubberbandColor, mouseNow[X], mouseNow[Y], true);		    //  setActionMode(RECT_FREEMOVE);		} else if (RECT_RESHAPE == getActionMode()) {			    reshaperectangle(false);	}		// modification by jeffrey, state machine change for control key vs. drag start		  else if(RECT_FREEMOVE == getActionMode()){		  flashBoxWidth=3f;		  baseBox = createBoxFromCells(dragStart, dragEnd);		  flashBox = baseBox;		  setFlash(null, rubberbandColor, e.getX(), e.getY(), true);        	  }	mousePrev[X] = mouseNow[X];	mousePrev[Y] = mouseNow[Y];    }    public void mouseMoved(MouseEvent e) {//		System.out.println("mousemoved");		if (mouseOutOfWindow(e))			return;    		mouseNow[X] = e.getX();	mouseNow[Y] = e.getY();	int temp = mouseNow[X];	int x = getWinMax(X);	int y = getWinMax(Y);	if (!horiz) {				mouseNow[X] = mouseNow[Y] * x / y;		mouseNow[Y] = temp * y / x;	}	if (MOUSEOVER == getActionMode())	{//	    if(this.drawDirection==LEFT)	    mouseover(e.getX(), e.getY());//	    if(this.drawDirection==RIGHT)//	    mouseover(this.getWinsize(0)-e.getX(), e.getY());//	    if(this.drawDirection==UP)//		mouseover(x-e.getY()*x/y, e.getX()*y/x);//	    if(this.drawDirection==DOWN)//	    mouseover(e.getY()*x/y,y-e.getX()*y/x);	}	mousePrev[X] = mouseNow[X];	mousePrev[Y] = mouseNow[Y];    }    /** Used when hitting a key should trigger an atomic action.     * Alternative is a {@link keyPressed() keyPressed}/{@link     * keyReleased() keyReleased} pair that could be used in     * conjunction with mouseclicks.     * @author Tamara Munzner */    public void keyTyped(KeyEvent e) {	char key = e.getKeyChar();	if (e.isShiftDown())	{		tj.setQuasimode(false);	    actionmodeReset();		System.out.println("upper case?");	}	System.out.println("you typed " + key + " kt + " + keytarget);	if (key >= '0' && key <= '3') {	    keytarget = TreeJuxtaposer.markGroup[key - '0'];//	    System.out.println("keytarget " + (key-'0') + " bravo");	} else if (key >= '4' && key <= '9') {		System.out.println("Are you sure? " + key + " should be between 0 and 3, inclusive");	} else if (key == 'f') {	    keytarget = TreeJuxtaposer.flashGroup;	} else if (key == 'd') {	    keytarget = TreeJuxtaposer.diffGroup;	} else if (key == 'l') {	    keytarget = TreeJuxtaposer.foundGroup;	} else if (key == 'h') {	    keytarget = HORIZ;	    setGrowDirection(HORIZ);	} else if (key == 'v') {	    keytarget = VERT;	    setGrowDirection(VERT);	} else if (key == 'a') {	    keytarget = ALL;	    setGrowDirection(ALL);	    setSelectionResolution(SUBTREE);	} else if (key == 'n') {	    keytarget = NODE;	    setSelectionResolution(NODE);	} else if (key == '.' || key == '>') { // with or w/o shift	    keytarget = DEVELOPER;	} else {	    if (keytarget != DEVELOPER) {		if (key == 'g') {		    if (keytarget == TreeJuxtaposer.markGroup[0] ||		    keytarget == TreeJuxtaposer.markGroup[1] ||			keytarget == TreeJuxtaposer.markGroup[2] ||			keytarget == TreeJuxtaposer.markGroup[3])			{				setMarkGroup(keytarget);//				System.out.println("set group to " + (keytarget) + " all by myself");			}		    else {		    	int newMark = getMarkGroup() + 1;			if (newMark > TreeJuxtaposer.markGroup[3]) 				setMarkGroup(TreeJuxtaposer.markGroup[0]);			else				setMarkGroup(newMark);				//			System.out.println("pre Priorities: 0:" + tj.getGroup(TreeJuxtaposer.markGroup[0]).getKey() + " 1:"//			+ tj.getGroup(TreeJuxtaposer.markGroup[1]).getKey() + " 2:"//			+ tj.getGroup(TreeJuxtaposer.markGroup[2]).getKey() + " 3:"//			+ tj.getGroup(TreeJuxtaposer.markGroup[3]).getKey());		    tj.setGroupPriority(getMarkGroup()); //			System.out.println("post Priorities: 0:" + tj.getGroup(TreeJuxtaposer.markGroup[0]).getKey() + " 1:"//			+ tj.getGroup(TreeJuxtaposer.markGroup[1]).getKey() + " 2:"//			+ tj.getGroup(TreeJuxtaposer.markGroup[2]).getKey() + " 3:"//			+ tj.getGroup(TreeJuxtaposer.markGroup[3]).getKey());			}			tj.requestRedrawAll();		} else if (key == 'k') {		    tj.toggleLinkedNav();			tj.requestRedrawAll();		} else if (key == 'r') {		    tj.reset();		} else if (key =='R') {		    reset();		} else if (key == 't') {		    if (keytarget == TreeJuxtaposer.markGroup[0] ||		    	keytarget == TreeJuxtaposer.markGroup[1] ||		    	keytarget == TreeJuxtaposer.markGroup[2] ||		    	keytarget == TreeJuxtaposer.markGroup[3] ||		    	keytarget == TreeJuxtaposer.flashGroup ||		    	keytarget == TreeJuxtaposer.diffGroup ||		    	keytarget == TreeJuxtaposer.foundGroup)		    		setActionGroup(keytarget);		    else setActionGroup(keytargetDefault);		    drawActiveSubtreeBox();		    setActionMode(ST_FREEMOVE);		    //actionmode = MOUSEOVER;		    if (getActionGroup() == TreeJuxtaposer.flashGroup) 			if (pickedNode != null) tj.setFocus(pickedNode, this);		    else {			ArrayList forestRoots = tj.getGroupForest(getActionGroup(), this); // array of TreeNodes			if (!forestRoots.isEmpty()) 			    tj.setFocus(((TreeNode)forestRoots.get(0)), this);		    }		} else if (key == 'b' || key == 'B' || key == 's' || key == 'S') {			/*		    if (keytarget == HORIZ || 			keytarget == ALL) {			setGrowDirection(keytarget);		    } else {			setGrowDirection(VERT);		    }		    */		    boolean grow=(key == 'b' || key == 'B');		    int numSteps = (jump) ? 1 : getNumAnimSteps();		    boolean horiz = getGrowDirection() != VERT;		    boolean vert = getGrowDirection() != HORIZ;			if (linkednav)			tj.resizeGroup(tj.getGroup(getActionGroup()), numSteps, grow, horiz, vert);		    else 			tj.resizeGroup(tj.getGroup(getActionGroup()), numSteps, grow, horiz, vert, this);		    if (getActionGroup() == TreeJuxtaposer.flashGroup) 			if (pickedNode != null) tj.setFocus(pickedNode, this);		    else {			ArrayList forestRoots = tj.getGroupForest(getActionGroup(), this); // array of TreeNodes			if (!forestRoots.isEmpty()) 			    tj.setFocus(((TreeNode)forestRoots.get(0)), this);		    }		    if (linkednav) tj.requestRedrawAll();		    else requestRedraw();		} else if (key == 'm' || key == 'M') {		    if (pickedNode != null) {		    	/* keytarget was over riding my nice panel implementation - jslack			if (keytarget == NODE) {			    setActionTarget(NODE);			} else {			    setActionTarget(ALL);			} 			*/			if (key == 'm')					// tj.clearGroup(getMarkGroup());  // replace 		           tj.unmarkGroup(getMarkGroup());		    else		    	// silly shift problem		    	tj.clearDrawers();			boolean selectSubtree=getSelectionResolution()==SUBTREE;			tj.doSelectGeom(pickedNode, selectSubtree, getMarkGroup(), this);			tj.setFocus(pickedNode, this);			tj.requestRedrawAll();			tj.lcaNode.add(pickedNode);		    if(tj.stateFrame.LCAMark.isSelected())		    	tj.doLCAGeom(TreeJuxtaposer.lcaGroup, this);//			System.out.println("selected a group: " + tj.getGroup(getMarkGroup()));			tj.requestRedrawAll();		    }		} else if (key == 'c') {		    if (keytarget == TreeJuxtaposer.markGroup[0] ||		    keytarget == TreeJuxtaposer.markGroup[1] ||			keytarget == TreeJuxtaposer.markGroup[2] ||			keytarget == TreeJuxtaposer.markGroup[3])			tj.unmarkGroup(keytarget);			tj.requestRedrawAll();	    } else if (keytarget == ALL) {			tj.unmarkGroup(TreeJuxtaposer.markGroup[0]);			tj.unmarkGroup(TreeJuxtaposer.markGroup[1]);			tj.unmarkGroup(TreeJuxtaposer.markGroup[2]);			tj.unmarkGroup(TreeJuxtaposer.markGroup[3]);			tj.requestRedrawAll();		    } else {//			tj.unmarkGroup(getMarkGroup());		    }		    tj.clearDrawers();//		    tj.requestRedrawAll();	    }		 else if (key == 'u') {		    tj.toggleShowDiffs();		} else if (key == 'w') {		    tj.toggleDrawLabels();		} else if (key == 'e') {		    actionmodeReset();		} 	    else {		System.out.println("second tier");		 if (key == 'A') {		    tj.toggleShowAlg();		} else if (key == 'N') {		    tj.requestRedrawAll();		} else if (key == 'b') {		    tj.toggleBigGrid();		} else if (key == 'g') {		    tj.toggleNoGrid();		} else if (key == 'c') {		    tj.toggleColorGrid();		} else if (key == 'T') {		    tj.toggleNoGeoms();		    requestRedraw();		} else if (key == 'H') {		    tj.toggleNoFlash();		} else if (key == 'o') {		    tj.toggleDrawOrder();		} else if (key == 'k') {		    tj.toggleExpandLeaves();		} else if (key == 'R') {		    tj.toggleLabelPosRight();		} else if (key == 'w') {		    tj.increaseLineThickness();		} else if (key == 'W') {		    tj.decreaseLineThickness();		} else if (key == 'm') {		    tj.increaseLabelBuffer();		} else if (key == 'M') {		    tj.decreaseLabelBuffer();		} else if (key == 'x') {		    tj.increaseMaxFontHeight();		} else if (key == 'X') {		    tj.decreaseMaxFontHeight();		} else if (key == 'e') {		    tj.increaseMinFontHeight();		    		} else if (key == 'E') {		    tj.decreaseMinFontHeight();		    		} else if (key == 'B') {		    tj.toggleLabelDrawBack();		} else if (key == 'p') {		    tj.toggleLabelPopup();

⌨️ 快捷键说明

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